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

Side by Side Diff: sky/engine/platform/scroll/Scrollbar.cpp

Issue 874823002: Move GestureEvent to NewEventDispatcher (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Build fixes Created 5 years, 11 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
« no previous file with comments | « sky/engine/platform/scroll/Scrollbar.h ('k') | sky/engine/public/web/WebViewClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "sky/engine/config.h" 26 #include "sky/engine/config.h"
27 #include "sky/engine/platform/scroll/Scrollbar.h" 27 #include "sky/engine/platform/scroll/Scrollbar.h"
28 28
29 #include "sky/engine/platform/PlatformGestureEvent.h"
30 #include "sky/engine/platform/graphics/GraphicsContext.h" 29 #include "sky/engine/platform/graphics/GraphicsContext.h"
31 #include "sky/engine/platform/scroll/ScrollAnimator.h" 30 #include "sky/engine/platform/scroll/ScrollAnimator.h"
32 #include "sky/engine/platform/scroll/ScrollableArea.h" 31 #include "sky/engine/platform/scroll/ScrollableArea.h"
33 #include "sky/engine/platform/scroll/Scrollbar.h" 32 #include "sky/engine/platform/scroll/Scrollbar.h"
34 #include "sky/engine/public/platform/Platform.h" 33 #include "sky/engine/public/platform/Platform.h"
35 #include "sky/engine/public/platform/WebPoint.h" 34 #include "sky/engine/public/platform/WebPoint.h"
36 #include "sky/engine/public/platform/WebRect.h" 35 #include "sky/engine/public/platform/WebRect.h"
37 36
38 // The position of the scrollbar thumb affects the appearance of the steppers, s o 37 // The position of the scrollbar thumb affects the appearance of the steppers, s o
39 // when the thumb moves, we have to invalidate them for painting. 38 // when the thumb moves, we have to invalidate them for painting.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (part == m_hoveredPart) 234 if (part == m_hoveredPart)
236 return; 235 return;
237 m_hoveredPart = part; 236 m_hoveredPart = part;
238 } 237 }
239 238
240 void Scrollbar::setPressedPart(ScrollbarPart part) 239 void Scrollbar::setPressedPart(ScrollbarPart part)
241 { 240 {
242 m_pressedPart = part; 241 m_pressedPart = part;
243 } 242 }
244 243
245 bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
246 {
247 switch (evt.type()) {
248 case PlatformEvent::GestureTapDown:
249 // FIXME(sky): Is setting the pressed part needed since we only have ove rlay scrollbars?
250 setPressedPart(NoPart);
251 m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContain ingView(evt.position()).x() : convertFromContainingView(evt.position()).y();
252 return true;
253 case PlatformEvent::GestureTapDownCancel:
254 case PlatformEvent::GestureScrollBegin:
255 if (m_pressedPart != ThumbPart)
256 return false;
257 m_scrollPos = m_pressedPos;
258 return true;
259 case PlatformEvent::GestureScrollUpdate:
260 case PlatformEvent::GestureScrollUpdateWithoutPropagation:
261 if (m_pressedPart != ThumbPart)
262 return false;
263 m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX() : evt .deltaY();
264 moveThumb(m_scrollPos);
265 return true;
266 case PlatformEvent::GestureScrollEnd:
267 case PlatformEvent::GestureLongPress:
268 case PlatformEvent::GestureFlingStart:
269 m_scrollPos = 0;
270 m_pressedPos = 0;
271 setPressedPart(NoPart);
272 return false;
273 case PlatformEvent::GestureTap: {
274 if (m_pressedPart != ThumbPart && m_pressedPart != NoPart && m_scrollabl eArea
275 && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPar tScrollGranularity())) {
276 return true;
277 }
278 m_scrollPos = 0;
279 m_pressedPos = 0;
280 setPressedPart(NoPart);
281 return false;
282 }
283 default:
284 // By default, we assume that gestures don't deselect the scrollbar.
285 return true;
286 }
287 }
288
289 void Scrollbar::mouseEntered() 244 void Scrollbar::mouseEntered()
290 { 245 {
291 if (m_scrollableArea) 246 if (m_scrollableArea)
292 m_scrollableArea->mouseEnteredScrollbar(this); 247 m_scrollableArea->mouseEnteredScrollbar(this);
293 } 248 }
294 249
295 void Scrollbar::mouseExited() 250 void Scrollbar::mouseExited()
296 { 251 {
297 if (m_scrollableArea) 252 if (m_scrollableArea)
298 m_scrollableArea->mouseExitedScrollbar(this); 253 m_scrollableArea->mouseExitedScrollbar(this);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 thumbRect.setWidth(thumbRect.width() - kScrollbarMargin); 408 thumbRect.setWidth(thumbRect.width() - kScrollbarMargin);
454 if (isLeftSideVerticalScrollbar()) 409 if (isLeftSideVerticalScrollbar())
455 thumbRect.setX(thumbRect.x() + kScrollbarMargin); 410 thumbRect.setX(thumbRect.x() + kScrollbarMargin);
456 } 411 }
457 412
458 DEFINE_STATIC_LOCAL(Color, color, (128, 128, 128, 128)); 413 DEFINE_STATIC_LOCAL(Color, color, (128, 128, 128, 128));
459 context->fillRect(thumbRect, color); 414 context->fillRect(thumbRect, color);
460 } 415 }
461 416
462 } // namespace blink 417 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/scroll/Scrollbar.h ('k') | sky/engine/public/web/WebViewClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698