mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-29 14:42:26 +00:00
parent
d5bcb63f82
commit
b1766c28b2
@ -588,6 +588,12 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
|
||||
event->event_code = EVENT_LBUTTONDOWN;
|
||||
else if (ev.button.button == SDL_BUTTON_RIGHT)
|
||||
event->event_code = EVENT_RBUTTONDOWN;
|
||||
#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
|
||||
else if (ev.button.button == SDL_BUTTON_WHEELUP)
|
||||
event->event_code = EVENT_WHEELUP;
|
||||
else if (ev.button.button == SDL_BUTTON_WHEELDOWN)
|
||||
event->event_code = EVENT_WHEELDOWN;
|
||||
#endif
|
||||
else
|
||||
break;
|
||||
km.x = event->mouse.x = ev.motion.x;
|
||||
|
@ -54,6 +54,8 @@ public:
|
||||
EVENT_LBUTTONUP = 5,
|
||||
EVENT_RBUTTONDOWN = 6,
|
||||
EVENT_RBUTTONUP = 7,
|
||||
EVENT_WHEELUP = 8,
|
||||
EVENT_WHEELDOWN = 9,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -85,6 +85,11 @@ void ListWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
||||
}
|
||||
}
|
||||
|
||||
void ListWidget::handleMouseWheel(int x, int y, int direction)
|
||||
{
|
||||
_scrollBar->handleMouseWheel(x, y, direction);
|
||||
}
|
||||
|
||||
bool ListWidget::handleKeyDown(char key, int modifiers)
|
||||
{
|
||||
bool handled = true;
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
|
||||
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
||||
virtual void handleMouseUp(int x, int y, int button, int clickCount);
|
||||
virtual void handleMouseWheel(int x, int y, int direction);
|
||||
virtual bool handleKeyDown(char key, int modifiers);
|
||||
virtual bool handleKeyUp(char key, int modifiers);
|
||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||
|
@ -31,6 +31,7 @@
|
||||
* - Allow for a horizontal scrollbar, too?
|
||||
* - If there are less items than fit on one pages, no scrolling can be done
|
||||
* and we thus should not highlight the arrows/slider.
|
||||
* - Allow the mouse wheel to scroll more than one line at a time
|
||||
*/
|
||||
|
||||
#define UP_DOWN_BOX_HEIGHT 10
|
||||
@ -104,6 +105,23 @@ void ScrollBarWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
||||
_draggingPart = kNoPart;
|
||||
}
|
||||
|
||||
void ScrollBarWidget::handleMouseWheel(int x, int y, int direction)
|
||||
{
|
||||
int old_pos = _currentPos;
|
||||
|
||||
if (_numEntries < _entriesPerPage)
|
||||
return;
|
||||
|
||||
if (direction < 0) {
|
||||
_currentPos--;
|
||||
} else {
|
||||
_currentPos++;
|
||||
}
|
||||
|
||||
// Make sure that _currentPos is still inside the bounds
|
||||
checkBounds(old_pos);
|
||||
}
|
||||
|
||||
void ScrollBarWidget::handleMouseMoved(int x, int y, int button)
|
||||
{
|
||||
// Do nothing if there are less items than fit on one page
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
|
||||
void handleMouseDown(int x, int y, int button, int clickCount);
|
||||
void handleMouseUp(int x, int y, int button, int clickCount);
|
||||
void handleMouseWheel(int x, int y, int direction);
|
||||
void handleMouseMoved(int x, int y, int button);
|
||||
void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); }
|
||||
void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); _part = kNoPart; draw(); }
|
||||
|
@ -163,6 +163,21 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount)
|
||||
w->handleMouseUp(x - w->_x, y - w->_y, button, clickCount);
|
||||
}
|
||||
|
||||
void Dialog::handleMouseWheel(int x, int y, int direction)
|
||||
{
|
||||
Widget *w;
|
||||
|
||||
// This may look a bit backwards, but I think it makes more sense for
|
||||
// the mouse wheel to primarily affect the widget the mouse is at than
|
||||
// the widget that happens to be focused.
|
||||
|
||||
w = findWidget(x, y);
|
||||
if (!w)
|
||||
w = _focusedWidget;
|
||||
if (w)
|
||||
w->handleMouseWheel(x, y, direction);
|
||||
}
|
||||
|
||||
void Dialog::handleKeyDown(char key, int modifiers)
|
||||
{
|
||||
if (_focusedWidget) {
|
||||
|
@ -64,6 +64,7 @@ protected:
|
||||
virtual void handleTickle(); // Called periodically (in every guiloop() )
|
||||
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
||||
virtual void handleMouseUp(int x, int y, int button, int clickCount);
|
||||
virtual void handleMouseWheel(int x, int y, int direction);
|
||||
virtual void handleKeyDown(char key, int modifiers);
|
||||
virtual void handleKeyUp(char key, int modifiers);
|
||||
virtual void handleMouseMoved(int x, int y, int button);
|
||||
|
@ -169,6 +169,12 @@ void NewGui::runLoop()
|
||||
case OSystem::EVENT_RBUTTONUP:
|
||||
activeDialog->handleMouseUp(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count);
|
||||
break;
|
||||
case OSystem::EVENT_WHEELUP:
|
||||
activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, -1);
|
||||
break;
|
||||
case OSystem::EVENT_WHEELDOWN:
|
||||
activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,7 @@ public:
|
||||
virtual void handleMouseEntered(int button) {}
|
||||
virtual void handleMouseLeft(int button) {}
|
||||
virtual void handleMouseMoved(int x, int y, int button) {}
|
||||
virtual void handleMouseWheel(int x, int y, int direction) {}
|
||||
virtual bool handleKeyDown(char key, int modifiers) { return false; } // Return true if the event was handled
|
||||
virtual bool handleKeyUp(char key, int modifiers) { return false; } // Return true if the event was handled
|
||||
virtual void handleTickle() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user