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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "ui/gfx/animation/animation_delegate.h" | 9 #include "ui/gfx/animation/animation_delegate.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 accessibility_events_enabled_ = enabled; | 66 accessibility_events_enabled_ = enabled; |
67 } | 67 } |
68 | 68 |
69 void set_focus_border_color(SkColor color) { focus_border_color_ = color; } | 69 void set_focus_border_color(SkColor color) { focus_border_color_ = color; } |
70 | 70 |
71 // Update UI based on control on/off state. | 71 // Update UI based on control on/off state. |
72 virtual void UpdateState(bool control_on) = 0; | 72 virtual void UpdateState(bool control_on) = 0; |
73 | 73 |
74 protected: | 74 protected: |
75 explicit Slider(SliderListener* listener); | 75 explicit Slider(SliderListener* listener); |
76 virtual void SetHighlighted(bool focus); | |
bruthig
2016/09/22 21:05:24
nit: Rename |focus| param to be consistent with fu
yiyix
2016/09/23 20:35:37
Done.
| |
76 | 77 |
77 // Returns the current position of the thumb on the slider. | 78 // Returns the current position of the thumb on the slider. |
78 float GetAnimatingValue() const; | 79 float GetAnimatingValue() const; |
79 | 80 |
80 virtual int GetThumbWidth() = 0; | 81 virtual int GetThumbWidth() = 0; |
81 | 82 |
83 // gfx::AnimationDelegate: | |
84 void AnimationProgressed(const gfx::Animation* animation) override; | |
85 | |
82 // views::View: | 86 // views::View: |
83 void OnPaint(gfx::Canvas* canvas) override; | 87 void OnPaint(gfx::Canvas* canvas) override; |
88 bool OnMousePressed(const ui::MouseEvent& event) override; | |
89 void OnMouseReleased(const ui::MouseEvent& event) override; | |
84 | 90 |
85 private: | 91 private: |
86 friend class test::SliderTestApi; | 92 friend class test::SliderTestApi; |
87 | 93 |
88 void SetValueInternal(float value, SliderChangeReason reason); | 94 void SetValueInternal(float value, SliderChangeReason reason); |
89 | 95 |
90 // Should be called on the Mouse Down event. Used to calculate relative | 96 // Should be called on the Mouse Down event. Used to calculate relative |
91 // position of the mouse cursor (or the touch point) on the button to | 97 // position of the mouse cursor (or the touch point) on the button to |
92 // accurately move the button using the MoveButtonTo() method. | 98 // accurately move the button using the MoveButtonTo() method. |
93 void PrepareForMove(const int new_x); | 99 void PrepareForMove(const int new_x); |
94 | 100 |
95 // Moves the button to the specified point and updates the value accordingly. | 101 // Moves the button to the specified point and updates the value accordingly. |
96 void MoveButtonTo(const gfx::Point& point); | 102 void MoveButtonTo(const gfx::Point& point); |
97 | 103 |
98 void OnPaintFocus(gfx::Canvas* canvas); | 104 void OnPaintFocus(gfx::Canvas* canvas); |
99 | 105 |
100 // Notify the listener_, if not NULL, that dragging started. | 106 // Notify the listener_, if not NULL, that dragging started. |
101 void OnSliderDragStarted(); | 107 void OnSliderDragStarted(); |
102 | 108 |
103 // Notify the listener_, if not NULL, that dragging ended. | 109 // Notify the listener_, if not NULL, that dragging ended. |
104 void OnSliderDragEnded(); | 110 void OnSliderDragEnded(); |
105 | 111 |
106 // views::View: | 112 // views::View: |
107 const char* GetClassName() const override; | 113 const char* GetClassName() const override; |
108 gfx::Size GetPreferredSize() const override; | 114 gfx::Size GetPreferredSize() const override; |
109 bool OnMousePressed(const ui::MouseEvent& event) override; | |
110 bool OnMouseDragged(const ui::MouseEvent& event) override; | 115 bool OnMouseDragged(const ui::MouseEvent& event) override; |
111 void OnMouseReleased(const ui::MouseEvent& event) override; | |
112 bool OnKeyPressed(const ui::KeyEvent& event) override; | 116 bool OnKeyPressed(const ui::KeyEvent& event) override; |
113 void GetAccessibleState(ui::AXViewState* state) override; | 117 void GetAccessibleState(ui::AXViewState* state) override; |
114 void OnFocus() override; | 118 void OnFocus() override; |
115 void OnBlur() override; | 119 void OnBlur() override; |
116 | 120 |
117 // ui::EventHandler: | 121 // ui::EventHandler: |
118 void OnGestureEvent(ui::GestureEvent* event) override; | 122 void OnGestureEvent(ui::GestureEvent* event) override; |
119 | 123 |
120 // gfx::AnimationDelegate: | |
121 void AnimationProgressed(const gfx::Animation* animation) override; | |
122 | |
123 void set_listener(SliderListener* listener) { | 124 void set_listener(SliderListener* listener) { |
124 listener_ = listener; | 125 listener_ = listener; |
125 } | 126 } |
126 | 127 |
127 SliderListener* listener_; | 128 SliderListener* listener_; |
128 | 129 |
129 std::unique_ptr<gfx::SlideAnimation> move_animation_; | 130 std::unique_ptr<gfx::SlideAnimation> move_animation_; |
130 | 131 |
131 float value_; | 132 float value_; |
132 float keyboard_increment_; | 133 float keyboard_increment_; |
133 float animating_value_; | 134 float animating_value_; |
134 bool value_is_valid_; | 135 bool value_is_valid_; |
135 base::string16 accessible_name_; | 136 base::string16 accessible_name_; |
136 bool accessibility_events_enabled_; | 137 bool accessibility_events_enabled_; |
137 SkColor focus_border_color_; | 138 SkColor focus_border_color_; |
138 | 139 |
139 // Relative position of the mouse cursor (or the touch point) on the slider's | 140 // Relative position of the mouse cursor (or the touch point) on the slider's |
140 // button. | 141 // button. |
141 int initial_button_offset_; | 142 int initial_button_offset_; |
142 | 143 |
143 DISALLOW_COPY_AND_ASSIGN(Slider); | 144 DISALLOW_COPY_AND_ASSIGN(Slider); |
144 }; | 145 }; |
145 | 146 |
146 } // namespace views | 147 } // namespace views |
147 | 148 |
148 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ | 149 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ |
OLD | NEW |