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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 void set_enable_accessibility_events(bool enabled) { | 65 void set_enable_accessibility_events(bool enabled) { |
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 virtual void SetFocus(bool focus){}; | |
bruthig
2016/09/21 00:27:46
The 'focus' concept is already defined on View and
bruthig
2016/09/21 00:27:46
Move definition to .cc file.
yiyix
2016/09/21 15:20:52
Done.
| |
76 bool OnMousePressed(const ui::MouseEvent& event) override; | |
77 void OnMouseReleased(const ui::MouseEvent& event) override; | |
bruthig
2016/09/21 00:27:46
OnMousePressed() and OnMouseReleased() should be g
yiyix
2016/09/21 15:20:52
Done.
| |
78 | |
79 protected: | |
bruthig
2016/09/21 00:27:46
nit: Remove, protected is already declared on line
yiyix
2016/09/21 15:20:52
Sorry again, It is not a fully finish version when
| |
75 explicit Slider(SliderListener* listener); | 80 explicit Slider(SliderListener* listener); |
bruthig
2016/09/21 00:27:46
Style guide specifies constructors should be decla
yiyix
2016/09/21 15:20:53
Done.
| |
76 | 81 |
77 // Returns the current position of the thumb on the slider. | 82 // Returns the current position of the thumb on the slider. |
78 float GetAnimatingValue() const; | 83 float GetAnimatingValue() const; |
79 | 84 |
80 virtual int GetThumbWidth() = 0; | 85 virtual int GetThumbWidth() = 0; |
81 | 86 |
87 // gfx::AnimationDelegate: | |
88 void AnimationProgressed(const gfx::Animation* animation) override; | |
89 | |
82 // views::View: | 90 // views::View: |
83 void OnPaint(gfx::Canvas* canvas) override; | 91 void OnPaint(gfx::Canvas* canvas) override; |
84 | 92 |
85 private: | 93 private: |
86 friend class test::SliderTestApi; | 94 friend class test::SliderTestApi; |
87 | 95 |
88 void SetValueInternal(float value, SliderChangeReason reason); | 96 void SetValueInternal(float value, SliderChangeReason reason); |
89 | 97 |
90 // Should be called on the Mouse Down event. Used to calculate relative | 98 // 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 | 99 // position of the mouse cursor (or the touch point) on the button to |
92 // accurately move the button using the MoveButtonTo() method. | 100 // accurately move the button using the MoveButtonTo() method. |
93 void PrepareForMove(const int new_x); | 101 void PrepareForMove(const int new_x); |
94 | 102 |
95 // Moves the button to the specified point and updates the value accordingly. | 103 // Moves the button to the specified point and updates the value accordingly. |
96 void MoveButtonTo(const gfx::Point& point); | 104 void MoveButtonTo(const gfx::Point& point); |
97 | 105 |
98 void OnPaintFocus(gfx::Canvas* canvas); | 106 void OnPaintFocus(gfx::Canvas* canvas); |
99 | 107 |
100 // Notify the listener_, if not NULL, that dragging started. | 108 // Notify the listener_, if not NULL, that dragging started. |
101 void OnSliderDragStarted(); | 109 void OnSliderDragStarted(); |
102 | 110 |
103 // Notify the listener_, if not NULL, that dragging ended. | 111 // Notify the listener_, if not NULL, that dragging ended. |
104 void OnSliderDragEnded(); | 112 void OnSliderDragEnded(); |
105 | 113 |
106 // views::View: | 114 // views::View: |
107 const char* GetClassName() const override; | 115 const char* GetClassName() const override; |
108 gfx::Size GetPreferredSize() const override; | 116 gfx::Size GetPreferredSize() const override; |
109 bool OnMousePressed(const ui::MouseEvent& event) override; | |
110 bool OnMouseDragged(const ui::MouseEvent& event) override; | 117 bool OnMouseDragged(const ui::MouseEvent& event) override; |
111 void OnMouseReleased(const ui::MouseEvent& event) override; | |
112 bool OnKeyPressed(const ui::KeyEvent& event) override; | 118 bool OnKeyPressed(const ui::KeyEvent& event) override; |
113 void GetAccessibleState(ui::AXViewState* state) override; | 119 void GetAccessibleState(ui::AXViewState* state) override; |
114 void OnFocus() override; | 120 void OnFocus() override; |
115 void OnBlur() override; | 121 void OnBlur() override; |
116 | 122 |
117 // ui::EventHandler: | 123 // ui::EventHandler: |
118 void OnGestureEvent(ui::GestureEvent* event) override; | 124 void OnGestureEvent(ui::GestureEvent* event) override; |
119 | 125 |
120 // gfx::AnimationDelegate: | |
121 void AnimationProgressed(const gfx::Animation* animation) override; | |
122 | |
123 void set_listener(SliderListener* listener) { | 126 void set_listener(SliderListener* listener) { |
124 listener_ = listener; | 127 listener_ = listener; |
125 } | 128 } |
126 | 129 |
127 SliderListener* listener_; | 130 SliderListener* listener_; |
128 | 131 |
129 std::unique_ptr<gfx::SlideAnimation> move_animation_; | 132 std::unique_ptr<gfx::SlideAnimation> move_animation_; |
130 | 133 |
131 float value_; | 134 float value_; |
132 float keyboard_increment_; | 135 float keyboard_increment_; |
133 float animating_value_; | 136 float animating_value_; |
134 bool value_is_valid_; | 137 bool value_is_valid_; |
135 base::string16 accessible_name_; | 138 base::string16 accessible_name_; |
136 bool accessibility_events_enabled_; | 139 bool accessibility_events_enabled_; |
137 SkColor focus_border_color_; | 140 SkColor focus_border_color_; |
138 | 141 |
139 // Relative position of the mouse cursor (or the touch point) on the slider's | 142 // Relative position of the mouse cursor (or the touch point) on the slider's |
140 // button. | 143 // button. |
141 int initial_button_offset_; | 144 int initial_button_offset_; |
142 | 145 |
143 DISALLOW_COPY_AND_ASSIGN(Slider); | 146 DISALLOW_COPY_AND_ASSIGN(Slider); |
144 }; | 147 }; |
145 | 148 |
146 } // namespace views | 149 } // namespace views |
147 | 150 |
148 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ | 151 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ |
OLD | NEW |