Author: bargull
Date: 2008-01-09 15:43:03 -0800 (Wed, 09 Jan 2008)
New Revision: 7794

Modified:
   openlaszlo/trunk/lps/components/utils/layouts/simplelayout.lzx
Log:
Change 20080106-bargull-0 by [EMAIL PROTECTED] on 2008-01-06 00:25:06
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fix simplelayout optimization-bug

New Features:

Bugs Fixed: LPP-3812 - "simplelayout does not correctly position views that are 
programmatically created"

Technical Reviewer: promanik
QA Reviewer: frisco
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
You need to take last visible subview to compute new layout-position. Just 
taking the last subview leads to a bug when this view is non-visible. Also 
fixed another bug, so now new layout-position correctly respects inset-property.


Tests:



Modified: openlaszlo/trunk/lps/components/utils/layouts/simplelayout.lzx
===================================================================
--- openlaszlo/trunk/lps/components/utils/layouts/simplelayout.lzx      
2008-01-09 22:02:01 UTC (rev 7793)
+++ openlaszlo/trunk/lps/components/utils/layouts/simplelayout.lzx      
2008-01-09 23:43:03 UTC (rev 7794)
@@ -28,18 +28,31 @@
     </method>
 
     <!--- @keywords private -->
-    <method name="addSubview" args="newsub">
+    <method name="addSubview" args="newsub"><![CDATA[
         this.updateDelegate.register( newsub,  "on" + this.sizeAxis);
         this.updateDelegate.register( newsub,  "onvisible" );
         //this is an optimization to avoid calling update in the simple case
         //where a single subview was just added
-        if ( ! this.locked &amp;&amp; this.subviews.length ){
-            var s= this.subviews[ this.subviews.length-1 ];
-            var p =  s[ this.axis ] + s[ this.sizeAxis ] + this.spacing;
-            newsub.setAttribute( this.axis , p  ) ;
+        if (!this.locked) {
+            var rv = null;
+            var sv = this.subviews;
+            for (var i = sv.length-1; i >= 0; --i) {
+                if (sv[i].visible) {
+                    rv = sv[i];
+                    break;
+                }
+            } 
+            
+            if (rv) {
+                var p = rv[ this.axis ] + rv[ this.sizeAxis ] + this.spacing;
+            } else {
+                var p = this.inset;
+            }
+            
+            newsub.setAttribute(this.axis, p);
         }
         super.addSubview( newsub );
-    </method>
+    ]]></method>
 
     <!--- This method is usually called automatically when any of the views
           controlled by the layout change their size in the layout axis, or
@@ -64,7 +77,7 @@
 </class>
 </library>
 <!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
-* Copyright 2001-2006 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * X_LZ_COPYRIGHT_END ****************************************************** -->
 <!-- @LZX_VERSION@                                                         -->


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to