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

View File

@ -17,6 +17,7 @@
#include <string.h>
#include <Catalog.h>
#include <ControlLook.h>
#include <Directory.h>
#include <File.h>
#include <FindDirectory.h>
@ -34,9 +35,6 @@ static const char* kSettingsFileName = "DeskCalc_settings";
const char* kAppName = B_TRANSLATE_SYSTEM_NAME("DeskCalc");
const char* kSignature = "application/x-vnd.Haiku-DeskCalc";
static const float kDefaultWindowWidth = 220.0;
static const float kDefaultWindowHeight = 140.0;
CalcApplication::CalcApplication()
:
@ -57,9 +55,8 @@ CalcApplication::ReadyToRun()
BMessage settings;
_LoadSettings(settings);
float scaling = be_plain_font->Size() / 12.0f;
BRect frame(0, 0, (kDefaultWindowWidth * scaling) - 1,
(kDefaultWindowHeight * scaling) - 1);
BRect frame(0, 0, be_control_look->DefaultLabelSpacing() * 37.0f,
be_control_look->DefaultLabelSpacing() * 23.0f);
fCalcWindow = new CalcWindow(frame, &settings);
// reveal window

View File

@ -343,9 +343,8 @@ ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
{
fDriverInterface->AcquireReference();
float scale = be_plain_font->Size() / 12.0f;
float tabHeight = 70.0f * scale;
BRect batteryRect(0, 0, 50 * scale, 50 * scale);
BRect batteryRect(BPoint(0, 0), be_control_look->ComposeIconSize(50));
float tabHeight = ceilf(batteryRect.Height() * 1.4f);
fBatteryTabView = new BatteryTabView("tabview");
fBatteryTabView->SetBorder(B_NO_BORDER);
fBatteryTabView->SetTabHeight(tabHeight);

View File

@ -47,6 +47,7 @@ All rights reserved.
#include <Alert.h>
#include <Button.h>
#include <Catalog.h>
#include <ControlLook.h>
#include <Collator.h>
#include <GroupView.h>
#include <GridView.h>
@ -72,7 +73,7 @@ const char* kDefaultOpenWithTemplate = "OpenWithSettings";
// make SaveState/RestoreState save the current window setting for
// other windows
const float kMaxMenuWidth = 200;
const float kMaxMenuWidthFactor = 33.0f;
const int32 kDocumentKnobWidth = 16;
const int32 kOpenAndMakeDefault = 'OpDf';
@ -1238,7 +1239,6 @@ OpenWithMenu::DoneBuildingItemList()
BFont font;
GetFont(&font);
float scaling = font.Size() / 12.0f;
// fill out the item labels
for (int32 index = 0; index < count; index++) {
@ -1273,7 +1273,7 @@ OpenWithMenu::DoneBuildingItemList()
label = path.Path();
}
font.TruncateString(&label, B_TRUNCATE_MIDDLE,
kMaxMenuWidth * scaling);
kMaxMenuWidthFactor * be_control_look->DefaultLabelSpacing());
}
#if DEBUG

View File

@ -1183,7 +1183,7 @@ Preview::Preview()
BControl("PreView", NULL, NULL, B_WILL_DRAW | B_SUBPIXEL_PRECISE)
{
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);
ResizeTo(previewWidth, previewHeight);