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

#include <controller_base.hpp>

Inheritance diagram for controller_base:

Classes

class  keyup_listener
 

Public Member Functions

 controller_base ()
 
virtual ~controller_base ()
 
virtual void play_slice ()
 
void apply_keyboard_scroll (int x, int y)
 
void set_scroll_up (bool on)
 
void set_scroll_down (bool on)
 
void set_scroll_left (bool on)
 
void set_scroll_right (bool on)
 
virtual hotkey::command_executorget_hotkey_command_executor ()
 Optionally get a command executor to handle context menu events. More...
 
- Public Member Functions inherited from events::sdl_handler
virtual void handle_window_event (const SDL_Event &)
 
virtual void process_event ()
 
virtual bool requires_event_focus (const SDL_Event *=nullptr) const
 
virtual void process_tooltip_string (int, int)
 
virtual void join ()
 
virtual void join (context &c)
 
virtual void join_same (sdl_handler *parent)
 
virtual void leave ()
 
virtual void join_global ()
 
virtual void leave_global ()
 
virtual bool has_joined ()
 
virtual bool has_joined_global ()
 
sdl_handleroperator= (sdl_handler &&)=delete
 Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More...
 
 sdl_handler (sdl_handler &&)=delete
 
- Public Member Functions inherited from events::pump_monitor
 pump_monitor ()
 
virtual ~pump_monitor ()
 

Protected Member Functions

virtual bool is_browsing () const
 
virtual events::mouse_handler_baseget_mouse_handler_base ()=0
 Get a reference to a mouse handler member a derived class uses. More...
 
virtual displayget_display ()=0
 Get a reference to a display member a derived class uses. More...
 
virtual soundsource::managerget_soundsource_man ()
 Get (optionally) a soundsources manager a derived class uses. More...
 
virtual plugins_contextget_plugins_context ()
 Get (optionally) a plugins context a derived class uses. More...
 
virtual bool have_keyboard_focus ()
 Derived classes should override this to return false when arrow keys should not scroll the map, hotkeys not processed etc, for example when a textbox is active. More...
 
virtual std::vector< std::string > additional_actions_pressed ()
 
bool handle_scroll (int mousex, int mousey, int mouse_flags)
 Handle scrolling by keyboard, joystick and moving mouse near map edges. More...
 
void handle_event (const SDL_Event &event) override
 Process mouse- and keypress-events from SDL. More...
 
virtual void process_focus_keydown_event (const SDL_Event &)
 Process keydown (only when the general map display does not have focus). More...
 
virtual void process () override
 
virtual void process_keydown_event (const SDL_Event &)
 Process keydown (always). More...
 
virtual void process_keyup_event (const SDL_Event &)
 Process keyup (always). More...
 
virtual void show_menu (const std::vector< config > &items_arg, int xloc, int yloc, bool context_menu, display &disp)
 
virtual void execute_action (const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu)
 
virtual bool in_context_menu (const hotkey::ui_command &cmd) const
 
void long_touch_callback (int x, int y)
 
- Protected Member Functions inherited from events::sdl_handler
 sdl_handler (const bool auto_join=true)
 
 sdl_handler (const sdl_handler &)
 
sdl_handleroperator= (const sdl_handler &)
 
virtual ~sdl_handler ()
 
virtual std::vector< sdl_handler * > handler_members ()
 

Protected Attributes

const game_config_viewgame_config_
 
CKey key_
 
bool scrolling_
 
bool scroll_up_
 
bool scroll_down_
 
bool scroll_left_
 
bool scroll_right_
 
std::chrono::steady_clock::time_point last_scroll_tick_
 
double scroll_carry_x_
 
double scroll_carry_y_
 

Private Attributes

keyup_listener key_release_listener_
 
bool last_mouse_is_touch_
 
size_t long_touch_timer_
 Context menu timer. More...
 

Detailed Description

Definition at line 66 of file controller_base.hpp.

Constructor & Destructor Documentation

◆ controller_base()

controller_base::controller_base ( )

Definition at line 39 of file controller_base.cpp.

◆ ~controller_base()

controller_base::~controller_base ( )
virtual

Definition at line 56 of file controller_base.cpp.

References long_touch_timer_, and gui2::remove_timer().

Member Function Documentation

◆ additional_actions_pressed()

virtual std::vector<std::string> controller_base::additional_actions_pressed ( )
inlineprotectedvirtual

Reimplemented in editor::editor_controller.

Definition at line 134 of file controller_base.hpp.

Referenced by play_slice().

◆ apply_keyboard_scroll()

void controller_base::apply_keyboard_scroll ( int  x,
int  y 
)

◆ execute_action()

void controller_base::execute_action ( const std::vector< std::string > &  items_arg,
int  xloc,
int  yloc,
bool  context_menu 
)
protectedvirtual

◆ get_display()

virtual display& controller_base::get_display ( )
protectedpure virtual

Get a reference to a display member a derived class uses.

Implemented in play_controller, and editor::editor_controller.

Referenced by execute_action(), handle_event(), handle_scroll(), long_touch_callback(), and play_slice().

◆ get_hotkey_command_executor()

virtual hotkey::command_executor* controller_base::get_hotkey_command_executor ( )
inlinevirtual

Optionally get a command executor to handle context menu events.

Reimplemented in play_controller, and editor::editor_controller.

Definition at line 97 of file controller_base.hpp.

Referenced by execute_action(), handle_event(), controller_base::keyup_listener::handle_event(), process(), and show_menu().

◆ get_mouse_handler_base()

virtual events::mouse_handler_base& controller_base::get_mouse_handler_base ( )
protectedpure virtual

Get a reference to a mouse handler member a derived class uses.

Implemented in play_controller, and editor::editor_controller.

Referenced by handle_event(), handle_scroll(), long_touch_callback(), and play_slice().

◆ get_plugins_context()

virtual plugins_context* controller_base::get_plugins_context ( )
inlineprotectedvirtual

Get (optionally) a plugins context a derived class uses.

Reimplemented in play_controller.

Definition at line 121 of file controller_base.hpp.

Referenced by play_slice().

◆ get_soundsource_man()

virtual soundsource::manager* controller_base::get_soundsource_man ( )
inlineprotectedvirtual

Get (optionally) a soundsources manager a derived class uses.

Reimplemented in play_controller.

Definition at line 115 of file controller_base.hpp.

Referenced by play_slice().

◆ handle_event()

void controller_base::handle_event ( const SDL_Event &  event)
overrideprotectedvirtual

◆ handle_scroll()

bool controller_base::handle_scroll ( int  mousex,
int  mousey,
int  mouse_flags 
)
protected

◆ have_keyboard_focus()

bool controller_base::have_keyboard_focus ( )
protectedvirtual

Derived classes should override this to return false when arrow keys should not scroll the map, hotkeys not processed etc, for example when a textbox is active.

Returns
true when arrow keys should scroll the map, false otherwise

Reimplemented in play_controller.

Definition at line 293 of file controller_base.cpp.

Referenced by handle_event().

◆ in_context_menu()

bool controller_base::in_context_menu ( const hotkey::ui_command cmd) const
protectedvirtual

◆ is_browsing()

virtual bool controller_base::is_browsing ( ) const
inlineprotectedvirtual

Reimplemented in play_controller.

Definition at line 103 of file controller_base.hpp.

Referenced by handle_event(), and play_slice().

◆ long_touch_callback()

void controller_base::long_touch_callback ( int  x,
int  y 
)
protected

◆ play_slice()

void controller_base::play_slice ( )
virtual

◆ process()

void controller_base::process ( )
overrideprotectedvirtual

◆ process_focus_keydown_event()

virtual void controller_base::process_focus_keydown_event ( const SDL_Event &  )
inlineprotectedvirtual

Process keydown (only when the general map display does not have focus).

Reimplemented in play_controller.

Definition at line 154 of file controller_base.hpp.

Referenced by handle_event().

◆ process_keydown_event()

virtual void controller_base::process_keydown_event ( const SDL_Event &  )
inlineprotectedvirtual

Process keydown (always).

Overridden in derived classes

Reimplemented in play_controller.

Definition at line 162 of file controller_base.hpp.

Referenced by handle_event().

◆ process_keyup_event()

virtual void controller_base::process_keyup_event ( const SDL_Event &  )
inlineprotectedvirtual

Process keyup (always).

  • Overridden in derived classes

Reimplemented in play_controller, and editor::editor_controller.

Definition at line 168 of file controller_base.hpp.

Referenced by handle_event().

◆ set_scroll_down()

void controller_base::set_scroll_down ( bool  on)
inline

Definition at line 81 of file controller_base.hpp.

References scroll_down_.

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

◆ set_scroll_left()

void controller_base::set_scroll_left ( bool  on)
inline

Definition at line 86 of file controller_base.hpp.

References scroll_left_.

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

◆ set_scroll_right()

void controller_base::set_scroll_right ( bool  on)
inline

Definition at line 91 of file controller_base.hpp.

References scroll_right_.

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

◆ set_scroll_up()

void controller_base::set_scroll_up ( bool  on)
inline

Definition at line 76 of file controller_base.hpp.

References scroll_up_.

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

◆ show_menu()

void controller_base::show_menu ( const std::vector< config > &  items_arg,
int  xloc,
int  yloc,
bool  context_menu,
display disp 
)
protectedvirtual

Member Data Documentation

◆ game_config_

const game_config_view& controller_base::game_config_
protected

◆ key_

CKey controller_base::key_
protected

Definition at line 182 of file controller_base.hpp.

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

◆ key_release_listener_

keyup_listener controller_base::key_release_listener_
private

Definition at line 216 of file controller_base.hpp.

◆ last_mouse_is_touch_

bool controller_base::last_mouse_is_touch_
private

Definition at line 218 of file controller_base.hpp.

Referenced by handle_event().

◆ last_scroll_tick_

std::chrono::steady_clock::time_point controller_base::last_scroll_tick_
protected

Definition at line 190 of file controller_base.hpp.

Referenced by handle_scroll().

◆ long_touch_timer_

size_t controller_base::long_touch_timer_
private

Context menu timer.

Definition at line 220 of file controller_base.hpp.

Referenced by handle_event(), long_touch_callback(), and ~controller_base().

◆ scroll_carry_x_

double controller_base::scroll_carry_x_
protected

Definition at line 193 of file controller_base.hpp.

Referenced by handle_scroll().

◆ scroll_carry_y_

double controller_base::scroll_carry_y_
protected

Definition at line 194 of file controller_base.hpp.

Referenced by handle_scroll().

◆ scroll_down_

bool controller_base::scroll_down_
protected

Definition at line 186 of file controller_base.hpp.

Referenced by handle_scroll(), and set_scroll_down().

◆ scroll_left_

bool controller_base::scroll_left_
protected

Definition at line 187 of file controller_base.hpp.

Referenced by handle_scroll(), and set_scroll_left().

◆ scroll_right_

bool controller_base::scroll_right_
protected

Definition at line 188 of file controller_base.hpp.

Referenced by handle_scroll(), and set_scroll_right().

◆ scroll_up_

bool controller_base::scroll_up_
protected

Definition at line 185 of file controller_base.hpp.

Referenced by handle_scroll(), and set_scroll_up().

◆ scrolling_

bool controller_base::scrolling_
protected

Definition at line 184 of file controller_base.hpp.

Referenced by handle_scroll(), and play_slice().


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