Use wxPoint instead of (x,y) pair in wxPanGestureEvent

Using higher level objects makes the code generating and using this
event shorter and more clear.
This commit is contained in:
Vadim Zeitlin
2017-11-21 17:34:51 +01:00
parent db71a10b29
commit bb2887930f
7 changed files with 70 additions and 91 deletions

View File

@@ -86,19 +86,22 @@ void MyGesturePanel::OnPan(wxPanGestureEvent& event)
wxLogMessage("Pan gesture started\n");
}
wxLogMessage("Pan gesture performed with deltaX = %d and deltaY = %d, with current position (%d,%d)\n",
event.GetDeltaX(), event.GetDeltaY(), event.GetPosition().x, event.GetPosition().y);
const wxPoint delta = event.GetDelta();
wxLogMessage("Pan gesture performed with delta = (%d,%d), "
"with current position (%d,%d)",
delta.x, delta.y,
event.GetPosition().x, event.GetPosition().y);
// Transform the distance using the tranpose of the matrix,
// Transform the distance using the transpose of the matrix,
// in order to translate the image to match the screen coordinates
wxMatrix2D m;
m_affineMatrix.Get(&m, NULL);
wxPoint2DDouble delta(m.m_11 * event.GetDeltaX() + m.m_12 * event.GetDeltaY(),
m.m_21 * event.GetDeltaX() + m.m_22 * event.GetDeltaY());
wxPoint2DDouble deltaD(m.m_11 * delta.x + m.m_12 * delta.y,
m.m_21 * delta.x + m.m_22 * delta.y);
// Add it to the total translation
m_translateDistance += delta;
m_translateDistance += deltaD;
if ( event.IsGestureEnd() )
{