[haiku-commits] haiku: hrev48376 - src/apps/charactermap

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 26 Nov 2014 08:34:11 +0100 (CET)

hrev48376 adds 2 changesets to branch 'master'
old head: aca8c0ceb22a9906af8cd9d17aae23b929aeadd8
new head: d67977a5aedf0cb4d2245f0f0494f0da2e428d5e
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=d67977a+%5Eaca8c0c

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

c3205c1: CharacterMap: show font family and style
  
  Signed-off-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
  
  Fixes #3651 item 2.

d67977a: CharacterMap: avoid jumping window size
  
  set explicit minimum width of character view to be a bit larger than
  fCodeView so that there isn't jumping of the pane sizes when fCodeView's
  contents are too long
  
  Signed-off-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
  
  Fixes #3651 part 9.

                                            [ dsizzle <dcieslak@xxxxxxxxx> ]

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

1 file changed, 29 insertions(+), 1 deletion(-)
src/apps/charactermap/CharacterWindow.cpp | 30 ++++++++++++++++++++++++++-

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

Commit:      c3205c10d7515bd8a6fcabe6a4e8de3e266a20b5
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c3205c1
Author:      dsizzle <dcieslak@xxxxxxxxx>
Date:        Tue Nov 25 20:04:23 2014 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Wed Nov 26 07:34:04 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/3651

CharacterMap: show font family and style

Signed-off-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

Fixes #3651 item 2.

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

diff --git a/src/apps/charactermap/CharacterWindow.cpp 
b/src/apps/charactermap/CharacterWindow.cpp
index 46ccb92..fd50bb9 100644
--- a/src/apps/charactermap/CharacterWindow.cpp
+++ b/src/apps/charactermap/CharacterWindow.cpp
@@ -171,9 +171,18 @@ CharacterWindow::CharacterWindow()
 
        const char* family;
        const char* style;
+       BString displayName;
+       
        if (settings.FindString("font family", &family) == B_OK
                && settings.FindString("font style", &style) == B_OK) {
                _SetFont(family, style);
+               displayName << family << " " << style; 
+       } else {
+               font_family currentFontFamily;
+               font_style currentFontStyle;
+               
fCharacterView->CharacterFont().GetFamilyAndStyle(&currentFontFamily,
+                       &currentFontStyle);
+               displayName << currentFontFamily << " " << currentFontStyle;
        }
 
        int32 fontSize;
@@ -193,7 +202,7 @@ CharacterWindow::CharacterWindow()
                fCharacterView, 0, false, true);
 
        fFontSizeSlider = new FontSizeSlider("fontSizeSlider",
-               B_TRANSLATE("Font size:"),
+               displayName,
                new BMessage(kMsgFontSizeChanged), kMinFontSize, kMaxFontSize);
        fFontSizeSlider->SetValue(fontSize);
 
@@ -344,6 +353,12 @@ CharacterWindow::MessageReceived(BMessage* message)
                                fSelectedFontItem = item;
 
                                _SetFont(item->Menu()->Name(), item->Label());
+                               
+                               BString displayName;
+                               displayName << item->Menu()->Name() << " " << 
item->Label();
+                       
+                               fFontSizeSlider->SetLabel(displayName);
+                               
                                item = item->Menu()->Superitem();
                                item->SetMarked(true);
                        }

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

Revision:    hrev48376
Commit:      d67977a5aedf0cb4d2245f0f0494f0da2e428d5e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d67977a
Author:      dsizzle <dcieslak@xxxxxxxxx>
Date:        Tue Nov 25 20:22:50 2014 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Wed Nov 26 07:34:05 2014 UTC

Ticket:      https://dev.haiku-os.org/ticket/3651

CharacterMap: avoid jumping window size

set explicit minimum width of character view to be a bit larger than
fCodeView so that there isn't jumping of the pane sizes when fCodeView's
contents are too long

Signed-off-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

Fixes #3651 part 9.

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

diff --git a/src/apps/charactermap/CharacterWindow.cpp 
b/src/apps/charactermap/CharacterWindow.cpp
index fd50bb9..4577e2f 100644
--- a/src/apps/charactermap/CharacterWindow.cpp
+++ b/src/apps/charactermap/CharacterWindow.cpp
@@ -15,6 +15,7 @@
 #include <Catalog.h>
 #include <File.h>
 #include <FindDirectory.h>
+#include <Font.h>
 #include <LayoutBuilder.h>
 #include <ListView.h>
 #include <Menu.h>
@@ -210,6 +211,18 @@ CharacterWindow::CharacterWindow()
        fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
                fCodeView->PreferredSize().Height()));
 
+       // set minimum width for character pane to prevent UI
+       // from jumping when longer code strings are displayed.
+       // use 'w' character for sizing as it's likely the widest
+       // character for a Latin font.  40 characters is a little
+       // wider than needed so hopefully this covers other 
+       // non-Latin fonts that may be wider.
+       BFont viewFont;
+       fCodeView->GetFont(&viewFont);
+       fCharacterView->SetExplicitMinSize(BSize(viewFont.StringWidth(
+               "w") * 40,
+               B_SIZE_UNSET));
+               
        BLayoutBuilder::Group<>(this, B_VERTICAL)
                .Add(menuBar)
                .AddGroup(B_HORIZONTAL)


Other related posts:

  • » [haiku-commits] haiku: hrev48376 - src/apps/charactermap - pulkomandy