本文整理汇总了C++中PlatformGestureEvent::type方法的典型用法代码示例。如果您正苦于以下问题:C++ PlatformGestureEvent::type方法的具体用法?C++ PlatformGestureEvent::type怎么用?C++ PlatformGestureEvent::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlatformGestureEvent
的用法示例。
在下文中一共展示了PlatformGestureEvent::type方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleGestureEvent
// FIXME: Refactor this code to share functionality with EventHandler::handleGestureEvent.
bool PopupContainer::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
{
switch (gestureEvent.type()) {
case PlatformEvent::GestureTap: {
PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(), NoButton, PlatformEvent::MouseMoved, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, PlatformEvent::MouseReleased, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
// handleMouseMoveEvent(fakeMouseMove);
handleMouseDownEvent(fakeMouseDown);
handleMouseReleaseEvent(fakeMouseUp);
return true;
}
case PlatformEvent::GestureDoubleTap:
break;
case PlatformEvent::GestureScrollUpdate:
case PlatformEvent::GestureScrollUpdateWithoutPropagation: {
PlatformWheelEvent syntheticWheelEvent(gestureEvent.position(), gestureEvent.globalPosition(), gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / 120.0f, gestureEvent.deltaY() / 120.0f, ScrollByPixelWheelEvent, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey());
handleWheelEvent(syntheticWheelEvent);
return true;
}
case PlatformEvent::GestureScrollBegin:
case PlatformEvent::GestureScrollEnd:
case PlatformEvent::GestureTapDown:
break;
default:
ASSERT_NOT_REACHED();
}
return false;
}
示例2: handleGestureEvent
// FIXME: Refactor this code to share functionality with EventHandler::handleGestureEvent.
bool PopupContainer::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
{
switch (gestureEvent.type()) {
case PlatformGestureEvent::TapType: {
PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(), NoButton, MouseEventMoved, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, MouseEventPressed, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, MouseEventReleased, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
// handleMouseMoveEvent(fakeMouseMove);
handleMouseDownEvent(fakeMouseDown);
handleMouseReleaseEvent(fakeMouseUp);
return true;
}
case PlatformGestureEvent::DoubleTapType:
break;
case PlatformGestureEvent::ScrollUpdateType: {
PlatformWheelEvent syntheticWheelEvent(gestureEvent.position(), gestureEvent.globalPosition(), gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / 120.0f, gestureEvent.deltaY() / 120.0f, ScrollByPixelWheelEvent, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey());
handleWheelEvent(syntheticWheelEvent);
return true;
}
case PlatformGestureEvent::ScrollBeginType:
case PlatformGestureEvent::ScrollEndType:
case PlatformGestureEvent::TapDownType:
break;
}
return false;
}
示例3: adoptRef
PassRefPtr<GestureEvent> GestureEvent::create(PassRefPtr<AbstractView> view, const PlatformGestureEvent& event)
{
AtomicString eventType;
switch (event.type()) {
case PlatformEvent::GestureScrollBegin:
eventType = eventNames().gesturescrollstartEvent; break;
case PlatformEvent::GestureScrollEnd:
eventType = eventNames().gesturescrollendEvent; break;
case PlatformEvent::GestureScrollUpdate:
case PlatformEvent::GestureScrollUpdateWithoutPropagation:
eventType = eventNames().gesturescrollupdateEvent; break;
case PlatformEvent::GestureTap:
eventType = eventNames().gesturetapEvent; break;
case PlatformEvent::GestureTapDown:
eventType = eventNames().gesturetapdownEvent; break;
case PlatformEvent::GestureTwoFingerTap:
case PlatformEvent::GestureLongPress:
case PlatformEvent::GesturePinchBegin:
case PlatformEvent::GesturePinchEnd:
case PlatformEvent::GesturePinchUpdate:
case PlatformEvent::GestureTapDownCancel:
default:
return 0;
}
return adoptRef(new GestureEvent(eventType, view, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.deltaX(), event.deltaY()));
}
示例4: adoptRefWillBeNoop
PassRefPtrWillBeRawPtr<GestureEvent> GestureEvent::create(PassRefPtrWillBeRawPtr<AbstractView> view, const PlatformGestureEvent& event)
{
AtomicString eventType;
float deltaX = 0;
float deltaY = 0;
float velocityX = 0;
float velocityY = 0;
bool inertial = false;
GestureSource source = GestureSourceUninitialized;
switch (event.source()) {
case PlatformGestureSourceTouchpad:
source = GestureSourceTouchpad;
break;
case PlatformGestureSourceTouchscreen:
source = GestureSourceTouchscreen;
break;
default:
ASSERT_NOT_REACHED();
}
switch (event.type()) {
case PlatformEvent::GestureScrollBegin:
eventType = EventTypeNames::gesturescrollstart; break;
case PlatformEvent::GestureScrollEnd:
eventType = EventTypeNames::gesturescrollend; break;
case PlatformEvent::GestureScrollUpdate:
// Only deltaX/Y are used when converting this
// back to a PlatformGestureEvent.
eventType = EventTypeNames::gesturescrollupdate;
deltaX = event.deltaX();
deltaY = event.deltaY();
inertial = event.inertial();
break;
case PlatformEvent::GestureTap:
eventType = EventTypeNames::gesturetap; break;
case PlatformEvent::GestureTapUnconfirmed:
eventType = EventTypeNames::gesturetapunconfirmed; break;
case PlatformEvent::GestureTapDown:
eventType = EventTypeNames::gesturetapdown; break;
case PlatformEvent::GestureShowPress:
eventType = EventTypeNames::gestureshowpress; break;
case PlatformEvent::GestureLongPress:
eventType = EventTypeNames::gesturelongpress; break;
case PlatformEvent::GestureFlingStart:
eventType = EventTypeNames::gestureflingstart;
velocityX = event.velocityX();
velocityY = event.velocityY();
break;
case PlatformEvent::GestureTwoFingerTap:
case PlatformEvent::GesturePinchBegin:
case PlatformEvent::GesturePinchEnd:
case PlatformEvent::GesturePinchUpdate:
case PlatformEvent::GestureTapDownCancel:
default:
return nullptr;
}
return adoptRefWillBeNoop(new GestureEvent(eventType, view, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(), event.modifiers(), deltaX, deltaY, velocityX, velocityY, inertial, event.timestamp(), event.resendingPluginId(), source));
}
示例5: zoom
void ScrollAnimatorNone::zoom(const PlatformGestureEvent& pge)
{
ASSERT(pge.type() == PlatformGestureEvent::DoubleTapType);
// FIXME: modify this so we can start even if the timer is active.
if (!m_animationTimer.isActive()) {
m_currentZoomScale = 1;
m_currentZoomTransX = 0;
m_currentZoomTransY = 0;
double currentTime = WTF::monotonicallyIncreasingTime();
float scale = pge.deltaX();
m_zoomData.m_startTime = currentTime - kTickTime / 2;
m_zoomData.m_startScale = m_currentZoomScale;
m_zoomData.m_desiredScale = scale;
// FIXME: Document then simplify the following equations.
m_zoomData.m_desiredTransX = (1 - scale) * pge.globalPosition().x();
m_zoomData.m_desiredTransY = (1 - scale) * pge.globalPosition().y();
#if ENABLE(DOUBLE_TAP_CENTERS)
if (pge.type() == PlatformGestureEvent::DoubleTapType) {
// Zoom to centre of display. Pinch-to-zoom may not want this behaviour.
m_zoomData.m_desiredTransX += m_scrollableArea->visibleWidth() / 2 - pge.globalPosition().x();
m_zoomData.m_desiredTransY += m_scrollableArea->visibleHeight() / 2 - pge.globalPosition().y();
}
#endif
m_zoomData.m_lastAnimationTime = currentTime;
m_zoomData.m_animationTime = kZoomTicks * kTickTime;
bool isContinuing = m_zoomData.animateZoom(currentTime);
double deltaToNextFrame = ceil((currentTime - m_startTime) * kFrameRate) / kFrameRate - (currentTime - m_startTime);
double nextTimerInterval = max(kMinimumTimerInterval, deltaToNextFrame);
if (isContinuing) {
m_animationTimer.startOneShot(nextTimerInterval);
m_zoomData.m_isAnimating = true;
notifyZoomChanged(ZoomAnimationContinuing);
} else
notifyZoomChanged(ZoomAnimationFinishing);
}
}
示例6: handleGestureEvent
void ScrollAnimatorNone::handleGestureEvent(const PlatformGestureEvent& pge)
{
TRACE_EVENT("ScrollAnimatorNone::handleGestureEvent", this, 0);
switch (pge.type()) {
case PlatformGestureEvent::DoubleTapType:
zoom(pge);
break;
default:
// TODO: add any other event types we should handle
{ }
}
}
示例7: gestureEvent
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
{
switch (evt.type()) {
case PlatformEvent::GestureTapDown:
// FIXME(sky): Is setting the pressed part needed since we only have overlay scrollbars?
setPressedPart(NoPart);
m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y();
return true;
case PlatformEvent::GestureTapDownCancel:
case PlatformEvent::GestureScrollBegin:
if (m_pressedPart != ThumbPart)
return false;
m_scrollPos = m_pressedPos;
return true;
case PlatformEvent::GestureScrollUpdate:
case PlatformEvent::GestureScrollUpdateWithoutPropagation:
if (m_pressedPart != ThumbPart)
return false;
m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX() : evt.deltaY();
moveThumb(m_scrollPos);
return true;
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->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) {
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;
}
}
示例8: gestureEvent
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
{
switch (evt.type()) {
case PlatformEvent::GestureTapDown:
setPressedPart(theme()->hitTest(this, evt.position()));
m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y();
return true;
case PlatformEvent::GestureTapDownCancel:
case PlatformEvent::GestureScrollBegin:
if (m_pressedPart != ThumbPart)
return false;
m_scrollPos = m_pressedPos;
return true;
case PlatformEvent::GestureScrollUpdate:
if (m_pressedPart != ThumbPart)
return false;
m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX() : evt.deltaY();
moveThumb(m_scrollPos, false);
return true;
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->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) {
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;
}
}
示例9: adoptRef
PassRefPtr<GestureEvent> GestureEvent::create(PassRefPtr<AbstractView> view, const PlatformGestureEvent& event)
{
AtomicString eventType;
float deltaX = 0;
float deltaY = 0;
switch (event.type()) {
case PlatformEvent::GestureScrollBegin:
eventType = EventTypeNames::gesturescrollstart; break;
case PlatformEvent::GestureScrollEnd:
eventType = EventTypeNames::gesturescrollend; break;
case PlatformEvent::GestureScrollUpdate:
case PlatformEvent::GestureScrollUpdateWithoutPropagation:
// Only deltaX/Y are used when converting this
// back to a PlatformGestureEvent.
eventType = EventTypeNames::gesturescrollupdate;
deltaX = event.deltaX();
deltaY = event.deltaY();
break;
case PlatformEvent::GestureTap:
eventType = EventTypeNames::gesturetap; break;
case PlatformEvent::GestureTapUnconfirmed:
eventType = EventTypeNames::gesturetapunconfirmed; break;
case PlatformEvent::GestureTapDown:
eventType = EventTypeNames::gesturetapdown; break;
case PlatformEvent::GestureShowPress:
eventType = EventTypeNames::gestureshowpress; break;
case PlatformEvent::GestureTwoFingerTap:
case PlatformEvent::GestureLongPress:
case PlatformEvent::GesturePinchBegin:
case PlatformEvent::GesturePinchEnd:
case PlatformEvent::GesturePinchUpdate:
case PlatformEvent::GestureTapDownCancel:
default:
return nullptr;
}
return adoptRef(new GestureEvent(eventType, view, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), deltaX, deltaY));
}
示例10: gestureEvent
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
{
bool handled = false;
switch (evt.type()) {
case PlatformEvent::GestureTapDown:
setPressedPart(theme()->hitTest(this, evt.position()));
m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y());
return true;
case PlatformEvent::GestureTapDownCancel:
case PlatformEvent::GestureScrollBegin:
if (m_pressedPart == ThumbPart) {
m_scrollPos = m_pressedPos;
return true;
}
break;
case PlatformEvent::GestureScrollUpdate:
case PlatformEvent::GestureScrollUpdateWithoutPropagation:
if (m_pressedPart == ThumbPart) {
m_scrollPos += HorizontalScrollbar ? evt.deltaX() : evt.deltaY();
moveThumb(m_scrollPos, false);
return true;
}
break;
case PlatformEvent::GestureScrollEnd:
m_scrollPos = 0;
break;
case PlatformEvent::GestureTap:
if (m_pressedPart != ThumbPart && m_pressedPart != NoPart)
handled = m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity());
break;
default:
break;
}
setPressedPart(NoPart);
m_pressedPos = 0;
return handled;
}
示例11: 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;
}
}