From 8b902d940af2d62c2dca094d0d7eb4f3649262e1 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Tue, 22 Mar 2016 11:06:28 -0700 Subject: [PATCH] IK: Use panel text color for select control labels NOTE: This should have no effect on the colors of these labels unless you have changed the panel text color and control text colors to be different. Both are black by default. In the case of the menu field, spinner, check box, radio button, slider, and text control labels we want to draw these labels using the panel text color instead of the control text color because they are drawn on top of the panel color. (the menu field label color was changed in a previous commit in this push). In all cases except the menu field the label color is specified by temporarily unsetting the B_IS_CONTROL flag while drawing the label. All use control look to draw the label. The control text color is meant to be used for text INSIDE the control, not the label text that accompanies the control -- at least that's the way I understand it. --- src/kits/interface/AbstractSpinner.cpp | 8 +++++--- src/kits/interface/CheckBox.cpp | 4 ++++ src/kits/interface/RadioButton.cpp | 4 ++++ src/kits/interface/Slider.cpp | 7 ++++++- src/kits/interface/TextControl.cpp | 4 ++++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/AbstractSpinner.cpp b/src/kits/interface/AbstractSpinner.cpp index ecccc88e64..d6239602b1 100644 --- a/src/kits/interface/AbstractSpinner.cpp +++ b/src/kits/interface/AbstractSpinner.cpp @@ -1453,9 +1453,11 @@ BAbstractSpinner::_DrawLabel(BRect updateRect) - fontHeight.descent) / 2.0f) + fontHeight.ascent + kFrameMargin * 2; - uint32 flags = 0; - if (!IsEnabled()) - flags |= BControlLook::B_DISABLED; + uint32 flags = be_control_look->Flags(this); + + // erase the is control flag before drawing the label so that the label + // will get drawn using B_PANEL_TEXT_COLOR. + flags &= ~BControlLook::B_IS_CONTROL; be_control_look->DrawLabel(this, label, LowColor(), flags, BPoint(x, y)); } diff --git a/src/kits/interface/CheckBox.cpp b/src/kits/interface/CheckBox.cpp index fc17585ed0..8e20d6bf0c 100644 --- a/src/kits/interface/CheckBox.cpp +++ b/src/kits/interface/CheckBox.cpp @@ -113,6 +113,10 @@ BCheckBox::Draw(BRect updateRect) BRect rect(checkBoxRect); be_control_look->DrawCheckBox(this, rect, updateRect, base, flags); + // erase the is control flag before drawing the label so that the label + // will get drawn using B_PANEL_TEXT_COLOR + flags &= ~BControlLook::B_IS_CONTROL; + BRect labelRect(Bounds()); labelRect.left = checkBoxRect.right + 1 + be_control_look->DefaultLabelSpacing(); diff --git a/src/kits/interface/RadioButton.cpp b/src/kits/interface/RadioButton.cpp index 6893ea4935..046983340a 100644 --- a/src/kits/interface/RadioButton.cpp +++ b/src/kits/interface/RadioButton.cpp @@ -99,6 +99,10 @@ BRadioButton::Draw(BRect updateRect) BRect rect(knobRect); be_control_look->DrawRadioButton(this, rect, updateRect, base, flags); + // erase the is control flag before drawing the label so that the label + // will get drawn using B_PANEL_TEXT_COLOR. + flags &= ~BControlLook::B_IS_CONTROL; + BRect labelRect(Bounds()); labelRect.left = knobRect.right + 1 + be_control_look->DefaultLabelSpacing(); diff --git a/src/kits/interface/Slider.cpp b/src/kits/interface/Slider.cpp index bcd7edd3b1..7888f5fc60 100644 --- a/src/kits/interface/Slider.cpp +++ b/src/kits/interface/Slider.cpp @@ -1150,9 +1150,14 @@ BSlider::DrawText() } else { view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT)); } - } else + } else { flags = be_control_look->Flags(this); + // erase the is control flag before drawing the label so that the label + // will get drawn using B_PANEL_TEXT_COLOR + flags &= ~BControlLook::B_IS_CONTROL; + } + font_height fontHeight; GetFontHeight(&fontHeight); if (Orientation() == B_HORIZONTAL) { diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index c05a1bcc93..16b528f684 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -376,6 +376,10 @@ BTextControl::Draw(BRect updateRect) rect.right = fDivider - kLabelInputSpacing; } + // erase the is control flag before drawing the label so that the label + // will get drawn using B_PANEL_TEXT_COLOR + flags &= ~BControlLook::B_IS_CONTROL; + be_control_look->DrawLabel(this, Label(), rect, updateRect, base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE)); }