From 9b99c678f1d824929cac15e6297000c68941d3bf Mon Sep 17 00:00:00 2001
From: looncraz <looncraz@looncraz.net>
Date: Sat, 9 Jan 2016 13:13:21 -0600
Subject: [PATCH] Improve BButton Color Adaptability
View color now shows through, so we keep the view color in sync with the
parent to act as the button background color. The low color is used to
determine the button color. The high color is used to determine the
button label color.
The default low and high colors are the control background and text colors,
respectfully. To maintain the identical appearance as before, the default
control background color is tinted to match the default panel background
color. As the color has a gradient applied anyway, no one will notice a
difference while playing with custom control colors.
---
src/kits/interface/Button.cpp | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/kits/interface/Button.cpp b/src/kits/interface/Button.cpp
index ab728e5..6d3fd4b 100644
a
|
b
|
void
|
133 | 133 | BButton::Draw(BRect updateRect) |
134 | 134 | { |
135 | 135 | BRect rect(Bounds()); |
136 | | rgb_color background = LowColor(); |
| 136 | rgb_color background = ViewColor(); |
| 137 | rgb_color base = LowColor(); |
| 138 | rgb_color textColor = HighColor(); |
137 | 139 | |
138 | | // Darken default control color to match default panel color. |
139 | | rgb_color base = tint_color(ui_color(B_CONTROL_BACKGROUND_COLOR), 1.115); |
140 | 140 | uint32 flags = be_control_look->Flags(this); |
141 | 141 | if (_Flag(FLAG_DEFAULT)) |
142 | 142 | flags |= BControlLook::B_DEFAULT_BUTTON; |
… |
… |
BButton::Draw(BRect updateRect)
|
163 | 163 | (Value() == B_CONTROL_OFF |
164 | 164 | ? B_INACTIVE_ICON_BITMAP : B_ACTIVE_ICON_BITMAP) |
165 | 165 | | (IsEnabled() ? 0 : B_DISABLED_ICON_BITMAP)); |
166 | | be_control_look->DrawLabel(this, Label(), icon, rect, updateRect, |
167 | | base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); |
| 166 | |
| 167 | be_control_look->DrawLabel(this, Label(), icon, rect, updateRect, base, |
| 168 | flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE), &textColor); |
168 | 169 | } |
169 | 170 | |
170 | 171 | |
… |
… |
BButton::AttachedToWindow()
|
230 | 231 | { |
231 | 232 | BControl::AttachedToWindow(); |
232 | 233 | |
| 234 | // Tint default control background color to match default panel background. |
| 235 | SetLowUIColor(B_CONTROL_BACKGROUND_COLOR, 1.115); |
| 236 | SetHighUIColor(B_CONTROL_TEXT_COLOR); |
| 237 | |
233 | 238 | if (IsDefault()) |
234 | 239 | Window()->SetDefaultButton(this); |
235 | 240 | } |