summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-25 04:00:18 +0000
committerdewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-25 04:00:18 +0000
commit9845051addca0f8ae1b0e902a9bec401d1ca9284 (patch)
tree4baac62a28edb1672095aeab33d2c0de55ac6180 /ui
parent8a50127ae51f6ae34dc44ff035d5ca7b262d73fc (diff)
downloadchromium_src-9845051addca0f8ae1b0e902a9bec401d1ca9284.zip
chromium_src-9845051addca0f8ae1b0e902a9bec401d1ca9284.tar.gz
chromium_src-9845051addca0f8ae1b0e902a9bec401d1ca9284.tar.bz2
Fix overlay scrollbar's response to gesture events.
BUG=249160 Review URL: https://chromiumcodereview.appspot.com/16909002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208383 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-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;