summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-30 00:53:40 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-30 00:53:40 +0300
commitf29616d8d1309ee135afe2b2e7baf1d91d677a95 (patch)
tree77624591a88075bc2b1128520d950c717d353288 /src
parentec51be4fd71babf30a73332bc4b73edb994ee462 (diff)
downloadmv-f29616d8d1309ee135afe2b2e7baf1d91d677a95.tar.gz
mv-f29616d8d1309ee135afe2b2e7baf1d91d677a95.tar.bz2
mv-f29616d8d1309ee135afe2b2e7baf1d91d677a95.tar.xz
mv-f29616d8d1309ee135afe2b2e7baf1d91d677a95.zip
Convert MouseButton enum into strong typed enum.
Diffstat (limited to 'src')
-rw-r--r--src/enums/events/mousebutton.h23
-rw-r--r--src/events/mouseevent.h6
-rw-r--r--src/gui/gui.cpp6
-rw-r--r--src/gui/gui.h6
-rw-r--r--src/gui/sdlinput.cpp4
-rw-r--r--src/gui/sdlinput.h5
-rw-r--r--src/gui/viewport.cpp4
-rw-r--r--src/gui/widgets/avatarlistbox.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/itemcontainer.cpp2
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp2
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/window.cpp2
-rw-r--r--src/input/mouseinput.h6
15 files changed, 36 insertions, 40 deletions
diff --git a/src/enums/events/mousebutton.h b/src/enums/events/mousebutton.h
index 51fddef5b..d3bfd20ed 100644
--- a/src/enums/events/mousebutton.h
+++ b/src/enums/events/mousebutton.h
@@ -64,19 +64,16 @@
#ifndef ENUMS_EVENTS_MOUSEBUTTON_H
#define ENUMS_EVENTS_MOUSEBUTTON_H
-namespace MouseButton
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(MouseButton)
{
- /**
- * Mouse button types.
- */
- enum Type
- {
- WHEEL = -1,
- EMPTY = 0,
- LEFT,
- RIGHT,
- MIDDLE
- };
-} // namespace MouseButton
+ WHEEL = -1,
+ EMPTY = 0,
+ LEFT,
+ RIGHT,
+ MIDDLE
+}
+enumEnd(MouseButton);
#endif // ENUMS_EVENTS_MOUSEBUTTON_H
diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h
index c4e5e14e4..1be008827 100644
--- a/src/events/mouseevent.h
+++ b/src/events/mouseevent.h
@@ -93,7 +93,7 @@ class MouseEvent: public InputGuiEvent
*/
MouseEvent(Widget *const source,
const MouseEventType::Type type,
- const MouseButton::Type button,
+ const MouseButtonT button,
const int x,
const int y,
const int clickCount) :
@@ -111,7 +111,7 @@ class MouseEvent: public InputGuiEvent
*
* @return The button of the mouse event.
*/
- MouseButton::Type getButton() const A_WARN_UNUSED
+ MouseButtonT getButton() const A_WARN_UNUSED
{ return mButton; }
/**
@@ -168,7 +168,7 @@ class MouseEvent: public InputGuiEvent
/**
* Holds the button of the mouse event.
*/
- MouseButton::Type mButton;
+ MouseButtonT mButton;
/**
* Holds the x-coordinate of the mouse event.
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 4cfd83f0f..23b640737 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -591,7 +591,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput)
const int mouseX = mouseInput.getX();
const int mouseY = mouseInput.getY();
- const MouseButton::Type button = mouseInput.getButton();
+ const MouseButtonT button = mouseInput.getButton();
// Check if there is a need to send mouse exited events by
// traversing the "widget with mouse" queue.
@@ -734,7 +734,7 @@ void Gui::handleMousePressed(const MouseInput &mouseInput)
{
const int x = mouseInput.getX();
const int y = mouseInput.getY();
- const MouseButton::Type button = mouseInput.getButton();
+ const MouseButtonT button = mouseInput.getButton();
const int timeStamp = mouseInput.getTimeStamp();
Widget *sourceWidget = getMouseEventSource(x, y);
@@ -803,7 +803,7 @@ void Gui::updateFonts()
void Gui::distributeMouseEvent(Widget *const source,
const MouseEventType::Type type,
- const MouseButton::Type button,
+ const MouseButtonT button,
const int x, const int y,
const bool force,
const bool toSourceOnly)
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 21cf7e015..b1d443b81 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -329,7 +329,7 @@ class Gui final
void distributeMouseEvent(Widget *const source,
const MouseEventType::Type type,
- const MouseButton::Type button,
+ const MouseButtonT button,
const int x, const int y,
const bool force = false,
const bool toSourceOnly = false);
@@ -468,7 +468,7 @@ class Gui final
/**
* Holds the last mouse button pressed.
*/
- MouseButton::Type mLastMousePressButton;
+ MouseButtonT mLastMousePressButton;
/**
* Holds the last mouse press time stamp.
@@ -496,7 +496,7 @@ class Gui final
* was initiated. Used to be able to release a drag
* when the same button is released.
*/
- MouseButton::Type mLastMouseDragButton;
+ MouseButtonT mLastMouseDragButton;
/**
* Holds a stack with all the widgets with the mouse.
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index cc3693418..16204e5e1 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -297,7 +297,7 @@ void SDLInput::convertKeyEventToKey(const SDL_Event &event, KeyInput &keyInput)
keyInput.setActionId(actionId);
}
-MouseButton::Type SDLInput::convertMouseButton(const int button)
+MouseButtonT SDLInput::convertMouseButton(const int button)
{
switch (button)
{
@@ -532,7 +532,7 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event)
}
void SDLInput::simulateMouseClick(const int x, const int y,
- const MouseButton::Type button)
+ const MouseButtonT button)
{
MouseInput mouseInput;
mouseInput.setX(x);
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
index 83797c553..fb1c2e924 100644
--- a/src/gui/sdlinput.h
+++ b/src/gui/sdlinput.h
@@ -118,7 +118,7 @@ class SDLInput final
MouseInput dequeueMouseInput() A_WARN_UNUSED;
void simulateMouseClick(const int x, const int y,
- const MouseButton::Type button);
+ const MouseButtonT button);
protected:
/**
@@ -128,8 +128,7 @@ class SDLInput final
* @param button an SDL mouse button.
* @return a Guichan mouse button.
*/
- static MouseButton::Type convertMouseButton(const int button)
- A_WARN_UNUSED;
+ static MouseButtonT convertMouseButton(const int button) A_WARN_UNUSED;
/**
* Converts an SDL event key to a key value.
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 2beed89d0..5a91f24b9 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -529,7 +529,7 @@ void Viewport::mousePressed(MouseEvent &event)
mMousePressX = event.getX();
mMousePressY = event.getY();
- const MouseButton::Type eventButton = event.getButton();
+ const MouseButtonT eventButton = event.getButton();
const int pixelX = mMousePressX + mPixelViewX;
const int pixelY = mMousePressY + mPixelViewY;
@@ -726,7 +726,7 @@ void Viewport::mouseReleased(MouseEvent &event)
mMouseClicked = false;
if (event.getSource() != this || event.isConsumed())
return;
- const MouseButton::Type eventButton = event.getButton();
+ const MouseButtonT eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
// long button press
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index a3c29a68a..a7d060b10 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -608,7 +608,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
ava->getType());
event.consume();
- const unsigned int eventButton = event.getButton();
+ const MouseButtonT eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
if (type == MapItemType::EMPTY)
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index db5caf6f7..f46d0f282 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -399,7 +399,7 @@ void DropDown::mouseReleased(MouseEvent &event)
if (mIsDragged)
mPushed = false;
- const MouseButton::Type button = event.getButton();
+ const MouseButtonT button = event.getButton();
const int x = event.getX();
const int y = event.getY();
// Released outside of widget. Can happen when we have modal
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 9024f74be..ff20e024e 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -400,7 +400,7 @@ void ItemContainer::mousePressed(MouseEvent &event)
if (!mInventory)
return;
- const MouseButton::Type button = event.getButton();
+ const MouseButtonT button = event.getButton();
mClicks = event.getClickCount();
if (button == MouseButton::LEFT || button == MouseButton::RIGHT)
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 70b4e19e5..9953d0e6b 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -62,7 +62,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event)
std::string url = link;
replaceAll(url, " ", "");
listener.url = url;
- const MouseButton::Type button = event->getButton();
+ const MouseButtonT button = event->getButton();
if (button == MouseButton::LEFT)
{
ConfirmDialog *const confirmDlg = new ConfirmDialog(
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 7971e0d33..796964801 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -219,7 +219,7 @@ void SpellShortcutContainer::mousePressed(MouseEvent &event)
if (index == -1)
return;
- const MouseButton::Type eventButton = event.getButton();
+ const MouseButtonT eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
const int itemId = getItemByIndex(index);
@@ -255,7 +255,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
}
const int itemId = getItemByIndex(index);
- const MouseButton::Type eventButton = event.getButton();
+ const MouseButtonT eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index 30dbe3770..44ea247cc 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -269,7 +269,7 @@ void VirtShortcutContainer::mousePressed(MouseEvent &event)
event.consume();
- const MouseButton::Type eventButton = event.getButton();
+ const MouseButtonT eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
if (mShortcut->getItem(index) > 0)
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index a48b2c062..2187056f9 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -810,7 +810,7 @@ void Window::mousePressed(MouseEvent &event)
mMoved = event.getY() <= static_cast<int>(mTitleBarHeight);
}
- const MouseButton::Type button = event.getButton();
+ const MouseButtonT button = event.getButton();
if (button == MouseButton::LEFT)
{
const int x = event.getX();
diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h
index c69bd72b7..f84303308 100644
--- a/src/input/mouseinput.h
+++ b/src/input/mouseinput.h
@@ -95,12 +95,12 @@ class MouseInput final
return mType;
}
- void setButton(MouseButton::Type button)
+ void setButton(MouseButtonT button)
{
mButton = button;
}
- MouseButton::Type getButton() const
+ MouseButtonT getButton() const
{
return mButton;
}
@@ -167,7 +167,7 @@ class MouseInput final
/**
* Holds the button of the mouse input.
*/
- MouseButton::Type mButton;
+ MouseButtonT mButton;
/**
* Holds the timestamp of the mouse input. Used to