Chromium Code Reviews| Index: ui/views/controls/scrollbar/overlay_scroll_bar.cc |
| diff --git a/ui/views/controls/scrollbar/overlay_scroll_bar.cc b/ui/views/controls/scrollbar/overlay_scroll_bar.cc |
| index c7e254a6a026ef8a00f9a3b45c988e7e857faa65..b9f52ef9cd50980d72200be6fad047331c3f8113 100644 |
| --- a/ui/views/controls/scrollbar/overlay_scroll_bar.cc |
| +++ b/ui/views/controls/scrollbar/overlay_scroll_bar.cc |
| @@ -62,10 +62,15 @@ gfx::Size OverlayScrollBarThumb::GetPreferredSize() { |
| void OverlayScrollBarThumb::OnPaint(gfx::Canvas* canvas) { |
| gfx::Rect local_bounds(GetLocalBounds()); |
| SkPaint paint; |
| - int alpha = (GetState() == CustomButton::STATE_HOVERED || |
| - GetState() == CustomButton::STATE_PRESSED) ? |
| - kThumbHoverAlpha : kThumbDefaultAlpha; |
| - alpha *= animation_opacity_; |
| + int alpha = kThumbDefaultAlpha * animation_opacity_; |
| + if (GetState() == CustomButton::STATE_HOVERED) { |
| + alpha = kThumbHoverAlpha * animation_opacity_; |
| + } else if(GetState() == CustomButton::STATE_PRESSED) { |
| + // If we are in pressed state, no need to worry about animation, |
| + // just display the deeper color. |
| + alpha = kThumbHoverAlpha; |
| + } |
| + |
| paint.setStyle(SkPaint::kFill_Style); |
| paint.setColor(SkColorSetARGB(alpha, 0, 0, 0)); |
| canvas->DrawRoundRect(local_bounds, kThumbCornerRadius, paint); |
| @@ -119,6 +124,14 @@ void OverlayScrollBar::OnMouseExitedScrollView(const ui::MouseEvent& event) { |
| animation_.Hide(); |
| } |
| +void OverlayScrollBar::OnGestureEvent(ui::GestureEvent* event) { |
| + if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN) |
| + animation_.Show(); |
| + else if (event->type() == ui::ET_GESTURE_SCROLL_END) |
| + animation_.Hide(); |
|
Jun Mukai
2013/06/13 19:11:23
The scrollbar doesn't hide when I fling the scroll
Jun Mukai
2013/06/21 21:12:43
How did you address the issue I commented? As far
|
| + BaseScrollBar::OnGestureEvent(event); |
| +} |
| + |
| gfx::Size OverlayScrollBar::GetPreferredSize() { |
| return gfx::Size(); |
| } |