[haiku-commits] r40122 - haiku/trunk/src/apps/bootmanager

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 4 Jan 2011 23:42:19 +0100 (CET)

Author: axeld
Date: 2011-01-04 23:42:19 +0100 (Tue, 04 Jan 2011)
New Revision: 40122
Changeset: http://dev.haiku-os.org/changeset/40122

Modified:
   haiku/trunk/src/apps/bootmanager/BootManagerController.cpp
   haiku/trunk/src/apps/bootmanager/BootManagerWindow.cpp
   haiku/trunk/src/apps/bootmanager/WizardView.cpp
   haiku/trunk/src/apps/bootmanager/WizardView.h
Log:
* Work in progress of using the layout API.


Modified: haiku/trunk/src/apps/bootmanager/BootManagerController.cpp
===================================================================
--- haiku/trunk/src/apps/bootmanager/BootManagerController.cpp  2011-01-04 
21:28:46 UTC (rev 40121)
+++ haiku/trunk/src/apps/bootmanager/BootManagerController.cpp  2011-01-04 
22:42:19 UTC (rev 40122)
@@ -224,7 +224,7 @@
 BootManagerController::CreatePage(int32 state, WizardView* wizard)
 {
        WizardPageView* page = NULL;
-       BRect frame = wizard->PageFrame();
+       BRect frame(0, 0, 300, 300);
 
        switch (state) {
                case kStateEntry:

Modified: haiku/trunk/src/apps/bootmanager/BootManagerWindow.cpp
===================================================================
--- haiku/trunk/src/apps/bootmanager/BootManagerWindow.cpp      2011-01-04 
21:28:46 UTC (rev 40121)
+++ haiku/trunk/src/apps/bootmanager/BootManagerWindow.cpp      2011-01-04 
22:42:19 UTC (rev 40122)
@@ -11,6 +11,7 @@
 
 #include <Application.h>
 #include <Catalog.h>
+#include <LayoutBuilder.h>
 #include <Roster.h>
 #include <Screen.h>
 
@@ -29,16 +30,16 @@
 BootManagerWindow::BootManagerWindow()
        :
        BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("BootManager",
-               "Window Title"),
-               B_TITLED_WINDOW,
-               B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
+                       "Window Title"), B_TITLED_WINDOW,
+               B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS)
 {
        float minWidth, maxWidth, minHeight, maxHeight;
        GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
        SetSizeLimits(250, maxWidth, 250, maxHeight);
 
-       fWizardView = new WizardView(Bounds(), "wizard", B_FOLLOW_ALL);
-       AddChild(fWizardView);
+       fWizardView = new WizardView("wizard");
+       BLayoutBuilder::Group<>(this)
+               .Add(fWizardView);
 
        fController.Initialize(fWizardView);
 

Modified: haiku/trunk/src/apps/bootmanager/WizardView.cpp
===================================================================
--- haiku/trunk/src/apps/bootmanager/WizardView.cpp     2011-01-04 21:28:46 UTC 
(rev 40121)
+++ haiku/trunk/src/apps/bootmanager/WizardView.cpp     2011-01-04 22:42:19 UTC 
(rev 40122)
@@ -1,16 +1,19 @@
 /*
- * Copyright 2008-2010, Haiku, Inc. All rights reserved.
+ * Copyright 2008-2011, Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             Michael Pfeiffer <laplace@xxxxxxxxxxxxxxxxxxxxx>
+ *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
  */
 
 
 #include "WizardView.h"
 
-#include <Box.h>
+#include <LayoutBuilder.h>
+#include <Button.h>
 #include <Catalog.h>
+#include <SeparatorView.h>
 
 #include "WizardPageView.h"
 
@@ -19,16 +22,9 @@
 #define B_TRANSLATE_CONTEXT "WizardView"
 
 
-static const float kSeparatorHeight = 2;
-static const float kSeparatorDistance = 5;
-static const float kBorderWidth = 10;
-static const float kBorderHeight = 5;
-
-
-WizardView::WizardView(BRect frame, const char* name, uint32 resizingMode)
+WizardView::WizardView(const char* name)
        :
-       BView(frame, name, resizingMode, 0),
-       fSeparator(NULL),
+       BGroupView(name, B_VERTICAL),
        fPrevious(NULL),
        fNext(NULL),
        fPage(NULL)
@@ -43,17 +39,6 @@
 }
 
 
-BRect
-WizardView::PageFrame()
-{
-       float left = kBorderWidth;
-       float right = Bounds().right - kBorderWidth;
-       float top = kBorderHeight;
-       float bottom = fSeparator->Frame().top - kSeparatorDistance - 1;
-       return BRect(left, top, right, bottom);
-}
-
-
 void
 WizardView::SetPage(WizardPageView* page)
 {
@@ -61,7 +46,7 @@
                return;
 
        if (fPage != NULL) {
-               RemoveChild(fPage);
+               fPageContainer->RemoveChild(fPage);
                delete fPage;
        }
 
@@ -69,10 +54,7 @@
        if (page == NULL)
                return;
 
-       BRect frame = PageFrame();
-       page->MoveTo(frame.left, frame.top);
-       page->ResizeTo(frame.Width()+1, frame.Height()+1);
-       AddChild(page);
+       fPageContainer->AddChild(page);
 }
 
 
@@ -102,19 +84,13 @@
 WizardView::SetPreviousButtonLabel(const char* text)
 {
        fPrevious->SetLabel(text);
-       fPrevious->ResizeToPreferred();
 }
 
 
 void
 WizardView::SetNextButtonLabel(const char* text)
 {
-       BRect frame = fNext->Frame();
        fNext->SetLabel(text);
-       fNext->ResizeToPreferred();
-       BRect newFrame = fNext->Frame();
-       fNext->MoveBy(frame.Width() - newFrame.Width(),
-               frame.Height() - newFrame.Height());
 }
 
 
@@ -134,39 +110,24 @@
 void
 WizardView::_BuildUI()
 {
-       SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-
-       float width = Bounds().Width();
-       float height = Bounds().Height();
-
-       fSeparator = new BBox(BRect(kBorderWidth, 0,
-               width - 1 - kBorderWidth, kSeparatorHeight - 1),
-               "separator",
-               B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
-       AddChild(fSeparator);
-
-       fPrevious = new BButton(BRect(0, 0, 100, 20), "previous",
+       fPageContainer = new BGroupView("page container");
+       fPageContainer->GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING,
+               B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, 
B_USE_DEFAULT_SPACING);
+       fPrevious = new BButton("previous",
                B_TRANSLATE_COMMENT("Previous", "Button"),
-               new BMessage(kMessagePrevious),
-               B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
-       AddChild(fPrevious);
-       fPrevious->ResizeToPreferred();
+               new BMessage(kMessagePrevious));
+       fNext = new BButton("next", B_TRANSLATE_COMMENT("Next", "Button"),
+               new BMessage(kMessageNext));
 
-       fNext = new BButton(BRect(0, 0, 100, 20), "next",
-               B_TRANSLATE_COMMENT("Next", "Button"),
-               new BMessage(kMessageNext),
-               B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
-       AddChild(fNext);
-       fNext->ResizeToPreferred();
-
-       // layout views
-       float buttonHeight = fPrevious->Bounds().Height();
-       float buttonTop = height - 1 - buttonHeight - kBorderHeight;
-       fPrevious->MoveTo(kBorderWidth, buttonTop);
-
-       fSeparator->MoveTo(kBorderWidth,
-               buttonTop - kSeparatorDistance - kSeparatorHeight);
-
-       fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1,
-               buttonTop);
+       BLayoutBuilder::Group<>(this)
+               .Add(fPageContainer)
+               .Add(new BSeparatorView(B_HORIZONTAL))
+               .AddGroup(B_HORIZONTAL)
+                       .SetInsets(B_USE_DEFAULT_SPACING, 0,
+                               B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
+                       .AddGlue()
+                       .Add(fPrevious)
+                       .Add(fNext)
+                       .End()
+               .End();
 }

Modified: haiku/trunk/src/apps/bootmanager/WizardView.h
===================================================================
--- haiku/trunk/src/apps/bootmanager/WizardView.h       2011-01-04 21:28:46 UTC 
(rev 40121)
+++ haiku/trunk/src/apps/bootmanager/WizardView.h       2011-01-04 22:42:19 UTC 
(rev 40122)
@@ -9,12 +9,10 @@
 #define WIZARD_VIEW_H
 
 
-#include <Box.h>
-#include <Button.h>
-#include <View.h>
+#include <GroupView.h>
 
 
-class BTextView;
+class BButton;
 class WizardPageView;
 
 
@@ -22,14 +20,11 @@
 const uint32 kMessagePrevious = 'prev';
 
 
-class WizardView : public BView {
+class WizardView : public BGroupView {
 public:
-                                                               
WizardView(BRect frame, const char* name,
-                                                                       uint32 
resizingMode);
+                                                               
WizardView(const char* name);
        virtual                                         ~WizardView();
 
-       virtual BRect                           PageFrame();
-
        virtual void                            SetPage(WizardPageView* page);
 
        virtual void                            PageCompleted();
@@ -44,7 +39,7 @@
                        void                            _BuildUI();
 
 private:
-                       BBox*                           fSeparator;
+                       BGroupView*                     fPageContainer;
                        BButton*                        fPrevious;
                        BButton*                        fNext;
 


Other related posts:

  • » [haiku-commits] r40122 - haiku/trunk/src/apps/bootmanager - axeld