The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
editor::brush_drag_mouse_action Class Referenceabstract

A brush-drag mouse action base class which adds brush and drag processing to a basic mouse action. More...

#include <mouse_action.hpp>

Inheritance diagram for editor::brush_drag_mouse_action:

Public Member Functions

 brush_drag_mouse_action (common_palette &palette, const brush *const *const brush, const CKey &key)
 
std::set< map_locationaffected_hexes (editor_display &disp, const map_location &hex)
 The affected hexes of a brush action are the result of projecting the current brush on the mouseover hex. More...
 
virtual std::unique_ptr< editor_actionclick_perform_left (editor_display &disp, const std::set< map_location > &hexes)=0
 The actual action function which is called by click() and drag(). More...
 
virtual std::unique_ptr< editor_actionclick_perform_right (editor_display &disp, const std::set< map_location > &hexes)=0
 The actual action function which is called by click() and drag(). More...
 
std::unique_ptr< editor_actionclick_left (editor_display &disp, int x, int y)
 Calls click_perform_left() More...
 
std::unique_ptr< editor_actionclick_right (editor_display &disp, int x, int y)
 Calls click_perform_right() More...
 
std::unique_ptr< editor_actiondrag_left (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Calls click_perform() for every new hex the mouse is dragged into. More...
 
std::unique_ptr< editor_actiondrag_right (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Calls click_perform for every new hex the mouse is dragged into. More...
 
std::unique_ptr< editor_actiondrag_end (editor_display &disp, int x, int y)
 End of dragging. More...
 
- Public Member Functions inherited from editor::mouse_action
 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::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

const brushget_brush ()
 Brush accessor. More...
 
- Protected Member Functions inherited from editor::mouse_action
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_drag_hex_
 The previous hex dragged into. More...
 
- Protected Attributes inherited from editor::mouse_action
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 Member Functions

template<std::unique_ptr< editor_action >(brush_drag_mouse_action::*)(editor_display &, const std::set< map_location > &) perform_func>
std::unique_ptr< editor_actiondrag_generic (editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
 Template helper gathering actions common for both drag_right and drag_left. More...
 

Private Attributes

const brush *const *const brush_
 Current brush handle. More...
 

Detailed Description

A brush-drag mouse action base class which adds brush and drag processing to a basic mouse action.

Definition at line 165 of file mouse_action.hpp.

Constructor & Destructor Documentation

◆ brush_drag_mouse_action()

editor::brush_drag_mouse_action::brush_drag_mouse_action ( common_palette palette,
const brush *const *const  brush,
const CKey key 
)
inline

Definition at line 168 of file mouse_action.hpp.

Member Function Documentation

◆ affected_hexes()

std::set< map_location > editor::brush_drag_mouse_action::affected_hexes ( editor_display disp,
const map_location hex 
)
virtual

The affected hexes of a brush action are the result of projecting the current brush on the mouseover hex.

Reimplemented from editor::mouse_action.

Reimplemented in editor::mouse_action_select.

Definition at line 187 of file mouse_action.cpp.

References get_brush(), and editor::brush::project().

Referenced by editor::mouse_action_select::affected_hexes(), click_left(), and click_right().

◆ click_left()

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

◆ click_perform_left()

virtual std::unique_ptr<editor_action> editor::brush_drag_mouse_action::click_perform_left ( editor_display disp,
const std::set< map_location > &  hexes 
)
pure virtual

The actual action function which is called by click() and drag().

Derived classes override this instead of click() and drag().

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

Referenced by click_left().

◆ click_perform_right()

virtual std::unique_ptr<editor_action> editor::brush_drag_mouse_action::click_perform_right ( editor_display disp,
const std::set< map_location > &  hexes 
)
pure virtual

The actual action function which is called by click() and drag().

Derived classes override this instead of click() and drag().

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

Referenced by click_right().

◆ click_right()

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

◆ drag_end()

std::unique_ptr< editor_action > editor::brush_drag_mouse_action::drag_end ( editor_display disp,
int  x,
int  y 
)

End of dragging.

Todo:
partial actions (the entire drag should end up as one action)

Definition at line 219 of file mouse_action.cpp.

◆ drag_generic()

template<std::unique_ptr< editor_action >(brush_drag_mouse_action::*)(editor_display &, const std::set< map_location > &) perform_func>
std::unique_ptr< editor_action > editor::brush_drag_mouse_action::drag_generic ( editor_display disp,
int  x,
int  y,
bool &  partial,
editor_action last_undo 
)
private

Template helper gathering actions common for both drag_right and drag_left.

The drags differ only in the worker function called, which should be passed as the template parameter. This exists only to avoid copy-pasting code.

Definition at line 226 of file mouse_action.cpp.

References a, display::hex_clicked_on(), LOG_ED, and partial.

◆ drag_left()

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

Calls click_perform() for every new hex the mouse is dragged into.

Todo:
partial actions support and merging of many drag actions into one

Reimplemented from editor::mouse_action.

Definition at line 207 of file mouse_action.cpp.

References partial.

◆ drag_right()

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

Calls click_perform for every new hex the mouse is dragged into.

Todo:
partial actions support and merging of many drag actions into one

Reimplemented from editor::mouse_action.

Definition at line 213 of file mouse_action.cpp.

References partial.

◆ get_brush()

const brush & editor::brush_drag_mouse_action::get_brush ( )
protected

Brush accessor.

Definition at line 242 of file mouse_action.cpp.

References brush_.

Referenced by affected_hexes().

Member Data Documentation

◆ brush_

const brush* const* const editor::brush_drag_mouse_action::brush_
private

Current brush handle.

Currently a pointer-to-pointer with full constness. The mouse action does not modify the brush, does not modify the pointer to the current brush, and we allow setting this pointr only once, hence the three "consts".

Definition at line 243 of file mouse_action.hpp.

Referenced by get_brush().

◆ previous_drag_hex_

map_location editor::brush_drag_mouse_action::previous_drag_hex_
protected

The previous hex dragged into.

Todo:
keep a set of all "visited" locations to reduce action count in long drags that hit the same hexes multiple times?

Definition at line 226 of file mouse_action.hpp.

Referenced by click_left(), and click_right().


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