summaryrefslogtreecommitdiffstats
path: root/ui/views/controls
diff options
context:
space:
mode:
Diffstat (limited to 'ui/views/controls')
-rw-r--r--ui/views/controls/scrollbar/overlay_scroll_bar.cc29
-rw-r--r--ui/views/controls/scrollbar/overlay_scroll_bar.h1
2 files changed, 26 insertions, 4 deletions
diff --git a/ui/views/controls/scrollbar/overlay_scroll_bar.cc b/ui/views/controls/scrollbar/overlay_scroll_bar.cc
index c7e254a..25228e4 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,22 @@ void OverlayScrollBar::OnMouseExitedScrollView(const ui::MouseEvent& event) {
animation_.Hide();
}
+void OverlayScrollBar::OnGestureEvent(ui::GestureEvent* event) {
+ switch (event->type()) {
+ case ui::ET_GESTURE_SCROLL_BEGIN:
+ animation_.Show();
+ break;
+ case ui::ET_GESTURE_SCROLL_END:
+ case ui::ET_SCROLL_FLING_START:
+ case ui::ET_GESTURE_END:
+ animation_.Hide();
+ break;
+ default:
+ break;
+ }
+ BaseScrollBar::OnGestureEvent(event);
+}
+
gfx::Size OverlayScrollBar::GetPreferredSize() {
return gfx::Size();
}
diff --git a/ui/views/controls/scrollbar/overlay_scroll_bar.h b/ui/views/controls/scrollbar/overlay_scroll_bar.h
index 043f5f7..ac64d35 100644
--- a/ui/views/controls/scrollbar/overlay_scroll_bar.h
+++ b/ui/views/controls/scrollbar/overlay_scroll_bar.h
@@ -19,6 +19,7 @@ class VIEWS_EXPORT OverlayScrollBar : public BaseScrollBar {
protected:
// BaseScrollBar overrides:
virtual gfx::Rect GetTrackBounds() const OVERRIDE;
+ virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
// ScrollBar overrides:
virtual int GetLayoutSize() const OVERRIDE;