Interface kit: Be explicit about text color for DrawLabel
Previously NULL was the default argument for text labels, this caused ControlLooks to pick "something" for the text color In particular this previously caused mismatched color pairs. Properly set this in the code to prevent this implicit color choosing. Api Clients can still pass = NULL directly if they wish for the controlLook to think of a color itself. Change-Id: Iea56e8d61269284f1d1470b852093bac5bf70de4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8963 Reviewed-by: John Scipione <[email protected]> Reviewed-by: nephele nephele <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
John Scipione
parent
2ff08f46cb
commit
812cf76fbf
@@ -1512,10 +1512,11 @@ ActivityView::Draw(BRect updateRect)
|
||||
DrawString(label.String(), BPoint(6 + colorBox.right, y));
|
||||
DrawString(text.String(), BPoint(frame.right - width, y));
|
||||
} else {
|
||||
rgb_color parentHigh = Parent()->HighColor();
|
||||
be_control_look->DrawLabel(this, label.String(),
|
||||
Parent()->ViewColor(), 0, BPoint(6 + colorBox.right, y));
|
||||
Parent()->ViewColor(), 0, BPoint(6 + colorBox.right, y), &parentHigh);
|
||||
be_control_look->DrawLabel(this, text.String(),
|
||||
Parent()->ViewColor(), 0, BPoint(frame.right - width, y));
|
||||
Parent()->ViewColor(), 0, BPoint(frame.right - width, y), &parentHigh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,9 @@ DefaultHeaderRenderer::DrawHeader(BView* view, BRect frame, BRect updateRect,
|
||||
frame.InsetBy(be_control_look->DefaultLabelSpacing(), 0);
|
||||
|
||||
if (value.Type() == B_STRING_TYPE) {
|
||||
rgb_color highColor = view->HighColor();
|
||||
be_control_look->DrawLabel(view, value.ToString(), frame, updateRect,
|
||||
view->LowColor(), 0);
|
||||
view->LowColor(), 0, &highColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,8 +160,9 @@ PackageCheckBox::Draw(BRect update)
|
||||
float width = StringWidth(string);
|
||||
BRect sizeRect = Bounds();
|
||||
sizeRect.left = sizeRect.right - width;
|
||||
rgb_color documentText = ui_color(B_DOCUMENT_TEXT_COLOR);
|
||||
be_control_look->DrawLabel(this, string, NULL, sizeRect, update,
|
||||
ui_color(B_DOCUMENT_BACKGROUND_COLOR), be_control_look->Flags(this));
|
||||
ui_color(B_DOCUMENT_BACKGROUND_COLOR), be_control_look->Flags(this), &documentText);
|
||||
}
|
||||
|
||||
|
||||
@@ -302,9 +303,9 @@ PackagesView::Draw(BRect updateRect)
|
||||
{
|
||||
if (CountChildren() > 0)
|
||||
return;
|
||||
|
||||
rgb_color highColor = HighColor();
|
||||
be_control_look->DrawLabel(this,
|
||||
B_TRANSLATE("No optional packages available."),
|
||||
Bounds(), updateRect, ViewColor(), BControlLook::B_DISABLED,
|
||||
BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
|
||||
BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE), &highColor);
|
||||
}
|
||||
|
||||
@@ -154,8 +154,9 @@ LabelView::Draw(BRect updateRect)
|
||||
if (!IsEnabled())
|
||||
flags |= BControlLook::B_DISABLED;
|
||||
|
||||
rgb_color text = ui_color(B_PANEL_TEXT_COLOR);
|
||||
be_control_look->DrawLabel(this, Text(), rect, updateRect,
|
||||
base, flags, BAlignment(Alignment(), B_ALIGN_MIDDLE));
|
||||
base, flags, BAlignment(Alignment(), B_ALIGN_MIDDLE), &text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +198,7 @@ HeaderTextControl::Draw(BRect updateRect)
|
||||
rect.InsetBy(-2, -2);
|
||||
|
||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
rgb_color text = ui_color(B_PANEL_TEXT_COLOR);
|
||||
uint32 flags = 0;
|
||||
if (!enabled)
|
||||
flags = BControlLook::B_DISABLED;
|
||||
@@ -219,7 +221,7 @@ HeaderTextControl::Draw(BRect updateRect)
|
||||
GetAlignment(&labelAlignment, NULL);
|
||||
|
||||
be_control_look->DrawLabel(this, Label(), rect, updateRect,
|
||||
base, flags, BAlignment(labelAlignment, B_ALIGN_MIDDLE));
|
||||
base, flags, BAlignment(labelAlignment, B_ALIGN_MIDDLE), &text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,8 +122,9 @@ void
|
||||
TabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect)
|
||||
{
|
||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
rgb_color text = ui_color(B_PANEL_TEXT_COLOR);
|
||||
be_control_look->DrawLabel(owner, fLabel.String(), frame, updateRect,
|
||||
base, 0, BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
|
||||
base, 0, BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE), &text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1474,7 +1474,8 @@ BAbstractSpinner::_DrawLabel(BRect updateRect)
|
||||
|
||||
uint32 flags = be_control_look->Flags(this);
|
||||
|
||||
be_control_look->DrawLabel(this, label, LowColor(), flags, BPoint(x, y));
|
||||
rgb_color highColor = HighColor();
|
||||
be_control_look->DrawLabel(this, label, LowColor(), flags, BPoint(x, y), &highColor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -973,6 +973,7 @@ BSlider::DrawText()
|
||||
BView* view = OffscreenView();
|
||||
|
||||
rgb_color base = ViewColor();
|
||||
rgb_color text = HighColor();
|
||||
uint32 flags = be_control_look->Flags(this);
|
||||
|
||||
font_height fontHeight;
|
||||
@@ -980,25 +981,25 @@ BSlider::DrawText()
|
||||
if (Orientation() == B_HORIZONTAL) {
|
||||
if (Label() != NULL) {
|
||||
be_control_look->DrawLabel(view, Label(), base, flags,
|
||||
BPoint(0.0f, ceilf(fontHeight.ascent)));
|
||||
BPoint(0.0f, ceilf(fontHeight.ascent)), &text);
|
||||
}
|
||||
|
||||
// the update text is updated in SetValue() only
|
||||
if (fUpdateText != NULL) {
|
||||
be_control_look->DrawLabel(view, fUpdateText, base, flags,
|
||||
BPoint(bounds.right - StringWidth(fUpdateText),
|
||||
ceilf(fontHeight.ascent)));
|
||||
ceilf(fontHeight.ascent)), &text);
|
||||
}
|
||||
|
||||
if (fMinLimitLabel != NULL) {
|
||||
be_control_look->DrawLabel(view, fMinLimitLabel, base, flags,
|
||||
BPoint(0.0f, bounds.bottom - fontHeight.descent));
|
||||
BPoint(0.0f, bounds.bottom - fontHeight.descent), &text);
|
||||
}
|
||||
|
||||
if (fMaxLimitLabel != NULL) {
|
||||
be_control_look->DrawLabel(view, fMaxLimitLabel, base, flags,
|
||||
BPoint(bounds.right - StringWidth(fMaxLimitLabel),
|
||||
bounds.bottom - fontHeight.descent));
|
||||
bounds.bottom - fontHeight.descent), &text);
|
||||
}
|
||||
} else {
|
||||
float lineHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent)
|
||||
@@ -1008,14 +1009,14 @@ BSlider::DrawText()
|
||||
if (Label() != NULL) {
|
||||
be_control_look->DrawLabel(view, Label(), base, flags,
|
||||
BPoint((bounds.Width() - StringWidth(Label())) / 2.0,
|
||||
baseLine));
|
||||
baseLine), &text);
|
||||
baseLine += lineHeight;
|
||||
}
|
||||
|
||||
if (fMaxLimitLabel != NULL) {
|
||||
be_control_look->DrawLabel(view, fMaxLimitLabel, base, flags,
|
||||
BPoint((bounds.Width() - StringWidth(fMaxLimitLabel)) / 2.0,
|
||||
baseLine));
|
||||
baseLine), &text);
|
||||
}
|
||||
|
||||
baseLine = bounds.bottom - ceilf(fontHeight.descent);
|
||||
@@ -1023,14 +1024,14 @@ BSlider::DrawText()
|
||||
if (fMinLimitLabel != NULL) {
|
||||
be_control_look->DrawLabel(view, fMinLimitLabel, base, flags,
|
||||
BPoint((bounds.Width() - StringWidth(fMinLimitLabel)) / 2.0,
|
||||
baseLine));
|
||||
baseLine), &text);
|
||||
baseLine -= lineHeight;
|
||||
}
|
||||
|
||||
if (fUpdateText != NULL) {
|
||||
be_control_look->DrawLabel(view, fUpdateText, base, flags,
|
||||
BPoint((bounds.Width() - StringWidth(fUpdateText)) / 2.0,
|
||||
baseLine));
|
||||
baseLine), &text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,10 +307,12 @@ BTab::DrawLabel(BView* owner, BRect frame)
|
||||
BAffineTransform transform;
|
||||
transform.RotateBy(center, rotation * M_PI / 180.0f);
|
||||
owner->SetTransform(transform);
|
||||
|
||||
rgb_color highColor = ui_color(B_PANEL_TEXT_COLOR);
|
||||
be_control_look->DrawLabel(owner, Label(), frame, frame,
|
||||
ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
IsEnabled() ? 0 : BControlLook::B_DISABLED,
|
||||
BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
|
||||
BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER), &highColor);
|
||||
owner->SetTransform(BAffineTransform());
|
||||
}
|
||||
|
||||
|
||||
@@ -361,6 +361,8 @@ BTextControl::Draw(BRect updateRect)
|
||||
rect.InsetBy(-2, -2);
|
||||
|
||||
rgb_color base = ViewColor();
|
||||
rgb_color text = HighColor();
|
||||
|
||||
uint32 flags = fLook;
|
||||
if (!enabled)
|
||||
flags |= BControlLook::B_DISABLED;
|
||||
@@ -379,7 +381,7 @@ BTextControl::Draw(BRect updateRect)
|
||||
}
|
||||
|
||||
be_control_look->DrawLabel(this, Label(), rect, updateRect,
|
||||
base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE));
|
||||
base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE), &text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user