mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-14 10:12:59 +02:00
Merge pull request #4865 from Laserlicht/touch_scroll_popup
allow scrolling in touch popups
This commit is contained in:
commit
2fed53d933
@ -83,16 +83,18 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin
|
||||
break;
|
||||
}
|
||||
case TouchState::TAP_DOWN_SHORT:
|
||||
case TouchState::TAP_DOWN_LONG_AWAIT:
|
||||
{
|
||||
Point distance = convertTouchToMouse(tfinger) - lastTapPosition;
|
||||
if ( std::abs(distance.x) > params.panningSensitivityThreshold || std::abs(distance.y) > params.panningSensitivityThreshold)
|
||||
{
|
||||
state = TouchState::TAP_DOWN_PANNING;
|
||||
state = state == TouchState::TAP_DOWN_SHORT ? TouchState::TAP_DOWN_PANNING : TouchState::TAP_DOWN_PANNING_POPUP;
|
||||
GH.events().dispatchGesturePanningStarted(lastTapPosition);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TouchState::TAP_DOWN_PANNING:
|
||||
case TouchState::TAP_DOWN_PANNING_POPUP:
|
||||
{
|
||||
emitPanningEvent(tfinger);
|
||||
break;
|
||||
@ -103,7 +105,6 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin
|
||||
break;
|
||||
}
|
||||
case TouchState::TAP_DOWN_LONG:
|
||||
case TouchState::TAP_DOWN_LONG_AWAIT:
|
||||
{
|
||||
// no-op
|
||||
break;
|
||||
@ -157,8 +158,11 @@ void InputSourceTouch::handleEventFingerDown(const SDL_TouchFingerEvent & tfinge
|
||||
CSH->getGlobalLobby().activateInterface();
|
||||
break;
|
||||
}
|
||||
case TouchState::TAP_DOWN_LONG:
|
||||
case TouchState::TAP_DOWN_LONG_AWAIT:
|
||||
lastTapPosition = convertTouchToMouse(tfinger);
|
||||
break;
|
||||
case TouchState::TAP_DOWN_LONG:
|
||||
case TouchState::TAP_DOWN_PANNING_POPUP:
|
||||
{
|
||||
// no-op
|
||||
break;
|
||||
@ -205,9 +209,10 @@ void InputSourceTouch::handleEventFingerUp(const SDL_TouchFingerEvent & tfinger)
|
||||
break;
|
||||
}
|
||||
case TouchState::TAP_DOWN_PANNING:
|
||||
case TouchState::TAP_DOWN_PANNING_POPUP:
|
||||
{
|
||||
GH.events().dispatchGesturePanningEnded(lastTapPosition, convertTouchToMouse(tfinger));
|
||||
state = TouchState::IDLE;
|
||||
state = state == TouchState::TAP_DOWN_PANNING ? TouchState::IDLE : TouchState::TAP_DOWN_LONG_AWAIT;
|
||||
break;
|
||||
}
|
||||
case TouchState::TAP_DOWN_DOUBLE:
|
||||
|
@ -45,6 +45,12 @@ enum class TouchState
|
||||
// UP -> transition to IDLE
|
||||
TAP_DOWN_PANNING,
|
||||
|
||||
// single finger is moving across screen
|
||||
// DOWN -> ignored
|
||||
// MOTION -> emit panning event
|
||||
// UP -> transition to TAP_DOWN_LONG_AWAIT
|
||||
TAP_DOWN_PANNING_POPUP,
|
||||
|
||||
// two fingers are touching the screen
|
||||
// DOWN -> ??? how to handle 3rd finger? Ignore?
|
||||
// MOTION -> emit pinch event
|
||||
@ -59,7 +65,7 @@ enum class TouchState
|
||||
|
||||
// right-click popup is active, waiting for new tap to hide popup
|
||||
// DOWN -> ignored
|
||||
// MOTION -> ignored
|
||||
// MOTION -> transition to TAP_DOWN_PANNING_POPUP
|
||||
// UP -> transition to IDLE, generate closePopup() event
|
||||
TAP_DOWN_LONG_AWAIT,
|
||||
};
|
||||
@ -79,7 +85,7 @@ struct TouchInputParameters
|
||||
uint32_t doubleTouchToleranceDistance = 50;
|
||||
|
||||
/// moving finger for distance larger than specified will be qualified as panning gesture instead of long press
|
||||
uint32_t panningSensitivityThreshold = 10;
|
||||
uint32_t panningSensitivityThreshold = 15;
|
||||
|
||||
/// gesture will be qualified as pinch if distance between fingers is at least specified here
|
||||
uint32_t pinchSensitivityThreshold = 10;
|
||||
|
Loading…
Reference in New Issue
Block a user