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

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

Issue 82113004: Fix key navigation to cut/copy/paste zoom button on wrench menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7
7 #include "ui/base/accessibility/accessible_view_state.h" 8 #include "ui/base/accessibility/accessible_view_state.h"
8 #include "ui/events/event.h" 9 #include "ui/events/event.h"
9 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
10 #include "ui/gfx/animation/throb_animation.h" 11 #include "ui/gfx/animation/throb_animation.h"
11 #include "ui/gfx/screen.h" 12 #include "ui/gfx/screen.h"
13 #include "ui/views/controls/button/blue_button.h"
14 #include "ui/views/controls/button/checkbox.h"
15 #include "ui/views/controls/button/image_button.h"
16 #include "ui/views/controls/button/label_button.h"
17 #include "ui/views/controls/button/menu_button.h"
18 #include "ui/views/controls/button/radio_button.h"
19 #include "ui/views/controls/button/text_button.h"
12 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
13 21
14 namespace views { 22 namespace views {
15 23
16 // How long the hover animation takes if uninterrupted. 24 // How long the hover animation takes if uninterrupted.
17 static const int kHoverFadeDurationMs = 150; 25 static const int kHoverFadeDurationMs = 150;
18 26
19 // static 27 // static
20 const char CustomButton::kViewClassName[] = "CustomButton"; 28 const char CustomButton::kViewClassName[] = "CustomButton";
21 29
22 //////////////////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////////////////
23 // CustomButton, public: 31 // CustomButton, public:
24 32
33 // static
34 const CustomButton* CustomButton::AsCustomButton(const views::View* view) {
35 return AsCustomButton(const_cast<views::View*>(view));
36 }
37
38 CustomButton* CustomButton::AsCustomButton(views::View* view) {
39 if (view) {
40 const char* classname = view->GetClassName();
41 if (!strcmp(classname, Checkbox::kViewClassName) ||
42 !strcmp(classname, CustomButton::kViewClassName) ||
43 !strcmp(classname, ImageButton::kViewClassName) ||
44 !strcmp(classname, LabelButton::kViewClassName) ||
45 !strcmp(classname, RadioButton::kViewClassName) ||
46 !strcmp(classname, MenuButton::kViewClassName) ||
47 !strcmp(classname, TextButton::kViewClassName)) {
48 return static_cast<CustomButton*>(view);
49 }
50 }
51 return NULL;
52 }
53
25 CustomButton::~CustomButton() { 54 CustomButton::~CustomButton() {
26 } 55 }
27 56
28 void CustomButton::SetState(ButtonState state) { 57 void CustomButton::SetState(ButtonState state) {
29 if (state == state_) 58 if (state == state_)
30 return; 59 return;
31 60
32 if (animate_on_state_change_ && 61 if (animate_on_state_change_ &&
33 (!is_throbbing_ || !hover_animation_->is_animating())) { 62 (!is_throbbing_ || !hover_animation_->is_animating())) {
34 is_throbbing_ = false; 63 is_throbbing_ = false;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (!details.is_add && state_ != STATE_DISABLED) 348 if (!details.is_add && state_ != STATE_DISABLED)
320 SetState(STATE_NORMAL); 349 SetState(STATE_NORMAL);
321 } 350 }
322 351
323 void CustomButton::OnBlur() { 352 void CustomButton::OnBlur() {
324 if (IsHotTracked()) 353 if (IsHotTracked())
325 SetState(STATE_NORMAL); 354 SetState(STATE_NORMAL);
326 } 355 }
327 356
328 } // namespace views 357 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698