From 1c8104a70e5ccd1a786ee52ddb17c281775ec4f5 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Fri, 20 Jan 2012 11:06:11 +1300 Subject: [PATCH] Add a test for nested BALMLayouts. --- src/tests/libs/alm/Jamfile | 7 +++ src/tests/libs/alm/NestedLayout.cpp | 70 +++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/tests/libs/alm/NestedLayout.cpp diff --git a/src/tests/libs/alm/Jamfile b/src/tests/libs/alm/Jamfile index 8a0002863e..9c183afec7 100644 --- a/src/tests/libs/alm/Jamfile +++ b/src/tests/libs/alm/Jamfile @@ -58,3 +58,10 @@ Application ALMBadLayout : : be libalm.so $(TARGET_LIBSTDC++) ; + + +Application ALMNestedLayout : + NestedLayout.cpp + : + be libalm.so $(TARGET_LIBSTDC++) +; diff --git a/src/tests/libs/alm/NestedLayout.cpp b/src/tests/libs/alm/NestedLayout.cpp new file mode 100644 index 0000000000..18ad835a2b --- /dev/null +++ b/src/tests/libs/alm/NestedLayout.cpp @@ -0,0 +1,70 @@ +/* + * Copyright 2007-2008, Christof Lutteroth, lutteroth@cs.auckland.ac.nz + * Copyright 2007-2008, James Kim, jkim202@ec.auckland.ac.nz + * Copyright 2010, Clemens Zeidler + * Copyright 2012, Haiku, Inc. + * Distributed under the terms of the MIT License. + */ + +#include +#include +#include +#include +#include + +// include this for ALM +#include "ALMLayout.h" + + +class NestedLayoutWindow : public BWindow { +public: + NestedLayoutWindow(BRect frame) + : + BWindow(frame, "ALM Nested Layout", B_TITLED_WINDOW, + B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) + { + button1 = new BButton("There should be space above this button!"); + + fLayout = new BALMLayout(); + BLayoutBuilder::Group<>(this, B_VERTICAL, 0) + .SetInsets(0) + .AddStrut(30) + .Add(fLayout); + + // add an area containing the button + // use the borders of the layout as the borders for the area + fLayout->AddView(button1, fLayout->Left(), fLayout->Top(), + fLayout->Right(), fLayout->Bottom()); + button1->SetExplicitMinSize(BSize(0, 50)); + button1->SetExplicitMaxSize(BSize(500, 500)); + button1->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, + B_ALIGN_USE_FULL_HEIGHT)); + } + +private: + BALMLayout* fLayout; + BButton* button1; +}; + + +class NestedLayout : public BApplication { +public: + NestedLayout() + : + BApplication("application/x-vnd.haiku.NestedLayout") + { + BRect frameRect; + frameRect.Set(100, 100, 300, 300); + NestedLayoutWindow* window = new NestedLayoutWindow(frameRect); + window->Show(); + } +}; + + +int +main() +{ + NestedLayout app; + app.Run(); + return 0; +}