| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 76 |
| 77 // Returns the current position of the thumb on the slider. | 77 // Returns the current position of the thumb on the slider. |
| 78 float GetAnimatingValue() const; | 78 float GetAnimatingValue() const; |
| 79 | 79 |
| 80 // Shows or hides the highlight on the slider thumb. The default |
| 81 // implementation does nothing. |
| 82 virtual void SetHighlighted(bool is_highlighted); |
| 83 |
| 84 // Gets the size of the slider's thumb. |
| 80 virtual int GetThumbWidth() = 0; | 85 virtual int GetThumbWidth() = 0; |
| 81 | 86 |
| 82 // views::View: | 87 // views::View: |
| 83 void OnPaint(gfx::Canvas* canvas) override; | 88 void OnPaint(gfx::Canvas* canvas) override; |
| 84 | 89 |
| 90 // gfx::AnimationDelegate: |
| 91 void AnimationProgressed(const gfx::Animation* animation) override; |
| 92 void AnimationEnded(const gfx::Animation* animation) override; |
| 93 |
| 85 private: | 94 private: |
| 86 friend class test::SliderTestApi; | 95 friend class test::SliderTestApi; |
| 87 | 96 |
| 88 void SetValueInternal(float value, SliderChangeReason reason); | 97 void SetValueInternal(float value, SliderChangeReason reason); |
| 89 | 98 |
| 90 // Should be called on the Mouse Down event. Used to calculate relative | 99 // 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 | 100 // position of the mouse cursor (or the touch point) on the button to |
| 92 // accurately move the button using the MoveButtonTo() method. | 101 // accurately move the button using the MoveButtonTo() method. |
| 93 void PrepareForMove(const int new_x); | 102 void PrepareForMove(const int new_x); |
| 94 | 103 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 bool OnMouseDragged(const ui::MouseEvent& event) override; | 119 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 111 void OnMouseReleased(const ui::MouseEvent& event) override; | 120 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 112 bool OnKeyPressed(const ui::KeyEvent& event) override; | 121 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 113 void GetAccessibleState(ui::AXViewState* state) override; | 122 void GetAccessibleState(ui::AXViewState* state) override; |
| 114 void OnFocus() override; | 123 void OnFocus() override; |
| 115 void OnBlur() override; | 124 void OnBlur() override; |
| 116 | 125 |
| 117 // ui::EventHandler: | 126 // ui::EventHandler: |
| 118 void OnGestureEvent(ui::GestureEvent* event) override; | 127 void OnGestureEvent(ui::GestureEvent* event) override; |
| 119 | 128 |
| 120 // gfx::AnimationDelegate: | |
| 121 void AnimationProgressed(const gfx::Animation* animation) override; | |
| 122 | |
| 123 void set_listener(SliderListener* listener) { | 129 void set_listener(SliderListener* listener) { |
| 124 listener_ = listener; | 130 listener_ = listener; |
| 125 } | 131 } |
| 126 | 132 |
| 127 SliderListener* listener_; | 133 SliderListener* listener_; |
| 128 | 134 |
| 129 std::unique_ptr<gfx::SlideAnimation> move_animation_; | 135 std::unique_ptr<gfx::SlideAnimation> move_animation_; |
| 130 | 136 |
| 131 float value_; | 137 float value_; |
| 132 float keyboard_increment_; | 138 float keyboard_increment_; |
| 133 float animating_value_; | 139 float initial_animating_value_; |
| 134 bool value_is_valid_; | 140 bool value_is_valid_; |
| 135 base::string16 accessible_name_; | 141 base::string16 accessible_name_; |
| 136 bool accessibility_events_enabled_; | 142 bool accessibility_events_enabled_; |
| 137 SkColor focus_border_color_; | 143 SkColor focus_border_color_; |
| 138 | 144 |
| 139 // Relative position of the mouse cursor (or the touch point) on the slider's | 145 // Relative position of the mouse cursor (or the touch point) on the slider's |
| 140 // button. | 146 // button. |
| 141 int initial_button_offset_; | 147 int initial_button_offset_; |
| 142 | 148 |
| 143 DISALLOW_COPY_AND_ASSIGN(Slider); | 149 DISALLOW_COPY_AND_ASSIGN(Slider); |
| 144 }; | 150 }; |
| 145 | 151 |
| 146 } // namespace views | 152 } // namespace views |
| 147 | 153 |
| 148 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ | 154 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ |
| OLD | NEW |