BButton: Use BControlLook for label spacing instead of a constant.
This gets button proportions under HiDPI much closer to the ones under a default font size. Still not quite there yet, though.
This commit is contained in:
@@ -35,9 +35,6 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const float kLabelMargin = 3;
|
|
||||||
|
|
||||||
|
|
||||||
BButton::BButton(BRect frame, const char* name, const char* label,
|
BButton::BButton(BRect frame, const char* name, const char* label,
|
||||||
BMessage* message, uint32 resizingMode, uint32 flags)
|
BMessage* message, uint32 resizingMode, uint32 flags)
|
||||||
:
|
:
|
||||||
@@ -157,7 +154,8 @@ BButton::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// always leave some room around the label
|
// always leave some room around the label
|
||||||
rect.InsetBy(kLabelMargin, kLabelMargin);
|
float labelMargin = be_control_look->DefaultLabelSpacing() / 2;
|
||||||
|
rect.InsetBy(labelMargin, labelMargin);
|
||||||
|
|
||||||
const BBitmap* icon = IconBitmap(
|
const BBitmap* icon = IconBitmap(
|
||||||
(Value() == B_CONTROL_OFF
|
(Value() == B_CONTROL_OFF
|
||||||
@@ -651,7 +649,7 @@ BButton::_ValidatePreferredSize()
|
|||||||
left, top, right, bottom);
|
left, top, right, bottom);
|
||||||
|
|
||||||
// width
|
// width
|
||||||
float width = left + right + 2 * kLabelMargin - 1;
|
float width = left + right + be_control_look->DefaultLabelSpacing() - 1;
|
||||||
|
|
||||||
const char* label = Label();
|
const char* label = Label();
|
||||||
if (label != NULL) {
|
if (label != NULL) {
|
||||||
@@ -667,7 +665,7 @@ BButton::_ValidatePreferredSize()
|
|||||||
width += be_control_look->DefaultLabelSpacing();
|
width += be_control_look->DefaultLabelSpacing();
|
||||||
|
|
||||||
// height
|
// height
|
||||||
float minHorizontalMargins = top + bottom + 2 * kLabelMargin;
|
float minHorizontalMargins = top + bottom + be_control_look->DefaultLabelSpacing();
|
||||||
float height = -1;
|
float height = -1;
|
||||||
|
|
||||||
if (label != NULL) {
|
if (label != NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user