本文整理汇总了C++中PlatformGestureEvent::deltaUnits方法的典型用法代码示例。如果您正苦于以下问题:C++ PlatformGestureEvent::deltaUnits方法的具体用法?C++ PlatformGestureEvent::deltaUnits怎么用?C++ PlatformGestureEvent::deltaUnits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlatformGestureEvent
的用法示例。
在下文中一共展示了PlatformGestureEvent::deltaUnits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gestureEvent
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt,
bool* shouldUpdateCapture) {
DCHECK(shouldUpdateCapture);
switch (evt.type()) {
case PlatformEvent::GestureTapDown:
setPressedPart(theme().hitTest(*this, evt.position()));
m_pressedPos = orientation() == HorizontalScrollbar
? convertFromRootFrame(evt.position()).x()
: convertFromRootFrame(evt.position()).y();
*shouldUpdateCapture = true;
return true;
case PlatformEvent::GestureTapDownCancel:
if (m_pressedPart != ThumbPart)
return false;
m_scrollPos = m_pressedPos;
return true;
case PlatformEvent::GestureScrollBegin:
switch (evt.source()) {
case PlatformGestureSourceTouchpad:
// Update the state on GSB for touchpad since GestureTapDown
// is not generated by that device. Touchscreen uses the tap down
// gesture since the scrollbar enters a visual active state.
*shouldUpdateCapture = true;
setPressedPart(NoPart);
m_pressedPos = 0;
return true;
case PlatformGestureSourceTouchscreen:
if (m_pressedPart != ThumbPart)
return false;
m_scrollPos = m_pressedPos;
return true;
default:
ASSERT_NOT_REACHED();
return true;
}
break;
case PlatformEvent::GestureScrollUpdate:
switch (evt.source()) {
case PlatformGestureSourceTouchpad: {
FloatSize delta(-evt.deltaX(), -evt.deltaY());
if (m_scrollableArea &&
m_scrollableArea->userScroll(evt.deltaUnits(), delta)
.didScroll()) {
return true;
}
return false;
}
case PlatformGestureSourceTouchscreen:
if (m_pressedPart != ThumbPart)
return false;
m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX()
: evt.deltaY();
moveThumb(m_scrollPos, false);
return true;
default:
ASSERT_NOT_REACHED();
return true;
}
break;
case PlatformEvent::GestureScrollEnd:
case PlatformEvent::GestureLongPress:
case PlatformEvent::GestureFlingStart:
m_scrollPos = 0;
m_pressedPos = 0;
setPressedPart(NoPart);
return false;
case PlatformEvent::GestureTap: {
if (m_pressedPart != ThumbPart && m_pressedPart != NoPart &&
m_scrollableArea &&
m_scrollableArea
->userScroll(
pressedPartScrollGranularity(),
toScrollDelta(pressedPartScrollDirectionPhysical(), 1))
.didScroll()) {
return true;
}
m_scrollPos = 0;
m_pressedPos = 0;
setPressedPart(NoPart);
return false;
}
default:
// By default, we assume that gestures don't deselect the scrollbar.
return true;
}
}