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

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

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 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 | « ui/views/controls/button/custom_button.h ('k') | ui/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) 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/base/accessibility/accessible_view_state.h" 7 #include "ui/base/accessibility/accessible_view_state.h"
8 #include "ui/base/animation/throb_animation.h"
9 #include "ui/base/events/event.h" 8 #include "ui/base/events/event.h"
10 #include "ui/base/keycodes/keyboard_codes.h" 9 #include "ui/base/keycodes/keyboard_codes.h"
10 #include "ui/gfx/animation/throb_animation.h"
11 #include "ui/gfx/screen.h" 11 #include "ui/gfx/screen.h"
12 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
13 13
14 namespace views { 14 namespace views {
15 15
16 // How long the hover animation takes if uninterrupted. 16 // How long the hover animation takes if uninterrupted.
17 static const int kHoverFadeDurationMs = 150; 17 static const int kHoverFadeDurationMs = 150;
18 18
19 // static 19 // static
20 const char CustomButton::kViewClassName[] = "CustomButton"; 20 const char CustomButton::kViewClassName[] = "CustomButton";
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 } 271 }
272 272
273 void CustomButton::VisibilityChanged(View* starting_from, bool visible) { 273 void CustomButton::VisibilityChanged(View* starting_from, bool visible) {
274 if (state_ == STATE_DISABLED) 274 if (state_ == STATE_DISABLED)
275 return; 275 return;
276 SetState(visible && IsMouseHovered() ? STATE_HOVERED : STATE_NORMAL); 276 SetState(visible && IsMouseHovered() ? STATE_HOVERED : STATE_NORMAL);
277 } 277 }
278 278
279 //////////////////////////////////////////////////////////////////////////////// 279 ////////////////////////////////////////////////////////////////////////////////
280 // CustomButton, ui::AnimationDelegate implementation: 280 // CustomButton, gfx::AnimationDelegate implementation:
281 281
282 void CustomButton::AnimationProgressed(const ui::Animation* animation) { 282 void CustomButton::AnimationProgressed(const gfx::Animation* animation) {
283 SchedulePaint(); 283 SchedulePaint();
284 } 284 }
285 285
286 //////////////////////////////////////////////////////////////////////////////// 286 ////////////////////////////////////////////////////////////////////////////////
287 // CustomButton, protected: 287 // CustomButton, protected:
288 288
289 CustomButton::CustomButton(ButtonListener* listener) 289 CustomButton::CustomButton(ButtonListener* listener)
290 : Button(listener), 290 : Button(listener),
291 state_(STATE_NORMAL), 291 state_(STATE_NORMAL),
292 animate_on_state_change_(true), 292 animate_on_state_change_(true),
293 is_throbbing_(false), 293 is_throbbing_(false),
294 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON), 294 triggerable_event_flags_(ui::EF_LEFT_MOUSE_BUTTON),
295 request_focus_on_press_(true) { 295 request_focus_on_press_(true) {
296 hover_animation_.reset(new ui::ThrobAnimation(this)); 296 hover_animation_.reset(new gfx::ThrobAnimation(this));
297 hover_animation_->SetSlideDuration(kHoverFadeDurationMs); 297 hover_animation_->SetSlideDuration(kHoverFadeDurationMs);
298 } 298 }
299 299
300 void CustomButton::StateChanged() { 300 void CustomButton::StateChanged() {
301 } 301 }
302 302
303 bool CustomButton::IsTriggerableEvent(const ui::Event& event) { 303 bool CustomButton::IsTriggerableEvent(const ui::Event& event) {
304 return event.type() == ui::ET_GESTURE_TAP_DOWN || 304 return event.type() == ui::ET_GESTURE_TAP_DOWN ||
305 event.type() == ui::ET_GESTURE_TAP || 305 event.type() == ui::ET_GESTURE_TAP ||
306 (event.IsMouseEvent() && 306 (event.IsMouseEvent() &&
(...skipping 12 matching lines...) Expand all
319 if (!details.is_add && state_ != STATE_DISABLED) 319 if (!details.is_add && state_ != STATE_DISABLED)
320 SetState(STATE_NORMAL); 320 SetState(STATE_NORMAL);
321 } 321 }
322 322
323 void CustomButton::OnBlur() { 323 void CustomButton::OnBlur() {
324 if (IsHotTracked()) 324 if (IsHotTracked())
325 SetState(STATE_NORMAL); 325 SetState(STATE_NORMAL);
326 } 326 }
327 327
328 } // namespace views 328 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.h ('k') | ui/views/controls/button/image_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698