[haiku-commits] haiku: hrev51578 - src/apps/firstbootprompt headers/os/interface

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 21 Nov 2017 13:12:27 +0100 (CET)

hrev51578 adds 2 changesets to branch 'master'
old head: 830758ad45ea9d634cb24786788fdb8ed6383f87
new head: 950b5664df52f29ea26ab015fc17a2c0f2bdea3b
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=950b5664df52+%5E830758ad45ea

----------------------------------------------------------------------------

24e63de5d334: Style fix: parameters should have a name.

950b5664df52: FirstBootPrompt: fix layout
  
  In some languages, the buttons would end up outside of window bounds, as
  changing the BTextView content does not automatically update the window
  size (even with B_AUTO_UPDATE_SIZE_LIMITS). So, we need to manually call
  ResizeToPreferred after changing the text.
  
  However, this exposed another problem: the view size is computed using
  GetHeightForWidth, with a width as small as allowed by layout
  constraints. In our cases, there weren't much layout constraints so we
  would end up asking the text view to compute its height for a width of
  52px, leading to a very high window. Add some explicit sizing
  constraints to the text view and language list to make sure we get a
  sane size.
  
  Also tweak the layout a little to allow the keymap menu field to be
  wider than the language list view, and make the window not resizable as
  that makes it much easier to keep things under control and there isn't
  really a need to resize it.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 28 insertions(+), 17 deletions(-)
headers/os/interface/Screen.h                 |  4 +--
src/apps/firstbootprompt/BootPromptWindow.cpp | 41 ++++++++++++++---------

############################################################################

Commit:      24e63de5d334909bbf2a559808879ead7b6a1b28
URL:         http://cgit.haiku-os.org/haiku/commit/?id=24e63de5d334
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Tue Nov 21 10:53:18 2017 UTC

Style fix: parameters should have a name.

----------------------------------------------------------------------------

diff --git a/headers/os/interface/Screen.h b/headers/os/interface/Screen.h
index e000f7f..3622d0a 100644
--- a/headers/os/interface/Screen.h
+++ b/headers/os/interface/Screen.h
@@ -82,8 +82,8 @@ public:
                        uint32                          DPMSState();
                        uint32                          DPMSCapabilites();
 
-                       status_t                        GetBrightness(float*);
-                       status_t                        SetBrightness(float);
+                       status_t                        GetBrightness(float* 
brightness);
+                       status_t                        SetBrightness(float 
brightness);
 
 private:
        // Forbidden and deprecated methods

############################################################################

Revision:    hrev51578
Commit:      950b5664df52f29ea26ab015fc17a2c0f2bdea3b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=950b5664df52
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Tue Nov 21 11:09:25 2017 UTC

FirstBootPrompt: fix layout

In some languages, the buttons would end up outside of window bounds, as
changing the BTextView content does not automatically update the window
size (even with B_AUTO_UPDATE_SIZE_LIMITS). So, we need to manually call
ResizeToPreferred after changing the text.

However, this exposed another problem: the view size is computed using
GetHeightForWidth, with a width as small as allowed by layout
constraints. In our cases, there weren't much layout constraints so we
would end up asking the text view to compute its height for a width of
52px, leading to a very high window. Add some explicit sizing
constraints to the text view and language list to make sure we get a
sane size.

Also tweak the layout a little to allow the keymap menu field to be
wider than the language list view, and make the window not resizable as
that makes it much easier to keep things under control and there isn't
really a need to resize it.

----------------------------------------------------------------------------

diff --git a/src/apps/firstbootprompt/BootPromptWindow.cpp 
b/src/apps/firstbootprompt/BootPromptWindow.cpp
index afc350c..0ffb57b 100644
--- a/src/apps/firstbootprompt/BootPromptWindow.cpp
+++ b/src/apps/firstbootprompt/BootPromptWindow.cpp
@@ -150,7 +150,8 @@ compare_void_menu_items(const void* _a, const void* _b)
 BootPromptWindow::BootPromptWindow()
        :
        BWindow(BRect(0, 0, 530, 400), "",
-               B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | 
B_NOT_CLOSABLE,
+               B_TITLED_WINDOW,
+               B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_CLOSABLE | 
B_NOT_RESIZABLE,
                B_ALL_WORKSPACES),
        fDefaultKeymapItem(NULL)
 {
@@ -166,11 +167,8 @@ BootPromptWindow::BootPromptWindow()
        // Carefully designed to not exceed the 640x480 resolution with a 12pt 
font.
        float width = fInfoTextView->StringWidth("Thank you for trying out 
Haiku,"
                " We hope you like it!") * 1.5;
-       float height = be_plain_font->Size() * 36;
 
-       BRect newFrame(0, 0, width, height);
-       newFrame = newFrame & BScreen().Frame();
-       ResizeTo(newFrame.Width(), newFrame.Height());
+       fInfoTextView->SetExplicitSize(BSize(width, B_SIZE_UNSET));
 
        fDesktopButton = new BButton("", new BMessage(MSG_BOOT_DESKTOP));
        fDesktopButton->SetTarget(be_app);
@@ -192,6 +190,13 @@ BootPromptWindow::BootPromptWindow()
        BScrollView* languagesScrollView = new BScrollView("languagesScroll",
                fLanguagesListView, B_WILL_DRAW, false, true);
 
+       // Make sure the language list view is always wide enough to show the
+       // largest language, with some extra space
+       float height = be_plain_font->Size() * 23;
+       fLanguagesListView->SetExplicitSize(
+               BSize(fLanguagesListView->StringWidth("Portuguese (Brazil)") + 
32,
+               height));
+
        fKeymapsMenuField = new BMenuField("", "", new BMenu(""));
        fKeymapsMenuField->Menu()->SetLabelFromMarked(true);
 
@@ -201,19 +206,23 @@ BootPromptWindow::BootPromptWindow()
 
        BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
                .AddGroup(B_HORIZONTAL)
-                       .AddGroup(B_VERTICAL)
-                               .AddGroup(B_VERTICAL)
-                                       .Add(fLanguagesLabelView)
-                                       .Add(languagesScrollView)
-                               .End()
-                               .AddGrid(0.f)
-                                       .AddMenuField(fKeymapsMenuField, 0, 0)
-                               .End()
-                       .End()
-                       .Add(fInfoTextView)
+                       .Add(fLanguagesLabelView)
                        .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
                                B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
                .End()
+               .AddGroup(B_HORIZONTAL)
+                       .Add(languagesScrollView)
+                       .AddGroup(B_VERTICAL)
+                               .Add(fInfoTextView)
+                               .AddGlue()
+                       .End()
+                       .SetInsets(B_USE_WINDOW_SPACING, 0)
+               .End()
+               .AddGroup(B_HORIZONTAL)
+                       .Add(fKeymapsMenuField)
+                       .AddGlue()
+                       .SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
+               .End()
                .Add(new BSeparatorView(B_HORIZONTAL))
                .AddGroup(B_HORIZONTAL)
                        .AddGlue()
@@ -318,6 +327,8 @@ BootPromptWindow::_UpdateStrings()
        fKeymapsMenuField->SetLabel(B_TRANSLATE("Keymap"));
        if (fKeymapsMenuField->Menu()->FindMarked() == NULL)
                fKeymapsMenuField->MenuItem()->SetLabel(B_TRANSLATE("Custom"));
+
+       ResizeToPreferred();
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev51578 - src/apps/firstbootprompt headers/os/interface - pulkomandy