25
25
#include " ui/views/view_class_properties.h"
26
26
27
27
// To be called from MdTextButtonBase::UpdateColors().
28
- #define BRAVE_MD_TEXT_BUTTON_UPDATE_COLORS \
29
- UpdateColorsForBrave (); \
30
- UpdateIconForBrave ();
28
+ #define BRAVE_MD_TEXT_BUTTON_UPDATE_COLORS UpdateIconForBrave ();
31
29
32
30
#define MdTextButton MdTextButtonBase
33
31
#include " src/ui/views/controls/button/md_text_button.cc"
@@ -207,10 +205,59 @@ void MdTextButton::SetLoading(bool loading) {
207
205
UpdateColors ();
208
206
}
209
207
208
+ void MdTextButton::UpdateTextColor () {
209
+ MdTextButtonBase::UpdateTextColor ();
210
+
211
+ // Once we update the buttons across Brave to use the new style, we can remove
212
+ // this branch.
213
+ if (kind_ == kOld ) {
214
+ if (GetProminent ())
215
+ return ;
216
+ const ui::NativeTheme* theme = GetNativeTheme ();
217
+ // Override different text hover color
218
+ if (theme->GetPlatformHighContrastColorScheme () !=
219
+ ui::NativeTheme::PlatformHighContrastColorScheme::kDark ) {
220
+ SetTextColor (ButtonState::STATE_HOVERED, kBraveBrandColor );
221
+ SetTextColor (ButtonState::STATE_PRESSED, kBraveBrandColor );
222
+ }
223
+ return ;
224
+ }
225
+
226
+ auto colors = GetButtonColors ();
227
+ SetTextColor (GetVisualState (), colors.text_color );
228
+ }
229
+
210
230
void MdTextButton::UpdateBackgroundColor () {
211
- // Handled via |UpdateColorsForBrave|.
231
+ // Once we update the buttons across Brave to use the new style, we can remove
232
+ // this branch.
212
233
if (kind_ == kOld ) {
213
234
MdTextButtonBase::UpdateBackgroundColor ();
235
+
236
+ // We don't modify the Prominent button at all.
237
+ if (GetProminent ()) {
238
+ return ;
239
+ }
240
+
241
+ // Override border color for hover on non-prominent
242
+ if (GetState () == ButtonState::STATE_PRESSED ||
243
+ GetState () == ButtonState::STATE_HOVERED) {
244
+ // First, get the same background fill color that MdTextButtonBase does.
245
+ // It is unfortunate to copy these lines almost as-is. Consider otherwise
246
+ // patching it in via a #define.
247
+ SkColor bg_color =
248
+ GetColorProvider ()->GetColor (ui::kColorDialogBackground );
249
+ if (GetBgColorOverride ()) {
250
+ bg_color = *GetBgColorOverride ();
251
+ }
252
+ if (GetState () == STATE_PRESSED) {
253
+ bg_color = GetNativeTheme ()->GetSystemButtonPressedColor (bg_color);
254
+ }
255
+ // The only thing that differs for Brave is the stroke color
256
+ SkColor stroke_color = kBraveBrandColor ;
257
+ SetBackground (CreateBackgroundFromPainter (
258
+ Painter::CreateRoundRectWith1PxBorderPainter (bg_color, stroke_color,
259
+ GetCornerRadius ())));
260
+ }
214
261
return ;
215
262
}
216
263
@@ -224,49 +271,6 @@ void MdTextButton::UpdateBackgroundColor() {
224
271
colors.background_color , colors.stroke_color , GetCornerRadius ())));
225
272
}
226
273
227
- void MdTextButton::UpdateOldColorsForBrave () {
228
- if (GetProminent ()) {
229
- return ;
230
- }
231
-
232
- const ui::NativeTheme* theme = GetNativeTheme ();
233
- // Override different text hover color
234
- if (theme->GetPlatformHighContrastColorScheme () !=
235
- ui::NativeTheme::PlatformHighContrastColorScheme::kDark ) {
236
- SetTextColor (ButtonState::STATE_HOVERED, kBraveBrandColor );
237
- SetTextColor (ButtonState::STATE_PRESSED, kBraveBrandColor );
238
- }
239
- // Override border color for hover on non-prominent
240
- if (GetState () == ButtonState::STATE_PRESSED ||
241
- GetState () == ButtonState::STATE_HOVERED) {
242
- // First, get the same background fill color that MdTextButtonBase does.
243
- // It is undfortunate to copy these lines almost as-is. Consider otherwise
244
- // patching it in via a #define.
245
- SkColor bg_color = GetColorProvider ()->GetColor (ui::kColorDialogBackground );
246
- if (GetBgColorOverride ()) {
247
- bg_color = *GetBgColorOverride ();
248
- }
249
- if (GetState () == STATE_PRESSED) {
250
- bg_color = GetNativeTheme ()->GetSystemButtonPressedColor (bg_color);
251
- }
252
- // The only thing that differs for Brave is the stroke color
253
- SkColor stroke_color = kBraveBrandColor ;
254
- SetBackground (CreateBackgroundFromPainter (
255
- Painter::CreateRoundRectWith1PxBorderPainter (bg_color, stroke_color,
256
- GetCornerRadius ())));
257
- }
258
- }
259
-
260
- // To be called from MdTextButtonBase::UpdateColors().
261
- void MdTextButton::UpdateColorsForBrave () {
262
- if (GetKind () == Kind::kOld ) {
263
- UpdateOldColorsForBrave ();
264
- return ;
265
- }
266
-
267
- SetTextColor (GetVisualState (), );
268
- }
269
-
270
274
void MdTextButton::UpdateIconForBrave () {
271
275
if (icon_) {
272
276
SetImageModel (
0 commit comments