Revision: 3807
          http://vexi.svn.sourceforge.net/vexi/?rev=3807&view=rev
Author:   clrg
Date:     2010-02-26 11:35:35 +0000 (Fri, 26 Feb 2010)

Log Message:
-----------
Feature: vexi.layout.aspect - for a box that maintains it's aspect ratio

Added Paths:
-----------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/aspect.t
    trunk/widgets/org.vexi.widgets/src/vexi/layout/aspect.t
    trunk/widgets/org.vexi.widgets/src_dev/visualtest/layout/
    trunk/widgets/org.vexi.widgets/src_dev/visualtest/layout/aspect.t

Added: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/aspect.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/aspect.t             
                (rev 0)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/aspect.t     
2010-02-26 11:35:35 UTC (rev 3807)
@@ -0,0 +1,50 @@
+<!-- Copyright 2009 - see COPYING for details [LGPL] -->
+
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns:util="vexi.util">
+    <meta:doc>
+        <author>Charles Goodwin</author>
+        <todo>
+            * border-left/right/top/bottom
+            * take more than one argument to border like CSS
+            * depth read function when border is image based
+            * depth should be read-only with image borders
+        </todo>
+    </meta:doc>
+    
+    <ui:box redirect=":$content">
+        <ui:box id="content" />
+        
+        thisbox.aspectwidth = 1;
+        thisbox.aspectheight = 1;
+        
+        thisbox.v_aspect = $content;
+        thisbox.v_content = $content;
+        thisbox.v_fillbox = $content;
+        thisbox.v_textbox = $content;
+        
+        thisbox.width ++= static.updateAspect;
+        thisbox.height ++= static.updateAspect;
+        thisbox.aspectwidth ++= static.updateAspect;
+        thisbox.aspectheight ++= static.updateAspect;
+        
+    </ui:box>
+    
+    /* maintain aspect after a width/height update */
+    static.updateAspect = function(v) {
+        cascade = v;
+        var aw = trapee.aspectwidth;
+        var ah = trapee.aspectheight;
+        var w = trapee.width / aw;
+        var h = trapee.height / ah;
+        if (h>w) {
+            // use width as limiting dimension
+            trapee.v_aspect.maxwidth = trapee.width;
+            trapee.v_aspect.maxheight = w * ah;
+        } else {
+            // use height as limiting dimension
+            trapee.v_aspect.maxwidth = h * aw;
+            trapee.v_aspect.maxheight = trapee.height;
+        }
+    }
+    
+</vexi>

Added: trunk/widgets/org.vexi.widgets/src/vexi/layout/aspect.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/vexi/layout/aspect.t                     
        (rev 0)
+++ trunk/widgets/org.vexi.widgets/src/vexi/layout/aspect.t     2010-02-26 
11:35:35 UTC (rev 3807)
@@ -0,0 +1,21 @@
+<!-- Copyright 2009 - see COPYING for details [LGPL] -->
+
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns="org.vexi.lib.layout">
+    <meta:doc>
+        <author>Charles Goodwin</author>
+        <name>Aspect</name>
+        <desc>For maintaining the aspect ratio of a box</desc>
+        <usage>
+            This widget has two principle properties:
+            
+            * aspectwidth, aspectheight [default is 1]
+            
+            Notes:
+            
+            * Do not preapply this template - preapply lib.layout.aspect
+        </usage>
+    </meta:doc>
+    
+    <aspect />
+    <container />
+</vexi>

Added: trunk/widgets/org.vexi.widgets/src_dev/visualtest/layout/aspect.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src_dev/visualtest/layout/aspect.t           
                (rev 0)
+++ trunk/widgets/org.vexi.widgets/src_dev/visualtest/layout/aspect.t   
2010-02-26 11:35:35 UTC (rev 3807)
@@ -0,0 +1,23 @@
+<vexi xmlns:ui="vexi://ui" xmlns="vexi.layout">
+    <ui:box orient="vertical" fill="white">
+        <ui:box height="10" />
+        <ui:box>
+            <ui:box orient="vertical">
+                <ui:box text="a square" />
+                <aspect fill="black" />
+                <ui:box text="a 2:1 rectangle" />
+                <aspect fill="black" aspectwidth="2" />
+            </ui:box>
+            <ui:box orient="vertical">
+                <ui:box text="a 1:2 rectangle" />
+                <aspect fill="black" aspectheight="2" />
+                <ui:box text="a 2:3 rectangle" />
+                <aspect fill="black" aspectwidth="3" aspectheight="2" />
+            </ui:box>
+        </ui:box>
+        <ui:box height="50" />
+        
+        vexi.ui.frame = thisbox;
+        
+    </ui:box>
+</vexi>
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to