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

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

Issue 9151011: Revert 116894 - Factor more colors into NativeTheme. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
53 // How long the hover fade animation should last. 77 // How long the hover fade animation should last.
54 static const int kHoverAnimationDurationMs = 170; 78 static const int kHoverAnimationDurationMs = 170;
55 79
56 // static 80 // static
57 const char TextButtonBase::kViewClassName[] = "views/TextButtonBase"; 81 const char TextButtonBase::kViewClassName[] = "views/TextButtonBase";
58 // static 82 // static
59 const char TextButton::kViewClassName[] = "views/TextButton"; 83 const char TextButton::kViewClassName[] = "views/TextButton";
60 // static 84 // static
61 const char NativeTextButton::kViewClassName[] = "views/NativeTextButton"; 85 const char NativeTextButton::kViewClassName[] = "views/NativeTextButton";
62 86
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 269
246 270
247 //////////////////////////////////////////////////////////////////////////////// 271 ////////////////////////////////////////////////////////////////////////////////
248 // TextButtonBase, public: 272 // TextButtonBase, public:
249 273
250 TextButtonBase::TextButtonBase(ButtonListener* listener, const string16& text) 274 TextButtonBase::TextButtonBase(ButtonListener* listener, const string16& text)
251 : CustomButton(listener), 275 : CustomButton(listener),
252 alignment_(ALIGN_LEFT), 276 alignment_(ALIGN_LEFT),
253 font_(ResourceBundle::GetSharedInstance().GetFont( 277 font_(ResourceBundle::GetSharedInstance().GetFont(
254 ResourceBundle::BaseFont)), 278 ResourceBundle::BaseFont)),
255 color_(gfx::NativeTheme::instance()->GetSystemColor( 279 color_(kEnabledColor),
256 gfx::NativeTheme::kColorId_TextButtonEnabledColor)), 280 color_enabled_(kEnabledColor),
257 color_enabled_(gfx::NativeTheme::instance()->GetSystemColor( 281 color_disabled_(kDisabledColor),
258 gfx::NativeTheme::kColorId_TextButtonEnabledColor)), 282 color_highlight_(kHighlightColor),
259 color_disabled_(gfx::NativeTheme::instance()->GetSystemColor( 283 color_hover_(kHoverColor),
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)),
265 text_halo_color_(0), 284 text_halo_color_(0),
266 has_text_halo_(false), 285 has_text_halo_(false),
267 active_text_shadow_color_(0), 286 active_text_shadow_color_(0),
268 inactive_text_shadow_color_(0), 287 inactive_text_shadow_color_(0),
269 has_shadow_(false), 288 has_shadow_(false),
270 shadow_offset_(gfx::Point(1, 1)), 289 shadow_offset_(gfx::Point(1, 1)),
271 max_width_(0), 290 max_width_(0),
272 show_multiple_icon_states_(true), 291 show_multiple_icon_states_(true),
273 is_default_(false), 292 is_default_(false),
274 multi_line_(false), 293 multi_line_(false),
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 return flags; 462 return flags;
444 } 463 }
445 464
446 void TextButtonBase::GetExtraParams( 465 void TextButtonBase::GetExtraParams(
447 gfx::NativeTheme::ExtraParams* params) const { 466 gfx::NativeTheme::ExtraParams* params) const {
448 params->button.checked = false; 467 params->button.checked = false;
449 params->button.indeterminate = false; 468 params->button.indeterminate = false;
450 params->button.is_default = false; 469 params->button.is_default = false;
451 params->button.has_border = false; 470 params->button.has_border = false;
452 params->button.classic_state = 0; 471 params->button.classic_state = 0;
453 params->button.background_color = 472 params->button.background_color = kBackgroundColor;
454 gfx::NativeTheme::instance()->GetSystemColor(
455 gfx::NativeTheme::kColorId_TextButtonBackgroundColor);
456 } 473 }
457 474
458 gfx::Rect TextButtonBase::GetContentBounds(int extra_width) const { 475 gfx::Rect TextButtonBase::GetContentBounds(int extra_width) const {
459 gfx::Insets insets = GetInsets(); 476 gfx::Insets insets = GetInsets();
460 int available_width = width() - insets.width(); 477 int available_width = width() - insets.width();
461 int content_width = text_size_.width() + extra_width; 478 int content_width = text_size_.width() + extra_width;
462 int content_x = 0; 479 int content_x = 0;
463 switch(alignment_) { 480 switch(alignment_) {
464 case ALIGN_LEFT: 481 case ALIGN_LEFT:
465 content_x = insets.left(); 482 content_x = insets.left();
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 #endif 851 #endif
835 } 852 }
836 853
837 void NativeTextButton::GetExtraParams( 854 void NativeTextButton::GetExtraParams(
838 gfx::NativeTheme::ExtraParams* params) const { 855 gfx::NativeTheme::ExtraParams* params) const {
839 TextButton::GetExtraParams(params); 856 TextButton::GetExtraParams(params);
840 params->button.has_border = true; 857 params->button.has_border = true;
841 } 858 }
842 859
843 } // namespace views 860 } // 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