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:
@@ -234,6 +234,26 @@ TBarApp::SaveSettings()
|
|||||||
void
|
void
|
||||||
TBarApp::InitSettings()
|
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;
|
desk_settings settings;
|
||||||
settings.vertical = fDefaultSettings.vertical = true;
|
settings.vertical = fDefaultSettings.vertical = true;
|
||||||
settings.left = fDefaultSettings.left = false;
|
settings.left = fDefaultSettings.left = false;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ All rights reserved.
|
|||||||
|
|
||||||
static const float kVerticalMiniMultiplier = 2.9f;
|
static const float kVerticalMiniMultiplier = 2.9f;
|
||||||
|
|
||||||
static float sIconGap = 0.0f;
|
float sIconGap = 0.0f;
|
||||||
float gDragWidth, gDragRegionWidth = 0.0f;
|
float gDragWidth, gDragRegionWidth = 0.0f;
|
||||||
float gMinReplicantHeight, gMinReplicantWidth = 0.0f;
|
float gMinReplicantHeight, gMinReplicantWidth = 0.0f;
|
||||||
float gMinimumTrayWidth, gMinimumWindowWidth, gMaximumWindowWidth = 0.0f;
|
float gMinimumTrayWidth, gMinimumWindowWidth, gMaximumWindowWidth = 0.0f;
|
||||||
@@ -142,26 +142,6 @@ TReplicantTray::TReplicantTray(TBarView* barView)
|
|||||||
fShelf(new TReplicantShelf(this)),
|
fShelf(new TReplicantShelf(this)),
|
||||||
fAlignmentSupport(false)
|
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
|
// scale replicants by font size
|
||||||
fMaxReplicantHeight = std::max(gMinReplicantHeight,
|
fMaxReplicantHeight = std::max(gMinReplicantHeight,
|
||||||
float(((TBarApp*)be_app)->IconSize()));
|
float(((TBarApp*)be_app)->IconSize()));
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ const int32 kGutter = 1;
|
|||||||
const int32 kTrayPadding = B_USE_HALF_ITEM_SPACING;
|
const int32 kTrayPadding = B_USE_HALF_ITEM_SPACING;
|
||||||
const int32 kClockMargin = 12;
|
const int32 kClockMargin = 12;
|
||||||
|
|
||||||
|
extern float sIconGap;
|
||||||
extern float gDragWidth, gDragRegionWidth;
|
extern float gDragWidth, gDragRegionWidth;
|
||||||
extern float gMinReplicantHeight, gMinReplicantWidth;
|
extern float gMinReplicantHeight, gMinReplicantWidth;
|
||||||
extern float gMinimumTrayWidth, gMinimumWindowWidth, gMaximumWindowWidth;
|
extern float gMinimumTrayWidth, gMinimumWindowWidth, gMaximumWindowWidth;
|
||||||
|
|||||||
Reference in New Issue
Block a user