A mouse action receives events from the controller, and responds to them by creating an appropriate editor_action object. More...
#include <mouse_action.hpp>
Public Member Functions | |
mouse_action (common_palette &palette, const CKey &key) | |
virtual | ~mouse_action () |
virtual bool | has_context_menu () const |
virtual void | move (editor_display &disp, const map_location &hex) |
Mouse move (not a drag). More... | |
void | update_brush_highlights (editor_display &disp, const map_location &hex) |
Unconditionally update the brush highlights for the current tool when hex is the center location. More... | |
virtual std::set< map_location > | affected_hexes (editor_display &disp, const map_location &hex) |
Locations that would be affected by a click, used by move to update highlights. More... | |
virtual editor_action * | click_left (editor_display &disp, int x, int y)=0 |
A click, possibly the beginning of a drag. More... | |
virtual editor_action * | click_right (editor_display &disp, int x, int y)=0 |
A click, possibly the beginning of a drag. More... | |
virtual editor_action * | drag_left (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo) |
Drag operation. More... | |
virtual editor_action * | drag_right (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo) |
Drag operation. More... | |
virtual editor_action * | drag_end_left (editor_display &disp, int x, int y) |
The end of dragging. More... | |
virtual editor_action * | drag_end_right (editor_display &disp, int x, int y) |
virtual editor_action * | up_left (editor_display &disp, int x, int y) |
virtual editor_action * | up_right (editor_display &disp, int x, int y) |
virtual editor_action * | key_event (editor_display &disp, const SDL_Event &e) |
Function called by the controller on a key event for the current mouse action. More... | |
void | set_toolbar_button (const theme::menu *value) |
Helper variable setter - pointer to a toolbar menu/button used for highlighting the current action. More... | |
const theme::menu * | toolbar_button () const |
Getter for the (possibly nullptr) associated menu/button. More... | |
common_palette & | get_palette () |
Getter for the associated palette. More... | |
virtual bool | supports_brushes () const |
Whether we need the brush bar, is used to grey it out. More... | |
virtual void | set_mouse_overlay (editor_display &disp) |
Set the mouse overlay for this action. More... | |
Protected Member Functions | |
bool | has_alt_modifier () const |
bool | has_shift_modifier () const |
bool | has_ctrl_modifier () const |
void | set_terrain_mouse_overlay (editor_display &disp, const t_translation::terrain_code &fg, const t_translation::terrain_code &bg) |
Helper function for derived classes that need a active-terrain mouse overlay. More... | |
Protected Attributes | |
map_location | previous_move_hex_ |
The hex previously used in move operations. More... | |
const CKey & | key_ |
Key presses, used for modifiers (alt, shift) in some operations. More... | |
Private Attributes | |
const theme::menu * | toolbar_button_ |
Pointer to an associated menu/button, if such exists. More... | |
common_palette & | palette_ |
Pointer to an associated palette, if such exists. More... | |
A mouse action receives events from the controller, and responds to them by creating an appropriate editor_action object.
Mouse actions may store some temporary data such as the last clicked hex for better handling of click-drag. They should not modify the map or trigger refreshes, but may set brush locations and similar overlays that should be visible around the mouse cursor, hence the display references are not const.
Definition at line 36 of file mouse_action.hpp.
|
inline |
Definition at line 39 of file mouse_action.hpp.
|
inlinevirtual |
Definition at line 47 of file mouse_action.hpp.
References affected_hexes(), click_left(), click_right(), drag_end_left(), drag_end_right(), drag_left(), drag_right(), e, has_context_menu(), key_event(), move(), up_left(), up_right(), and update_brush_highlights().
|
virtual |
Locations that would be affected by a click, used by move to update highlights.
Defaults to highlight the mouseover hex. Maybe also used for actually performing the action in click() or drag().
Reimplemented in editor::mouse_action_fill, editor::mouse_action_paste, editor::brush_drag_mouse_action, and editor::mouse_action_select.
Definition at line 45 of file mouse_action.cpp.
Referenced by editor::brush_drag_mouse_action::brush_drag_mouse_action(), editor::brush_drag_mouse_action::click_left(), editor::brush_drag_mouse_action::click_right(), editor::brush_drag_mouse_action::drag_generic(), editor::mouse_action_fill::mouse_action_fill(), editor::mouse_action_paste::mouse_action_paste(), update_brush_highlights(), and ~mouse_action().
|
pure virtual |
A click, possibly the beginning of a drag.
Must be overridden.
Implemented in editor::mouse_action_starting_position, editor::mouse_action_fill, editor::mouse_action_paste, editor::mouse_action_paint, editor::brush_drag_mouse_action, editor::mouse_action_item, editor::mouse_action_unit, editor::mouse_action_village, and editor::mouse_action_map_label.
Referenced by editor::brush_drag_mouse_action::brush_drag_mouse_action(), editor::editor_controller::left_click(), editor::mouse_action_fill::mouse_action_fill(), editor::mouse_action_paint::mouse_action_paint(), editor::mouse_action_paste::mouse_action_paste(), editor::mouse_action_starting_position::mouse_action_starting_position(), and ~mouse_action().
|
pure virtual |
A click, possibly the beginning of a drag.
Must be overridden.
Implemented in editor::mouse_action_starting_position, editor::mouse_action_fill, editor::mouse_action_paste, editor::mouse_action_paint, editor::brush_drag_mouse_action, editor::mouse_action_item, editor::mouse_action_unit, editor::mouse_action_select, editor::mouse_action_village, and editor::mouse_action_map_label.
Referenced by editor::brush_drag_mouse_action::brush_drag_mouse_action(), editor::mouse_action_fill::mouse_action_fill(), editor::mouse_action_paint::mouse_action_paint(), editor::mouse_action_paste::mouse_action_paste(), editor::mouse_action_starting_position::mouse_action_starting_position(), editor::editor_controller::right_click(), and ~mouse_action().
|
virtual |
The end of dragging.
Defaults to no action.
Reimplemented in editor::mouse_action_item, and editor::mouse_action_unit.
Definition at line 65 of file mouse_action.cpp.
Referenced by editor::editor_controller::left_drag_end(), and ~mouse_action().
|
virtual |
Definition at line 71 of file mouse_action.cpp.
Referenced by editor::editor_controller::right_drag_end(), and ~mouse_action().
|
virtual |
Drag operation.
A click should have occurred earlier. Defaults to no action.
Reimplemented in editor::brush_drag_mouse_action, editor::mouse_action_item, editor::mouse_action_unit, and editor::mouse_action_map_label.
Definition at line 53 of file mouse_action.cpp.
Referenced by editor::brush_drag_mouse_action::brush_drag_mouse_action(), editor::editor_controller::mouse_motion(), and ~mouse_action().
|
virtual |
Drag operation.
A click should have occurred earlier. Defaults to no action.
Reimplemented in editor::brush_drag_mouse_action.
Definition at line 59 of file mouse_action.cpp.
Referenced by editor::brush_drag_mouse_action::brush_drag_mouse_action(), editor::editor_controller::mouse_motion(), and ~mouse_action().
|
inline |
Getter for the associated palette.
Definition at line 118 of file mouse_action.hpp.
References palette_.
Referenced by editor::editor_toolkit::get_palette().
|
protected |
Definition at line 125 of file mouse_action.cpp.
References key_.
Referenced by key_event(), and supports_brushes().
|
virtual |
Reimplemented in editor::mouse_action_paste, editor::mouse_action_select, editor::mouse_action_item, and editor::mouse_action_unit.
Definition at line 27 of file mouse_action.cpp.
Referenced by editor::mouse_action_paste::mouse_action_paste(), editor::editor_controller::right_click_show_menu(), and ~mouse_action().
|
protected |
Definition at line 135 of file mouse_action.cpp.
References key_.
Referenced by editor::mouse_action_paint::click_left(), editor::mouse_action_fill::click_left(), editor::mouse_action_select::click_perform_left(), editor::mouse_action_paint::click_perform_left(), editor::mouse_action_paint::click_perform_right(), editor::mouse_action_paint::click_right(), editor::mouse_action_fill::click_right(), supports_brushes(), and editor::mouse_action_starting_position::up_left().
|
protected |
Definition at line 130 of file mouse_action.cpp.
References key_.
Referenced by editor::mouse_action_select::affected_hexes(), editor::mouse_action_fill::click_left(), editor::mouse_action_paint::click_perform_left(), editor::mouse_action_paint::click_perform_right(), editor::mouse_action_fill::click_right(), editor::mouse_action_select::set_mouse_overlay(), and supports_brushes().
|
virtual |
Function called by the controller on a key event for the current mouse action.
Defaults to starting position processing.
Reimplemented in editor::mouse_action_select.
Definition at line 89 of file mouse_action.cpp.
References a, display::get_map(), has_alt_modifier(), gamemap::is_starting_position(), editor::editor_display::map(), gamemap::MAX_PLAYERS, gamemap::on_board(), previous_move_hex_, display::scroll_to_tile(), gamemap::starting_position(), map_location::valid(), and display::WARP.
Referenced by editor::mouse_action_select::key_event(), editor::editor_controller::process_keyup_event(), and ~mouse_action().
|
virtual |
Mouse move (not a drag).
Never changes anything (other than temporary highlights and similar)
Reimplemented in editor::mouse_action_item, and editor::mouse_action_unit.
Definition at line 32 of file mouse_action.cpp.
References previous_move_hex_, and update_brush_highlights().
Referenced by editor::brush_drag_mouse_action::drag_generic(), editor::editor_controller::mouse_motion(), and ~mouse_action().
|
virtual |
Set the mouse overlay for this action.
Defaults to an empty overlay.
Reimplemented in editor::mouse_action_starting_position, editor::mouse_action_fill, editor::mouse_action_paste, editor::mouse_action_paint, editor::mouse_action_item, editor::mouse_action_unit, editor::mouse_action_select, editor::mouse_action_village, and editor::mouse_action_map_label.
Definition at line 120 of file mouse_action.cpp.
References display::set_mouseover_hex_overlay().
Referenced by editor::mouse_action_fill::mouse_action_fill(), editor::mouse_action_paint::mouse_action_paint(), editor::mouse_action_paste::mouse_action_paste(), editor::mouse_action_starting_position::mouse_action_starting_position(), editor::editor_toolkit::set_mouseover_overlay(), and supports_brushes().
|
protected |
Helper function for derived classes that need a active-terrain mouse overlay.
Definition at line 144 of file mouse_action.cpp.
References adjust_surface_alpha(), terrain_type::editor_image(), ERR_ED, image::get_hexmask(), image::get_image(), display::get_map(), gamemap::get_terrain_info(), display::hex_size(), mask_surface(), scale_surface(), sdl_blit(), display::set_mouseover_hex_overlay(), utf8::size(), and game_config::tile_size.
Referenced by editor::mouse_action_paint::set_mouse_overlay(), editor::mouse_action_fill::set_mouse_overlay(), and supports_brushes().
|
inline |
Helper variable setter - pointer to a toolbar menu/button used for highlighting the current action.
Should always be nullptr or point to a valid menu.
Definition at line 108 of file mouse_action.hpp.
References toolbar_button_.
|
inlinevirtual |
Whether we need the brush bar, is used to grey it out.
Reimplemented in editor::mouse_action_paint, and editor::mouse_action_select.
Definition at line 121 of file mouse_action.hpp.
References has_alt_modifier(), has_ctrl_modifier(), has_shift_modifier(), set_mouse_overlay(), and set_terrain_mouse_overlay().
Referenced by editor::editor_controller::can_execute_command().
|
inline |
Getter for the (possibly nullptr) associated menu/button.
Definition at line 113 of file mouse_action.hpp.
References toolbar_button_.
|
virtual |
Reimplemented in editor::mouse_action_starting_position, editor::mouse_action_item, editor::mouse_action_unit, editor::mouse_action_map_label, and editor::mouse_action_village.
Definition at line 83 of file mouse_action.cpp.
Referenced by editor::editor_controller::left_mouse_up(), editor::mouse_action_starting_position::mouse_action_starting_position(), and ~mouse_action().
|
virtual |
Reimplemented in editor::mouse_action_starting_position, editor::mouse_action_village, and editor::mouse_action_map_label.
Definition at line 77 of file mouse_action.cpp.
Referenced by editor::mouse_action_starting_position::mouse_action_starting_position(), editor::editor_controller::right_mouse_up(), and ~mouse_action().
void editor::mouse_action::update_brush_highlights | ( | editor_display & | disp, |
const map_location & | hex | ||
) |
Unconditionally update the brush highlights for the current tool when hex is the center location.
Definition at line 40 of file mouse_action.cpp.
References affected_hexes(), and editor::editor_display::set_brush_locs().
Referenced by editor::mouse_action_select::key_event(), editor::mouse_action_item::move(), editor::mouse_action_unit::move(), move(), editor::mouse_action_map_label::up_left(), editor::mouse_action_starting_position::up_left(), editor::editor_toolkit::update_mouse_action_highlights(), and ~mouse_action().
|
protected |
Key presses, used for modifiers (alt, shift) in some operations.
Definition at line 148 of file mouse_action.hpp.
Referenced by has_alt_modifier(), has_ctrl_modifier(), and has_shift_modifier().
|
private |
Pointer to an associated palette, if such exists.
Definition at line 159 of file mouse_action.hpp.
Referenced by get_palette().
|
protected |
The hex previously used in move operations.
Definition at line 143 of file mouse_action.hpp.
Referenced by editor::mouse_action_select::key_event(), key_event(), editor::mouse_action_unit::move(), editor::mouse_action_item::move(), and move().
|
private |
Pointer to an associated menu/button, if such exists.
Definition at line 154 of file mouse_action.hpp.
Referenced by set_toolbar_button(), and toolbar_button().