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 #ifndef UI_VIEWS_CONTROLS_SLIDER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_SLIDER_H_ |
6 #define UI_VIEWS_CONTROLS_SLIDER_H_ | 6 #define UI_VIEWS_CONTROLS_SLIDER_H_ |
7 | 7 |
8 #include "ui/base/animation/animation_delegate.h" | 8 #include "ui/gfx/animation/animation_delegate.h" |
9 #include "ui/views/view.h" | 9 #include "ui/views/view.h" |
10 #include "ui/views/views_export.h" | 10 #include "ui/views/views_export.h" |
11 | 11 |
12 typedef unsigned int SkColor; | 12 typedef unsigned int SkColor; |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 class ImageSkia; | 15 class ImageSkia; |
16 } | |
17 | |
18 namespace ui { | |
19 class SlideAnimation; | 16 class SlideAnimation; |
20 } | 17 } |
21 | 18 |
22 namespace views { | 19 namespace views { |
23 | 20 |
24 class Slider; | 21 class Slider; |
25 | 22 |
26 enum SliderChangeReason { | 23 enum SliderChangeReason { |
27 VALUE_CHANGED_BY_USER, // value was changed by the user (by clicking, e.g.) | 24 VALUE_CHANGED_BY_USER, // value was changed by the user (by clicking, e.g.) |
28 VALUE_CHANGED_BY_API, // value was changed by a call to SetValue. | 25 VALUE_CHANGED_BY_API, // value was changed by a call to SetValue. |
29 }; | 26 }; |
30 | 27 |
31 class VIEWS_EXPORT SliderListener { | 28 class VIEWS_EXPORT SliderListener { |
32 public: | 29 public: |
33 virtual void SliderValueChanged(Slider* sender, | 30 virtual void SliderValueChanged(Slider* sender, |
34 float value, | 31 float value, |
35 float old_value, | 32 float old_value, |
36 SliderChangeReason reason) = 0; | 33 SliderChangeReason reason) = 0; |
37 | 34 |
38 // Invoked when a drag starts or ends (more specifically, when the mouse | 35 // Invoked when a drag starts or ends (more specifically, when the mouse |
39 // button is pressed or released). | 36 // button is pressed or released). |
40 virtual void SliderDragStarted(Slider* sender) {} | 37 virtual void SliderDragStarted(Slider* sender) {} |
41 virtual void SliderDragEnded(Slider* sender) {} | 38 virtual void SliderDragEnded(Slider* sender) {} |
42 | 39 |
43 protected: | 40 protected: |
44 virtual ~SliderListener() {} | 41 virtual ~SliderListener() {} |
45 }; | 42 }; |
46 | 43 |
47 class VIEWS_EXPORT Slider : public View, | 44 class VIEWS_EXPORT Slider : public View, |
48 public ui::AnimationDelegate { | 45 public gfx::AnimationDelegate { |
49 public: | 46 public: |
50 enum Orientation { | 47 enum Orientation { |
51 HORIZONTAL, | 48 HORIZONTAL, |
52 VERTICAL | 49 VERTICAL |
53 }; | 50 }; |
54 | 51 |
55 Slider(SliderListener* listener, Orientation orientation); | 52 Slider(SliderListener* listener, Orientation orientation); |
56 virtual ~Slider(); | 53 virtual ~Slider(); |
57 | 54 |
58 float value() const { return value_; } | 55 float value() const { return value_; } |
(...skipping 30 matching lines...) Expand all Loading... |
89 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 86 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
90 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 87 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
91 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 88 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
92 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 89 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
93 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 90 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
94 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | 91 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; |
95 | 92 |
96 // ui::EventHandler overrides: | 93 // ui::EventHandler overrides: |
97 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 94 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
98 | 95 |
99 // ui::AnimationDelegate overrides: | 96 // gfx::AnimationDelegate overrides: |
100 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 97 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
101 | 98 |
102 SliderListener* listener_; | 99 SliderListener* listener_; |
103 Orientation orientation_; | 100 Orientation orientation_; |
104 | 101 |
105 scoped_ptr<ui::SlideAnimation> move_animation_; | 102 scoped_ptr<gfx::SlideAnimation> move_animation_; |
106 | 103 |
107 float value_; | 104 float value_; |
108 float keyboard_increment_; | 105 float keyboard_increment_; |
109 float animating_value_; | 106 float animating_value_; |
110 bool value_is_valid_; | 107 bool value_is_valid_; |
111 string16 accessible_name_; | 108 string16 accessible_name_; |
112 bool accessibility_events_enabled_; | 109 bool accessibility_events_enabled_; |
113 SkColor focus_border_color_; | 110 SkColor focus_border_color_; |
114 | 111 |
115 // Relative position of the mouse cursor (or the touch point) on the slider's | 112 // Relative position of the mouse cursor (or the touch point) on the slider's |
116 // button. | 113 // button. |
117 gfx::Point initial_button_offset_; | 114 gfx::Point initial_button_offset_; |
118 | 115 |
119 const int* bar_active_images_; | 116 const int* bar_active_images_; |
120 const int* bar_disabled_images_; | 117 const int* bar_disabled_images_; |
121 const gfx::ImageSkia* thumb_; | 118 const gfx::ImageSkia* thumb_; |
122 const gfx::ImageSkia* images_[4]; | 119 const gfx::ImageSkia* images_[4]; |
123 int bar_height_; | 120 int bar_height_; |
124 | 121 |
125 DISALLOW_COPY_AND_ASSIGN(Slider); | 122 DISALLOW_COPY_AND_ASSIGN(Slider); |
126 }; | 123 }; |
127 | 124 |
128 } // namespace views | 125 } // namespace views |
129 | 126 |
130 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ | 127 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ |
OLD | NEW |