Deskbar: Compute basic metrics earlier, in TBarApp::InitSettings().

This way we know the minimum and maximum window width earlier
and consumers of them do not come up with "0" incorrectly.

Fixes #17890.
This commit is contained in:
Augustin Cavalier 2022-08-29 15:55:41 -04:00
parent f34e3931e8
commit fac73debbf
3 changed files with 22 additions and 21 deletions

View File

@ -234,6 +234,26 @@ TBarApp::SaveSettings()
void
TBarApp::InitSettings()
{
// compute metrics
sIconGap = ceilf(be_control_look->DefaultLabelSpacing() / 3.0f);
gDragRegionWidth = be_control_look->ComposeSpacing(B_USE_HALF_ITEM_SPACING);
gDragWidth = ceilf(gDragRegionWidth * 0.6f);
gMinReplicantHeight = gMinReplicantWidth =
be_control_look->ComposeIconSize(B_MINI_ICON).IntegerWidth() + 1;
// 1 pixel for left gutter
// space for replicant tray (6 items)
// 6 pixel drag region
gMinimumTrayWidth = sIconGap + gMinReplicantWidth
+ (kMinimumReplicantCount * sIconGap)
+ (kMinimumReplicantCount * gMinReplicantWidth) + kGutter;
gMinimumWindowWidth = kGutter + gMinimumTrayWidth + gDragRegionWidth;
gMaximumWindowWidth = gMinimumWindowWidth * 2;
// defaults
desk_settings settings;
settings.vertical = fDefaultSettings.vertical = true;
settings.left = fDefaultSettings.left = false;

View File

@ -79,7 +79,7 @@ All rights reserved.
static const float kVerticalMiniMultiplier = 2.9f;
static float sIconGap = 0.0f;
float sIconGap = 0.0f;
float gDragWidth, gDragRegionWidth = 0.0f;
float gMinReplicantHeight, gMinReplicantWidth = 0.0f;
float gMinimumTrayWidth, gMinimumWindowWidth, gMaximumWindowWidth = 0.0f;
@ -142,26 +142,6 @@ TReplicantTray::TReplicantTray(TBarView* barView)
fShelf(new TReplicantShelf(this)),
fAlignmentSupport(false)
{
if (sIconGap == 0.0f) {
sIconGap = ceilf(be_control_look->DefaultLabelSpacing() / 3.0f);
gDragRegionWidth = be_control_look->ComposeSpacing(B_USE_HALF_ITEM_SPACING);
gDragWidth = ceilf(gDragRegionWidth * 0.6f);
gMinReplicantHeight = gMinReplicantWidth =
be_control_look->ComposeIconSize(B_MINI_ICON).IntegerWidth() + 1;
// 1 pixel for left gutter
// space for replicant tray (6 items)
// 6 pixel drag region
gMinimumTrayWidth = sIconGap + gMinReplicantWidth
+ (kMinimumReplicantCount * sIconGap)
+ (kMinimumReplicantCount * gMinReplicantWidth) + kGutter;
gMinimumWindowWidth = kGutter + gMinimumTrayWidth + gDragRegionWidth;
gMaximumWindowWidth = gMinimumWindowWidth * 2;
}
// scale replicants by font size
fMaxReplicantHeight = std::max(gMinReplicantHeight,
float(((TBarApp*)be_app)->IconSize()));

View File

@ -54,6 +54,7 @@ const int32 kGutter = 1;
const int32 kTrayPadding = B_USE_HALF_ITEM_SPACING;
const int32 kClockMargin = 12;
extern float sIconGap;
extern float gDragWidth, gDragRegionWidth;
extern float gMinReplicantHeight, gMinReplicantWidth;
extern float gMinimumTrayWidth, gMinimumWindowWidth, gMaximumWindowWidth;