Remove "font size / 12" calculations from various places.

Use spacing values from BControlLook instead.
This commit is contained in:
Augustin Cavalier
2022-09-28 19:36:59 -04:00
parent 396ffed536
commit 59d0a83200
4 changed files with 9 additions and 13 deletions
+3 -6
View File
@@ -17,6 +17,7 @@
#include <string.h> #include <string.h>
#include <Catalog.h> #include <Catalog.h>
#include <ControlLook.h>
#include <Directory.h> #include <Directory.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h> #include <FindDirectory.h>
@@ -34,9 +35,6 @@ static const char* kSettingsFileName = "DeskCalc_settings";
const char* kAppName = B_TRANSLATE_SYSTEM_NAME("DeskCalc"); const char* kAppName = B_TRANSLATE_SYSTEM_NAME("DeskCalc");
const char* kSignature = "application/x-vnd.Haiku-DeskCalc"; const char* kSignature = "application/x-vnd.Haiku-DeskCalc";
static const float kDefaultWindowWidth = 220.0;
static const float kDefaultWindowHeight = 140.0;
CalcApplication::CalcApplication() CalcApplication::CalcApplication()
: :
@@ -57,9 +55,8 @@ CalcApplication::ReadyToRun()
BMessage settings; BMessage settings;
_LoadSettings(settings); _LoadSettings(settings);
float scaling = be_plain_font->Size() / 12.0f; BRect frame(0, 0, be_control_look->DefaultLabelSpacing() * 37.0f,
BRect frame(0, 0, (kDefaultWindowWidth * scaling) - 1, be_control_look->DefaultLabelSpacing() * 23.0f);
(kDefaultWindowHeight * scaling) - 1);
fCalcWindow = new CalcWindow(frame, &settings); fCalcWindow = new CalcWindow(frame, &settings);
// reveal window // reveal window
+2 -3
View File
@@ -343,9 +343,8 @@ ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
{ {
fDriverInterface->AcquireReference(); fDriverInterface->AcquireReference();
float scale = be_plain_font->Size() / 12.0f; BRect batteryRect(BPoint(0, 0), be_control_look->ComposeIconSize(50));
float tabHeight = 70.0f * scale; float tabHeight = ceilf(batteryRect.Height() * 1.4f);
BRect batteryRect(0, 0, 50 * scale, 50 * scale);
fBatteryTabView = new BatteryTabView("tabview"); fBatteryTabView = new BatteryTabView("tabview");
fBatteryTabView->SetBorder(B_NO_BORDER); fBatteryTabView->SetBorder(B_NO_BORDER);
fBatteryTabView->SetTabHeight(tabHeight); fBatteryTabView->SetTabHeight(tabHeight);
+3 -3
View File
@@ -47,6 +47,7 @@ All rights reserved.
#include <Alert.h> #include <Alert.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h> #include <Catalog.h>
#include <ControlLook.h>
#include <Collator.h> #include <Collator.h>
#include <GroupView.h> #include <GroupView.h>
#include <GridView.h> #include <GridView.h>
@@ -72,7 +73,7 @@ const char* kDefaultOpenWithTemplate = "OpenWithSettings";
// make SaveState/RestoreState save the current window setting for // make SaveState/RestoreState save the current window setting for
// other windows // other windows
const float kMaxMenuWidth = 200; const float kMaxMenuWidthFactor = 33.0f;
const int32 kDocumentKnobWidth = 16; const int32 kDocumentKnobWidth = 16;
const int32 kOpenAndMakeDefault = 'OpDf'; const int32 kOpenAndMakeDefault = 'OpDf';
@@ -1238,7 +1239,6 @@ OpenWithMenu::DoneBuildingItemList()
BFont font; BFont font;
GetFont(&font); GetFont(&font);
float scaling = font.Size() / 12.0f;
// fill out the item labels // fill out the item labels
for (int32 index = 0; index < count; index++) { for (int32 index = 0; index < count; index++) {
@@ -1273,7 +1273,7 @@ OpenWithMenu::DoneBuildingItemList()
label = path.Path(); label = path.Path();
} }
font.TruncateString(&label, B_TRUNCATE_MIDDLE, font.TruncateString(&label, B_TRUNCATE_MIDDLE,
kMaxMenuWidth * scaling); kMaxMenuWidthFactor * be_control_look->DefaultLabelSpacing());
} }
#if DEBUG #if DEBUG
@@ -1183,7 +1183,7 @@ Preview::Preview()
BControl("PreView", NULL, NULL, B_WILL_DRAW | B_SUBPIXEL_PRECISE) BControl("PreView", NULL, NULL, B_WILL_DRAW | B_SUBPIXEL_PRECISE)
{ {
float aspectRatio = BScreen().Frame().Width() / BScreen().Frame().Height(); float aspectRatio = BScreen().Frame().Width() / BScreen().Frame().Height();
float previewWidth = 120.0f * std::max(1.0f, be_plain_font->Size() / 12.0f); float previewWidth = be_control_look->DefaultLabelSpacing() * 20.0f;
float previewHeight = ceil(previewWidth / aspectRatio); float previewHeight = ceil(previewWidth / aspectRatio);
ResizeTo(previewWidth, previewHeight); ResizeTo(previewWidth, previewHeight);