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

Side by Side Diff: ui/views/controls/scrollbar/overlay_scroll_bar.cc

Issue 16909002: Fix overlay scrollbar's response to gesture events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix normal state Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/scrollbar/overlay_scroll_bar.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" 5 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
6 6
7 #include "third_party/skia/include/core/SkColor.h" 7 #include "third_party/skia/include/core/SkColor.h"
8 #include "third_party/skia/include/core/SkXfermode.h" 8 #include "third_party/skia/include/core/SkXfermode.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/background.h" 10 #include "ui/views/background.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 OverlayScrollBarThumb::~OverlayScrollBarThumb() { 55 OverlayScrollBarThumb::~OverlayScrollBarThumb() {
56 } 56 }
57 57
58 gfx::Size OverlayScrollBarThumb::GetPreferredSize() { 58 gfx::Size OverlayScrollBarThumb::GetPreferredSize() {
59 return gfx::Size(kThumbMinimumSize, kThumbMinimumSize); 59 return gfx::Size(kThumbMinimumSize, kThumbMinimumSize);
60 } 60 }
61 61
62 void OverlayScrollBarThumb::OnPaint(gfx::Canvas* canvas) { 62 void OverlayScrollBarThumb::OnPaint(gfx::Canvas* canvas) {
63 gfx::Rect local_bounds(GetLocalBounds()); 63 gfx::Rect local_bounds(GetLocalBounds());
64 SkPaint paint; 64 SkPaint paint;
65 int alpha = (GetState() == CustomButton::STATE_HOVERED || 65 int alpha = kThumbDefaultAlpha * animation_opacity_;
66 GetState() == CustomButton::STATE_PRESSED) ? 66 if (GetState() == CustomButton::STATE_HOVERED) {
67 kThumbHoverAlpha : kThumbDefaultAlpha; 67 alpha = kThumbHoverAlpha * animation_opacity_;
68 alpha *= animation_opacity_; 68 } else if(GetState() == CustomButton::STATE_PRESSED) {
69 // If we are in pressed state, no need to worry about animation,
70 // just display the deeper color.
71 alpha = kThumbHoverAlpha;
72 }
73
69 paint.setStyle(SkPaint::kFill_Style); 74 paint.setStyle(SkPaint::kFill_Style);
70 paint.setColor(SkColorSetARGB(alpha, 0, 0, 0)); 75 paint.setColor(SkColorSetARGB(alpha, 0, 0, 0));
71 canvas->DrawRoundRect(local_bounds, kThumbCornerRadius, paint); 76 canvas->DrawRoundRect(local_bounds, kThumbCornerRadius, paint);
72 } 77 }
73 78
74 void OverlayScrollBarThumb::AnimationProgressed( 79 void OverlayScrollBarThumb::AnimationProgressed(
75 const ui::Animation* animation) { 80 const ui::Animation* animation) {
76 animation_opacity_ = animation->GetCurrentValue(); 81 animation_opacity_ = animation->GetCurrentValue();
77 SchedulePaint(); 82 SchedulePaint();
78 } 83 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 117 }
113 118
114 void OverlayScrollBar::OnMouseEnteredScrollView(const ui::MouseEvent& event) { 119 void OverlayScrollBar::OnMouseEnteredScrollView(const ui::MouseEvent& event) {
115 animation_.Show(); 120 animation_.Show();
116 } 121 }
117 122
118 void OverlayScrollBar::OnMouseExitedScrollView(const ui::MouseEvent& event) { 123 void OverlayScrollBar::OnMouseExitedScrollView(const ui::MouseEvent& event) {
119 animation_.Hide(); 124 animation_.Hide();
120 } 125 }
121 126
127 void OverlayScrollBar::OnGestureEvent(ui::GestureEvent* event) {
128 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN)
129 animation_.Show();
130 else if (event->type() == ui::ET_GESTURE_SCROLL_END)
131 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
132 BaseScrollBar::OnGestureEvent(event);
133 }
134
122 gfx::Size OverlayScrollBar::GetPreferredSize() { 135 gfx::Size OverlayScrollBar::GetPreferredSize() {
123 return gfx::Size(); 136 return gfx::Size();
124 } 137 }
125 138
126 void OverlayScrollBar::Layout() { 139 void OverlayScrollBar::Layout() {
127 gfx::Rect thumb_bounds = GetTrackBounds(); 140 gfx::Rect thumb_bounds = GetTrackBounds();
128 BaseScrollBarThumb* thumb = GetThumb(); 141 BaseScrollBarThumb* thumb = GetThumb();
129 if (IsHorizontal()) { 142 if (IsHorizontal()) {
130 thumb_bounds.set_x(thumb->x()); 143 thumb_bounds.set_x(thumb->x());
131 thumb_bounds.set_width(thumb->width()); 144 thumb_bounds.set_width(thumb->width());
132 } else { 145 } else {
133 thumb_bounds.set_y(thumb->y()); 146 thumb_bounds.set_y(thumb->y());
134 thumb_bounds.set_height(thumb->height()); 147 thumb_bounds.set_height(thumb->height());
135 } 148 }
136 thumb->SetBoundsRect(thumb_bounds); 149 thumb->SetBoundsRect(thumb_bounds);
137 } 150 }
138 151
139 void OverlayScrollBar::OnPaint(gfx::Canvas* canvas) { 152 void OverlayScrollBar::OnPaint(gfx::Canvas* canvas) {
140 } 153 }
141 154
142 } // namespace views 155 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/overlay_scroll_bar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698