Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ui/views/controls/button/label_button.cc

Issue 120823003: [Views] Only paint background of text portion of LabelButton in inverted color theme. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/controls/button/label_button_border.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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()) {
281 gfx::Rect rect(label()->bounds());
282 canvas->FillRect(rect, label()->background_color());
msw 2014/01/03 00:16:39 nit: s/label()/label_/; inline label_->bounds(); d
Greg Billock 2014/01/06 17:29:20 Done.
283 }
284
278 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); 285 Painter::PaintFocusPainter(this, canvas, focus_painter_.get());
279 } 286 }
280 287
281 void LabelButton::OnFocus() { 288 void LabelButton::OnFocus() {
282 View::OnFocus(); 289 View::OnFocus();
283 // Typically the border renders differently when focused. 290 // Typically the border renders differently when focused.
284 SchedulePaint(); 291 SchedulePaint();
285 } 292 }
286 293
287 void LabelButton::OnBlur() { 294 void LabelButton::OnBlur() {
288 View::OnBlur(); 295 View::OnBlur();
289 // Typically the border renders differently when focused. 296 // Typically the border renders differently when focused.
290 SchedulePaint(); 297 SchedulePaint();
291 } 298 }
292 299
293 void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { 300 void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
294 params->button.checked = false; 301 params->button.checked = false;
295 params->button.indeterminate = false; 302 params->button.indeterminate = false;
296 params->button.is_default = is_default_; 303 params->button.is_default = is_default_;
297 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); 304 params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
298 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; 305 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
299 params->button.classic_state = 0; 306 params->button.classic_state = 0;
300 params->button.background_color = label()->background_color(); 307 params->button.background_color = label()->background_color();
msw 2014/01/03 00:16:39 nit: s/label()/label_/ here for consistency.
Greg Billock 2014/01/06 17:29:20 Done.
301 } 308 }
302 309
303 void LabelButton::ResetColorsFromNativeTheme() { 310 void LabelButton::ResetColorsFromNativeTheme() {
304 const ui::NativeTheme* theme = GetNativeTheme(); 311 const ui::NativeTheme* theme = GetNativeTheme();
305 SkColor colors[STATE_COUNT] = { 312 SkColor colors[STATE_COUNT] = {
306 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor), 313 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor),
307 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), 314 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor),
308 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), 315 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor),
309 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor), 316 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor),
310 }; 317 };
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 return ui::NativeTheme::kNormal; 412 return ui::NativeTheme::kNormal;
406 } 413 }
407 414
408 ui::NativeTheme::State LabelButton::GetForegroundThemeState( 415 ui::NativeTheme::State LabelButton::GetForegroundThemeState(
409 ui::NativeTheme::ExtraParams* params) const { 416 ui::NativeTheme::ExtraParams* params) const {
410 GetExtraParams(params); 417 GetExtraParams(params);
411 return ui::NativeTheme::kHovered; 418 return ui::NativeTheme::kHovered;
412 } 419 }
413 420
414 } // namespace views 421 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/button/label_button_border.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698