changeset 1435:3c5287b8eebb

Temporary fix on Mac for box miscalculation when box is not expandable but items are in complex layouts. There is a fundamental flaw in the calculation of these types of boxes... and after looking at the code... in general the layout code does a lot more calculation than necessary... I will be rewriting and simplifying this code in the near future... but this is a temporary fix to get things to work better in the meantime.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 07 Dec 2011 18:51:48 +0000
parents 2cca36ec3da6
children 18c1b999dd65
files dw.h mac/dw.m
diffstat 2 files changed, 20 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Tue Dec 06 22:36:55 2011 +0000
+++ b/dw.h	Wed Dec 07 18:51:48 2011 +0000
@@ -675,6 +675,8 @@
    int count;
    /* Box type - horizontal or vertical */
    int type;
+   /* Keep track of how box is packed */
+   int hsize, vsize;
    /* Padding */
    int pad, parentpad, grouppadx, grouppady;
    /* Groupbox */
--- a/mac/dw.m	Tue Dec 06 22:36:55 2011 +0000
+++ b/mac/dw.m	Wed Dec 07 18:51:48 2011 +0000
@@ -2491,6 +2491,8 @@
                     tmp->parentyratio = thisbox->yratio;
 
                     tmp->parentpad = tmp->pad;
+                    tmp->hsize = thisbox->items[z].hsize;
+                    tmp->vsize = thisbox->items[z].vsize;
 
                     /* Just in case */
                     tmp->xratio = thisbox->xratio;
@@ -2607,19 +2609,11 @@
         }
         else
         {
-            if(thisbox->items[z].width == -1)
-            {
-                /* figure out how much space this item requires */
-                /* thisbox->items[z].width = */
-            }
+            (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2);
+            if(thisbox->items[z].hsize != SIZEEXPAND)
+                (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
             else
-            {
-                (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2);
-                if(thisbox->items[z].hsize != SIZEEXPAND)
-                    (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
-                else
-                    (*usedpadx) += thisbox->items[z].pad*2;
-            }
+                (*usedpadx) += thisbox->items[z].pad*2;
         }
         if(thisbox->type == DW_HORZ)
         {
@@ -2638,19 +2632,11 @@
         }
         else
         {
-            if(thisbox->items[z].height == -1)
-            {
-                /* figure out how much space this item requires */
-                /* thisbox->items[z].height = */
-            }
+            (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2);
+            if(thisbox->items[z].vsize != SIZEEXPAND)
+                (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height;
             else
-            {
-                (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2);
-                if(thisbox->items[z].vsize != SIZEEXPAND)
-                    (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height;
-                else
-                    (*usedpady) += thisbox->items[z].pad*2;
-            }
+                (*usedpady) += thisbox->items[z].pad*2;
         }
     }
 
@@ -2751,8 +2737,14 @@
 
                 point.x = currentx + pad;
                 point.y = currenty + pad;
-                size.width = width + vectorx;
-                size.height = height + vectory;
+                if(thisbox->type == DW_VERT && thisbox->hsize == SIZESTATIC && thisbox->items[z].hsize == SIZEEXPAND && thisbox->width)
+                    size.width = thisbox->width;
+                else
+                    size.width = width + vectorx;
+                if(thisbox->type == DW_HORZ && thisbox->vsize == SIZESTATIC && thisbox->items[z].vsize == SIZEEXPAND && thisbox->height)
+                    size.height = thisbox->height;
+                else
+                    size.height = height + vectory;
                 [handle setFrameOrigin:point];
                 [handle setFrameSize:size];