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

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

Issue 2680643002: Add old_state parameter to CustomButton::StateChanged (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/label_button.h » ('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/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "ui/accessibility/ax_node_data.h" 7 #include "ui/accessibility/ax_node_data.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/event_utils.h" 9 #include "ui/events/event_utils.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 hover_animation_.Reset(); 93 hover_animation_.Reset();
94 } else if (state_ == STATE_NORMAL) { 94 } else if (state_ == STATE_NORMAL) {
95 // For NORMAL -> HOVERED, animate from not hovered (0) to hovered (1). 95 // For NORMAL -> HOVERED, animate from not hovered (0) to hovered (1).
96 hover_animation_.Show(); 96 hover_animation_.Show();
97 } else { 97 } else {
98 // For PRESSED/DISABLED -> HOVERED, simply set the state to hovered (1). 98 // For PRESSED/DISABLED -> HOVERED, simply set the state to hovered (1).
99 hover_animation_.Reset(1); 99 hover_animation_.Reset(1);
100 } 100 }
101 } 101 }
102 102
103 ButtonState old_state = state_;
103 state_ = state; 104 state_ = state;
104 StateChanged(); 105 StateChanged(old_state);
105 SchedulePaint(); 106 SchedulePaint();
106 } 107 }
107 108
108 void CustomButton::StartThrobbing(int cycles_til_stop) { 109 void CustomButton::StartThrobbing(int cycles_til_stop) {
109 if (!animate_on_state_change_) 110 if (!animate_on_state_change_)
110 return; 111 return;
111 is_throbbing_ = true; 112 is_throbbing_ = true;
112 hover_animation_.StartThrobbing(cycles_til_stop); 113 hover_animation_.StartThrobbing(cycles_til_stop);
113 } 114 }
114 115
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 is_throbbing_(false), 431 is_throbbing_(false),
431 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), 432 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON),
432 request_focus_on_press_(false), 433 request_focus_on_press_(false),
433 notify_action_(NOTIFY_ON_RELEASE), 434 notify_action_(NOTIFY_ON_RELEASE),
434 has_ink_drop_action_on_click_(false), 435 has_ink_drop_action_on_click_(false),
435 hide_ink_drop_when_showing_context_menu_(true), 436 hide_ink_drop_when_showing_context_menu_(true),
436 ink_drop_base_color_(gfx::kPlaceholderColor) { 437 ink_drop_base_color_(gfx::kPlaceholderColor) {
437 hover_animation_.SetSlideDuration(kHoverFadeDurationMs); 438 hover_animation_.SetSlideDuration(kHoverFadeDurationMs);
438 } 439 }
439 440
440 void CustomButton::StateChanged() { 441 void CustomButton::StateChanged(ButtonState old_state) {}
441 }
442 442
443 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { 443 bool CustomButton::IsTriggerableEvent(const ui::Event& event) {
444 return event.type() == ui::ET_GESTURE_TAP_DOWN || 444 return event.type() == ui::ET_GESTURE_TAP_DOWN ||
445 event.type() == ui::ET_GESTURE_TAP || 445 event.type() == ui::ET_GESTURE_TAP ||
446 (event.IsMouseEvent() && 446 (event.IsMouseEvent() &&
447 (triggerable_event_flags_ & event.flags()) != 0); 447 (triggerable_event_flags_ & event.flags()) != 0);
448 } 448 }
449 449
450 bool CustomButton::ShouldEnterPushedState(const ui::Event& event) { 450 bool CustomButton::ShouldEnterPushedState(const ui::Event& event) {
451 return IsTriggerableEvent(event); 451 return IsTriggerableEvent(event);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 views::InkDropState::ACTION_PENDING || 491 views::InkDropState::ACTION_PENDING ||
492 GetInkDrop()->GetTargetInkDropState() == 492 GetInkDrop()->GetTargetInkDropState() ==
493 views::InkDropState::ALTERNATE_ACTION_PENDING) { 493 views::InkDropState::ALTERNATE_ACTION_PENDING) {
494 AnimateInkDrop(views::InkDropState::HIDDEN, 494 AnimateInkDrop(views::InkDropState::HIDDEN,
495 ui::LocatedEvent::FromIfValid(&event)); 495 ui::LocatedEvent::FromIfValid(&event));
496 } 496 }
497 Button::OnClickCanceled(event); 497 Button::OnClickCanceled(event);
498 } 498 }
499 499
500 } // namespace views 500 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/label_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698