Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: ui/views/controls/slider.h

Issue 2335513002: Adding ripple effect for clicks on MD slider (Closed)
Patch Set: address comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Set to true to show the highlight of the thumb on the slider; and set to
81 // false to hide the effect.
varkha 2016/09/24 13:59:18 nit: maybe just "Shows or hides the highlight on t
yiyix 2016/09/29 19:09:39 I like that it points out the default implementati
82 virtual void SetHighlighted(bool is_highlighted);
83
80 virtual int GetThumbWidth() = 0; 84 virtual int GetThumbWidth() = 0;
varkha 2016/09/24 13:59:18 nit: doc?
yiyix 2016/09/29 19:09:39 Done.
81 85
82 // views::View: 86 // views::View:
83 void OnPaint(gfx::Canvas* canvas) override; 87 void OnPaint(gfx::Canvas* canvas) override;
84 88
89 // gfx::AnimationDelegate:
90 void AnimationProgressed(const gfx::Animation* animation) override;
91 void AnimationEnded(const gfx::Animation* animation) override;
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
(...skipping 15 matching lines...) Expand all
110 bool OnMouseDragged(const ui::MouseEvent& event) override; 118 bool OnMouseDragged(const ui::MouseEvent& event) override;
111 void OnMouseReleased(const ui::MouseEvent& event) override; 119 void OnMouseReleased(const ui::MouseEvent& event) override;
112 bool OnKeyPressed(const ui::KeyEvent& event) override; 120 bool OnKeyPressed(const ui::KeyEvent& event) override;
113 void GetAccessibleState(ui::AXViewState* state) override; 121 void GetAccessibleState(ui::AXViewState* state) override;
114 void OnFocus() override; 122 void OnFocus() override;
115 void OnBlur() override; 123 void OnBlur() override;
116 124
117 // ui::EventHandler: 125 // ui::EventHandler:
118 void OnGestureEvent(ui::GestureEvent* event) override; 126 void OnGestureEvent(ui::GestureEvent* event) override;
119 127
120 // gfx::AnimationDelegate:
121 void AnimationProgressed(const gfx::Animation* animation) override;
122
123 void set_listener(SliderListener* listener) { 128 void set_listener(SliderListener* listener) {
124 listener_ = listener; 129 listener_ = listener;
125 } 130 }
126 131
127 SliderListener* listener_; 132 SliderListener* listener_;
128 133
129 std::unique_ptr<gfx::SlideAnimation> move_animation_; 134 std::unique_ptr<gfx::SlideAnimation> move_animation_;
130 135
131 float value_; 136 float value_;
132 float keyboard_increment_; 137 float keyboard_increment_;
133 float animating_value_; 138 float initial_animating_value_;
134 bool value_is_valid_; 139 bool value_is_valid_;
135 base::string16 accessible_name_; 140 base::string16 accessible_name_;
136 bool accessibility_events_enabled_; 141 bool accessibility_events_enabled_;
137 SkColor focus_border_color_; 142 SkColor focus_border_color_;
138 143
139 // Relative position of the mouse cursor (or the touch point) on the slider's 144 // Relative position of the mouse cursor (or the touch point) on the slider's
140 // button. 145 // button.
141 int initial_button_offset_; 146 int initial_button_offset_;
142 147
143 DISALLOW_COPY_AND_ASSIGN(Slider); 148 DISALLOW_COPY_AND_ASSIGN(Slider);
144 }; 149 };
145 150
146 } // namespace views 151 } // namespace views
147 152
148 #endif // UI_VIEWS_CONTROLS_SLIDER_H_ 153 #endif // UI_VIEWS_CONTROLS_SLIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698