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

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

Issue 6154001: Move animation code to new ui/base/animation directory.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | « views/controls/button/custom_button.h ('k') | views/controls/button/image_button.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/button/custom_button.h" 5 #include "views/controls/button/custom_button.h"
6 6
7 #include "app/keyboard_codes.h" 7 #include "app/keyboard_codes.h"
8 #include "app/throb_animation.h" 8 #include "ui/base/animation/throb_animation.h"
9 #include "views/screen.h" 9 #include "views/screen.h"
10 10
11 namespace views { 11 namespace views {
12 12
13 // How long the hover animation takes if uninterrupted. 13 // How long the hover animation takes if uninterrupted.
14 static const int kHoverFadeDurationMs = 150; 14 static const int kHoverFadeDurationMs = 150;
15 15
16 // static 16 // static
17 const char CustomButton::kViewClassName[] = "views/CustomButton"; 17 const char CustomButton::kViewClassName[] = "views/CustomButton";
18 18
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 //////////////////////////////////////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////////////
114 // CustomButton, protected: 114 // CustomButton, protected:
115 115
116 CustomButton::CustomButton(ButtonListener* listener) 116 CustomButton::CustomButton(ButtonListener* listener)
117 : Button(listener), 117 : Button(listener),
118 state_(BS_NORMAL), 118 state_(BS_NORMAL),
119 animate_on_state_change_(true), 119 animate_on_state_change_(true),
120 is_throbbing_(false), 120 is_throbbing_(false),
121 triggerable_event_flags_(MouseEvent::EF_LEFT_BUTTON_DOWN), 121 triggerable_event_flags_(MouseEvent::EF_LEFT_BUTTON_DOWN),
122 request_focus_on_press_(true) { 122 request_focus_on_press_(true) {
123 hover_animation_.reset(new ThrobAnimation(this)); 123 hover_animation_.reset(new ui::ThrobAnimation(this));
124 hover_animation_->SetSlideDuration(kHoverFadeDurationMs); 124 hover_animation_->SetSlideDuration(kHoverFadeDurationMs);
125 } 125 }
126 126
127 bool CustomButton::IsTriggerableEvent(const MouseEvent& e) { 127 bool CustomButton::IsTriggerableEvent(const MouseEvent& e) {
128 return (triggerable_event_flags_ & e.GetFlags()) != 0; 128 return (triggerable_event_flags_ & e.GetFlags()) != 0;
129 } 129 }
130 130
131 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
132 // CustomButton, View overrides (protected): 132 // CustomButton, View overrides (protected):
133 133
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 bool CustomButton::IsHotTracked() const { 255 bool CustomButton::IsHotTracked() const {
256 return state_ == BS_HOT; 256 return state_ == BS_HOT;
257 } 257 }
258 258
259 void CustomButton::WillLoseFocus() { 259 void CustomButton::WillLoseFocus() {
260 if (IsHotTracked()) 260 if (IsHotTracked())
261 SetState(BS_NORMAL); 261 SetState(BS_NORMAL);
262 } 262 }
263 263
264 //////////////////////////////////////////////////////////////////////////////// 264 ////////////////////////////////////////////////////////////////////////////////
265 // CustomButton, AnimationDelegate implementation: 265 // CustomButton, ui::AnimationDelegate implementation:
266 266
267 void CustomButton::AnimationProgressed(const Animation* animation) { 267 void CustomButton::AnimationProgressed(const ui::Animation* animation) {
268 SchedulePaint(); 268 SchedulePaint();
269 } 269 }
270 270
271 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) { 271 bool CustomButton::ShouldEnterPushedState(const MouseEvent& e) {
272 return IsTriggerableEvent(e); 272 return IsTriggerableEvent(e);
273 } 273 }
274 274
275 } // namespace views 275 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/button/custom_button.h ('k') | views/controls/button/image_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698