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

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

Issue 9101004: Factor more colors into NativeTheme. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 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 | « ui/views/controls/button/text_button.h ('k') | ui/views/controls/menu/menu_item_view.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) 2011 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/text_button.h" 5 #include "ui/views/controls/button/text_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
11 #include "ui/base/animation/throb_animation.h" 11 #include "ui/base/animation/throb_animation.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 static const int kPreferredNativeThemePaddingVertical = 5; 43 static const int kPreferredNativeThemePaddingVertical = 5;
44 44
45 // By default the focus rect is drawn at the border of the view. 45 // By default the focus rect is drawn at the border of the view.
46 // For a button, we inset the focus rect by 3 pixels so that it 46 // For a button, we inset the focus rect by 3 pixels so that it
47 // doesn't draw on top of the button's border. This roughly matches 47 // doesn't draw on top of the button's border. This roughly matches
48 // how the Windows native focus rect for buttons looks. A subclass 48 // how the Windows native focus rect for buttons looks. A subclass
49 // that draws a button with different padding may need to 49 // that draws a button with different padding may need to
50 // override OnPaintFocusBorder and do something different. 50 // override OnPaintFocusBorder and do something different.
51 static const int kFocusRectInset = 3; 51 static const int kFocusRectInset = 3;
52 52
53 // Default background color for buttons.
54 const SkColor kBackgroundColor = SkColorSetRGB(0xde, 0xde, 0xde);
55
56 #if defined(USE_AURA)
57 // static
58 const SkColor TextButtonBase::kEnabledColor = SkColorSetRGB(0x44, 0x44, 0x44);
59 // static
60 const SkColor TextButtonBase::kHighlightColor = SkColorSetRGB(0, 0, 0);
61 // static
62 const SkColor TextButtonBase::kDisabledColor = SkColorSetRGB(0x99, 0x99, 0x99);
63 // static
64 const SkColor TextButtonBase::kHoverColor = TextButton::kEnabledColor;
65 #else // !defined(USE_AURA)
66 // static
67 const SkColor TextButtonBase::kEnabledColor = SkColorSetRGB(6, 45, 117);
68 // static
69 const SkColor TextButtonBase::kHighlightColor =
70 SkColorSetARGB(200, 255, 255, 255);
71 // static
72 const SkColor TextButtonBase::kDisabledColor = SkColorSetRGB(161, 161, 146);
73 // static
74 const SkColor TextButtonBase::kHoverColor = TextButton::kEnabledColor;
75 #endif // defined(USE_AURA)
76
77 // How long the hover fade animation should last. 53 // How long the hover fade animation should last.
78 static const int kHoverAnimationDurationMs = 170; 54 static const int kHoverAnimationDurationMs = 170;
79 55
80 // static 56 // static
81 const char TextButtonBase::kViewClassName[] = "views/TextButtonBase"; 57 const char TextButtonBase::kViewClassName[] = "views/TextButtonBase";
82 // static 58 // static
83 const char TextButton::kViewClassName[] = "views/TextButton"; 59 const char TextButton::kViewClassName[] = "views/TextButton";
84 // static 60 // static
85 const char NativeTextButton::kViewClassName[] = "views/NativeTextButton"; 61 const char NativeTextButton::kViewClassName[] = "views/NativeTextButton";
86 62
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 245
270 246
271 //////////////////////////////////////////////////////////////////////////////// 247 ////////////////////////////////////////////////////////////////////////////////
272 // TextButtonBase, public: 248 // TextButtonBase, public:
273 249
274 TextButtonBase::TextButtonBase(ButtonListener* listener, const string16& text) 250 TextButtonBase::TextButtonBase(ButtonListener* listener, const string16& text)
275 : CustomButton(listener), 251 : CustomButton(listener),
276 alignment_(ALIGN_LEFT), 252 alignment_(ALIGN_LEFT),
277 font_(ResourceBundle::GetSharedInstance().GetFont( 253 font_(ResourceBundle::GetSharedInstance().GetFont(
278 ResourceBundle::BaseFont)), 254 ResourceBundle::BaseFont)),
279 color_(kEnabledColor), 255 color_(gfx::NativeTheme::instance()->GetSystemColor(
280 color_enabled_(kEnabledColor), 256 gfx::NativeTheme::kColorId_TextButtonEnabledColor)),
281 color_disabled_(kDisabledColor), 257 color_enabled_(gfx::NativeTheme::instance()->GetSystemColor(
282 color_highlight_(kHighlightColor), 258 gfx::NativeTheme::kColorId_TextButtonEnabledColor)),
283 color_hover_(kHoverColor), 259 color_disabled_(gfx::NativeTheme::instance()->GetSystemColor(
260 gfx::NativeTheme::kColorId_TextButtonDisabledColor)),
261 color_highlight_(gfx::NativeTheme::instance()->GetSystemColor(
262 gfx::NativeTheme::kColorId_TextButtonHighlightColor)),
263 color_hover_(gfx::NativeTheme::instance()->GetSystemColor(
264 gfx::NativeTheme::kColorId_TextButtonHoverColor)),
284 text_halo_color_(0), 265 text_halo_color_(0),
285 has_text_halo_(false), 266 has_text_halo_(false),
286 active_text_shadow_color_(0), 267 active_text_shadow_color_(0),
287 inactive_text_shadow_color_(0), 268 inactive_text_shadow_color_(0),
288 has_shadow_(false), 269 has_shadow_(false),
289 shadow_offset_(gfx::Point(1, 1)), 270 shadow_offset_(gfx::Point(1, 1)),
290 max_width_(0), 271 max_width_(0),
291 show_multiple_icon_states_(true), 272 show_multiple_icon_states_(true),
292 is_default_(false), 273 is_default_(false),
293 multi_line_(false), 274 multi_line_(false),
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 return flags; 443 return flags;
463 } 444 }
464 445
465 void TextButtonBase::GetExtraParams( 446 void TextButtonBase::GetExtraParams(
466 gfx::NativeTheme::ExtraParams* params) const { 447 gfx::NativeTheme::ExtraParams* params) const {
467 params->button.checked = false; 448 params->button.checked = false;
468 params->button.indeterminate = false; 449 params->button.indeterminate = false;
469 params->button.is_default = false; 450 params->button.is_default = false;
470 params->button.has_border = false; 451 params->button.has_border = false;
471 params->button.classic_state = 0; 452 params->button.classic_state = 0;
472 params->button.background_color = kBackgroundColor; 453 params->button.background_color =
454 gfx::NativeTheme::instance()->GetSystemColor(
455 gfx::NativeTheme::kColorId_TextButtonBackgroundColor);
473 } 456 }
474 457
475 gfx::Rect TextButtonBase::GetContentBounds(int extra_width) const { 458 gfx::Rect TextButtonBase::GetContentBounds(int extra_width) const {
476 gfx::Insets insets = GetInsets(); 459 gfx::Insets insets = GetInsets();
477 int available_width = width() - insets.width(); 460 int available_width = width() - insets.width();
478 int content_width = text_size_.width() + extra_width; 461 int content_width = text_size_.width() + extra_width;
479 int content_x = 0; 462 int content_x = 0;
480 switch(alignment_) { 463 switch(alignment_) {
481 case ALIGN_LEFT: 464 case ALIGN_LEFT:
482 content_x = insets.left(); 465 content_x = insets.left();
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 #endif 834 #endif
852 } 835 }
853 836
854 void NativeTextButton::GetExtraParams( 837 void NativeTextButton::GetExtraParams(
855 gfx::NativeTheme::ExtraParams* params) const { 838 gfx::NativeTheme::ExtraParams* params) const {
856 TextButton::GetExtraParams(params); 839 TextButton::GetExtraParams(params);
857 params->button.has_border = true; 840 params->button.has_border = true;
858 } 841 }
859 842
860 } // namespace views 843 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/text_button.h ('k') | ui/views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698