diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-11-23 20:45:06 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-18 19:34:20 +0100 |
commit | 48bc8dd33e38de832d4c23dbc3c4d45d03f9a55d (patch) | |
tree | 1b48a5b7a89fa289de72574226109346add68a2a /src/menu | |
parent | 9839da19aa250277e7c00d3fe7e67d1fd906eb01 (diff) | |
download | usdx-48bc8dd33e38de832d4c23dbc3c4d45d03f9a55d.tar.gz usdx-48bc8dd33e38de832d4c23dbc3c4d45d03f9a55d.tar.xz usdx-48bc8dd33e38de832d4c23dbc3c4d45d03f9a55d.zip |
menu: mouse events now take points, not the single coords
Diffstat (limited to '')
-rw-r--r-- | src/menu/event_manager.cpp | 6 | ||||
-rw-r--r-- | src/menu/event_manager.hpp | 8 | ||||
-rw-r--r-- | src/menu/software_mouse_pointer.cpp | 14 | ||||
-rw-r--r-- | src/menu/software_mouse_pointer.hpp | 6 |
4 files changed, 18 insertions, 16 deletions
diff --git a/src/menu/event_manager.cpp b/src/menu/event_manager.cpp index cb15352a..5b2e49df 100644 --- a/src/menu/event_manager.cpp +++ b/src/menu/event_manager.cpp @@ -102,15 +102,15 @@ namespace usdx break; case SDL_MOUSEMOTION: - mouse_move(event.motion.x, event.motion.y); + mouse_move(Point<int>(event.motion.x, event.motion.y)); break; case SDL_MOUSEBUTTONDOWN: - mouse_down(event.button.button, event.button.x, event.button.y); + mouse_down(event.button.button, Point<int>(event.button.x, event.button.y)); break; case SDL_MOUSEBUTTONUP: - mouse_up(event.button.button, event.button.x, event.button.y); + mouse_up(event.button.button, Point<int>(event.button.x, event.button.y)); } } } diff --git a/src/menu/event_manager.hpp b/src/menu/event_manager.hpp index 7c2738d1..5f02e66d 100644 --- a/src/menu/event_manager.hpp +++ b/src/menu/event_manager.hpp @@ -38,6 +38,8 @@ #include <log4cpp/Category.hh> +#include "utils/point.hpp" + namespace usdx { /** @@ -122,9 +124,9 @@ namespace usdx bool available(void); - boost::signals2::signal<void (uint16_t, uint16_t)> mouse_move; - boost::signals2::signal<void (uint8_t, uint16_t, uint16_t)> mouse_down; - boost::signals2::signal<void (uint8_t, uint16_t, uint16_t)> mouse_up; + boost::signals2::signal<void (const Point<int>&)> mouse_move; + boost::signals2::signal<void (uint8_t, const Point<int>&)> mouse_down; + boost::signals2::signal<void (uint8_t, const Point<int>&)> mouse_up; }; }; diff --git a/src/menu/software_mouse_pointer.cpp b/src/menu/software_mouse_pointer.cpp index d5be92d1..c99f4315 100644 --- a/src/menu/software_mouse_pointer.cpp +++ b/src/menu/software_mouse_pointer.cpp @@ -50,11 +50,11 @@ namespace usdx texture_pressed = new Disposer<Texture>(new Texture("game/themes/Deluxe/interface/cursor_pressed.png")); mouse_move_connection = event_manager->mouse_move.connect( - boost::bind(&SoftwareMousePointer::on_mouse_move, this, _1, _2)); + boost::bind(&SoftwareMousePointer::on_mouse_move, this, _1)); mouse_down_connection = event_manager->mouse_down.connect( - boost::bind(&SoftwareMousePointer::on_mouse_down, this, _1, _2, _3)); + boost::bind(&SoftwareMousePointer::on_mouse_down, this, _1, _2)); mouse_up_connection = event_manager->mouse_up.connect( - boost::bind(&SoftwareMousePointer::on_mouse_up, this, _1, _2, _3)); + boost::bind(&SoftwareMousePointer::on_mouse_up, this, _1, _2)); } SoftwareMousePointer::~SoftwareMousePointer() @@ -122,13 +122,13 @@ namespace usdx } } - void SoftwareMousePointer::on_mouse_move(uint16_t x, uint16_t y) + void SoftwareMousePointer::on_mouse_move(const Point<int>& p) { - set_position(x, y); + set_position(p.get_x(), p.get_y()); update(); } - void SoftwareMousePointer::on_mouse_down(uint8_t button, uint16_t x, uint16_t y) + void SoftwareMousePointer::on_mouse_down(uint8_t button, const Point<int>& p) { if (button == 1) { boost::unique_lock<boost::shared_mutex> lock(down_mutex); @@ -138,7 +138,7 @@ namespace usdx update(); } - void SoftwareMousePointer::on_mouse_up(uint8_t button, uint16_t x, uint16_t y) + void SoftwareMousePointer::on_mouse_up(uint8_t button, const Point<int>& p) { if (button == 1) { boost::unique_lock<boost::shared_mutex> lock(down_mutex); diff --git a/src/menu/software_mouse_pointer.hpp b/src/menu/software_mouse_pointer.hpp index 797236ff..91ba294b 100644 --- a/src/menu/software_mouse_pointer.hpp +++ b/src/menu/software_mouse_pointer.hpp @@ -68,9 +68,9 @@ namespace usdx SoftwareMousePointer(Container* parent, EventManager* event_manager); virtual ~SoftwareMousePointer(); - void on_mouse_move(uint16_t x, uint16_t y); - void on_mouse_down(uint8_t button, uint16_t x, uint16_t y); - void on_mouse_up(uint8_t button, uint16_t x, uint16_t y); + void on_mouse_move(const Point<int>& p); + void on_mouse_down(uint8_t button, const Point<int>& p); + void on_mouse_up(uint8_t button, const Point<int>& p); bool is_down(void) const; }; |