OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/controls/button/label_button.h" | 5 #include "ui/views/controls/button/label_button.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/animation/throb_animation.h" | 10 #include "ui/gfx/animation/throb_animation.h" |
11 #include "ui/gfx/canvas.h" | |
11 #include "ui/gfx/font_list.h" | 12 #include "ui/gfx/font_list.h" |
12 #include "ui/gfx/sys_color_change_listener.h" | 13 #include "ui/gfx/sys_color_change_listener.h" |
13 #include "ui/native_theme/native_theme.h" | 14 #include "ui/native_theme/native_theme.h" |
14 #include "ui/views/controls/button/label_button_border.h" | 15 #include "ui/views/controls/button/label_button_border.h" |
15 #include "ui/views/painter.h" | 16 #include "ui/views/painter.h" |
16 #include "ui/views/window/dialog_delegate.h" | 17 #include "ui/views/window/dialog_delegate.h" |
17 | 18 |
18 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
19 #include "ui/native_theme/native_theme_win.h" | 20 #include "ui/native_theme/native_theme_win.h" |
20 #endif | 21 #endif |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 image_->SetBoundsRect(gfx::Rect(image_origin, image_size)); | 269 image_->SetBoundsRect(gfx::Rect(image_origin, image_size)); |
269 label_->SetBoundsRect(gfx::Rect(label_origin, label_size)); | 270 label_->SetBoundsRect(gfx::Rect(label_origin, label_size)); |
270 } | 271 } |
271 | 272 |
272 const char* LabelButton::GetClassName() const { | 273 const char* LabelButton::GetClassName() const { |
273 return kViewClassName; | 274 return kViewClassName; |
274 } | 275 } |
275 | 276 |
276 void LabelButton::OnPaint(gfx::Canvas* canvas) { | 277 void LabelButton::OnPaint(gfx::Canvas* canvas) { |
277 View::OnPaint(canvas); | 278 View::OnPaint(canvas); |
279 | |
280 if (gfx::IsInvertedColorScheme()) | |
sky
2014/01/06 20:20:37
This ends up being after the border is painted. Do
Greg Billock
2014/01/06 21:13:44
I placed this here to try and mimic the sequencing
msw
2014/01/06 21:50:57
Do label_->set_background(CreateSolidBackground(SK
Greg Billock
2014/01/06 22:14:46
That's true, we're kind of already pushing the lab
msw
2014/01/06 22:34:55
Neither Label nor LabelButton seem to set any back
Greg Billock
2014/01/06 23:51:02
ok. This seems to work fine.*
* There are still a
msw
2014/01/07 00:00:54
Yeah, I think these are long-standing issues; many
| |
281 canvas->FillRect(label_->bounds(), label_->background_color()); | |
282 | |
278 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); | 283 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); |
279 } | 284 } |
280 | 285 |
281 void LabelButton::OnFocus() { | 286 void LabelButton::OnFocus() { |
282 View::OnFocus(); | 287 View::OnFocus(); |
283 // Typically the border renders differently when focused. | 288 // Typically the border renders differently when focused. |
284 SchedulePaint(); | 289 SchedulePaint(); |
285 } | 290 } |
286 | 291 |
287 void LabelButton::OnBlur() { | 292 void LabelButton::OnBlur() { |
288 View::OnBlur(); | 293 View::OnBlur(); |
289 // Typically the border renders differently when focused. | 294 // Typically the border renders differently when focused. |
290 SchedulePaint(); | 295 SchedulePaint(); |
291 } | 296 } |
292 | 297 |
293 void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { | 298 void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { |
294 params->button.checked = false; | 299 params->button.checked = false; |
295 params->button.indeterminate = false; | 300 params->button.indeterminate = false; |
296 params->button.is_default = is_default_; | 301 params->button.is_default = is_default_; |
297 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); | 302 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); |
298 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; | 303 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; |
299 params->button.classic_state = 0; | 304 params->button.classic_state = 0; |
300 params->button.background_color = label()->background_color(); | 305 params->button.background_color = label_->background_color(); |
301 } | 306 } |
302 | 307 |
303 void LabelButton::ResetColorsFromNativeTheme() { | 308 void LabelButton::ResetColorsFromNativeTheme() { |
304 const ui::NativeTheme* theme = GetNativeTheme(); | 309 const ui::NativeTheme* theme = GetNativeTheme(); |
305 SkColor colors[STATE_COUNT] = { | 310 SkColor colors[STATE_COUNT] = { |
306 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor), | 311 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor), |
307 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), | 312 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), |
308 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), | 313 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), |
309 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor), | 314 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor), |
310 }; | 315 }; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 return ui::NativeTheme::kNormal; | 410 return ui::NativeTheme::kNormal; |
406 } | 411 } |
407 | 412 |
408 ui::NativeTheme::State LabelButton::GetForegroundThemeState( | 413 ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
409 ui::NativeTheme::ExtraParams* params) const { | 414 ui::NativeTheme::ExtraParams* params) const { |
410 GetExtraParams(params); | 415 GetExtraParams(params); |
411 return ui::NativeTheme::kHovered; | 416 return ui::NativeTheme::kHovered; |
412 } | 417 } |
413 | 418 |
414 } // namespace views | 419 } // namespace views |
OLD | NEW |