Author: czeidler Date: 2010-09-21 00:47:13 +0200 (Tue, 21 Sep 2010) New Revision: 38750 Changeset: http://dev.haiku-os.org/changeset/38750 Modified: haiku/trunk/headers/libs/alm/Area.h haiku/trunk/headers/libs/alm/BALMLayout.h haiku/trunk/headers/libs/alm/Column.h haiku/trunk/headers/libs/alm/Row.h haiku/trunk/headers/libs/alm/XTab.h haiku/trunk/headers/libs/alm/YTab.h haiku/trunk/src/libs/alm/Area.cpp haiku/trunk/src/libs/alm/BALMLayout.cpp haiku/trunk/src/libs/alm/Column.cpp haiku/trunk/src/libs/alm/Row.cpp haiku/trunk/src/libs/alm/XTab.cpp haiku/trunk/src/libs/alm/YTab.cpp Log: Encapsulate the solver in the ALM layout class. Modified: haiku/trunk/headers/libs/alm/Area.h =================================================================== --- haiku/trunk/headers/libs/alm/Area.h 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/headers/libs/alm/Area.h 2010-09-20 22:47:13 UTC (rev 38750) @@ -13,11 +13,11 @@ #include <SupportDefs.h> #include <View.h> +#include "Column.h" +#include "LinearSpec.h" +#include "Row.h" #include "XTab.h" #include "YTab.h" -#include "Area.h" -#include "Row.h" -#include "Column.h" class Constraint; @@ -26,8 +26,6 @@ namespace BALM { -class BALMLayout; - /** * Rectangular area in the GUI, defined by a tab on each side. */ @@ -96,22 +94,22 @@ BList* HasSameSizeAs(Area* area); protected: - Area(BALMLayout* ls, XTab* left, YTab* top, - XTab* right, YTab* bottom, - BView* content, - BSize minContentSize); - Area(BALMLayout* ls, Row* row, Column* column, - BView* content, - BSize minContentSize); + Area(BALMLayout* layout, + LinearSpec* ls, XTab* left, YTab* top, + XTab* right, YTab* bottom, BView* content, + BSize minContentSize); + Area(BALMLayout* layout, + LinearSpec* ls, Row* row, Column* column, + BView* content, BSize minContentSize); void DoLayout(); private: void InitChildArea(); void UpdateHorizontal(); void UpdateVertical(); - void Init(BALMLayout* ls, XTab* left, YTab* top, - XTab* right, YTab* bottom, - BView* content, + void Init(BALMLayout* layout, + LinearSpec* ls, XTab* left, YTab* top, + XTab* right, YTab* bottom, BView* content, BSize minContentSize); public: @@ -124,7 +122,10 @@ BList* fConstraints; private: - BALMLayout* fLS; + // TODO remove the layout pointer when making Area a LayoutItem + BALMLayout* fALMLayout; + + LinearSpec* fLS; XTab* fLeft; XTab* fRight; YTab* fTop; Modified: haiku/trunk/headers/libs/alm/BALMLayout.h =================================================================== --- haiku/trunk/headers/libs/alm/BALMLayout.h 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/headers/libs/alm/BALMLayout.h 2010-09-20 22:47:13 UTC (rev 38750) @@ -27,7 +27,7 @@ /** * A GUI layout engine using the ALM. */ -class BALMLayout : public BAbstractLayout, public LinearSpec { +class BALMLayout : public BAbstractLayout { public: BALMLayout(); void SolveLayout(); @@ -80,6 +80,8 @@ char* PerformancePath() const; void SetPerformancePath(char* path); + LinearSpec* Solver(); + private: BSize CalculateMinSize(); BSize CalculateMaxSize(); @@ -89,6 +91,8 @@ LayoutStyleType fLayoutStyle; bool fActivated; + LinearSpec fSolver; + BList* fAreas; XTab* fLeft; XTab* fRight; Modified: haiku/trunk/headers/libs/alm/Column.h =================================================================== --- haiku/trunk/headers/libs/alm/Column.h 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/headers/libs/alm/Column.h 2010-09-20 22:47:13 UTC (rev 38750) @@ -3,15 +3,15 @@ * Copyright 2007-2008, James Kim, jkim202@xxxxxxxxxxxxxxxxx * Distributed under the terms of the MIT License. */ - #ifndef COLUMN_H #define COLUMN_H -#include "Constraint.h" - #include <List.h> +#include "Constraint.h" +#include "LinearSpec.h" + namespace BALM { class BALMLayout; @@ -21,36 +21,35 @@ * Represents a column defined by two x-tabs. */ class Column { - public: - XTab* Left() const; - XTab* Right() const; - Column* Previous() const; - void SetPrevious(Column* value); - Column* Next() const; - void SetNext(Column* value); - //~ string ToString(); - void InsertBefore(Column* column); - void InsertAfter(Column* column); - Constraint* HasSameWidthAs(Column* column); - BList* Constraints() const; - void SetConstraints(BList* constraints); - ~Column(); + XTab* Left() const; + XTab* Right() const; + Column* Previous() const; + void SetPrevious(Column* value); + Column* Next() const; + void SetNext(Column* value); + //~ string ToString(); + void InsertBefore(Column* column); + void InsertAfter(Column* column); + Constraint* HasSameWidthAs(Column* column); + BList* Constraints() const; + void SetConstraints(BList* constraints); + ~Column(); protected: - Column(BALMLayout* ls); + Column(LinearSpec* ls); protected: - BALMLayout* fLS; - XTab* fLeft; - XTab* fRight; + LinearSpec* fLS; + XTab* fLeft; + XTab* fRight; private: - Column* fPrevious; - Column* fNext; - Constraint* fPreviousGlue; - Constraint* fNextGlue; - BList* fConstraints; + Column* fPrevious; + Column* fNext; + Constraint* fPreviousGlue; + Constraint* fNextGlue; + BList* fConstraints; public: friend class BALMLayout; Modified: haiku/trunk/headers/libs/alm/Row.h =================================================================== --- haiku/trunk/headers/libs/alm/Row.h 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/headers/libs/alm/Row.h 2010-09-20 22:47:13 UTC (rev 38750) @@ -7,11 +7,12 @@ #ifndef ROW_H #define ROW_H +#include <List.h> + #include "Constraint.h" +#include "LinearSpec.h" -#include <List.h> - namespace BALM { class BALMLayout; @@ -21,36 +22,35 @@ * Represents a row defined by two y-tabs. */ class Row { - public: - YTab* Top() const; - YTab* Bottom() const; - Row* Previous() const; - void SetPrevious(Row* value); - Row* Next() const; - void SetNext(Row* value); - //~ string ToString(); - void InsertBefore(Row* row); - void InsertAfter(Row* row); - Constraint* HasSameHeightAs(Row* row); - BList* Constraints() const; - void SetConstraints(BList* constraints); - ~Row(); + YTab* Top() const; + YTab* Bottom() const; + Row* Previous() const; + void SetPrevious(Row* value); + Row* Next() const; + void SetNext(Row* value); + //~ string ToString(); + void InsertBefore(Row* row); + void InsertAfter(Row* row); + Constraint* HasSameHeightAs(Row* row); + BList* Constraints() const; + void SetConstraints(BList* constraints); + ~Row(); protected: - Row(BALMLayout* ls); + Row(LinearSpec* ls); protected: - BALMLayout* fLS; - YTab* fTop; - YTab* fBottom; + LinearSpec* fLS; + YTab* fTop; + YTab* fBottom; private: - Row* fPrevious; - Row* fNext; - Constraint* fPreviousGlue; - Constraint* fNextGlue; - BList* fConstraints; + Row* fPrevious; + Row* fNext; + Constraint* fPreviousGlue; + Constraint* fNextGlue; + BList* fConstraints; public: friend class BALMLayout; Modified: haiku/trunk/headers/libs/alm/XTab.h =================================================================== --- haiku/trunk/headers/libs/alm/XTab.h 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/headers/libs/alm/XTab.h 2010-09-20 22:47:13 UTC (rev 38750) @@ -3,32 +3,30 @@ * Copyright 2007-2008, James Kim, jkim202@xxxxxxxxxxxxxxxxx * Distributed under the terms of the MIT License. */ - #ifndef X_TAB_H #define X_TAB_H +#include "LinearSpec.h" #include "Variable.h" namespace BALM { - -class BALMLayout; + /** * Vertical grid line (x-tab). */ class XTab : public Variable { - protected: - XTab(BALMLayout* ls); + XTab(LinearSpec* ls); protected: - /** - * Property signifying if there is a constraint which relates - * this tab to a different tab that is further to the left. - * Only used for reverse engineering. - */ - bool fLeftLink; + /** + * Property signifying if there is a constraint which relates + * this tab to a different tab that is further to the left. + * Only used for reverse engineering. + */ + bool fLeftLink; public: friend class Area; Modified: haiku/trunk/headers/libs/alm/YTab.h =================================================================== --- haiku/trunk/headers/libs/alm/YTab.h 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/headers/libs/alm/YTab.h 2010-09-20 22:47:13 UTC (rev 38750) @@ -3,31 +3,30 @@ * Copyright 2007-2008, James Kim, jkim202@xxxxxxxxxxxxxxxxx * Distributed under the terms of the MIT License. */ - #ifndef Y_TAB_H #define Y_TAB_H +#include "LinearSpec.h" #include "Variable.h" + namespace BALM { - -class BALMLayout; + /** * Horizontal grid line (y-tab). */ class YTab : public Variable { - protected: - YTab(BALMLayout* ls); + YTab(LinearSpec* ls); protected: - /** - * Property signifying if there is a constraint which relates - * this tab to a different tab that is further to the top. - * Only used for reverse engineering. - */ - bool fTopLink; + /** + * Property signifying if there is a constraint which relates + * this tab to a different tab that is further to the top. + * Only used for reverse engineering. + */ + bool fTopLink; public: friend class Area; Modified: haiku/trunk/src/libs/alm/Area.cpp =================================================================== --- haiku/trunk/src/libs/alm/Area.cpp 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/src/libs/alm/Area.cpp 2010-09-20 22:47:13 UTC (rev 38750) @@ -85,7 +85,7 @@ fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); } else UpdateHorizontal(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -120,7 +120,7 @@ fMaxContentWidth->SetLeftSide(-1.0, fLeft, 1.0, fRight); } else UpdateHorizontal(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -151,7 +151,7 @@ fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); } else UpdateVertical(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -182,7 +182,7 @@ fMaxContentHeight->SetLeftSide(-1.0, fTop, 1.0, fBottom); } else UpdateVertical(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -206,7 +206,7 @@ SetTop(row->Top()); SetBottom(row->Bottom()); fRow = row; - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -230,7 +230,7 @@ SetLeft(column->Left()); SetRight(column->Right()); fColumn = column; - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -252,7 +252,7 @@ { if (fChildArea == NULL) fContent = content; else fChildArea->fContent = content; - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -319,7 +319,7 @@ fMinContentHeight->SetRightSide(fMinContentSize.Height()); } else fChildArea->SetMinContentSize(min); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -354,7 +354,7 @@ } } else fChildArea->SetMaxContentSize(max); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -398,7 +398,7 @@ } } else fChildArea->SetPreferredContentSize(preferred); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -422,7 +422,7 @@ } } else fChildArea->SetShrinkPenalties(shrink); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -448,7 +448,7 @@ } } else fChildArea->SetGrowPenalties(grow); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -458,7 +458,8 @@ double Area::ContentAspectRatio() const { - return (fChildArea == NULL) ? fContentAspectRatio : fChildArea->fContentAspectRatio; + return (fChildArea == NULL) ? fContentAspectRatio + : fChildArea->fContentAspectRatio; } @@ -482,7 +483,7 @@ } } else fChildArea->SetContentAspectRatio(ratio); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -505,7 +506,7 @@ fAlignment = alignment; UpdateHorizontal(); UpdateVertical(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -515,7 +516,7 @@ void Area::SetHorizontalAlignment(alignment horizontal) { fAlignment.SetHorizontal(horizontal); UpdateHorizontal(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -527,7 +528,7 @@ { fAlignment.SetVertical(vertical); UpdateVertical(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -549,7 +550,7 @@ { fLeftInset = left; UpdateHorizontal(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -571,7 +572,7 @@ { fTopInset = top; UpdateVertical(); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } @@ -633,7 +634,7 @@ if (PreferredContentSize() != Content()->PreferredSize()){ SetPreferredContentSize(Content()->PreferredSize()); - fLS->InvalidateLayout(); + fALMLayout->InvalidateLayout(); } if (dynamic_cast<BButton*>(Content()) != NULL @@ -729,7 +730,7 @@ if (fChildArea != NULL) delete fChildArea; for (int32 i = 0; i < fConstraints->CountItems(); i++) delete (Constraint*)fConstraints->ItemAt(i); - fLS->Areas()->RemoveItem(this); + fALMLayout->Areas()->RemoveItem(this); } @@ -737,10 +738,10 @@ * Constructor. * Uses XTabs and YTabs. */ -Area::Area(BALMLayout* ls, XTab* left, YTab* top, XTab* right, YTab* bottom, - BView* content, BSize minContentSize) +Area::Area(BALMLayout* layout, LinearSpec* ls, XTab* left, YTab* top, + XTab* right, YTab* bottom, BView* content, BSize minContentSize) { - Init(ls, left, top, right, bottom, content, minContentSize); + Init(layout, ls, left, top, right, bottom, content, minContentSize); } @@ -748,11 +749,11 @@ * Constructor. * Uses Rows and Columns. */ -Area::Area(BALMLayout* ls, Row* row, Column* column, BView* content, - BSize minContentSize) +Area::Area(BALMLayout* layout, LinearSpec* ls, Row* row, Column* column, + BView* content, BSize minContentSize) { - Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom(), + Init(layout, ls, column->Left(), row->Top(), column->Right(), row->Bottom(), content, minContentSize); fRow = row; fColumn = column; @@ -763,9 +764,10 @@ * Initialize variables. */ void -Area::Init(BALMLayout* ls, XTab* left, YTab* top, XTab* right, YTab* bottom, - BView* content, BSize minContentSize) +Area::Init(BALMLayout* layout, LinearSpec* ls, XTab* left, YTab* top, + XTab* right, YTab* bottom, BView* content, BSize minContentSize) { + fALMLayout = layout; fConstraints = new BList(2); fMaxContentSize = kMaxSize; @@ -848,8 +850,8 @@ // add a child area with new tabs, // and add constraints that set its tabs to be equal to the // coresponding tabs of this area (for a start) - fChildArea = new Area(fLS, new XTab(fLS), new YTab(fLS), new XTab(fLS), - new YTab(fLS), fContent, BSize(0, 0)); + fChildArea = new Area(fALMLayout, fLS, new XTab(fLS), new YTab(fLS), + new XTab(fLS), new YTab(fLS), fContent, BSize(0, 0)); fLeftConstraint = fLeft->IsEqual(fChildArea->Left()); fConstraints->AddItem(fLeftConstraint); fTopConstraint = fTop->IsEqual(fChildArea->Top()); Modified: haiku/trunk/src/libs/alm/BALMLayout.cpp =================================================================== --- haiku/trunk/src/libs/alm/BALMLayout.cpp 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/src/libs/alm/BALMLayout.cpp 2010-09-20 22:47:13 UTC (rev 38750) @@ -21,17 +21,16 @@ */ BALMLayout::BALMLayout() : - BAbstractLayout(), - LinearSpec() + BAbstractLayout() { fLayoutStyle = FIT_TO_SIZE; fActivated = true; fAreas = new BList(1); - fLeft = new XTab(this); - fRight = new XTab(this); - fTop = new YTab(this); - fBottom = new YTab(this); + fLeft = new XTab(&fSolver); + fRight = new XTab(&fSolver); + fTop = new YTab(&fSolver); + fBottom = new YTab(&fSolver); // the Left tab is always at x-position 0, and the Top tab is always at y-position 0 fLeft->SetRange(0, 0); @@ -75,12 +74,13 @@ ResultType result; for (int32 tries = 0; tries < 15; tries++) { - result = Solve(); + result = fSolver.Solve(); if (fPerformancePath != NULL) { - char buffer [100]; + /*char buffer [100]; file->Write(buffer, sprintf(buffer, "%d\t%fms\t#vars=%ld\t" - "#constraints=%ld\n", result, SolvingTime(), - Variables()->CountItems(), Constraints()->CountItems())); + "#constraints=%ld\n", result, fSolver.SolvingTime(), + fSolver.Variables()->CountItems(), + fSolver.Constraints()->CountItems()));*/ } if (result == OPTIMAL || result == INFEASIBLE) break; @@ -97,7 +97,7 @@ XTab* BALMLayout::AddXTab() { - return new XTab(this); + return new XTab(&fSolver); } @@ -109,7 +109,7 @@ YTab* BALMLayout::AddYTab() { - return new YTab(this); + return new YTab(&fSolver); } @@ -121,7 +121,7 @@ Row* BALMLayout::AddRow() { - return new Row(this); + return new Row(&fSolver); } @@ -135,7 +135,7 @@ Row* BALMLayout::AddRow(YTab* top, YTab* bottom) { - Row* row = new Row(this); + Row* row = new Row(&fSolver); if (top != NULL) row->Constraints()->AddItem(row->Top()->IsEqual(top)); if (bottom != NULL) @@ -152,7 +152,7 @@ Column* BALMLayout::AddColumn() { - return new Column(this); + return new Column(&fSolver); } @@ -166,7 +166,7 @@ Column* BALMLayout::AddColumn(XTab* left, XTab* right) { - Column* column = new Column(this); + Column* column = new Column(&fSolver); if (left != NULL) column->Constraints()->AddItem(column->Left()->IsEqual(left)); if (right != NULL) column->Constraints()->AddItem(column->Right()->IsEqual(right)); return column; @@ -191,7 +191,8 @@ InvalidateLayout(); if (content != NULL) TargetView()->AddChild(content); - Area* area = new Area(this, left, top, right, bottom, content, minContentSize); + Area* area = new Area(this, &fSolver, left, top, right, bottom, content, + minContentSize); fAreas->AddItem(area); return area; } @@ -213,7 +214,7 @@ InvalidateLayout(); if (content != NULL) TargetView()->AddChild(content); - Area* area = new Area(this, row, column, content, minContentSize); + Area* area = new Area(this, &fSolver, row, column, content, minContentSize); fAreas->AddItem(area); return area; } @@ -236,7 +237,8 @@ InvalidateLayout(); if (content != NULL) TargetView()->AddChild(content); - Area* area = new Area(this, left, top, right, bottom, content, BSize(0, 0)); + Area* area = new Area(this, &fSolver, left, top, right, bottom, content, + BSize(0, 0)); area->SetDefaultBehavior(); area->SetAutoPreferredContentSize(false); fAreas->AddItem(area); @@ -258,7 +260,7 @@ InvalidateLayout(); if (content != NULL) TargetView()->AddChild(content); - Area* area = new Area(this, row, column, content, BSize(0, 0)); + Area* area = new Area(this, &fSolver, row, column, content, BSize(0, 0)); area->SetDefaultBehavior(); area->SetAutoPreferredContentSize(false); fAreas->AddItem(area); @@ -546,14 +548,15 @@ SolveLayout(); // if new layout is infasible, use previous layout - if (Result() == INFEASIBLE) { + if (fSolver.Result() == INFEASIBLE) { fActivated = true; // now layout calculation is allowed to run again return; } - if (Result() != OPTIMAL) { - Save("failed-layout.txt"); - printf("Could not solve the layout specification (%d). ", Result()); + if (fSolver.Result() != OPTIMAL) { + fSolver.Save("failed-layout.txt"); + printf("Could not solve the layout specification (%d). ", + fSolver.Result()); printf("Saved specification in file failed-layout.txt\n"); } @@ -596,32 +599,41 @@ } +LinearSpec* +BALMLayout::Solver() +{ + return &fSolver; +} + + /** * Caculates the miminum size. */ BSize BALMLayout::CalculateMinSize() { - SummandList* oldObjFunction = ObjFunction(); + SummandList* oldObjFunction = fSolver.ObjFunction(); SummandList* newObjFunction = new SummandList(2); newObjFunction->AddItem(new Summand(1.0, fRight)); newObjFunction->AddItem(new Summand(1.0, fBottom)); - SetObjFunction(newObjFunction); + fSolver.SetObjFunction(newObjFunction); SolveLayout(); - SetObjFunction(oldObjFunction); - UpdateObjFunction(); + fSolver.SetObjFunction(oldObjFunction); + fSolver.UpdateObjFunction(); delete newObjFunction->ItemAt(0); delete newObjFunction->ItemAt(1); delete newObjFunction; - if (Result() == UNBOUNDED) + if (fSolver.Result() == UNBOUNDED) return Area::kMinSize; - if (Result() != OPTIMAL) { - Save("failed-layout.txt"); - printf("Could not solve the layout specification (%d). Saved specification in file failed-layout.txt", Result()); + if (fSolver.Result() != OPTIMAL) { + fSolver.Save("failed-layout.txt"); + printf("Could not solve the layout specification (%d). " + "Saved specification in file failed-layout.txt", fSolver.Result()); } - return BSize(Right()->Value() - Left()->Value(), Bottom()->Value() - Top()->Value()); + return BSize(Right()->Value() - Left()->Value(), + Bottom()->Value() - Top()->Value()); } @@ -631,26 +643,28 @@ BSize BALMLayout::CalculateMaxSize() { - SummandList* oldObjFunction = ObjFunction(); + SummandList* oldObjFunction = fSolver.ObjFunction(); SummandList* newObjFunction = new SummandList(2); newObjFunction->AddItem(new Summand(-1.0, fRight)); newObjFunction->AddItem(new Summand(-1.0, fBottom)); - SetObjFunction(newObjFunction); + fSolver.SetObjFunction(newObjFunction); SolveLayout(); - SetObjFunction(oldObjFunction); - UpdateObjFunction(); + fSolver.SetObjFunction(oldObjFunction); + fSolver.UpdateObjFunction(); delete newObjFunction->ItemAt(0); delete newObjFunction->ItemAt(1); delete newObjFunction; - if (Result() == UNBOUNDED) + if (fSolver.Result() == UNBOUNDED) return Area::kMaxSize; - if (Result() != OPTIMAL) { - Save("failed-layout.txt"); - printf("Could not solve the layout specification (%d). Saved specification in file failed-layout.txt", Result()); + if (fSolver.Result() != OPTIMAL) { + fSolver.Save("failed-layout.txt"); + printf("Could not solve the layout specification (%d). " + "Saved specification in file failed-layout.txt", fSolver.Result()); } - return BSize(Right()->Value() - Left()->Value(), Bottom()->Value() - Top()->Value()); + return BSize(Right()->Value() - Left()->Value(), + Bottom()->Value() - Top()->Value()); } @@ -661,11 +675,13 @@ BALMLayout::CalculatePreferredSize() { SolveLayout(); - if (Result() != OPTIMAL) { - Save("failed-layout.txt"); - printf("Could not solve the layout specification (%d). Saved specification in file failed-layout.txt", Result()); + if (fSolver.Result() != OPTIMAL) { + fSolver.Save("failed-layout.txt"); + printf("Could not solve the layout specification (%d). " + "Saved specification in file failed-layout.txt", fSolver.Result()); } - return BSize(Right()->Value() - Left()->Value(), Bottom()->Value() - Top()->Value()); + return BSize(Right()->Value() - Left()->Value(), + Bottom()->Value() - Top()->Value()); } Modified: haiku/trunk/src/libs/alm/Column.cpp =================================================================== --- haiku/trunk/src/libs/alm/Column.cpp 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/src/libs/alm/Column.cpp 2010-09-20 22:47:13 UTC (rev 38750) @@ -204,7 +204,7 @@ /** * Constructor. */ -Column::Column(BALMLayout* ls) +Column::Column(LinearSpec* ls) { fLS = ls; fLeft = new XTab(ls); Modified: haiku/trunk/src/libs/alm/Row.cpp =================================================================== --- haiku/trunk/src/libs/alm/Row.cpp 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/src/libs/alm/Row.cpp 2010-09-20 22:47:13 UTC (rev 38750) @@ -206,7 +206,7 @@ /** * Constructor. */ -Row::Row(BALMLayout* ls) +Row::Row(LinearSpec* ls) { fLS = ls; fTop = new YTab(ls); Modified: haiku/trunk/src/libs/alm/XTab.cpp =================================================================== --- haiku/trunk/src/libs/alm/XTab.cpp 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/src/libs/alm/XTab.cpp 2010-09-20 22:47:13 UTC (rev 38750) @@ -5,13 +5,12 @@ */ #include "XTab.h" -#include "BALMLayout.h" /** * Constructor. */ -XTab::XTab(BALMLayout* ls) +XTab::XTab(LinearSpec* ls) : Variable(ls) { fLeftLink = false; Modified: haiku/trunk/src/libs/alm/YTab.cpp =================================================================== --- haiku/trunk/src/libs/alm/YTab.cpp 2010-09-20 22:32:36 UTC (rev 38749) +++ haiku/trunk/src/libs/alm/YTab.cpp 2010-09-20 22:47:13 UTC (rev 38750) @@ -5,13 +5,12 @@ */ #include "YTab.h" -#include "BALMLayout.h" /** * Constructor. */ -YTab::YTab(BALMLayout* ls) +YTab::YTab(LinearSpec* ls) : Variable(ls) { fTopLink = false;