#include <mouse_handler_base.hpp>
Public Member Functions | |
mouse_handler_base () | |
virtual | ~mouse_handler_base () |
virtual display & | gui ()=0 |
Reference to the used display objects. More... | |
virtual const display & | gui () const =0 |
Const version. More... | |
bool | is_dragging () const |
virtual int | drag_threshold () const |
void | mouse_motion_event (const SDL_MouseMotionEvent &event, const bool browse) |
void | mouse_update (const bool browse, map_location loc) |
update the mouse with a fake mouse motion More... | |
bool | get_show_menu () const |
bool | mouse_motion_default (int x, int y, bool update) |
This handles minimap scrolling and click-drag. More... | |
virtual void | mouse_motion (int x, int y, const bool browse, bool update=false, map_location new_loc=map_location::null_location())=0 |
Called when a mouse motion event takes place. More... | |
virtual void | mouse_press (const SDL_MouseButtonEvent &event, const bool browse) |
bool | is_left_click (const SDL_MouseButtonEvent &event) const |
bool | is_middle_click (const SDL_MouseButtonEvent &event) const |
bool | is_right_click (const SDL_MouseButtonEvent &event) const |
virtual void | mouse_wheel (int xscroll, int yscroll, bool browse) |
Called when scrolling with the mouse wheel. More... | |
virtual bool | allow_mouse_wheel_scroll (int x, int y) |
Derived classes can override this to disable mousewheel scrolling under some circumstances, e.g. More... | |
virtual bool | left_click (int x, int y, const bool browse) |
Overridden in derived classes, called on a left click (mousedown). More... | |
virtual void | move_action (bool browse) |
Overridden in derived class. More... | |
virtual void | left_drag_end (int x, int y, const bool browse) |
Called whenever the left mouse drag has "ended". More... | |
virtual void | left_mouse_up (int x, int y, const bool browse) |
Called when the left mouse button is up. More... | |
virtual bool | right_click (int x, int y, const bool browse) |
Overridden in derived classes, called on a right click (mousedown). More... | |
virtual bool | right_click_show_menu (int x, int y, const bool browse) |
Called in the default right_click when the context menu is about to be shown, can be used for preprocessing and preventing the menu from being displayed without rewriting the right click function. More... | |
virtual void | right_drag_end (int x, int y, const bool browse) |
Called whenever the right mouse drag has "ended". More... | |
virtual void | right_mouse_up (int x, int y, const bool browse) |
Called when the right mouse button is up. More... | |
virtual void | mouse_wheel_up (int x, int y, const bool browse) |
Called when the mouse wheel is scrolled up. More... | |
virtual void | mouse_wheel_down (int x, int y, const bool browse) |
Called when the mouse wheel is scrolled down. More... | |
virtual void | mouse_wheel_left (int x, int y, const bool browse) |
Called when the mouse wheel is scrolled left. More... | |
virtual void | mouse_wheel_right (int x, int y, const bool browse) |
Called when the mouse wheel is scrolled right. More... | |
void | set_scroll_start (int x, int y) |
Called when the middle click scrolling. More... | |
const map_location | get_scroll_start () |
bool | scroll_started () |
Protected Member Functions | |
void | cancel_dragging () |
void | clear_dragging (const SDL_MouseButtonEvent &event, bool browse) |
void | init_dragging (bool &dragging_flag) |
Protected Attributes | |
bool | simple_warp_ |
MMB click (on game map) state flag. More... | |
bool | minimap_scrolling_ |
minimap scrolling (scroll-drag) state flag More... | |
bool | dragging_left_ |
LMB drag init flag. More... | |
bool | dragging_started_ |
Actual drag flag. More... | |
bool | dragging_right_ |
RMB drag init flag. More... | |
int | drag_from_x_ |
Drag start position x. More... | |
int | drag_from_y_ |
Drag start position y. More... | |
map_location | drag_from_hex_ |
Drag start map location. More... | |
map_location | last_hex_ |
last highlighted hex More... | |
bool | show_menu_ |
Show context menu flag. More... | |
int | scroll_start_x_ |
Relative to middle click scrolling. More... | |
int | scroll_start_y_ |
bool | scroll_started_ |
Definition at line 35 of file mouse_handler_base.hpp.
events::mouse_handler_base::mouse_handler_base | ( | ) |
Definition at line 51 of file mouse_handler_base.cpp.
|
inlinevirtual |
Definition at line 38 of file mouse_handler_base.hpp.
Derived classes can override this to disable mousewheel scrolling under some circumstances, e.g.
when the mouse wheel controls something else, but the event is also received by this class
Reimplemented in editor::editor_controller.
Definition at line 212 of file mouse_handler_base.cpp.
|
protected |
Definition at line 338 of file mouse_handler_base.cpp.
References dragging_left_, dragging_right_, dragging_started_, and cursor::set_dragging().
Referenced by mouse_press().
|
protected |
Definition at line 346 of file mouse_handler_base.cpp.
References dragging_left_, dragging_right_, dragging_started_, left_drag_end(), right_drag_end(), and cursor::set_dragging().
Referenced by mouse_press().
|
inlinevirtual |
Reimplemented in events::mouse_handler.
Definition at line 57 of file mouse_handler_base.hpp.
Referenced by mouse_motion_default().
|
inline |
Definition at line 172 of file mouse_handler_base.hpp.
References scroll_start_x_, and scroll_start_y_.
Referenced by controller_base::handle_scroll().
|
inline |
Definition at line 64 of file mouse_handler_base.hpp.
References show_menu_.
|
pure virtual |
Reference to the used display objects.
Derived classes should ensure this is always valid. Note the constructor of this class cannot use this.
Implemented in editor::editor_controller, and events::mouse_handler.
Referenced by init_dragging(), left_click(), mouse_motion_default(), mouse_press(), mouse_wheel(), and right_click().
|
pure virtual |
Const version.
Implemented in editor::editor_controller, and events::mouse_handler.
|
protected |
Definition at line 331 of file mouse_handler_base.cpp.
References drag_from_hex_, drag_from_x_, drag_from_y_, gui(), and display::hex_clicked_on().
Referenced by mouse_press().
bool events::mouse_handler_base::is_dragging | ( | ) | const |
Definition at line 68 of file mouse_handler_base.cpp.
References dragging_left_, and dragging_right_.
Referenced by editor::editor_controller::mouse_motion(), and mouse_motion_default().
bool events::mouse_handler_base::is_left_click | ( | const SDL_MouseButtonEvent & | event | ) | const |
Definition at line 193 of file mouse_handler_base.cpp.
References events::command_active().
Referenced by mouse_press().
bool events::mouse_handler_base::is_middle_click | ( | const SDL_MouseButtonEvent & | event | ) | const |
Definition at line 199 of file mouse_handler_base.cpp.
Referenced by mouse_press().
bool events::mouse_handler_base::is_right_click | ( | const SDL_MouseButtonEvent & | event | ) | const |
Definition at line 205 of file mouse_handler_base.cpp.
References events::command_active().
Referenced by mouse_press().
Overridden in derived classes, called on a left click (mousedown).
Defaults to process (initiate) minimap scrolling.
Reimplemented in editor::editor_controller.
Definition at line 222 of file mouse_handler_base.cpp.
References tooltips::click(), gui(), last_hex_, display::minimap_location_on(), minimap_scrolling_, display::scroll_to_tile(), map_location::valid(), and display::WARP.
Referenced by mouse_press().
Called whenever the left mouse drag has "ended".
Reimplemented in editor::editor_controller.
Definition at line 244 of file mouse_handler_base.cpp.
References move_action().
Referenced by clear_dragging().
Called when the left mouse button is up.
Reimplemented in editor::editor_controller, and events::mouse_handler.
Definition at line 249 of file mouse_handler_base.cpp.
Referenced by mouse_press().
|
pure virtual |
Called when a mouse motion event takes place.
Derived classes must provide an implementation, possibly using mouse_motion_default().
Implemented in editor::editor_controller, and events::mouse_handler.
Referenced by mouse_motion_event(), mouse_update(), and controller_base::play_slice().
This handles minimap scrolling and click-drag.
Definition at line 85 of file mouse_handler_base.cpp.
References drag_from_x_, drag_from_y_, drag_threshold(), dragging_left_, dragging_right_, dragging_started_, gui(), is_dragging(), last_hex_, display::minimap_location_on(), minimap_scrolling_, tooltips::process(), display::scroll_to_tile(), cursor::set_dragging(), simple_warp_, map_location::valid(), and display::WARP.
Referenced by events::mouse_handler::mouse_motion().
void events::mouse_handler_base::mouse_motion_event | ( | const SDL_MouseMotionEvent & | event, |
const bool | browse | ||
) |
Definition at line 73 of file mouse_handler_base.cpp.
References mouse_motion().
Referenced by controller_base::handle_event().
|
virtual |
Reimplemented in events::mouse_handler.
Definition at line 131 of file mouse_handler_base.cpp.
References cancel_dragging(), clear_dragging(), dragging_left_, dragging_right_, dragging_started_, gui(), display::hex_clicked_on(), init_dragging(), is_left_click(), is_middle_click(), is_right_click(), last_hex_, left_click(), left_mouse_up(), preferences::middle_click_scrolls(), display::minimap_location_on(), minimap_scrolling_, mouse_update(), right_click(), right_mouse_up(), scroll_started_, display::scroll_to_tile(), cursor::set_dragging(), set_scroll_start(), show_menu_, simple_warp_, map_location::valid(), and display::WARP.
Referenced by controller_base::handle_event(), and events::mouse_handler::mouse_press().
void events::mouse_handler_base::mouse_update | ( | const bool | browse, |
map_location | loc | ||
) |
update the mouse with a fake mouse motion
Definition at line 78 of file mouse_handler_base.cpp.
References mouse_motion().
Referenced by mouse_press(), and controller_base::play_slice().
Called when scrolling with the mouse wheel.
Definition at line 253 of file mouse_handler_base.cpp.
References display::find_slider(), gui(), mouse_wheel_down(), mouse_wheel_left(), mouse_wheel_right(), mouse_wheel_up(), sdl::point_in_rect(), display::scroll(), and preferences::scroll_speed().
Referenced by controller_base::handle_event().
Called when the mouse wheel is scrolled down.
Reimplemented in events::mouse_handler.
Definition at line 294 of file mouse_handler_base.cpp.
Referenced by mouse_wheel().
Called when the mouse wheel is scrolled left.
Reimplemented in events::mouse_handler.
Definition at line 298 of file mouse_handler_base.cpp.
Referenced by mouse_wheel().
Called when the mouse wheel is scrolled right.
Reimplemented in events::mouse_handler.
Definition at line 302 of file mouse_handler_base.cpp.
Referenced by mouse_wheel().
Called when the mouse wheel is scrolled up.
Reimplemented in events::mouse_handler.
Definition at line 290 of file mouse_handler_base.cpp.
Referenced by mouse_wheel().
|
virtual |
Overridden in derived class.
Called on drag+drop movements.
Reimplemented in events::mouse_handler.
Definition at line 239 of file mouse_handler_base.cpp.
Referenced by left_drag_end().
Overridden in derived classes, called on a right click (mousedown).
Defaults to displaying the menu (by setting the appropriate flag) if right_click_show_menu returns true.
Reimplemented in editor::editor_controller.
Definition at line 306 of file mouse_handler_base.cpp.
References theme::context_menu(), display::draw(), display::get_theme(), gui(), right_click_show_menu(), show_menu_, and WRN_DP.
Referenced by mouse_press().
Called in the default right_click when the context menu is about to be shown, can be used for preprocessing and preventing the menu from being displayed without rewriting the right click function.
Reimplemented in editor::editor_controller, and events::mouse_handler.
Definition at line 217 of file mouse_handler_base.cpp.
Referenced by right_click().
Called whenever the right mouse drag has "ended".
Reimplemented in editor::editor_controller.
Definition at line 321 of file mouse_handler_base.cpp.
Referenced by clear_dragging().
Called when the right mouse button is up.
Reimplemented in editor::editor_controller.
Definition at line 327 of file mouse_handler_base.cpp.
Referenced by mouse_press().
|
inline |
Definition at line 173 of file mouse_handler_base.hpp.
References scroll_started_.
Called when the middle click scrolling.
Definition at line 171 of file mouse_handler_base.hpp.
References scroll_start_x_, and scroll_start_y_.
Referenced by controller_base::handle_scroll(), and mouse_press().
|
protected |
Drag start map location.
Definition at line 195 of file mouse_handler_base.hpp.
Referenced by init_dragging(), and editor::editor_controller::mouse_motion().
|
protected |
Drag start position x.
Definition at line 191 of file mouse_handler_base.hpp.
Referenced by init_dragging(), and mouse_motion_default().
|
protected |
Drag start position y.
Definition at line 193 of file mouse_handler_base.hpp.
Referenced by init_dragging(), and mouse_motion_default().
|
protected |
LMB drag init flag.
Definition at line 185 of file mouse_handler_base.hpp.
Referenced by cancel_dragging(), clear_dragging(), is_dragging(), editor::editor_controller::mouse_motion(), mouse_motion_default(), and mouse_press().
|
protected |
RMB drag init flag.
Definition at line 189 of file mouse_handler_base.hpp.
Referenced by cancel_dragging(), clear_dragging(), is_dragging(), editor::editor_controller::mouse_motion(), mouse_motion_default(), and mouse_press().
|
protected |
Actual drag flag.
Definition at line 187 of file mouse_handler_base.hpp.
Referenced by cancel_dragging(), clear_dragging(), events::mouse_handler::mouse_motion(), mouse_motion_default(), and mouse_press().
|
protected |
last highlighted hex
Definition at line 198 of file mouse_handler_base.hpp.
Referenced by events::mouse_handler::get_last_hex(), left_click(), events::mouse_handler::mouse_motion(), mouse_motion_default(), mouse_press(), events::mouse_handler::move_action(), events::mouse_handler::select_hex(), events::mouse_handler::select_or_action(), and events::mouse_handler::selected_unit().
|
protected |
minimap scrolling (scroll-drag) state flag
Definition at line 183 of file mouse_handler_base.hpp.
Referenced by left_click(), mouse_motion_default(), and mouse_press().
|
protected |
Relative to middle click scrolling.
Definition at line 204 of file mouse_handler_base.hpp.
Referenced by get_scroll_start(), and set_scroll_start().
|
protected |
Definition at line 205 of file mouse_handler_base.hpp.
Referenced by get_scroll_start(), and set_scroll_start().
|
protected |
Definition at line 206 of file mouse_handler_base.hpp.
Referenced by mouse_press(), and scroll_started().
|
protected |
Show context menu flag.
Definition at line 201 of file mouse_handler_base.hpp.
Referenced by get_show_menu(), mouse_press(), and right_click().
|
protected |
MMB click (on game map) state flag.
Definition at line 181 of file mouse_handler_base.hpp.
Referenced by mouse_motion_default(), and mouse_press().