OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
15 #include "third_party/skia/include/core/SkPaint.h" | 15 #include "third_party/skia/include/core/SkPaint.h" |
16 #include "ui/accessibility/ax_view_state.h" | 16 #include "ui/accessibility/ax_view_state.h" |
17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
19 #include "ui/gfx/animation/slide_animation.h" | 19 #include "ui/gfx/animation/slide_animation.h" |
20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/geometry/point.h" | 21 #include "ui/gfx/geometry/point.h" |
22 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
23 #include "ui/resources/grit/ui_resources.h" | 23 #include "ui/resources/grit/ui_resources.h" |
24 #include "ui/views/resources/grit/views_resources.h" | 24 #include "ui/views/resources/grit/views_resources.h" |
| 25 #include "ui/views/style/platform_style.h" |
25 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 const int kSlideValueChangeDurationMS = 150; | 29 const int kSlideValueChangeDurationMS = 150; |
29 | 30 |
30 const int kBarImagesActive[] = { | 31 const int kBarImagesActive[] = { |
31 IDR_SLIDER_ACTIVE_LEFT, | 32 IDR_SLIDER_ACTIVE_LEFT, |
32 IDR_SLIDER_ACTIVE_CENTER, | 33 IDR_SLIDER_ACTIVE_CENTER, |
33 IDR_SLIDER_PRESSED_CENTER, | 34 IDR_SLIDER_PRESSED_CENTER, |
34 IDR_SLIDER_PRESSED_RIGHT, | 35 IDR_SLIDER_PRESSED_RIGHT, |
(...skipping 25 matching lines...) Expand all Loading... |
60 orientation_(orientation), | 61 orientation_(orientation), |
61 value_(0.f), | 62 value_(0.f), |
62 keyboard_increment_(0.1f), | 63 keyboard_increment_(0.1f), |
63 animating_value_(0.f), | 64 animating_value_(0.f), |
64 value_is_valid_(false), | 65 value_is_valid_(false), |
65 accessibility_events_enabled_(true), | 66 accessibility_events_enabled_(true), |
66 focus_border_color_(0), | 67 focus_border_color_(0), |
67 bar_active_images_(kBarImagesActive), | 68 bar_active_images_(kBarImagesActive), |
68 bar_disabled_images_(kBarImagesDisabled) { | 69 bar_disabled_images_(kBarImagesDisabled) { |
69 EnableCanvasFlippingForRTLUI(true); | 70 EnableCanvasFlippingForRTLUI(true); |
70 SetFocusable(true); | 71 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::SLIDER, this); |
71 UpdateState(true); | 72 UpdateState(true); |
72 } | 73 } |
73 | 74 |
74 Slider::~Slider() { | 75 Slider::~Slider() { |
75 } | 76 } |
76 | 77 |
77 void Slider::SetValue(float value) { | 78 void Slider::SetValue(float value) { |
78 SetValueInternal(value, VALUE_CHANGED_BY_API); | 79 SetValueInternal(value, VALUE_CHANGED_BY_API); |
79 } | 80 } |
80 | 81 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if (listener_) | 364 if (listener_) |
364 listener_->SliderDragStarted(this); | 365 listener_->SliderDragStarted(this); |
365 } | 366 } |
366 | 367 |
367 void Slider::OnSliderDragEnded() { | 368 void Slider::OnSliderDragEnded() { |
368 if (listener_) | 369 if (listener_) |
369 listener_->SliderDragEnded(this); | 370 listener_->SliderDragEnded(this); |
370 } | 371 } |
371 | 372 |
372 } // namespace views | 373 } // namespace views |
OLD | NEW |