[haiku-commits] r39641 - in haiku/trunk: headers/libs/alm src/libs/alm

  • From: clemens.zeidler@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 26 Nov 2010 05:20:39 +0100 (CET)

Author: czeidler
Date: 2010-11-26 05:20:38 +0100 (Fri, 26 Nov 2010)
New Revision: 39641
Changeset: http://dev.haiku-os.org/changeset/39641

Modified:
   haiku/trunk/headers/libs/alm/ALMLayout.h
   haiku/trunk/headers/libs/alm/Area.h
   haiku/trunk/src/libs/alm/ALMLayout.cpp
   haiku/trunk/src/libs/alm/Area.cpp
Log:
Keep the preferred size ratio into account. This make layout behaviour much 
more intuitive when resizing a window. Thanks Christof.



Modified: haiku/trunk/headers/libs/alm/ALMLayout.h
===================================================================
--- haiku/trunk/headers/libs/alm/ALMLayout.h    2010-11-26 01:03:27 UTC (rev 
39640)
+++ haiku/trunk/headers/libs/alm/ALMLayout.h    2010-11-26 04:20:38 UTC (rev 
39641)
@@ -151,6 +151,9 @@
                        float                           fSpacing;
 
                        Area*                           fCurrentArea;
+
+                       Variable*                       fScaleWidth;
+                       Variable*                       fScaleHeight;
 };
 
 }      // namespace BALM

Modified: haiku/trunk/headers/libs/alm/Area.h
===================================================================
--- haiku/trunk/headers/libs/alm/Area.h 2010-11-26 01:03:27 UTC (rev 39640)
+++ haiku/trunk/headers/libs/alm/Area.h 2010-11-26 04:20:38 UTC (rev 39641)
@@ -107,8 +107,12 @@
                                                                
Area(BLayoutItem* item);
 
                        void                            _Init(LinearSpec* ls, 
XTab* left, YTab* top,
-                                                                       XTab* 
right, YTab* bottom);
-                       void                            _Init(LinearSpec* ls, 
Row* row, Column* column);
+                                                                       XTab* 
right, YTab* bottom,
+                                                                       
Variable* scaleWidth,
+                                                                       
Variable* scaleHeight);
+                       void                            _Init(LinearSpec* ls, 
Row* row, Column* column,
+                                                                       
Variable* scaleWidth,
+                                                                       
Variable* scaleHeight);
 
                        void                            _DoLayout();
 
@@ -145,6 +149,9 @@
                        double                          fContentAspectRatio;
                        Constraint*                     fContentAspectRatioC;
 
+                       Variable*                       fScaleWidth;
+                       Variable*                       fScaleHeight;
+
 public:
        friend class            BALMLayout;
 

Modified: haiku/trunk/src/libs/alm/ALMLayout.cpp
===================================================================
--- haiku/trunk/src/libs/alm/ALMLayout.cpp      2010-11-26 01:03:27 UTC (rev 
39640)
+++ haiku/trunk/src/libs/alm/ALMLayout.cpp      2010-11-26 04:20:38 UTC (rev 
39641)
@@ -52,12 +52,16 @@
        fPreferredSize = kUnsetSize;
 
        fPerformancePath = NULL;
+
+       fScaleWidth = fSolver->AddVariable();
+       fScaleHeight = fSolver->AddVariable();
 }
 
 
 BALMLayout::~BALMLayout()
 {
-       
+       delete fScaleWidth;
+       delete fScaleHeight;
 }
 
 
@@ -479,7 +483,7 @@
                return NULL;
        fCurrentArea = area;
 
-       area->_Init(fSolver, left, top, right, bottom);
+       area->_Init(fSolver, left, top, right, bottom, fScaleWidth, 
fScaleHeight);
        return area;
 }
 
@@ -494,7 +498,7 @@
                return NULL;
        fCurrentArea = area;
 
-       area->_Init(fSolver, row, column);
+       area->_Init(fSolver, row, column, fScaleWidth, fScaleHeight);
        return area;
 }
 

Modified: haiku/trunk/src/libs/alm/Area.cpp
===================================================================
--- haiku/trunk/src/libs/alm/Area.cpp   2010-11-26 01:03:27 UTC (rev 39640)
+++ haiku/trunk/src/libs/alm/Area.cpp   2010-11-26 04:20:38 UTC (rev 39641)
@@ -593,7 +593,8 @@
  * Initialize variables.
  */
 void
-Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom)
+Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom,
+       Variable* scaleWidth, Variable* scaleHeight)
 {
        fLS = ls;
        fLeft = left;
@@ -601,6 +602,9 @@
        fTop = top;
        fBottom = bottom;
 
+       fScaleWidth = scaleWidth;
+       fScaleHeight = scaleHeight;
+
        // adds the two essential constraints of the area that make sure that 
the
        // left x-tab is really to the left of the right x-tab, and the top 
y-tab
        // really above the bottom y-tab
@@ -612,11 +616,12 @@
        fConstraints.AddItem(fMinContentWidth);
        fConstraints.AddItem(fMinContentHeight);
 
-       fPreferredContentWidth = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight,
-               OperatorType(EQ), 0, fShrinkPenalties.Height(), 
fGrowPenalties.Width());
+       fPreferredContentWidth = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight, 
-1.0,
+               fScaleWidth, OperatorType(EQ), 0, fShrinkPenalties.Height(),
+               fGrowPenalties.Width());
 
-       fPreferredContentHeight = fLS->AddConstraint(-1.0, fTop, 1.0, fBottom,
-               OperatorType(EQ), 0, fShrinkPenalties.Height(),
+       fPreferredContentHeight = fLS->AddConstraint(-1.0, fTop, 1.0, fBottom, 
-1.0,
+               fScaleHeight, OperatorType(EQ), 0, fShrinkPenalties.Height(),
                fGrowPenalties.Height());
 
        fConstraints.AddItem(fPreferredContentWidth);
@@ -625,9 +630,11 @@
 
 
 void
-Area::_Init(LinearSpec* ls, Row* row, Column* column)
+Area::_Init(LinearSpec* ls, Row* row, Column* column, Variable* scaleWidth,
+       Variable* scaleHeight)
 {
-       _Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom());
+       _Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom(),
+               scaleWidth, scaleHeight);
        fRow = row;
        fColumn = column;
 }
@@ -718,6 +725,9 @@
        if (preferred.height > 0)
                height = preferred.Height() + TopInset() + BottomInset();
 
-       fPreferredContentWidth->SetRightSide(width);
-       fPreferredContentHeight->SetRightSide(height);
+       fPreferredContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight, -width,
+               fScaleWidth);
+
+       fPreferredContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom, -height,
+               fScaleHeight);
 }


Other related posts:

  • » [haiku-commits] r39641 - in haiku/trunk: headers/libs/alm src/libs/alm - clemens . zeidler