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

Side by Side Diff: ui/views/controls/slider.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/slider.h ('k') | ui/views/corewm/window_animations.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/slider.h" 5 #include "ui/views/controls/slider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "grit/ui_resources.h" 11 #include "grit/ui_resources.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
14 #include "third_party/skia/include/core/SkPaint.h" 14 #include "third_party/skia/include/core/SkPaint.h"
15 #include "ui/base/accessibility/accessible_view_state.h" 15 #include "ui/base/accessibility/accessible_view_state.h"
16 #include "ui/base/animation/slide_animation.h"
17 #include "ui/base/events/event.h" 16 #include "ui/base/events/event.h"
18 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/animation/slide_animation.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/point.h" 20 #include "ui/gfx/point.h"
21 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
22 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
23 23
24 namespace { 24 namespace {
25 const int kSlideValueChangeDurationMS = 150; 25 const int kSlideValueChangeDurationMS = 150;
26 26
27 const int kBarImagesActive[] = { 27 const int kBarImagesActive[] = {
28 IDR_SLIDER_ACTIVE_LEFT, 28 IDR_SLIDER_ACTIVE_LEFT,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return; 88 return;
89 float old_value = value_; 89 float old_value = value_;
90 value_ = value; 90 value_ = value;
91 if (listener_) 91 if (listener_)
92 listener_->SliderValueChanged(this, value_, old_value, reason); 92 listener_->SliderValueChanged(this, value_, old_value, reason);
93 93
94 if (old_value_valid && base::MessageLoop::current()) { 94 if (old_value_valid && base::MessageLoop::current()) {
95 // Do not animate when setting the value of the slider for the first time. 95 // Do not animate when setting the value of the slider for the first time.
96 // There is no message-loop when running tests. So we cannot animate then. 96 // There is no message-loop when running tests. So we cannot animate then.
97 animating_value_ = old_value; 97 animating_value_ = old_value;
98 move_animation_.reset(new ui::SlideAnimation(this)); 98 move_animation_.reset(new gfx::SlideAnimation(this));
99 move_animation_->SetSlideDuration(kSlideValueChangeDurationMS); 99 move_animation_->SetSlideDuration(kSlideValueChangeDurationMS);
100 move_animation_->Show(); 100 move_animation_->Show();
101 AnimationProgressed(move_animation_.get()); 101 AnimationProgressed(move_animation_.get());
102 } else { 102 } else {
103 SchedulePaint(); 103 SchedulePaint();
104 } 104 }
105 if (accessibility_events_enabled_ && GetWidget()) { 105 if (accessibility_events_enabled_ && GetWidget()) {
106 NotifyAccessibilityEvent( 106 NotifyAccessibilityEvent(
107 ui::AccessibilityTypes::EVENT_VALUE_CHANGED, true); 107 ui::AccessibilityTypes::EVENT_VALUE_CHANGED, true);
108 } 108 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 PrepareForMove(event->location()); 297 PrepareForMove(event->location());
298 MoveButtonTo(event->location()); 298 MoveButtonTo(event->location());
299 event->SetHandled(); 299 event->SetHandled();
300 } else if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || 300 } else if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
301 event->type() == ui::ET_GESTURE_SCROLL_END) { 301 event->type() == ui::ET_GESTURE_SCROLL_END) {
302 MoveButtonTo(event->location()); 302 MoveButtonTo(event->location());
303 event->SetHandled(); 303 event->SetHandled();
304 } 304 }
305 } 305 }
306 306
307 void Slider::AnimationProgressed(const ui::Animation* animation) { 307 void Slider::AnimationProgressed(const gfx::Animation* animation) {
308 animating_value_ = animation->CurrentValueBetween(animating_value_, value_); 308 animating_value_ = animation->CurrentValueBetween(animating_value_, value_);
309 SchedulePaint(); 309 SchedulePaint();
310 } 310 }
311 311
312 void Slider::GetAccessibleState(ui::AccessibleViewState* state) { 312 void Slider::GetAccessibleState(ui::AccessibleViewState* state) {
313 state->role = ui::AccessibilityTypes::ROLE_SLIDER; 313 state->role = ui::AccessibilityTypes::ROLE_SLIDER;
314 state->name = accessible_name_; 314 state->name = accessible_name_;
315 state->value = UTF8ToUTF16( 315 state->value = UTF8ToUTF16(
316 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5))); 316 base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5)));
317 } 317 }
318 318
319 void Slider::OnPaintFocusBorder(gfx::Canvas* canvas) { 319 void Slider::OnPaintFocusBorder(gfx::Canvas* canvas) {
320 if (!focus_border_color_) { 320 if (!focus_border_color_) {
321 View::OnPaintFocusBorder(canvas); 321 View::OnPaintFocusBorder(canvas);
322 } else if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { 322 } else if (HasFocus() && (focusable() || IsAccessibilityFocusable())) {
323 canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3), 323 canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3),
324 focus_border_color_); 324 focus_border_color_);
325 } 325 }
326 } 326 }
327 327
328 } // namespace views 328 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/slider.h ('k') | ui/views/corewm/window_animations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698