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

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

Issue 14118013: Restrict the new button style to the new dialog style flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | no next file » | 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/animation/throb_animation.h" 9 #include "ui/base/animation/throb_animation.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/native_theme/native_theme.h" 11 #include "ui/native_theme/native_theme.h"
12 #include "ui/views/controls/button/label_button_border.h" 12 #include "ui/views/controls/button/label_button_border.h"
13 #include "ui/views/focus_border.h" 13 #include "ui/views/focus_border.h"
14 #include "ui/views/window/dialog_delegate.h"
14 15
15 #if defined(OS_WIN) 16 #if defined(OS_WIN)
16 #include "ui/gfx/color_utils.h" 17 #include "ui/gfx/color_utils.h"
17 #include "ui/native_theme/native_theme_win.h" 18 #include "ui/native_theme/native_theme_win.h"
18 #endif 19 #endif
19 20
20 namespace { 21 namespace {
21 22
22 // The spacing between the icon and text. 23 // The spacing between the icon and text.
23 const int kSpacing = 5; 24 const int kSpacing = 5;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 if (style_ == STYLE_BUTTON) { 126 if (style_ == STYLE_BUTTON) {
126 int style = label_->font().GetStyle(); 127 int style = label_->font().GetStyle();
127 style = is_default ? style | gfx::Font::BOLD : style & !gfx::Font::BOLD; 128 style = is_default ? style | gfx::Font::BOLD : style & !gfx::Font::BOLD;
128 label_->SetFont(label_->font().DeriveFont(0, style)); 129 label_->SetFont(label_->font().DeriveFont(0, style));
129 } 130 }
130 } 131 }
131 132
132 void LabelButton::SetStyle(ButtonStyle style) { 133 void LabelButton::SetStyle(ButtonStyle style) {
133 // Use the new button style instead of the native button style. 134 // Use the new button style instead of the native button style.
134 // TODO(msw): Officialy deprecate and remove STYLE_NATIVE_TEXTBUTTON. 135 // TODO(msw): Officialy deprecate and remove STYLE_NATIVE_TEXTBUTTON.
135 if (style == STYLE_NATIVE_TEXTBUTTON) 136 if (DialogDelegate::UseNewStyle() && style == STYLE_NATIVE_TEXTBUTTON)
136 style = STYLE_BUTTON; 137 style = STYLE_BUTTON;
137 138
138 style_ = style; 139 style_ = style;
139 set_border(new LabelButtonBorder(style)); 140 set_border(new LabelButtonBorder(style));
140 // Inset the button focus rect from the actual border; roughly match Windows. 141 // Inset the button focus rect from the actual border; roughly match Windows.
141 if (style == STYLE_TEXTBUTTON || style == STYLE_NATIVE_TEXTBUTTON) 142 if (style == STYLE_TEXTBUTTON || style == STYLE_NATIVE_TEXTBUTTON)
142 set_focus_border(FocusBorder::CreateDashedFocusBorder(3, 3, 3, 3)); 143 set_focus_border(FocusBorder::CreateDashedFocusBorder(3, 3, 3, 3));
143 if (style == STYLE_BUTTON || style == STYLE_NATIVE_TEXTBUTTON) { 144 if (style == STYLE_BUTTON || style == STYLE_NATIVE_TEXTBUTTON) {
144 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 145 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
145 set_focusable(true); 146 set_focusable(true);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 params->button.indeterminate = false; 334 params->button.indeterminate = false;
334 params->button.is_default = is_default_; 335 params->button.is_default = is_default_;
335 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); 336 params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
336 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; 337 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
337 params->button.classic_state = 0; 338 params->button.classic_state = 0;
338 params->button.background_color = GetNativeTheme()->GetSystemColor( 339 params->button.background_color = GetNativeTheme()->GetSystemColor(
339 ui::NativeTheme::kColorId_TextButtonBackgroundColor); 340 ui::NativeTheme::kColorId_TextButtonBackgroundColor);
340 } 341 }
341 342
342 } // namespace views 343 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698