FIRE-30873: Correct click error when infinite scrolling
parent
68ae9e3604
commit
868f1c5a21
|
|
@ -120,8 +120,12 @@ void FSVirtualTrackpad::determineThumbClickError(S32 x, S32 y)
|
|||
_thumbClickOffsetX = 0;
|
||||
_thumbClickOffsetY = 0;
|
||||
|
||||
S32 errorX = _valueX - x;
|
||||
S32 errorY = _valueY - y;
|
||||
S32 errorX = _valueX;
|
||||
S32 errorY = _valueY;
|
||||
wrapOrClipCursorPosition(&errorX, &errorY);
|
||||
errorX -= x;
|
||||
errorY -= y;
|
||||
|
||||
if (fabs(errorX) > mImgSunFront->getWidth() / 2.0)
|
||||
return;
|
||||
if (fabs(errorY) > mImgSunFront->getHeight() / 2.0)
|
||||
|
|
@ -131,6 +135,36 @@ void FSVirtualTrackpad::determineThumbClickError(S32 x, S32 y)
|
|||
_thumbClickOffsetY = errorY;
|
||||
}
|
||||
|
||||
void FSVirtualTrackpad::updateClickErrorIfInfiniteScrolling()
|
||||
{
|
||||
if (!mInfiniteScrollMode)
|
||||
return;
|
||||
S32 errorX = _valueX;
|
||||
S32 errorY = _valueY;
|
||||
|
||||
LLRect rect = mTouchArea->getRect();
|
||||
while (errorX > rect.mRight)
|
||||
{
|
||||
errorX -= rect.getWidth();
|
||||
_thumbClickOffsetX += rect.getWidth();
|
||||
}
|
||||
while (errorX < rect.mLeft)
|
||||
{
|
||||
errorX += rect.getWidth();
|
||||
_thumbClickOffsetX -= rect.getWidth();
|
||||
}
|
||||
while (errorY > rect.mTop)
|
||||
{
|
||||
errorY -= rect.getHeight();
|
||||
_thumbClickOffsetY += rect.getHeight();
|
||||
}
|
||||
while (errorY < rect.mBottom)
|
||||
{
|
||||
errorY += rect.getHeight();
|
||||
_thumbClickOffsetY -= rect.getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
void FSVirtualTrackpad::determineThumbClickErrorForPinch(S32 x, S32 y)
|
||||
{
|
||||
if (!mTouchArea)
|
||||
|
|
@ -141,8 +175,12 @@ void FSVirtualTrackpad::determineThumbClickErrorForPinch(S32 x, S32 y)
|
|||
_pinchThumbClickOffsetX = 0;
|
||||
_pinchThumbClickOffsetY = 0;
|
||||
|
||||
S32 errorX = _pinchValueX - x;
|
||||
S32 errorY = _pinchValueY - y;
|
||||
S32 errorX = _pinchValueX;
|
||||
S32 errorY = _pinchValueY;
|
||||
wrapOrClipCursorPosition(&errorX, &errorY);
|
||||
errorX -= x;
|
||||
errorY -= y;
|
||||
|
||||
if (fabs(errorX) > mImgMoonFront->getWidth() / 2.0)
|
||||
return;
|
||||
if (fabs(errorY) > mImgMoonFront->getHeight() / 2.0)
|
||||
|
|
@ -152,6 +190,36 @@ void FSVirtualTrackpad::determineThumbClickErrorForPinch(S32 x, S32 y)
|
|||
_pinchThumbClickOffsetY = errorY;
|
||||
}
|
||||
|
||||
void FSVirtualTrackpad::updateClickErrorIfInfiniteScrollingForPinch()
|
||||
{
|
||||
if (!mInfiniteScrollMode)
|
||||
return;
|
||||
S32 errorX = _valueX;
|
||||
S32 errorY = _valueY;
|
||||
|
||||
LLRect rect = mTouchArea->getRect();
|
||||
while (errorX > rect.mRight)
|
||||
{
|
||||
errorX -= rect.getWidth();
|
||||
_pinchThumbClickOffsetX += rect.getWidth();
|
||||
}
|
||||
while (errorX < rect.mLeft)
|
||||
{
|
||||
errorX += rect.getWidth();
|
||||
_pinchThumbClickOffsetX -= rect.getWidth();
|
||||
}
|
||||
while (errorY > rect.mTop)
|
||||
{
|
||||
errorY -= rect.getHeight();
|
||||
_pinchThumbClickOffsetY += rect.getHeight();
|
||||
}
|
||||
while (errorY < rect.mBottom)
|
||||
{
|
||||
errorY += rect.getHeight();
|
||||
_pinchThumbClickOffsetY -= rect.getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
void FSVirtualTrackpad::draw()
|
||||
{
|
||||
mImgSphere->draw(mTouchArea->getRect(), mTouchArea->isInEnabledChain() ? UI_VERTEX_COLOR : UI_VERTEX_COLOR % 0.5f);
|
||||
|
|
@ -335,6 +403,7 @@ bool FSVirtualTrackpad::handleMouseDown(S32 x, S32 y, MASK mask)
|
|||
if (isPointInTouchArea(x, y))
|
||||
{
|
||||
determineThumbClickError(x, y);
|
||||
updateClickErrorIfInfiniteScrolling();
|
||||
_valueWheelClicks = 0;
|
||||
_lastValueX = _valueX;
|
||||
_lastValueY = _valueY;
|
||||
|
|
@ -369,6 +438,7 @@ bool FSVirtualTrackpad::handleRightMouseDown(S32 x, S32 y, MASK mask)
|
|||
if (isPointInTouchArea(x, y))
|
||||
{
|
||||
determineThumbClickErrorForPinch(x, y);
|
||||
updateClickErrorIfInfiniteScrollingForPinch();
|
||||
_pinchValueWheelClicks = 0;
|
||||
_lastPinchValueX = _pinchValueX;
|
||||
_lastPinchValueY = _pinchValueY;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,9 @@ private:
|
|||
void wrapOrClipCursorPosition(S32* x, S32* y);
|
||||
|
||||
void determineThumbClickError(S32 x, S32 y);
|
||||
void updateClickErrorIfInfiniteScrolling();
|
||||
void determineThumbClickErrorForPinch(S32 x, S32 y);
|
||||
void updateClickErrorIfInfiniteScrollingForPinch();
|
||||
|
||||
|
||||
LLVector3 normalizePixelPos(S32 x, S32 y, S32 z) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue