diff --git a/src/tests/libs/alm/FriendLayout.cpp b/src/tests/libs/alm/FriendLayout.cpp new file mode 100644 index 0000000000..7433a5277d --- /dev/null +++ b/src/tests/libs/alm/FriendLayout.cpp @@ -0,0 +1,106 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz + * Copyright 2010, Clemens Zeidler + * Distributed under the terms of the MIT License. + */ + +#include +#include +#include +#include +#include + +// include this for ALM +#include "ALMLayout.h" +#include "ALMLayoutBuilder.h" + + +class FriendWindow : public BWindow { +public: + FriendWindow(BRect frame) + : + BWindow(frame, "ALM Friend Test", B_TITLED_WINDOW, + B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) + { + BButton* button1 = _MakeButton("friends!"); + BButton* button2 = _MakeButton("friends!"); + BButton* button3 = _MakeButton("friends!"); + + BButton* button4 = _MakeButton("friends!"); + BButton* button5 = _MakeButton("friends!"); + BButton* button6 = _MakeButton("friends!"); + + BALMLayout* layout1 = new BALMLayout(10, 10); + BView* almView1 = _MakeALMView(layout1); + + BReference xTabs[2]; + layout1->AddXTabs(xTabs, 2); + + BALM::BALMLayoutBuilder(layout1) + .Add(button1, layout1->Left(), layout1->Top(), + xTabs[0], layout1->Bottom()) + .StartingAt(button1) + .AddToRight(button2, xTabs[1]) + .AddToRight(button3, layout1->Right()); + + BALMLayout* layout2 = new BALMLayout(10, 10, layout1); + BView* almView2 = _MakeALMView(layout2); + + BALM::BALMLayoutBuilder(layout2) + .Add(button4, layout2->Left(), layout2->Top(), xTabs[0]) + .StartingAt(button4) + .AddBelow(button5, NULL, xTabs[0], xTabs[1]) + .AddBelow(button6, layout2->Bottom(), + xTabs[0], layout2->Right()); + + BLayoutBuilder::Group<>(this, B_VERTICAL) + .Add(almView1) + .Add(almView2); + } + +private: + BButton* _MakeButton(const char* label) + { + BButton* button = new BButton(label); + button->SetExplicitMinSize(BSize(0, 50)); + button->SetExplicitMaxSize(BSize(500, 500)); + button->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, + B_ALIGN_USE_FULL_HEIGHT)); + return button; + } + + BView* _MakeALMView(BALMLayout* layout) + { + BView* view = new BView(NULL, 0, layout); + view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + return view; + } + + BALMLayout* fLayout; + BButton* button1; +}; + + +class Friend : public BApplication { +public: + Friend() + : + BApplication("application/x-vnd.haiku.Friend") + { + BRect frameRect; + frameRect.Set(100, 100, 300, 300); + FriendWindow* window = new FriendWindow(frameRect); + window->Show(); + } +}; + + +int +main() +{ + Friend app; + app.Run(); + return 0; +} + diff --git a/src/tests/libs/alm/Jamfile b/src/tests/libs/alm/Jamfile index 9c183afec7..91ceef3c37 100644 --- a/src/tests/libs/alm/Jamfile +++ b/src/tests/libs/alm/Jamfile @@ -52,7 +52,6 @@ Application ALMComplexButtons : be libalm.so $(TARGET_LIBSTDC++) ; - Application ALMBadLayout : BadLayout.cpp : @@ -65,3 +64,10 @@ Application ALMNestedLayout : : be libalm.so $(TARGET_LIBSTDC++) ; + + +Application ALMFriendLayout : + FriendLayout.cpp + : + be libalm.so $(TARGET_LIBSTDC++) +;