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

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

Issue 13639003: Make LabelButton STYLE_NATIVE_TEXTBUTTON focusable; etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment. 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 | ui/views/focus/focus_manager_unittest_win.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/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"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE); 116 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE);
117 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel); 117 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel);
118 } 118 }
119 119
120 void LabelButton::SetStyle(ButtonStyle style) { 120 void LabelButton::SetStyle(ButtonStyle style) {
121 style_ = style; 121 style_ = style;
122 set_border(new LabelButtonBorder(style)); 122 set_border(new LabelButtonBorder(style));
123 // Inset the button focus rect from the actual border; roughly match Windows. 123 // Inset the button focus rect from the actual border; roughly match Windows.
124 if (style == STYLE_TEXTBUTTON || style == STYLE_NATIVE_TEXTBUTTON) 124 if (style == STYLE_TEXTBUTTON || style == STYLE_NATIVE_TEXTBUTTON)
125 set_focus_border(FocusBorder::CreateDashedFocusBorder(3, 3, 3, 3)); 125 set_focus_border(FocusBorder::CreateDashedFocusBorder(3, 3, 3, 3));
126 if (style == STYLE_BUTTON || style_ == STYLE_NATIVE_TEXTBUTTON) 126 if (style == STYLE_BUTTON || style == STYLE_NATIVE_TEXTBUTTON)
127 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 127 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
128 if (style == STYLE_NATIVE_TEXTBUTTON)
129 set_focusable(true);
128 if (style == STYLE_BUTTON) { 130 if (style == STYLE_BUTTON) {
129 set_min_size(gfx::Size(70, 31)); 131 set_min_size(gfx::Size(70, 31));
130 const SkColor color = GetNativeTheme()->GetSystemColor( 132 const SkColor color = GetNativeTheme()->GetSystemColor(
131 ui::NativeTheme::kColorId_WindowBackground); 133 ui::NativeTheme::kColorId_WindowBackground);
132 label_->SetShadowColors(color, color); 134 label_->SetShadowColors(color, color);
133 label_->SetShadowOffset(0, 1); 135 label_->SetShadowOffset(0, 1);
134 } 136 }
135 // Invalidate the layout to pickup the new insets from the border. 137 // Invalidate the layout to pickup the new insets from the border.
136 InvalidateLayout(); 138 InvalidateLayout();
137 ResetColorsFromNativeTheme(); 139 ResetColorsFromNativeTheme();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 params->button.indeterminate = false; 307 params->button.indeterminate = false;
306 params->button.is_default = is_default_; 308 params->button.is_default = is_default_;
307 params->button.is_focused = HasFocus() && IsAccessibilityFocusable(); 309 params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
308 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON; 310 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
309 params->button.classic_state = 0; 311 params->button.classic_state = 0;
310 params->button.background_color = GetNativeTheme()->GetSystemColor( 312 params->button.background_color = GetNativeTheme()->GetSystemColor(
311 ui::NativeTheme::kColorId_TextButtonBackgroundColor); 313 ui::NativeTheme::kColorId_TextButtonBackgroundColor);
312 } 314 }
313 315
314 } // namespace views 316 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/focus/focus_manager_unittest_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698