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

Unified Diff: ui/views/controls/slider.cc

Issue 2335513002: Adding ripple effect for clicks on MD slider (Closed)
Patch Set: imporve animation Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« ui/views/controls/slider.h ('K') | « ui/views/controls/slider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/slider.cc
diff --git a/ui/views/controls/slider.cc b/ui/views/controls/slider.cc
index dd1148ff1a59123e6f2c960404aee5ffe732267c..8ba08edb9e4c80eb1afb30c1bb1ac0aacef177db 100644
--- a/ui/views/controls/slider.cc
+++ b/ui/views/controls/slider.cc
@@ -176,6 +176,10 @@ float Slider::GetAnimatingValue() const{
: value_;
}
+void Slider::SetHighlighted(bool focus) {
+ return;
bruthig 2016/09/22 21:05:24 nit: Remove
yiyix 2016/09/23 20:35:37 Highlight needs a default implementation, so non_m
bruthig 2016/09/23 22:24:39 I was just asking you to remove the return; statem
+}
+
bool Slider::OnMousePressed(const ui::MouseEvent& event) {
if (!event.IsOnlyLeftMouseButton())
return false;
@@ -207,11 +211,13 @@ bool Slider::OnKeyPressed(const ui::KeyEvent& event) {
}
void Slider::OnFocus() {
+ SetHighlighted(true);
View::OnFocus();
SchedulePaint();
}
void Slider::OnBlur() {
+ SetHighlighted(false);
View::OnBlur();
SchedulePaint();
}
@@ -241,8 +247,12 @@ void Slider::OnGestureEvent(ui::GestureEvent* event) {
}
void Slider::AnimationProgressed(const gfx::Animation* animation) {
- animating_value_ = animation->CurrentValueBetween(animating_value_, value_);
- SchedulePaint();
+ if (move_animation_.get() && (animation == move_animation_.get())) {
bruthig 2016/09/22 21:05:24 nit: Checking that |move_animation_| here is redun
+ float old_animating_value = animating_value_;
+ animating_value_ = animation->CurrentValueBetween(animating_value_, value_);
+ if (animating_value_ != old_animating_value)
+ SchedulePaint();
+ }
}
void Slider::GetAccessibleState(ui::AXViewState* state) {
@@ -253,11 +263,13 @@ void Slider::GetAccessibleState(ui::AXViewState* state) {
}
void Slider::OnSliderDragStarted() {
+ SetHighlighted(true);
if (listener_)
listener_->SliderDragStarted(this);
}
void Slider::OnSliderDragEnded() {
+ SetHighlighted(false);
if (listener_)
listener_->SliderDragEnded(this);
}
« ui/views/controls/slider.h ('K') | « ui/views/controls/slider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698