Properly integrate MouseButton enum into the GUI core:

- The previous code used enumerations for DialogContainer, and constants for everything in src/gui
 - It took me over 3 hours to determine that a '1' in the first didn't mean the same as a '1' in the second
 - If ever there was a reason for strongly named constants (enum class), this was it.
This commit is contained in:
Stephen Anthony 2017-12-29 16:56:09 -03:30
parent 542fed69ed
commit a15d5d8b06
43 changed files with 152 additions and 153 deletions

View File

@ -60,7 +60,7 @@ void EventHandlerSDL2::pollEvent()
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
{ {
handleMouseMotionEvent(myEvent.motion.x, myEvent.motion.y, handleMouseMotionEvent(myEvent.motion.x, myEvent.motion.y,
myEvent.motion.xrel, myEvent.motion.yrel, 0); myEvent.motion.xrel, myEvent.motion.yrel);
break; break;
} }

View File

@ -251,7 +251,7 @@ void DataGridWidget::setRange(int lower, int upper)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::handleMouseDown(int x, int y, int button, int clickCount) void DataGridWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
if (!isEnabled()) if (!isEnabled())
return; return;
@ -277,7 +277,7 @@ void DataGridWidget::handleMouseDown(int x, int y, int button, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::handleMouseUp(int x, int y, int button, int clickCount) void DataGridWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
// If this was a double click and the mouse is still over the selected item, // If this was a double click and the mouse is still over the selected item,
// send the double click command // send the double click command

View File

@ -97,8 +97,8 @@ class DataGridWidget : public EditableWidget
void receivedFocusWidget() override; void receivedFocusWidget() override;
void lostFocusWidget() override; void lostFocusWidget() override;
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
bool handleText(char text) override; bool handleText(char text) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;

View File

@ -106,7 +106,7 @@ void PromptWidget::drawWidget(bool hilite)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::handleMouseDown(int x, int y, int button, int clickCount) void PromptWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
// cerr << "PromptWidget::handleMouseDown\n"; // cerr << "PromptWidget::handleMouseDown\n";
} }

View File

@ -71,7 +71,7 @@ class PromptWidget : public Widget, public CommandSender
void addToHistory(const char *str); void addToHistory(const char *str);
void historyScroll(int direction); void historyScroll(int direction);
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
bool handleText(char text) override; bool handleText(char text) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;

View File

@ -123,12 +123,12 @@ void RomListSettings::loadConfig()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListSettings::handleMouseDown(int x, int y, int button, int clickCount) void RomListSettings::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
// Close dialog if mouse click is outside it (simulates a context menu) // Close dialog if mouse click is outside it (simulates a context menu)
// Otherwise let the base dialog class process it // Otherwise let the base dialog class process it
if(x >= 0 && x < _w && y >= 0 && y < _h) if(x >= 0 && x < _w && y >= 0 && y < _h)
Dialog::handleMouseDown(x, y, button, clickCount); Dialog::handleMouseDown(x, y, b, clickCount);
else else
close(); close();
} }

View File

@ -52,7 +52,7 @@ class RomListSettings : public Dialog, public CommandSender
private: private:
void loadConfig() override; void loadConfig() override;
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -238,13 +238,13 @@ void RomListWidget::scrollToCurrent(int item)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount) void RomListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
if (!isEnabled()) if (!isEnabled())
return; return;
// Grab right mouse button for context menu, left for selection/edit mode // Grab right mouse button for context menu, left for selection/edit mode
if(button == 2) if(b == MouseButton::RIGHT)
{ {
// Set selected and add menu at current x,y mouse location // Set selected and add menu at current x,y mouse location
_selectedItem = findItem(x, y); _selectedItem = findItem(x, y);
@ -270,7 +270,7 @@ void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::handleMouseUp(int x, int y, int button, int clickCount) void RomListWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
// If this was a double click and the mouse is still over the selected item, // If this was a double click and the mouse is still over the selected item,
// send the double click command // send the double click command

View File

@ -58,8 +58,8 @@ class RomListWidget : public EditableWidget
void setHighlighted(int item); void setHighlighted(int item);
protected: protected:
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
bool handleText(char text) override; bool handleText(char text) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;

View File

@ -112,7 +112,7 @@ TiaInfoWidget::TiaInfoWidget(GuiObject* boss, const GUI::Font& lfont,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaInfoWidget::handleMouseDown(int x, int y, int button, int clickCount) void TiaInfoWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
//cerr << "TiaInfoWidget button press: x = " << x << ", y = " << y << endl; //cerr << "TiaInfoWidget button press: x = " << x << ", y = " << y << endl;
} }

View File

@ -49,7 +49,7 @@ class TiaInfoWidget : public Widget, public CommandSender
CheckboxWidget* myVBlank; CheckboxWidget* myVBlank;
private: private:
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -92,10 +92,10 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaOutputWidget::handleMouseDown(int x, int y, int button, int clickCount) void TiaOutputWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
// Grab right mouse button for command context menu // Grab right mouse button for command context menu
if(button == 2) if(b == MouseButton::RIGHT)
{ {
myClickX = x; myClickX = x;
myClickY = y; myClickY = y;

View File

@ -42,7 +42,7 @@ class TiaOutputWidget : public Widget, public CommandSender
// For example, clicking an area may cause an action // For example, clicking an area may cause an action
// (fill to this scanline, etc). // (fill to this scanline, etc).
/* /*
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;
bool handleKeyUp(StellaKey key, StellaMod mod) override; bool handleKeyUp(StellaKey key, StellaMod mod) override;
@ -58,7 +58,7 @@ class TiaOutputWidget : public Widget, public CommandSender
uInt32 myLineBuffer[320]; uInt32 myLineBuffer[320];
private: private:
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
void drawWidget(bool hilite) override; void drawWidget(bool hilite) override;

View File

@ -102,18 +102,18 @@ void TiaZoomWidget::recalc()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::handleMouseDown(int x, int y, int button, int clickCount) void TiaZoomWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
// Button 1 is for 'drag'/movement of the image // Button 1 is for 'drag'/movement of the image
// Button 2 is for context menu // Button 2 is for context menu
if(button == 1) if(b == MouseButton::LEFT)
{ {
// Indicate mouse drag started/in progress // Indicate mouse drag started/in progress
myMouseMoving = true; myMouseMoving = true;
myXClick = x; myXClick = x;
myYClick = y; myYClick = y;
} }
else if(button == 2) else if(b == MouseButton::RIGHT)
{ {
// Add menu at current x,y mouse location // Add menu at current x,y mouse location
myMenu->show(x + getAbsX(), y + getAbsY()); myMenu->show(x + getAbsX(), y + getAbsY());
@ -121,7 +121,7 @@ void TiaZoomWidget::handleMouseDown(int x, int y, int button, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::handleMouseUp(int x, int y, int button, int clickCount) void TiaZoomWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
myMouseMoving = false; myMouseMoving = false;
} }
@ -136,7 +136,7 @@ void TiaZoomWidget::handleMouseWheel(int x, int y, int direction)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::handleMouseMoved(int x, int y, int button) void TiaZoomWidget::handleMouseMoved(int x, int y)
{ {
// TODO: Not yet working - finish for next release // TODO: Not yet working - finish for next release
#if 0 #if 0
@ -165,7 +165,7 @@ void TiaZoomWidget::handleMouseMoved(int x, int y, int button)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::handleMouseLeft(int button) void TiaZoomWidget::handleMouseLeft()
{ {
myMouseMoving = false; myMouseMoving = false;
} }

View File

@ -39,11 +39,11 @@ class TiaZoomWidget : public Widget, public CommandSender
void zoom(int level); void zoom(int level);
void recalc(); void recalc();
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
void handleMouseMoved(int x, int y, int button) override; void handleMouseMoved(int x, int y) override;
void handleMouseLeft(int button) override; void handleMouseLeft() override;
bool handleEvent(Event::Type event) override; bool handleEvent(Event::Type event) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;

View File

@ -41,7 +41,7 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ToggleWidget::handleMouseDown(int x, int y, int button, int clickCount) void ToggleWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
if (!isEnabled()) if (!isEnabled())
return; return;
@ -62,7 +62,7 @@ void ToggleWidget::handleMouseDown(int x, int y, int button, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ToggleWidget::handleMouseUp(int x, int y, int button, int clickCount) void ToggleWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
if (!isEnabled() || !_editable) if (!isEnabled() || !_editable)
return; return;

View File

@ -66,8 +66,8 @@ class ToggleWidget : public Widget, public CommandSender
void drawWidget(bool hilite) override = 0; void drawWidget(bool hilite) override = 0;
int findItem(int x, int y); int findItem(int x, int y);
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;

View File

@ -648,7 +648,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::handleMouseMotionEvent(int x, int y, int xrel, int yrel, int button) void EventHandler::handleMouseMotionEvent(int x, int y, int xrel, int yrel)
{ {
// Determine which mode we're in, then send the event to the appropriate place // Determine which mode we're in, then send the event to the appropriate place
if(myState == EventHandlerState::EMULATION) if(myState == EventHandlerState::EMULATION)
@ -661,7 +661,7 @@ void EventHandler::handleMouseMotionEvent(int x, int y, int xrel, int yrel, int
mySkipMouseMotion = false; mySkipMouseMotion = false;
} }
else if(myOverlay) else if(myOverlay)
myOverlay->handleMouseMotionEvent(x, y, button); myOverlay->handleMouseMotionEvent(x, y);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -304,7 +304,7 @@ class EventHandler
*/ */
void handleTextEvent(char text); void handleTextEvent(char text);
void handleKeyEvent(StellaKey key, StellaMod mod, bool state); void handleKeyEvent(StellaKey key, StellaMod mod, bool state);
void handleMouseMotionEvent(int x, int y, int xrel, int yrel, int button); void handleMouseMotionEvent(int x, int y, int xrel, int yrel);
void handleMouseButtonEvent(MouseButton b, bool pressed, int x, int y); void handleMouseButtonEvent(MouseButton b, bool pressed, int x, int y);
void handleJoyEvent(int stick, int button, uInt8 state); void handleJoyEvent(int stick, int button, uInt8 state);
void handleJoyAxisEvent(int stick, int axis, int value); void handleJoyAxisEvent(int stick, int axis, int value);

View File

@ -20,21 +20,22 @@
// Enumeration representing the different states of operation // Enumeration representing the different states of operation
enum class EventHandlerState { enum class EventHandlerState {
NONE,
EMULATION, EMULATION,
TIMEMACHINE, TIMEMACHINE,
PAUSE, PAUSE,
LAUNCHER, LAUNCHER,
OPTIONSMENU, OPTIONSMENU,
CMDMENU, CMDMENU,
DEBUGGER DEBUGGER,
NONE
}; };
enum class MouseButton { enum class MouseButton {
LEFT, LEFT,
RIGHT, RIGHT,
WHEELDOWN, WHEELDOWN,
WHEELUP WHEELUP,
NONE
}; };
enum class JoyHat { enum class JoyHat {

View File

@ -164,7 +164,7 @@ bool CheckListWidget::handleEvent(Event::Type e)
{ {
case Event::UISelect: case Event::UISelect:
// Simulate a mouse button click // Simulate a mouse button click
_checkList[ListWidget::getSelected()]->handleMouseUp(0, 0, 1, 0); _checkList[ListWidget::getSelected()]->handleMouseUp(0, 0, MouseButton::LEFT, 0);
return true; return true;
default: default:

View File

@ -233,13 +233,13 @@ bool ContextMenu::sendSelectionLast()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleMouseDown(int x, int y, int button, int clickCount) void ContextMenu::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
// Compute over which item the mouse is... // Compute over which item the mouse is...
int item = findItem(x, y); int item = findItem(x, y);
// Only do a selection when the left button is in the dialog // Only do a selection when the left button is in the dialog
if(button == 1) if(b == MouseButton::LEFT)
{ {
if(item != -1) if(item != -1)
{ {
@ -252,7 +252,7 @@ void ContextMenu::handleMouseDown(int x, int y, int button, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleMouseMoved(int x, int y, int button) void ContextMenu::handleMouseMoved(int x, int y)
{ {
// Compute over which item the mouse is... // Compute over which item the mouse is...
int item = findItem(x, y); int item = findItem(x, y);
@ -264,7 +264,7 @@ void ContextMenu::handleMouseMoved(int x, int y, int button)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ContextMenu::handleMouseClicks(int x, int y, int button) bool ContextMenu::handleMouseClicks(int x, int y, MouseButton b)
{ {
// Let continuous mouse clicks come through, as the scroll buttons need them // Let continuous mouse clicks come through, as the scroll buttons need them
return true; return true;

View File

@ -82,9 +82,9 @@ class ContextMenu : public Dialog, public CommandSender
bool sendSelectionLast(); bool sendSelectionLast();
private: private:
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseMoved(int x, int y, int button) override; void handleMouseMoved(int x, int y) override;
bool handleMouseClicks(int x, int y, int button) override; bool handleMouseClicks(int x, int y, MouseButton b) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
void handleKeyDown(StellaKey key, StellaMod mod) override; void handleKeyDown(StellaKey key, StellaMod mod) override;
void handleJoyDown(int stick, int button) override; void handleJoyDown(int stick, int button) override;

View File

@ -90,7 +90,7 @@ void Dialog::close(bool refresh)
{ {
if (_mouseWidget) if (_mouseWidget)
{ {
_mouseWidget->handleMouseLeft(0); _mouseWidget->handleMouseLeft();
_mouseWidget = nullptr; _mouseWidget = nullptr;
} }
@ -377,7 +377,7 @@ void Dialog::handleKeyUp(StellaKey key, StellaMod mod)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleMouseDown(int x, int y, int button, int clickCount) void Dialog::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
Widget* w = findWidget(x, y); Widget* w = findWidget(x, y);
@ -386,11 +386,11 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount)
if(w) if(w)
w->handleMouseDown(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), w->handleMouseDown(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y),
button, clickCount); b, clickCount);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleMouseUp(int x, int y, int button, int clickCount) void Dialog::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
if(_focusedWidget) if(_focusedWidget)
{ {
@ -402,7 +402,7 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount)
Widget* w = _dragWidget; Widget* w = _dragWidget;
if(w) if(w)
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y),
button, clickCount); b, clickCount);
_dragWidget = nullptr; _dragWidget = nullptr;
} }
@ -422,7 +422,7 @@ void Dialog::handleMouseWheel(int x, int y, int direction)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleMouseMoved(int x, int y, int button) void Dialog::handleMouseMoved(int x, int y)
{ {
Widget* w; Widget* w;
@ -438,17 +438,17 @@ void Dialog::handleMouseMoved(int x, int y, int button)
if(mouseInFocusedWidget && _mouseWidget != w) if(mouseInFocusedWidget && _mouseWidget != w)
{ {
if(_mouseWidget) if(_mouseWidget)
_mouseWidget->handleMouseLeft(button); _mouseWidget->handleMouseLeft();
_mouseWidget = w; _mouseWidget = w;
w->handleMouseEntered(button); w->handleMouseEntered();
} }
else if (!mouseInFocusedWidget && _mouseWidget == w) else if (!mouseInFocusedWidget && _mouseWidget == w)
{ {
_mouseWidget = nullptr; _mouseWidget = nullptr;
w->handleMouseLeft(button); w->handleMouseLeft();
} }
w->handleMouseMoved(x - wx, y - wy, button); w->handleMouseMoved(x - wx, y - wy);
} }
// While a "drag" is in process (i.e. mouse is moved while a button is pressed), // While a "drag" is in process (i.e. mouse is moved while a button is pressed),
@ -461,24 +461,24 @@ void Dialog::handleMouseMoved(int x, int y, int button)
if (_mouseWidget != w) if (_mouseWidget != w)
{ {
if (_mouseWidget) if (_mouseWidget)
_mouseWidget->handleMouseLeft(button); _mouseWidget->handleMouseLeft();
if (w) if (w)
w->handleMouseEntered(button); w->handleMouseEntered();
_mouseWidget = w; _mouseWidget = w;
} }
if (w && (w->getFlags() & WIDGET_TRACK_MOUSE)) if (w && (w->getFlags() & WIDGET_TRACK_MOUSE))
w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button); w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Dialog::handleMouseClicks(int x, int y, int button) bool Dialog::handleMouseClicks(int x, int y, MouseButton b)
{ {
Widget* w = findWidget(x, y); Widget* w = findWidget(x, y);
if(w) if(w)
return w->handleMouseClicks(x - (w->getAbsX() - _x), return w->handleMouseClicks(x - (w->getAbsX() - _x),
y - (w->getAbsY() - _y), button); y - (w->getAbsY() - _y), b);
else else
return false; return false;
} }

View File

@ -86,11 +86,11 @@ class Dialog : public GuiObject
virtual void handleText(char text); virtual void handleText(char text);
virtual void handleKeyDown(StellaKey key, StellaMod modifiers); virtual void handleKeyDown(StellaKey key, StellaMod modifiers);
virtual void handleKeyUp(StellaKey key, StellaMod modifiers); virtual void handleKeyUp(StellaKey key, StellaMod modifiers);
virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseDown(int x, int y, MouseButton b, int clickCount);
virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, MouseButton b, int clickCount);
virtual void handleMouseWheel(int x, int y, int direction); virtual void handleMouseWheel(int x, int y, int direction);
virtual void handleMouseMoved(int x, int y, int button); virtual void handleMouseMoved(int x, int y);
virtual bool handleMouseClicks(int x, int y, int button); virtual bool handleMouseClicks(int x, int y, MouseButton b);
virtual void handleJoyDown(int stick, int button); virtual void handleJoyDown(int stick, int button);
virtual void handleJoyUp(int stick, int button); virtual void handleJoyUp(int stick, int button);
virtual void handleJoyAxis(int stick, int axis, int value); virtual void handleJoyAxis(int stick, int axis, int value);

View File

@ -65,11 +65,11 @@ void DialogContainer::updateTime(uInt64 time)
} }
// Mouse button still pressed // Mouse button still pressed
if(myCurrentMouseDown.button != -1 && myClickRepeatTime < myTime) if(myCurrentMouseDown.b != MouseButton::NONE && myClickRepeatTime < myTime)
{ {
activeDialog->handleMouseDown(myCurrentMouseDown.x - activeDialog->_x, activeDialog->handleMouseDown(myCurrentMouseDown.x - activeDialog->_x,
myCurrentMouseDown.y - activeDialog->_y, myCurrentMouseDown.y - activeDialog->_y,
myCurrentMouseDown.button, 1); myCurrentMouseDown.b, 1);
myClickRepeatTime = myTime + kRepeatSustainDelay; myClickRepeatTime = myTime + kRepeatSustainDelay;
} }
@ -182,7 +182,7 @@ void DialogContainer::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DialogContainer::handleMouseMotionEvent(int x, int y, int button) void DialogContainer::handleMouseMotionEvent(int x, int y)
{ {
if(myDialogStack.empty()) if(myDialogStack.empty())
return; return;
@ -190,9 +190,7 @@ void DialogContainer::handleMouseMotionEvent(int x, int y, int button)
// Send the event to the dialog box on the top of the stack // Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top(); Dialog* activeDialog = myDialogStack.top();
activeDialog->surface().translateCoords(x, y); activeDialog->surface().translateCoords(x, y);
activeDialog->handleMouseMoved(x - activeDialog->_x, activeDialog->handleMouseMoved(x - activeDialog->_x, y - activeDialog->_y);
y - activeDialog->_y,
button);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -206,7 +204,6 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
Dialog* activeDialog = myDialogStack.top(); Dialog* activeDialog = myDialogStack.top();
activeDialog->surface().translateCoords(x, y); activeDialog->surface().translateCoords(x, y);
int button = b == MouseButton::LEFT ? 1 : 2;
switch(b) switch(b)
{ {
case MouseButton::LEFT: case MouseButton::LEFT:
@ -237,27 +234,26 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
// Now account for repeated mouse events (click and hold), but only // Now account for repeated mouse events (click and hold), but only
// if the dialog wants them // if the dialog wants them
if(activeDialog->handleMouseClicks(x - activeDialog->_x, y - activeDialog->_y, if(activeDialog->handleMouseClicks(x - activeDialog->_x, y - activeDialog->_y, b))
button))
{ {
myCurrentMouseDown.x = x; myCurrentMouseDown.x = x;
myCurrentMouseDown.y = y; myCurrentMouseDown.y = y;
myCurrentMouseDown.button = button; myCurrentMouseDown.b = b;
myClickRepeatTime = myTime + kRepeatInitialDelay; myClickRepeatTime = myTime + kRepeatInitialDelay;
} }
else else
myCurrentMouseDown.button = -1; myCurrentMouseDown.b = MouseButton::NONE;
activeDialog->handleMouseDown(x - activeDialog->_x, y - activeDialog->_y, activeDialog->handleMouseDown(x - activeDialog->_x, y - activeDialog->_y,
button, myLastClick.count); b, myLastClick.count);
} }
else else
{ {
activeDialog->handleMouseUp(x - activeDialog->_x, y - activeDialog->_y, activeDialog->handleMouseUp(x - activeDialog->_x, y - activeDialog->_y,
button, myLastClick.count); b, myLastClick.count);
if(button == myCurrentMouseDown.button) if(b == myCurrentMouseDown.b)
myCurrentMouseDown.button = -1; myCurrentMouseDown.b = MouseButton::NONE;
} }
break; break;
@ -268,6 +264,9 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
case MouseButton::WHEELDOWN: case MouseButton::WHEELDOWN:
activeDialog->handleMouseWheel(x - activeDialog->_x, y - activeDialog->_y, 1); activeDialog->handleMouseWheel(x - activeDialog->_x, y - activeDialog->_y, 1);
break; break;
case MouseButton::NONE: // should never get here
break;
} }
} }
@ -346,7 +345,7 @@ void DialogContainer::handleJoyHatEvent(int stick, int hat, JoyHat value)
void DialogContainer::reset() void DialogContainer::reset()
{ {
myCurrentKeyDown.keycode = KBDK_UNKNOWN; myCurrentKeyDown.keycode = KBDK_UNKNOWN;
myCurrentMouseDown.button = -1; myCurrentMouseDown.b = MouseButton::NONE;
myLastClick.x = myLastClick.y = 0; myLastClick.x = myLastClick.y = 0;
myLastClick.time = 0; myLastClick.time = 0;
myLastClick.count = 0; myLastClick.count = 0;

View File

@ -77,11 +77,10 @@ class DialogContainer
/** /**
Handle a mouse motion event. Handle a mouse motion event.
@param x The x location @param x The x location
@param y The y location @param y The y location
@param button The currently pressed button
*/ */
void handleMouseMotionEvent(int x, int y, int button); void handleMouseMotionEvent(int x, int y);
/** /**
Handle a mouse button event. Handle a mouse button event.
@ -174,7 +173,7 @@ class DialogContainer
struct { struct {
int x; int x;
int y; int y;
int button; MouseButton b;
} myCurrentMouseDown; } myCurrentMouseDown;
uInt64 myClickRepeatTime; uInt64 myClickRepeatTime;

View File

@ -41,7 +41,7 @@ void EditTextWidget::setText(const string& str, bool changed)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) void EditTextWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
if(!isEditable()) if(!isEditable())
return; return;

View File

@ -42,7 +42,7 @@ class EditTextWidget : public EditableWidget
GUI::Rect getEditRect() const override; GUI::Rect getEditRect() const override;
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
protected: protected:
string _backupString; string _backupString;

View File

@ -432,16 +432,16 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::handleMouseDown(int x, int y, int button, int clickCount) void LauncherDialog::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
// Grab right mouse button for context menu, send left to base class // Grab right mouse button for context menu, send left to base class
if(button == 2) if(b == MouseButton::RIGHT)
{ {
// Add menu at current x,y mouse location // Add menu at current x,y mouse location
myMenu->show(x + getAbsX(), y + getAbsY()); myMenu->show(x + getAbsX(), y + getAbsY());
} }
else else
Dialog::handleMouseDown(x, y, button, clickCount); Dialog::handleMouseDown(x, y, b, clickCount);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -79,7 +79,7 @@ class LauncherDialog : public Dialog
private: private:
void handleKeyDown(StellaKey key, StellaMod mod) override; void handleKeyDown(StellaKey key, StellaMod mod) override;
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
void loadConfig() override; void loadConfig() override;

View File

@ -191,7 +191,7 @@ void ListWidget::scrollBarRecalc()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::handleMouseDown(int x, int y, int button, int clickCount) void ListWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
if (!isEnabled()) if (!isEnabled())
return; return;
@ -216,7 +216,7 @@ void ListWidget::handleMouseDown(int x, int y, int button, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ListWidget::handleMouseUp(int x, int y, int button, int clickCount) void ListWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
// If this was a double click and the mouse is still over the selected item, // If this was a double click and the mouse is still over the selected item,
// send the double click command // send the double click command

View File

@ -65,8 +65,8 @@ class ListWidget : public EditableWidget
static void setQuickSelectDelay(uInt64 time) { _QUICK_SELECT_DELAY = time; } static void setQuickSelectDelay(uInt64 time) { _QUICK_SELECT_DELAY = time; }
protected: protected:
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
bool handleText(char text) override; bool handleText(char text) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;

View File

@ -131,7 +131,7 @@ const Variant& PopUpWidget::getSelectedTag() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount) void PopUpWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
if(isEnabled() && !myMenu->isVisible()) if(isEnabled() && !myMenu->isVisible())
{ {
@ -159,14 +159,14 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction)
#ifdef FLAT_UI #ifdef FLAT_UI
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseEntered(int button) void PopUpWidget::handleMouseEntered()
{ {
setFlags(WIDGET_HILITED); setFlags(WIDGET_HILITED);
setDirty(); setDirty();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseLeft(int button) void PopUpWidget::handleMouseLeft()
{ {
clearFlags(WIDGET_HILITED); clearFlags(WIDGET_HILITED);
setDirty(); setDirty();
@ -182,7 +182,7 @@ bool PopUpWidget::handleEvent(Event::Type e)
switch(e) switch(e)
{ {
case Event::UISelect: case Event::UISelect:
handleMouseDown(0, 0, 1, 0); handleMouseDown(0, 0, MouseButton::LEFT, 0);
return true; return true;
case Event::UIUp: case Event::UIUp:
case Event::UILeft: case Event::UILeft:

View File

@ -62,11 +62,11 @@ class PopUpWidget : public Widget, public CommandSender
bool wantsFocus() const override { return true; } bool wantsFocus() const override { return true; }
protected: protected:
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
#ifdef FLAT_UI #ifdef FLAT_UI
void handleMouseEntered(int button) override; void handleMouseEntered() override;
void handleMouseLeft(int button) override; void handleMouseLeft() override;
#endif #endif
bool handleEvent(Event::Type e) override; bool handleEvent(Event::Type e) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;

View File

@ -173,7 +173,7 @@ RadioButtonWidget::RadioButtonWidget(GuiObject* boss, const GUI::Font& font,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RadioButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) void RadioButtonWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
if(isEnabled() && _editable && x >= 0 && x < _w && y >= 0 && y < _h) if(isEnabled() && _editable && x >= 0 && x < _w && y >= 0 && y < _h)
{ {

View File

@ -34,7 +34,7 @@ class RadioButtonWidget : public CheckboxWidget
const string& label, RadioButtonGroup* group, const string& label, RadioButtonGroup* group,
int cmd = 0); int cmd = 0);
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void setState(bool state, bool send = true); void setState(bool state, bool send = true);
protected: protected:

View File

@ -74,7 +74,7 @@ ScrollBarWidget::ScrollBarWidget(GuiObject* boss, const GUI::Font& font,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseDown(int x, int y, int button, void ScrollBarWidget::handleMouseDown(int x, int y, MouseButton b,
int clickCount) int clickCount)
{ {
// Ignore subsequent mouse clicks when the slider is being moved // Ignore subsequent mouse clicks when the slider is being moved
@ -118,7 +118,7 @@ void ScrollBarWidget::handleMouseDown(int x, int y, int button,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseUp(int x, int y, int button, void ScrollBarWidget::handleMouseUp(int x, int y, MouseButton b,
int clickCount) int clickCount)
{ {
_draggingPart = kNoPart; _draggingPart = kNoPart;
@ -142,7 +142,7 @@ void ScrollBarWidget::handleMouseWheel(int x, int y, int direction)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseMoved(int x, int y, int button) void ScrollBarWidget::handleMouseMoved(int x, int y)
{ {
// Do nothing if there are less items than fit on one page // Do nothing if there are less items than fit on one page
if(_numEntries <= _entriesPerPage) if(_numEntries <= _entriesPerPage)
@ -184,7 +184,7 @@ void ScrollBarWidget::handleMouseMoved(int x, int y, int button)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ScrollBarWidget::handleMouseClicks(int x, int y, int button) bool ScrollBarWidget::handleMouseClicks(int x, int y, MouseButton b)
{ {
// Let continuous mouse clicks come through, as the scroll buttons need them // Let continuous mouse clicks come through, as the scroll buttons need them
return true; return true;
@ -206,13 +206,13 @@ void ScrollBarWidget::checkBounds(int old_pos)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseEntered(int button) void ScrollBarWidget::handleMouseEntered()
{ {
setFlags(WIDGET_HILITED); setFlags(WIDGET_HILITED);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseLeft(int button) void ScrollBarWidget::handleMouseLeft()
{ {
_part = kNoPart; _part = kNoPart;
clearFlags(WIDGET_HILITED); clearFlags(WIDGET_HILITED);

View File

@ -45,12 +45,12 @@ class ScrollBarWidget : public Widget, public CommandSender
void drawWidget(bool hilite) override; void drawWidget(bool hilite) override;
void checkBounds(int old_pos); void checkBounds(int old_pos);
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseMoved(int x, int y, int button) override; void handleMouseMoved(int x, int y) override;
bool handleMouseClicks(int x, int y, int button) override; bool handleMouseClicks(int x, int y, MouseButton b) override;
void handleMouseEntered(int button) override; void handleMouseEntered() override;
void handleMouseLeft(int button) override; void handleMouseLeft() override;
public: public:
int _numEntries; int _numEntries;

View File

@ -171,7 +171,7 @@ void TabWidget::setParentWidget(int tabID, Widget* parent)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) void TabWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
assert(y < _tabHeight); assert(y < _tabHeight);
@ -194,14 +194,14 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::handleMouseEntered(int button) void TabWidget::handleMouseEntered()
{ {
setFlags(WIDGET_HILITED); setFlags(WIDGET_HILITED);
setDirty(); setDirty();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::handleMouseLeft(int button) void TabWidget::handleMouseLeft()
{ {
clearFlags(WIDGET_HILITED); clearFlags(WIDGET_HILITED);
setDirty(); setDirty();

View File

@ -59,9 +59,9 @@ class TabWidget : public Widget, public CommandSender
void loadConfig() override; void loadConfig() override;
protected: protected:
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered(int button) override; void handleMouseEntered() override;
void handleMouseLeft(int button) override; void handleMouseLeft() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
bool handleEvent(Event::Type event) override; bool handleEvent(Event::Type event) override;

View File

@ -400,14 +400,14 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseEntered(int button) void ButtonWidget::handleMouseEntered()
{ {
setFlags(WIDGET_HILITED); setFlags(WIDGET_HILITED);
setDirty(); setDirty();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseLeft(int button) void ButtonWidget::handleMouseLeft()
{ {
clearFlags(WIDGET_HILITED); clearFlags(WIDGET_HILITED);
setDirty(); setDirty();
@ -423,7 +423,7 @@ bool ButtonWidget::handleEvent(Event::Type e)
{ {
case Event::UISelect: case Event::UISelect:
// Simulate mouse event // Simulate mouse event
handleMouseUp(0, 0, 1, 0); handleMouseUp(0, 0, MouseButton::LEFT, 0);
return true; return true;
default: default:
return false; return false;
@ -431,7 +431,7 @@ bool ButtonWidget::handleEvent(Event::Type e)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) void ButtonWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
{ {
@ -572,21 +572,21 @@ CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseEntered(int button) void CheckboxWidget::handleMouseEntered()
{ {
setFlags(WIDGET_HILITED); setFlags(WIDGET_HILITED);
setDirty(); setDirty();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseLeft(int button) void CheckboxWidget::handleMouseLeft()
{ {
clearFlags(WIDGET_HILITED); clearFlags(WIDGET_HILITED);
setDirty(); setDirty();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) void CheckboxWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
if(isEnabled() && _editable && x >= 0 && x < _w && y >= 0 && y < _h) if(isEnabled() && _editable && x >= 0 && x < _w && y >= 0 && y < _h)
{ {
@ -728,7 +728,7 @@ void SliderWidget::setStepValue(int value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::handleMouseMoved(int x, int y, int button) void SliderWidget::handleMouseMoved(int x, int y)
{ {
// TODO: when the mouse is dragged outside the widget, the slider should // TODO: when the mouse is dragged outside the widget, the slider should
// snap back to the old value. // snap back to the old value.
@ -737,17 +737,17 @@ void SliderWidget::handleMouseMoved(int x, int y, int button)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount) void SliderWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{ {
if(isEnabled()) if(isEnabled() && b == MouseButton::LEFT)
{ {
_isDragging = true; _isDragging = true;
handleMouseMoved(x, y, button); handleMouseMoved(x, y);
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount) void SliderWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{ {
if(isEnabled() && _isDragging) if(isEnabled() && _isDragging)
sendCommand(_cmd, _value, _id); sendCommand(_cmd, _value, _id);

View File

@ -68,13 +68,13 @@ class Widget : public GuiObject
virtual bool handleText(char text) { return false; } virtual bool handleText(char text) { return false; }
virtual bool handleKeyDown(StellaKey key, StellaMod mod) { return false; } virtual bool handleKeyDown(StellaKey key, StellaMod mod) { return false; }
virtual bool handleKeyUp(StellaKey key, StellaMod mod) { return false; } virtual bool handleKeyUp(StellaKey key, StellaMod mod) { return false; }
virtual void handleMouseDown(int x, int y, int button, int clickCount) { } virtual void handleMouseDown(int x, int y, MouseButton b, int clickCount) { }
virtual void handleMouseUp(int x, int y, int button, int clickCount) { } virtual void handleMouseUp(int x, int y, MouseButton b, int clickCount) { }
virtual void handleMouseEntered(int button) { } virtual void handleMouseEntered() { }
virtual void handleMouseLeft(int button) { } virtual void handleMouseLeft() { }
virtual void handleMouseMoved(int x, int y, int button) { } virtual void handleMouseMoved(int x, int y) { }
virtual void handleMouseWheel(int x, int y, int direction) { } virtual void handleMouseWheel(int x, int y, int direction) { }
virtual bool handleMouseClicks(int x, int y, int button) { return false; } virtual bool handleMouseClicks(int x, int y, MouseButton b) { return false; }
virtual void handleJoyDown(int stick, int button) { } virtual void handleJoyDown(int stick, int button) { }
virtual void handleJoyUp(int stick, int button) { } virtual void handleJoyUp(int stick, int button) { }
virtual void handleJoyAxis(int stick, int axis, int value) { } virtual void handleJoyAxis(int stick, int axis, int value) { }
@ -226,9 +226,9 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
int getCmd() const { return _cmd; } int getCmd() const { return _cmd; }
protected: protected:
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered(int button) override; void handleMouseEntered() override;
void handleMouseLeft(int button) override; void handleMouseLeft() override;
bool handleEvent(Event::Type event) override; bool handleEvent(Event::Type event) override;
void drawWidget(bool hilite) override; void drawWidget(bool hilite) override;
@ -267,9 +267,9 @@ class CheckboxWidget : public ButtonWidget
void toggleState() { setState(!_state); } void toggleState() { setState(!_state); }
bool getState() const { return _state; } bool getState() const { return _state; }
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered(int button) override; void handleMouseEntered() override;
void handleMouseLeft(int button) override; void handleMouseLeft() override;
static int boxSize() { return 14; } // box is square static int boxSize() { return 14; } // box is square
@ -315,9 +315,9 @@ class SliderWidget : public ButtonWidget
int getStepValue() const { return _stepValue; } int getStepValue() const { return _stepValue; }
protected: protected:
void handleMouseMoved(int x, int y, int button) override; void handleMouseMoved(int x, int y) override;
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
bool handleEvent(Event::Type event) override; bool handleEvent(Event::Type event) override;