Combined separate horizontal/vertical mouse wheel event types

Instead of separate Event::MouseWheel{Vertical,Horizontal}Moved events, a single Event::MouseWheelScrolled event is used for all wheel-related events.
The new Mouse::Wheel enum is used to differentiate between mouse wheels.
This commit is contained in:
Jan Haller 2015-03-31 22:19:43 +02:00 committed by Lukas Dürrenberger
parent 534a23e074
commit 22c9674389
5 changed files with 88 additions and 85 deletions

View file

@ -381,18 +381,20 @@ void WindowImplCocoa::mouseWheelScrolledAt(float deltaX, float deltaY, int x, in
scaleOutXY(event.mouseWheel, m_delegate);
pushEvent(event);
event.type = Event::MouseWheelVerticalMoved;
event.mouseWheelVertical.delta = deltaY;
event.mouseWheelVertical.x = x;
event.mouseWheelVertical.y = y;
scaleOutXY(event.mouseWheelVertical, m_delegate);
event.type = Event::MouseWheelScrolled;
event.mouseWheelScroll.wheel = Mouse::VerticalWheel;
event.mouseWheelScroll.delta = deltaY;
event.mouseWheelScroll.x = x;
event.mouseWheelScroll.y = y;
scaleOutXY(event.mouseWheelScroll, m_delegate);
pushEvent(event);
event.type = Event::MouseWheelHorizontalMoved;
event.mouseWheelHorizontal.delta = deltaX;
event.mouseWheelHorizontal.x = x;
event.mouseWheelHorizontal.y = y;
scaleOutXY(event.mouseWheelHorizontal, m_delegate);
event.type = Event::MouseWheelScrolled;
event.mouseWheelScroll.wheel = Mouse::HorizontalWheel;
event.mouseWheelScroll.delta = deltaX;
event.mouseWheelScroll.x = x;
event.mouseWheelScroll.y = y;
scaleOutXY(event.mouseWheelScroll, m_delegate);
pushEvent(event);
}

View file

@ -2127,24 +2127,26 @@ bool WindowImplX11::processEvent(xcb_generic_event_t* windowEvent)
Event event;
event.type = Event::MouseWheelMoved;
event.mouseWheel.delta = button == XCB_BUTTON_INDEX_4 ? 1 : -1;
event.mouseWheel.delta = (button == XCB_BUTTON_INDEX_4) ? 1 : -1;
event.mouseWheel.x = e->event_x;
event.mouseWheel.y = e->event_y;
pushEvent(event);
event.type = Event::MouseWheelVerticalMoved;
event.mouseWheelVertical.delta = button == XCB_BUTTON_INDEX_4 ? 1 : -1;
event.mouseWheelVertical.x = e->event_x;
event.mouseWheelVertical.y = e->event_y;
event.type = Event::MouseWheelScrolled;
event.mouseWheelScroll.wheel = Mouse::VerticalWheel;
event.mouseWheelScroll.delta = (button == XCB_BUTTON_INDEX_4) ? 1 : -1;
event.mouseWheelScroll.x = e->event_x;
event.mouseWheelScroll.y = e->event_y;
pushEvent(event);
}
else if ((button == 6) || (button == 7))
{
Event event;
event.type = Event::MouseWheelHorizontalMoved;
event.mouseWheelHorizontal.delta = button == 6 ? 1 : -1;
event.mouseWheelHorizontal.x = e->event_x;
event.mouseWheelHorizontal.y = e->event_y;
event.type = Event::MouseWheelScrolled;
event.mouseWheelScroll.wheel = Mouse::HorizontalWheel;
event.mouseWheelScroll.delta = (button == 6) ? 1 : -1;
event.mouseWheelScroll.x = e->event_x;
event.mouseWheelScroll.y = e->event_y;
pushEvent(event);
}
break;

View file

@ -665,7 +665,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
break;
}
// Mouse wheel event
// Vertical mouse wheel event
case WM_MOUSEWHEEL:
{
// Mouse position is in screen coordinates, convert it to window coordinates
@ -684,16 +684,16 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
event.mouseWheel.y = position.y;
pushEvent(event);
event.type = Event::MouseWheelVerticalMoved;
event.mouseWheelVertical.delta = static_cast<float>(delta) / 120.f;
event.mouseWheelVertical.x = position.x;
event.mouseWheelVertical.y = position.y;
event.type = Event::MouseWheelScrolled;
event.mouseWheelScroll.wheel = Mouse::VerticalWheel;
event.mouseWheelScroll.delta = static_cast<float>(delta) / 120.f;
event.mouseWheelScroll.x = position.x;
event.mouseWheelScroll.y = position.y;
pushEvent(event);
break;
}
// Mouse wheel event
// Horizontal mouse wheel event
case WM_MOUSEHWHEEL:
{
// Mouse position is in screen coordinates, convert it to window coordinates
@ -705,10 +705,11 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
Int16 delta = static_cast<Int16>(HIWORD(wParam));
Event event;
event.type = Event::MouseWheelHorizontalMoved;
event.mouseWheelHorizontal.delta = -static_cast<float>(delta) / 120.f;
event.mouseWheelHorizontal.x = position.x;
event.mouseWheelHorizontal.y = position.y;
event.type = Event::MouseWheelScrolled;
event.mouseWheelScroll.wheel = Mouse::HorizontalWheel;
event.mouseWheelScroll.delta = -static_cast<float>(delta) / 120.f;
event.mouseWheelScroll.x = position.x;
event.mouseWheelScroll.y = position.y;
pushEvent(event);
break;
}