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

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

Issue 10912063: events: Get rid of GestureStatus in favour of EventResult. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base_scroll_bar.h" 5 #include "ui/views/controls/scrollbar/base_scroll_bar.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 default: 160 default:
161 break; 161 break;
162 } 162 }
163 if (amount != SCROLL_NONE) { 163 if (amount != SCROLL_NONE) {
164 ScrollByAmount(amount); 164 ScrollByAmount(amount);
165 return true; 165 return true;
166 } 166 }
167 return false; 167 return false;
168 } 168 }
169 169
170 ui::GestureStatus BaseScrollBar::OnGestureEvent(const ui::GestureEvent& event) { 170 ui::EventResult BaseScrollBar::OnGestureEvent(const ui::GestureEvent& event) {
171 // If a fling is in progress, then stop the fling for any incoming gesture 171 // If a fling is in progress, then stop the fling for any incoming gesture
172 // event (except for the GESTURE_END event that is generated at the end of the 172 // event (except for the GESTURE_END event that is generated at the end of the
173 // fling). 173 // fling).
174 if (scroll_animator_.get() && scroll_animator_->is_scrolling() && 174 if (scroll_animator_.get() && scroll_animator_->is_scrolling() &&
175 (event.type() != ui::ET_GESTURE_END || 175 (event.type() != ui::ET_GESTURE_END ||
176 event.details().touch_points() > 1)) { 176 event.details().touch_points() > 1)) {
177 scroll_animator_->Stop(); 177 scroll_animator_->Stop();
178 } 178 }
179 179
180 if (event.type() == ui::ET_GESTURE_TAP_DOWN) { 180 if (event.type() == ui::ET_GESTURE_TAP_DOWN) {
181 ProcessPressEvent(event); 181 ProcessPressEvent(event);
182 return ui::GESTURE_STATUS_CONSUMED; 182 return ui::ER_CONSUMED;
183 } 183 }
184 184
185 if (event.type() == ui::ET_GESTURE_LONG_PRESS) { 185 if (event.type() == ui::ET_GESTURE_LONG_PRESS) {
186 // For a long-press, the repeater started in tap-down should continue. So 186 // For a long-press, the repeater started in tap-down should continue. So
187 // return early. 187 // return early.
188 return ui::GESTURE_STATUS_UNKNOWN; 188 return ui::ER_UNHANDLED;
189 } 189 }
190 190
191 ResetState(); 191 ResetState();
192 192
193 if (event.type() == ui::ET_GESTURE_TAP) { 193 if (event.type() == ui::ET_GESTURE_TAP) {
194 // TAP_DOWN would have already scrolled some amount. So scrolling again on 194 // TAP_DOWN would have already scrolled some amount. So scrolling again on
195 // TAP is not necessary. 195 // TAP is not necessary.
196 return ui::GESTURE_STATUS_CONSUMED; 196 return ui::ER_CONSUMED;
197 } 197 }
198 198
199 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN || 199 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN ||
200 event.type() == ui::ET_GESTURE_SCROLL_END) 200 event.type() == ui::ET_GESTURE_SCROLL_END)
201 return ui::GESTURE_STATUS_CONSUMED; 201 return ui::ER_CONSUMED;
202 202
203 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) { 203 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) {
204 ScrollByContentsOffset(IsHorizontal() ? event.details().scroll_x() : 204 ScrollByContentsOffset(IsHorizontal() ? event.details().scroll_x() :
205 event.details().scroll_y()); 205 event.details().scroll_y());
206 return ui::GESTURE_STATUS_CONSUMED; 206 return ui::ER_CONSUMED;
207 } 207 }
208 208
209 if (event.type() == ui::ET_SCROLL_FLING_START) { 209 if (event.type() == ui::ET_SCROLL_FLING_START) {
210 if (!scroll_animator_.get()) 210 if (!scroll_animator_.get())
211 scroll_animator_.reset(new ScrollAnimator(this)); 211 scroll_animator_.reset(new ScrollAnimator(this));
212 scroll_animator_->Start(IsHorizontal() ? event.details().velocity_x() : 0.f, 212 scroll_animator_->Start(IsHorizontal() ? event.details().velocity_x() : 0.f,
213 IsHorizontal() ? 0.f : event.details().velocity_y()); 213 IsHorizontal() ? 0.f : event.details().velocity_y());
214 return ui::GESTURE_STATUS_CONSUMED; 214 return ui::ER_CONSUMED;
215 } 215 }
216 216
217 return ui::GESTURE_STATUS_UNKNOWN; 217 return ui::ER_UNHANDLED;
218 } 218 }
219 219
220 bool BaseScrollBar::OnMouseWheel(const ui::MouseWheelEvent& event) { 220 bool BaseScrollBar::OnMouseWheel(const ui::MouseWheelEvent& event) {
221 ScrollByContentsOffset(event.offset()); 221 ScrollByContentsOffset(event.offset());
222 return true; 222 return true;
223 } 223 }
224 224
225 /////////////////////////////////////////////////////////////////////////////// 225 ///////////////////////////////////////////////////////////////////////////////
226 // BaseScrollBar, ScrollDelegate implementation: 226 // BaseScrollBar, ScrollDelegate implementation:
227 227
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 thumb_position = thumb_position - (thumb_->GetSize() / 2); 450 thumb_position = thumb_position - (thumb_->GetSize() / 2);
451 return (thumb_position * contents_size_) / GetTrackSize(); 451 return (thumb_position * contents_size_) / GetTrackSize();
452 } 452 }
453 453
454 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { 454 void BaseScrollBar::SetThumbTrackState(CustomButton::ButtonState state) {
455 thumb_track_state_ = state; 455 thumb_track_state_ = state;
456 SchedulePaint(); 456 SchedulePaint();
457 } 457 }
458 458
459 } // namespace views 459 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/base_scroll_bar.h ('k') | ui/views/controls/scrollbar/native_scroll_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698