CharacterMap: improved initial window size, and position.
* By making it scale with the font size, and by using BWindow::CenterOnScreen(). * Minor cleanup.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2010, Axel Dörfler, [email protected].
|
||||
* Copyright 2009-2015, Axel Dörfler, [email protected].
|
||||
* Copyright 2011, Philippe Saint-Pierre, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@@ -33,9 +33,11 @@
|
||||
#include "CharacterView.h"
|
||||
#include "UnicodeBlockView.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "CharacterWindow"
|
||||
|
||||
|
||||
static const uint32 kMsgUnicodeBlockSelected = 'unbs';
|
||||
static const uint32 kMsgCharacterChanged = 'chch';
|
||||
static const uint32 kMsgFontSelected = 'fnts';
|
||||
@@ -125,7 +127,7 @@ CharacterWindow::CharacterWindow()
|
||||
:
|
||||
BWindow(BRect(100, 100, 700, 550), B_TRANSLATE_SYSTEM_NAME("CharacterMap"),
|
||||
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||
{
|
||||
BMessage settings;
|
||||
_LoadSettings(settings);
|
||||
@@ -134,6 +136,10 @@ CharacterWindow::CharacterWindow()
|
||||
if (settings.FindRect("window frame", &frame) == B_OK) {
|
||||
MoveTo(frame.LeftTop());
|
||||
ResizeTo(frame.Width(), frame.Height());
|
||||
} else {
|
||||
float scaling = be_plain_font->Size() / 12.0f;
|
||||
ResizeTo(Frame().Width() * scaling, Frame().Height() * scaling);
|
||||
CenterOnScreen();
|
||||
}
|
||||
|
||||
// create GUI
|
||||
@@ -211,7 +217,7 @@ CharacterWindow::CharacterWindow()
|
||||
fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
|
||||
fCodeView->PreferredSize().Height()));
|
||||
|
||||
// set minimum width for character pane to prevent UI
|
||||
// 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
|
||||
@@ -219,8 +225,7 @@ CharacterWindow::CharacterWindow()
|
||||
// non-Latin fonts that may be wider.
|
||||
BFont viewFont;
|
||||
fCodeView->GetFont(&viewFont);
|
||||
fCharacterView->SetExplicitMinSize(BSize(viewFont.StringWidth(
|
||||
"w") * 40,
|
||||
fCharacterView->SetExplicitMinSize(BSize(viewFont.StringWidth("w") * 40,
|
||||
B_SIZE_UNSET));
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||
@@ -467,7 +472,7 @@ CharacterWindow::_LoadSettings(BMessage& settings)
|
||||
{
|
||||
BFile file;
|
||||
status_t status = _OpenSettings(file, B_READ_ONLY);
|
||||
if (status < B_OK)
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return settings.Unflatten(&file);
|
||||
@@ -533,7 +538,6 @@ BMenu*
|
||||
CharacterWindow::_CreateFontMenu()
|
||||
{
|
||||
BMenu* menu = new BMenu(B_TRANSLATE("Font"));
|
||||
|
||||
_UpdateFontMenu(menu);
|
||||
|
||||
return menu;
|
||||
@@ -589,10 +593,9 @@ CharacterWindow::_UpdateFontMenu(BMenu* menu)
|
||||
}
|
||||
|
||||
|
||||
void CharacterWindow::MenusBeginning()
|
||||
void
|
||||
CharacterWindow::MenusBeginning()
|
||||
{
|
||||
if (update_font_families(false) == true) {
|
||||
if (update_font_families(false) == true)
|
||||
_UpdateFontMenu(fFontMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user