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

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

Issue 15061006: views: Switch Checkbox over to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SetCustomImage() Created 7 years, 7 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
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 size.set_width(std::min(max_size_.width(), size.width())); 187 size.set_width(std::min(max_size_.width(), size.width()));
188 if (max_size_.height() > 0) 188 if (max_size_.height() > 0)
189 size.set_height(std::min(max_size_.height(), size.height())); 189 size.set_height(std::min(max_size_.height(), size.height()));
190 return size; 190 return size;
191 } 191 }
192 192
193 const char* LabelButton::GetClassName() const { 193 const char* LabelButton::GetClassName() const {
194 return kViewClassName; 194 return kViewClassName;
195 } 195 }
196 196
197 void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
198 params->button.checked = false;
199 params->button.indeterminate = false;
200 params->button.is_default = is_default_;
201 params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
202 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
203 params->button.classic_state = 0;
204 params->button.background_color = GetNativeTheme()->GetSystemColor(
205 ui::NativeTheme::kColorId_ButtonBackgroundColor);
206 }
207
197 void LabelButton::ResetColorsFromNativeTheme() { 208 void LabelButton::ResetColorsFromNativeTheme() {
198 const ui::NativeTheme* theme = GetNativeTheme(); 209 const ui::NativeTheme* theme = GetNativeTheme();
199 SkColor colors[STATE_COUNT] = { 210 SkColor colors[STATE_COUNT] = {
200 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor), 211 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor),
201 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), 212 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor),
202 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), 213 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor),
203 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor), 214 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor),
204 }; 215 };
205 216
206 // Certain styles do not change text color when hovered or pressed. 217 // Certain styles do not change text color when hovered or pressed.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return ui::NativeTheme::kPushButton; 296 return ui::NativeTheme::kPushButton;
286 } 297 }
287 298
288 gfx::Rect LabelButton::GetThemePaintRect() const { 299 gfx::Rect LabelButton::GetThemePaintRect() const {
289 return GetLocalBounds(); 300 return GetLocalBounds();
290 } 301 }
291 302
292 ui::NativeTheme::State LabelButton::GetThemeState( 303 ui::NativeTheme::State LabelButton::GetThemeState(
293 ui::NativeTheme::ExtraParams* params) const { 304 ui::NativeTheme::ExtraParams* params) const {
294 GetExtraParams(params); 305 GetExtraParams(params);
295 switch(state()) { 306 switch (state()) {
296 case STATE_NORMAL: return ui::NativeTheme::kNormal; 307 case STATE_NORMAL: return ui::NativeTheme::kNormal;
297 case STATE_HOVERED: return ui::NativeTheme::kHovered; 308 case STATE_HOVERED: return ui::NativeTheme::kHovered;
298 case STATE_PRESSED: return ui::NativeTheme::kPressed; 309 case STATE_PRESSED: return ui::NativeTheme::kPressed;
299 case STATE_DISABLED: return ui::NativeTheme::kDisabled; 310 case STATE_DISABLED: return ui::NativeTheme::kDisabled;
300 case STATE_COUNT: NOTREACHED() << "Unknown state: " << state(); 311 case STATE_COUNT: NOTREACHED() << "Unknown state: " << state();
301 } 312 }
302 return ui::NativeTheme::kNormal; 313 return ui::NativeTheme::kNormal;
303 } 314 }
304 315
305 const ui::Animation* LabelButton::GetThemeAnimation() const { 316 const ui::Animation* LabelButton::GetThemeAnimation() const {
(...skipping 12 matching lines...) Expand all
318 GetExtraParams(params); 329 GetExtraParams(params);
319 return ui::NativeTheme::kNormal; 330 return ui::NativeTheme::kNormal;
320 } 331 }
321 332
322 ui::NativeTheme::State LabelButton::GetForegroundThemeState( 333 ui::NativeTheme::State LabelButton::GetForegroundThemeState(
323 ui::NativeTheme::ExtraParams* params) const { 334 ui::NativeTheme::ExtraParams* params) const {
324 GetExtraParams(params); 335 GetExtraParams(params);
325 return ui::NativeTheme::kHovered; 336 return ui::NativeTheme::kHovered;
326 } 337 }
327 338
328 void LabelButton::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
329 params->button.checked = false;
330 params->button.indeterminate = false;
331 params->button.is_default = is_default_;
332 params->button.is_focused = HasFocus() && IsAccessibilityFocusable();
333 params->button.has_border = style() == STYLE_NATIVE_TEXTBUTTON;
334 params->button.classic_state = 0;
335 params->button.background_color = GetNativeTheme()->GetSystemColor(
336 ui::NativeTheme::kColorId_ButtonBackgroundColor);
337 }
338
339 } // namespace views 339 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698