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:
{
handleMouseMotionEvent(myEvent.motion.x, myEvent.motion.y,
myEvent.motion.xrel, myEvent.motion.yrel, 0);
myEvent.motion.xrel, myEvent.motion.yrel);
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())
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,
// send the double click command

View File

@ -97,8 +97,8 @@ class DataGridWidget : public EditableWidget
void receivedFocusWidget() override;
void lostFocusWidget() override;
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseUp(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, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override;
bool handleText(char text) 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";
}

View File

@ -71,7 +71,7 @@ class PromptWidget : public Widget, public CommandSender
void addToHistory(const char *str);
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;
bool handleText(char text) 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)
// Otherwise let the base dialog class process it
if(x >= 0 && x < _w && y >= 0 && y < _h)
Dialog::handleMouseDown(x, y, button, clickCount);
Dialog::handleMouseDown(x, y, b, clickCount);
else
close();
}

View File

@ -52,7 +52,7 @@ class RomListSettings : public Dialog, public CommandSender
private:
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;
// 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())
return;
// 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
_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,
// send the double click command

View File

@ -58,8 +58,8 @@ class RomListWidget : public EditableWidget
void setHighlighted(int item);
protected:
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseUp(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, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override;
bool handleText(char text) 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;
}

View File

@ -49,7 +49,7 @@ class TiaInfoWidget : public Widget, public CommandSender
CheckboxWidget* myVBlank;
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;
// 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
if(button == 2)
if(b == MouseButton::RIGHT)
{
myClickX = x;
myClickY = y;

View File

@ -42,7 +42,7 @@ class TiaOutputWidget : public Widget, public CommandSender
// For example, clicking an area may cause an action
// (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;
bool handleKeyDown(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];
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 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 2 is for context menu
if(button == 1)
if(b == MouseButton::LEFT)
{
// Indicate mouse drag started/in progress
myMouseMoving = true;
myXClick = x;
myYClick = y;
}
else if(button == 2)
else if(b == MouseButton::RIGHT)
{
// Add menu at current x,y mouse location
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;
}
@ -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
#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;
}

View File

@ -39,11 +39,11 @@ class TiaZoomWidget : public Widget, public CommandSender
void zoom(int level);
void recalc();
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseUp(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, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override;
void handleMouseMoved(int x, int y, int button) override;
void handleMouseLeft(int button) override;
void handleMouseMoved(int x, int y) override;
void handleMouseLeft() override;
bool handleEvent(Event::Type event) 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())
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)
return;

View File

@ -66,8 +66,8 @@ class ToggleWidget : public Widget, public CommandSender
void drawWidget(bool hilite) override = 0;
int findItem(int x, int y);
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseUp(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, MouseButton b, int clickCount) override;
bool handleKeyDown(StellaKey key, StellaMod mod) 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
if(myState == EventHandlerState::EMULATION)
@ -661,7 +661,7 @@ void EventHandler::handleMouseMotionEvent(int x, int y, int xrel, int yrel, int
mySkipMouseMotion = false;
}
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 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 handleJoyEvent(int stick, int button, uInt8 state);
void handleJoyAxisEvent(int stick, int axis, int value);

View File

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

View File

@ -164,7 +164,7 @@ bool CheckListWidget::handleEvent(Event::Type e)
{
case Event::UISelect:
// Simulate a mouse button click
_checkList[ListWidget::getSelected()]->handleMouseUp(0, 0, 1, 0);
_checkList[ListWidget::getSelected()]->handleMouseUp(0, 0, MouseButton::LEFT, 0);
return true;
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...
int item = findItem(x, y);
// Only do a selection when the left button is in the dialog
if(button == 1)
if(b == MouseButton::LEFT)
{
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...
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
return true;

View File

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

View File

@ -90,7 +90,7 @@ void Dialog::close(bool refresh)
{
if (_mouseWidget)
{
_mouseWidget->handleMouseLeft(0);
_mouseWidget->handleMouseLeft();
_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);
@ -386,11 +386,11 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount)
if(w)
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)
{
@ -402,7 +402,7 @@ void Dialog::handleMouseUp(int x, int y, int button, int clickCount)
Widget* w = _dragWidget;
if(w)
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y),
button, clickCount);
b, clickCount);
_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;
@ -438,17 +438,17 @@ void Dialog::handleMouseMoved(int x, int y, int button)
if(mouseInFocusedWidget && _mouseWidget != w)
{
if(_mouseWidget)
_mouseWidget->handleMouseLeft(button);
_mouseWidget->handleMouseLeft();
_mouseWidget = w;
w->handleMouseEntered(button);
w->handleMouseEntered();
}
else if (!mouseInFocusedWidget && _mouseWidget == w)
{
_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),
@ -461,24 +461,24 @@ void Dialog::handleMouseMoved(int x, int y, int button)
if (_mouseWidget != w)
{
if (_mouseWidget)
_mouseWidget->handleMouseLeft(button);
_mouseWidget->handleMouseLeft();
if (w)
w->handleMouseEntered(button);
w->handleMouseEntered();
_mouseWidget = w;
}
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);
if(w)
return w->handleMouseClicks(x - (w->getAbsX() - _x),
y - (w->getAbsY() - _y), button);
y - (w->getAbsY() - _y), b);
else
return false;
}

View File

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

View File

@ -65,11 +65,11 @@ void DialogContainer::updateTime(uInt64 time)
}
// Mouse button still pressed
if(myCurrentMouseDown.button != -1 && myClickRepeatTime < myTime)
if(myCurrentMouseDown.b != MouseButton::NONE && myClickRepeatTime < myTime)
{
activeDialog->handleMouseDown(myCurrentMouseDown.x - activeDialog->_x,
myCurrentMouseDown.y - activeDialog->_y,
myCurrentMouseDown.button, 1);
myCurrentMouseDown.b, 1);
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())
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
Dialog* activeDialog = myDialogStack.top();
activeDialog->surface().translateCoords(x, y);
activeDialog->handleMouseMoved(x - activeDialog->_x,
y - activeDialog->_y,
button);
activeDialog->handleMouseMoved(x - activeDialog->_x, y - activeDialog->_y);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -206,7 +204,6 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
Dialog* activeDialog = myDialogStack.top();
activeDialog->surface().translateCoords(x, y);
int button = b == MouseButton::LEFT ? 1 : 2;
switch(b)
{
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
// if the dialog wants them
if(activeDialog->handleMouseClicks(x - activeDialog->_x, y - activeDialog->_y,
button))
if(activeDialog->handleMouseClicks(x - activeDialog->_x, y - activeDialog->_y, b))
{
myCurrentMouseDown.x = x;
myCurrentMouseDown.y = y;
myCurrentMouseDown.button = button;
myCurrentMouseDown.b = b;
myClickRepeatTime = myTime + kRepeatInitialDelay;
}
else
myCurrentMouseDown.button = -1;
myCurrentMouseDown.b = MouseButton::NONE;
activeDialog->handleMouseDown(x - activeDialog->_x, y - activeDialog->_y,
button, myLastClick.count);
b, myLastClick.count);
}
else
{
activeDialog->handleMouseUp(x - activeDialog->_x, y - activeDialog->_y,
button, myLastClick.count);
b, myLastClick.count);
if(button == myCurrentMouseDown.button)
myCurrentMouseDown.button = -1;
if(b == myCurrentMouseDown.b)
myCurrentMouseDown.b = MouseButton::NONE;
}
break;
@ -268,6 +264,9 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed,
case MouseButton::WHEELDOWN:
activeDialog->handleMouseWheel(x - activeDialog->_x, y - activeDialog->_y, 1);
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()
{
myCurrentKeyDown.keycode = KBDK_UNKNOWN;
myCurrentMouseDown.button = -1;
myCurrentMouseDown.b = MouseButton::NONE;
myLastClick.x = myLastClick.y = 0;
myLastClick.time = 0;
myLastClick.count = 0;

View File

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

View File

@ -42,7 +42,7 @@ class EditTextWidget : public EditableWidget
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:
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
if(button == 2)
if(b == MouseButton::RIGHT)
{
// Add menu at current x,y mouse location
myMenu->show(x + getAbsX(), y + getAbsY());
}
else
Dialog::handleMouseDown(x, y, button, clickCount);
Dialog::handleMouseDown(x, y, b, clickCount);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -79,7 +79,7 @@ class LauncherDialog : public Dialog
private:
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 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())
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,
// send the double click command

View File

@ -65,8 +65,8 @@ class ListWidget : public EditableWidget
static void setQuickSelectDelay(uInt64 time) { _QUICK_SELECT_DELAY = time; }
protected:
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseUp(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, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override;
bool handleText(char text) 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())
{
@ -159,14 +159,14 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction)
#ifdef FLAT_UI
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseEntered(int button)
void PopUpWidget::handleMouseEntered()
{
setFlags(WIDGET_HILITED);
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseLeft(int button)
void PopUpWidget::handleMouseLeft()
{
clearFlags(WIDGET_HILITED);
setDirty();
@ -182,7 +182,7 @@ bool PopUpWidget::handleEvent(Event::Type e)
switch(e)
{
case Event::UISelect:
handleMouseDown(0, 0, 1, 0);
handleMouseDown(0, 0, MouseButton::LEFT, 0);
return true;
case Event::UIUp:
case Event::UILeft:

View File

@ -62,11 +62,11 @@ class PopUpWidget : public Widget, public CommandSender
bool wantsFocus() const override { return true; }
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;
#ifdef FLAT_UI
void handleMouseEntered(int button) override;
void handleMouseLeft(int button) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
#endif
bool handleEvent(Event::Type e) 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)
{

View File

@ -34,7 +34,7 @@ class RadioButtonWidget : public CheckboxWidget
const string& label, RadioButtonGroup* group,
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);
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)
{
// 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)
{
_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
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
return true;
@ -206,13 +206,13 @@ void ScrollBarWidget::checkBounds(int old_pos)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseEntered(int button)
void ScrollBarWidget::handleMouseEntered()
{
setFlags(WIDGET_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseLeft(int button)
void ScrollBarWidget::handleMouseLeft()
{
_part = kNoPart;
clearFlags(WIDGET_HILITED);

View File

@ -45,12 +45,12 @@ class ScrollBarWidget : public Widget, public CommandSender
void drawWidget(bool hilite) override;
void checkBounds(int old_pos);
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseUp(int x, int y, int button, int clickCount) override;
void handleMouseMoved(int x, int y, int button) override;
bool handleMouseClicks(int x, int y, int button) override;
void handleMouseEntered(int button) override;
void handleMouseLeft(int button) override;
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseMoved(int x, int y) override;
bool handleMouseClicks(int x, int y, MouseButton b) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
public:
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);
@ -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);
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::handleMouseLeft(int button)
void TabWidget::handleMouseLeft()
{
clearFlags(WIDGET_HILITED);
setDirty();

View File

@ -59,9 +59,9 @@ class TabWidget : public Widget, public CommandSender
void loadConfig() override;
protected:
void handleMouseDown(int x, int y, int button, int clickCount) override;
void handleMouseEntered(int button) override;
void handleMouseLeft(int button) override;
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) 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);
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseLeft(int button)
void ButtonWidget::handleMouseLeft()
{
clearFlags(WIDGET_HILITED);
setDirty();
@ -423,7 +423,7 @@ bool ButtonWidget::handleEvent(Event::Type e)
{
case Event::UISelect:
// Simulate mouse event
handleMouseUp(0, 0, 1, 0);
handleMouseUp(0, 0, MouseButton::LEFT, 0);
return true;
default:
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)
{
@ -572,21 +572,21 @@ CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseEntered(int button)
void CheckboxWidget::handleMouseEntered()
{
setFlags(WIDGET_HILITED);
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseLeft(int button)
void CheckboxWidget::handleMouseLeft()
{
clearFlags(WIDGET_HILITED);
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)
{
@ -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
// 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;
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)
sendCommand(_cmd, _value, _id);

View File

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