Revision: 3347
          http://vexi.svn.sourceforge.net/vexi/?rev=3347&view=rev
Author:   clrg
Date:     2009-01-09 06:02:01 +0000 (Fri, 09 Jan 2009)

Log Message:
-----------
More consistent resize behaviour
- frame resizable always matches root shrink
- for resizable frames, root content size is constrained to frame size
- removes flicker / fixes odd frame resizing behaviour

Modified Paths:
--------------
    trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
    trunk/core/org.vexi.core/src/org/vexi/core/Surface.java

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2009-01-08 02:40:29 UTC 
(rev 3346)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2009-01-09 06:02:01 UTC 
(rev 3347)
@@ -103,9 +103,6 @@
     private final void set(int mask) { flags |= mask; }
     private final void clear(int mask) { flags &= ~mask; }
     private final boolean test(int mask) { return ((flags & mask) == mask); }
-
-    /** for Surface to find out if root box is resizable */
-    protected final boolean isRootResizable() { return !test(SHRINK); }
     
     /** for Surface to set the x/y properties of the root box */
     protected final void setRootPosition(int x, int y) throws JSExn {
@@ -115,8 +112,14 @@
         }
         //#end
     }
+    
+    /** for Surface to check if a root box is visible */
+    static final boolean testDisplay(Box b) { return b.test(DISPLAY); }
 
+    /** for Surface to find out if root box is resizable */
+    static final  boolean testShrink(Box b) { return b.test(SHRINK); }
 
+
     // Flags 
//////////////////////////////////////////////////////////////////////
 
     private static final boolean HORIZONTAL          = true;
@@ -442,13 +445,22 @@
         }
         newwidth = min(maxwidth, max(minwidth, newwidth));
 
-        // mark 
+        // assign contentwidth and mark for place in parent and placing of 
children 
         if (newwidth != contentwidth) {
-            
PUT_BOX_FIELD(SC_contentwidth,JSU.N(newwidth),contentwidth=newwidth,CONTENTWIDTH_TRAP)
-            setPlace();
             if (parent != null) {
+                
PUT_BOX_FIELD(SC_contentwidth,JSU.N(newwidth),contentwidth=newwidth,CONTENTWIDTH_TRAP)
+                setPlace();
                 parent.set(PLACE);
                 parent.setConstrain();
+            } else {
+                // constrain contentwidth to frame width
+                if (getSurface()!=null && !test(SHRINK)) {
+                    newwidth = min(getSurface().pendingWidth, newwidth);
+                }
+                if (newwidth != contentwidth) {
+                    
PUT_BOX_FIELD(SC_contentwidth,JSU.N(newwidth),contentwidth=newwidth,CONTENTWIDTH_TRAP)
+                    setPlace();
+                }
             }
         }
         //#end
@@ -1592,9 +1604,6 @@
             b = b.parent;
         } while(true);
     }
-    
-    /** for Surface to check if a root box is visible */
-    static final boolean testDisplay(Box b) { return b.test(DISPLAY); }
 
     /** establish visible, invoking read traps if required */
     private final boolean isVisible() throws JSExn {

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Surface.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Surface.java     2009-01-08 
02:40:29 UTC (rev 3346)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Surface.java     2009-01-09 
06:02:01 UTC (rev 3347)
@@ -74,6 +74,7 @@
     DirtyList dirtyRegions = new DirtyList();          ///< Dirty regions on 
the surface
     protected Picture icon;
     private boolean visible = false;
+    private boolean resizable = false;
 
     public int topInset = 0;
     public int leftInset = 0;
@@ -400,12 +401,15 @@
     /** only run if scheduled */
     public Object run(Object o) {
         // TODO: document this in the reference
-        boolean b = Box.testDisplay(root);
-        if (visible != b) {
-            visible = b;
-            makeVisible(b);
+        if (resizable != Box.testShrink(root)) {
+            resizable = Box.testShrink(root); 
+            setResizable(resizable);
         }
-        if (b) render();
+        if (visible != Box.testDisplay(root)) {
+            visible = Box.testDisplay(root);
+            makeVisible(visible);
+        }
+        if (visible) render();
         return null;
     }
 
@@ -459,7 +463,6 @@
             pendingHeight = fh != null ? JSU.toInt(fh) : 
Platform.getScreenHeight() / 2;
             JS align = root.getAndTriggerTraps(SC_framealign);
             setAlign(align == null ? null : JSU.toString(align));
-            setResizable(root.isRootResizable());
             Refresh();
         } catch (JSExn jse) {
             // FIXME: handle exceptions from icon/titlebar traps properly
@@ -493,7 +496,7 @@
             int cwidth = root.contentwidth;
             int cheight = root.contentheight;
             mouseUpdateRequired = root.reflow(pendingWidth, pendingHeight) || 
mouseUpdateRequired;
-            if (cwidth!=root.contentwidth || cheight!=root.contentheight)
+            if (Box.testShrink(root) && (cwidth!=root.contentwidth || 
cheight!=root.contentheight))
                 setMinimumSize(root.contentwidth, root.contentheight);
         } while(abort);
 


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

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to