Revision: 3552
          http://vexi.svn.sourceforge.net/vexi/?rev=3552&view=rev
Author:   clrg
Date:     2009-07-14 04:36:29 +0000 (Tue, 14 Jul 2009)

Log Message:
-----------
Continue improving layout / some things that slipped through the cracks of the 
previous layout commit

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

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2009-07-14 01:17:26 UTC 
(rev 3551)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2009-07-14 04:36:29 UTC 
(rev 3552)
@@ -231,9 +231,9 @@
 
     // specified directly by user
     protected int minwidth = 0;
-    protected int maxwidth = Integer.MAX_VALUE;
+    protected int maxwidth = MAX_DIMENSION;
     protected int minheight = 0;
-    protected int maxheight = Integer.MAX_VALUE;
+    protected int maxheight = MAX_DIMENSION;
 
     // computed during reflow
     protected int x = 0;
@@ -543,7 +543,6 @@
                             int numflexible = 0;
                             int num_minsize = 0;
                             int num_maxsize = 0;
-                            int sum_maxsize = 0;
                             int num_passive = 0;
                             for (Box child = getChild(i=0); child != null; 
child = getChild(++i)) {
                                 if (!child.test(DISPLAY)) continue;
@@ -558,7 +557,6 @@
                                 } else if (child.maxwidth<targetsize) {
                                     max_maxsize = max(max_maxsize, 
child.maxwidth);
                                     num_maxsize++;
-                                    sum_maxsize += 
child.maxwidth-child.contentwidth;
                                     total += (float)child.maxwidth;
                                 } else {
                                     numflexible++;
@@ -568,9 +566,8 @@
                             // no active children - nothing to do
                             if (numactive==0) return;
                             // no solution required - reset total and break out
-                            if (num_maxsize+num_passive==numactive && 
sum_maxsize<=width) {
+                            if (num_maxsize+num_passive==numactive && 
(int)(total+0.5)<=width) {
                                 targetsize = width;
-                                total = 0;
                                 break;
                             }
                             // test to see if targetsize produces a solution 
that rounds
@@ -588,8 +585,9 @@
                                 } else {
                                     targetsize = (float)min_minsize + 
((float)width-total)/(float)num_minsize;
                                 }
-                            } else break;
-                            // reset total and try again
+                            } else { total = 0; break; }
+                            // reset outer variables and try again
+                            numactive = 0;
                             total = 0;
                             // give a helpful report if no solution is found
                             if (j>=99) {
@@ -603,7 +601,7 @@
                         }
 
                         // REMARK: slack only needed if total was reset to 0
-                        float slack_x = (total==0) ? 
(float)(width-contentwidth)/numactive : 0;
+                        float slack_x = (total==0) ? 0 : 
(float)(width-total)/numactive;
                         // we use total (a float) to keep tabs on final layout 
totals
                         // so we do not get stray pixel sized gaps caused by 
rounding
                         total = 0;
@@ -613,16 +611,20 @@
                             child_height = child.test(VSHRINK) ? 
child.contentheight : min(child.maxheight, height);
                             child_y = top ? 0 : (bottom ? height-child_height 
: (height-child_height)/2);
                             // width, x
-                            if (child.test(HSHRINK) || targetsize > 
child.maxwidth || slack_x > 0.0) {
+                            if (slack_x > 0.0) {
                                 child_x = (int)(total+0.5+(left ? 0 : (right ? 
slack_x : slack_x/2)));
                                 child_width = child.test(HSHRINK) ? 
child.contentwidth : child.maxwidth;
                                 total += slack_x + (float)child_width;
                             } else {
                                 child_x = (int)(total+0.5);
-                                if (child.contentwidth > targetsize) {
+                                if (child.test(HSHRINK) || child.contentwidth 
> targetsize) {
                                     child_width = child.contentwidth;
-                                    total += child_width;
+                                    total += (float)child_width;
+                                } else if (targetsize > child.maxwidth) {
+                                    child_width = child.maxwidth;
+                                    total += (float)child_width;
                                 } else {
+                                    // REMARK: this bit of float magic makes 
layout gapless
                                     child_width = 
(int)(total+targetsize+0.5)-(int)(total+0.5);
                                     total += targetsize;
                                 }
@@ -659,7 +661,6 @@
                             int numflexible = 0;
                             int num_minsize = 0;
                             int num_maxsize = 0;
-                            int sum_maxsize = 0;
                             int num_passive = 0;
                             for (Box child = getChild(i=0); child != null; 
child = getChild(++i)) {
                                 if (!child.test(DISPLAY)) continue;
@@ -674,7 +675,6 @@
                                 } else if (child.maxheight<targetsize) {
                                     max_maxsize = max(max_maxsize, 
child.maxheight);
                                     num_maxsize++;
-                                    sum_maxsize += 
child.maxheight-child.contentheight;
                                     total += (float)child.maxheight;
                                 } else {
                                     numflexible++;
@@ -684,9 +684,8 @@
                             // no active children - nothing to do
                             if (numactive==0) return;
                             // no solution required - reset total and break out
-                            if (num_maxsize+num_passive==numactive && 
sum_maxsize<=height) {
+                            if (num_maxsize+num_passive==numactive && 
(int)(total+0.5)<=height) {
                                 targetsize = height;
-                                total = 0;
                                 break;
                             }
                             // test to see if targetsize produces a solution 
that rounds
@@ -704,8 +703,9 @@
                                 } else {
                                     targetsize = (float)min_minsize + 
((float)height-total)/(float)num_minsize;
                                 }
-                            } else break;
-                            // reset total and try again
+                            } else { total = 0; break; }
+                            // reset outer variables and try again
+                            numactive = 0;
                             total = 0;
                             // give a helpful report if no solution is found
                             if (j>=99) {
@@ -719,7 +719,7 @@
                         }
 
                         // REMARK: slack only needed if total was reset to 0
-                        float slack_y = (total==0) ? 
(float)(height-contentheight)/numactive : 0;
+                        float slack_y = (total==0) ? 0 : 
(float)(height-total)/numactive;
                         // we use total (a float) to keep tabs on final layout 
totals
                         // so we do not get stray pixel sized gaps caused by 
rounding
                         total = 0;
@@ -729,16 +729,20 @@
                             child_width = child.test(HSHRINK) ? 
child.contentwidth : min(child.maxwidth, width);
                             child_x = left ? 0 : (right ? width-child_width : 
(width-child_width)/2);
                             // height, y
-                            if (slack_y > 0.0 || child.test(VSHRINK) || 
targetsize > child.maxheight) {
+                            if (slack_y > 0.0) {
                                 child_y = (int)(total+0.5+(top ? 0 : (bottom ? 
slack_y : slack_y/2)));
                                 child_height = child.test(VSHRINK) ? 
child.contentheight : child.maxheight;
                                 total += slack_y + child_height;
                             } else {
                                 child_y = (int)(total+0.5);
-                                if (child.contentheight > targetsize) {
+                                if (child.test(VSHRINK) || child.contentheight 
> targetsize) {
                                     child_height = child.contentheight;
-                                    total += child_height;
+                                    total += (float)child_height;
+                                } else if (targetsize > child.maxheight) {
+                                    child_height = child.maxheight;
+                                    total += (float)child_height;
                                 } else {
+                                    // REMARK: this bit of float magic makes 
layout gapless
                                     child_height = 
(int)(total+targetsize+0.5)-(int)(total+0.5);
                                     total += targetsize;
                                 }


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

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to