The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
editor::mouse_action Class Referenceabstract

A mouse action receives events from the controller, and responds to them by creating an appropriate editor_action object. More...

#include <mouse_action.hpp>

Inheritance diagram for editor::mouse_action:

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_locationaffected_hexes (editor_display &disp, const map_location &hex)
 Locations that would be affected by a click, used by move to update highlights. More...
 
virtual std::unique_ptr< editor_actionclick_left (editor_display &disp, int x, int y)=0
 A click, possibly the beginning of a drag. More...
 
virtual std::unique_ptr< editor_actionclick_right (editor_display &disp, int x, int y)=0
 A click, possibly the beginning of a drag. More...
 
virtual std::unique_ptr< editor_actiondrag_left (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Drag operation. More...
 
virtual std::unique_ptr< editor_actiondrag_right (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Drag operation. More...
 
virtual std::unique_ptr< editor_actiondrag_end_left (editor_display &disp, int x, int y)
 The end of dragging. More...
 
virtual std::unique_ptr< editor_actiondrag_end_right (editor_display &disp, int x, int y)
 
virtual std::unique_ptr< editor_actionup_left (editor_display &disp, int x, int y)
 
virtual std::unique_ptr< editor_actionup_right (editor_display &disp, int x, int y)
 
virtual std::unique_ptr< editor_actionkey_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::menutoolbar_button () const
 Getter for the (possibly nullptr) associated menu/button. More...
 
common_paletteget_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 CKeykey_
 Key presses, used for modifiers (alt, shift) in some operations. More...
 

Private Attributes

const theme::menutoolbar_button_
 Pointer to an associated menu/button, if such exists. More...
 
common_palettepalette_
 Pointer to an associated palette, if such exists. More...
 

Detailed Description

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 35 of file mouse_action.hpp.

Constructor & Destructor Documentation

◆ mouse_action()

editor::mouse_action::mouse_action ( common_palette palette,
const CKey key 
)
inline

Definition at line 38 of file mouse_action.hpp.

◆ ~mouse_action()

virtual editor::mouse_action::~mouse_action ( )
inlinevirtual

Definition at line 46 of file mouse_action.hpp.

Member Function Documentation

◆ affected_hexes()

std::set< map_location > editor::mouse_action::affected_hexes ( editor_display disp,
const map_location hex 
)
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_select, editor::mouse_action_fill, editor::mouse_action_paste, and editor::brush_drag_mouse_action.

Definition at line 48 of file mouse_action.cpp.

Referenced by update_brush_highlights().

◆ click_left()

virtual std::unique_ptr<editor_action> editor::mouse_action::click_left ( editor_display disp,
int  x,
int  y 
)
pure virtual

◆ click_right()

virtual std::unique_ptr<editor_action> editor::mouse_action::click_right ( editor_display disp,
int  x,
int  y 
)
pure virtual

◆ drag_end_left()

std::unique_ptr< editor_action > editor::mouse_action::drag_end_left ( editor_display disp,
int  x,
int  y 
)
virtual

The end of dragging.

Defaults to no action.

Reimplemented in editor::mouse_action_unit, editor::mouse_action_map_label, and editor::mouse_action_item.

Definition at line 68 of file mouse_action.cpp.

Referenced by editor::editor_controller::left_drag_end().

◆ drag_end_right()

std::unique_ptr< editor_action > editor::mouse_action::drag_end_right ( editor_display disp,
int  x,
int  y 
)
virtual

Definition at line 74 of file mouse_action.cpp.

Referenced by editor::editor_controller::right_drag_end().

◆ drag_left()

std::unique_ptr< editor_action > editor::mouse_action::drag_left ( editor_display disp,
int  x,
int  y,
bool &  partial,
editor_action last_undo 
)
virtual

Drag operation.

A click should have occurred earlier. Defaults to no action.

Reimplemented in editor::mouse_action_unit, editor::mouse_action_map_label, editor::mouse_action_item, and editor::brush_drag_mouse_action.

Definition at line 56 of file mouse_action.cpp.

Referenced by editor::editor_controller::mouse_motion().

◆ drag_right()

std::unique_ptr< editor_action > editor::mouse_action::drag_right ( editor_display disp,
int  x,
int  y,
bool &  partial,
editor_action last_undo 
)
virtual

Drag operation.

A click should have occurred earlier. Defaults to no action.

Reimplemented in editor::brush_drag_mouse_action.

Definition at line 62 of file mouse_action.cpp.

Referenced by editor::editor_controller::mouse_motion().

◆ get_palette()

common_palette& editor::mouse_action::get_palette ( )
inline

Getter for the associated palette.

Definition at line 117 of file mouse_action.hpp.

References palette_.

Referenced by editor::editor_toolkit::get_palette().

◆ has_alt_modifier()

bool editor::mouse_action::has_alt_modifier ( ) const
protected

Definition at line 128 of file mouse_action.cpp.

References key_.

Referenced by key_event().

◆ has_context_menu()

bool editor::mouse_action::has_context_menu ( ) const
virtual

◆ has_ctrl_modifier()

bool editor::mouse_action::has_ctrl_modifier ( ) const
protected

◆ has_shift_modifier()

bool editor::mouse_action::has_shift_modifier ( ) const
protected

◆ key_event()

std::unique_ptr< editor_action > editor::mouse_action::key_event ( editor_display disp,
const SDL_Event &  e 
)
virtual

◆ move()

void editor::mouse_action::move ( editor_display disp,
const map_location hex 
)
virtual

Mouse move (not a drag).

Never changes anything (other than temporary highlights and similar)

Reimplemented in editor::mouse_action_unit, and editor::mouse_action_item.

Definition at line 33 of file mouse_action.cpp.

References previous_move_hex_, and update_brush_highlights().

Referenced by editor::editor_controller::mouse_motion().

◆ set_mouse_overlay()

void editor::mouse_action::set_mouse_overlay ( editor_display disp)
virtual

◆ set_terrain_mouse_overlay()

void editor::mouse_action::set_terrain_mouse_overlay ( editor_display disp,
const t_translation::terrain_code fg,
const t_translation::terrain_code bg 
)
protected

◆ set_toolbar_button()

void editor::mouse_action::set_toolbar_button ( const theme::menu value)
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 107 of file mouse_action.hpp.

References toolbar_button_.

◆ supports_brushes()

virtual bool editor::mouse_action::supports_brushes ( ) const
inlinevirtual

Whether we need the brush bar, is used to grey it out.

Reimplemented in editor::mouse_action_select, and editor::mouse_action_paint.

Definition at line 120 of file mouse_action.hpp.

Referenced by editor::editor_controller::can_execute_command().

◆ toolbar_button()

const theme::menu* editor::mouse_action::toolbar_button ( ) const
inline

Getter for the (possibly nullptr) associated menu/button.

Definition at line 112 of file mouse_action.hpp.

References toolbar_button_.

◆ up_left()

std::unique_ptr< editor_action > editor::mouse_action::up_left ( editor_display disp,
int  x,
int  y 
)
virtual

◆ up_right()

std::unique_ptr< editor_action > editor::mouse_action::up_right ( editor_display disp,
int  x,
int  y 
)
virtual

◆ update_brush_highlights()

void editor::mouse_action::update_brush_highlights ( editor_display disp,
const map_location hex 
)

Member Data Documentation

◆ key_

const CKey& editor::mouse_action::key_
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().

◆ palette_

common_palette& editor::mouse_action::palette_
private

Pointer to an associated palette, if such exists.

Definition at line 159 of file mouse_action.hpp.

Referenced by get_palette().

◆ previous_move_hex_

map_location editor::mouse_action::previous_move_hex_
protected

The hex previously used in move operations.

Definition at line 143 of file mouse_action.hpp.

Referenced by key_event(), editor::mouse_action_select::key_event(), move(), editor::mouse_action_item::move(), and editor::mouse_action_unit::move().

◆ toolbar_button_

const theme::menu* editor::mouse_action::toolbar_button_
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().


The documentation for this class was generated from the following files: