This is the base class for hotkey event matching. More...
#include <hotkey_item.hpp>
Public Member Functions | |
hotkey_base () | |
Initialises a new empty hotkey that will be disabled. More... | |
void | set_command (const std::string &command) |
void | set_mods (unsigned int mods) |
Set keyboard modifiers. More... | |
const std::string & | get_command () const |
Returns the string name of the HOTKEY_COMMAND. More... | |
const std::string | get_description () const |
Returns the translated description. More... | |
virtual bool | hidden () const |
This controls whether the item should appear in the hotkey preferences. More... | |
bool | is_default () const |
This indicates whether a hotkey is from the default config or if it's from the user preferences. More... | |
void | unset_default () |
Used to indicate that a hotkey is overridden and should be treated as a user-set hotkey. More... | |
bool | is_disabled () const |
void | disable () |
void | enable () |
void | clear () |
Unbind this hotkey by linking it to the null-command. More... | |
bool | null () const |
Returns whether this hotkey points to the null-command. More... | |
bool | active () const |
virtual bool | valid () const =0 |
Evaluates whether the hotkey bindings are valid. More... | |
void | save (config &cfg) const |
Save the hotkey into the configuration object. More... | |
const std::string | get_name () const |
Return "name" of hotkey. More... | |
bool | matches (const SDL_Event &event) const |
Used to evaluate whether: More... | |
virtual bool | bindings_equal (hotkey_ptr other) |
Checks whether the hotkey bindings and scope are equal. More... | |
virtual | ~hotkey_base () |
Protected Member Functions | |
virtual const std::string | get_name_helper () const =0 |
This is invoked by hotkey_base::get_name and must be implemented by subclasses. More... | |
virtual bool | matches_helper (const SDL_Event &event) const =0 |
This is invoked by hotkey_base::matches as a helper for the concrete classes. More... | |
virtual void | save_helper (config &cfg) const =0 |
virtual bool | bindings_equal_helper (hotkey_ptr other) const =0 |
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes. More... | |
Protected Attributes | |
std::string | command_ |
The command that should be executed, or "null". More... | |
bool | is_default_ |
is_default_ is true if the hot-key is part of the default hot-key list defined in data/core/hotkeys.cfg. More... | |
bool | is_disabled_ |
unsigned int | mod_ |
This is the base class for hotkey event matching.
Definition at line 36 of file hotkey_item.hpp.
|
inline |
Initialises a new empty hotkey that will be disabled.
Definition at line 42 of file hotkey_item.hpp.
|
inlinevirtual |
Definition at line 178 of file hotkey_item.hpp.
|
inline |
|
virtual |
Checks whether the hotkey bindings and scope are equal.
other | the hokey bindings to compare against. |
Definition at line 84 of file hotkey_item.cpp.
References bindings_equal_helper(), get_command(), hotkey::get_hotkey_command(), mod_, and hotkey::hotkey_command::scope.
|
protectedpure virtual |
This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.
Implementing classes should only check their parts of the hotkey.
other | The other hotkey the check against. Not guaranteed to be the same subclass. |
Implemented in hotkey::hotkey_void, hotkey::hotkey_mouse, and hotkey::hotkey_keyboard.
Referenced by bindings_equal().
|
inline |
Unbind this hotkey by linking it to the null-command.
Definition at line 119 of file hotkey_item.hpp.
References command_.
|
inline |
Definition at line 107 of file hotkey_item.hpp.
References is_disabled_.
|
inline |
Definition at line 111 of file hotkey_item.hpp.
References is_disabled_.
|
inline |
Returns the string name of the HOTKEY_COMMAND.
Definition at line 63 of file hotkey_item.hpp.
References command_.
Referenced by bindings_equal(), matches(), hotkey::hotkey_keyboard::matches_helper(), and save().
const std::string hotkey::hotkey_base::get_description | ( | ) | const |
Returns the translated description.
const std::string hotkey::hotkey_base::get_name | ( | ) | const |
Return "name" of hotkey.
Example :"ctrl+alt+g"
Definition at line 49 of file hotkey_item.cpp.
References get_name_helper(), and mod_.
|
protectedpure virtual |
This is invoked by hotkey_base::get_name and must be implemented by subclasses.
Keyboard modifiers are handled in this class, other hotkeys in the respective classes
Implemented in hotkey::hotkey_mouse, hotkey::hotkey_void, and hotkey::hotkey_keyboard.
Referenced by get_name().
|
inlinevirtual |
This controls whether the item should appear in the hotkey preferences.
Definition at line 79 of file hotkey_item.hpp.
|
inline |
This indicates whether a hotkey is from the default config or if it's from the user preferences.
Definition at line 89 of file hotkey_item.hpp.
References is_default_.
|
inline |
Definition at line 103 of file hotkey_item.hpp.
References is_disabled_.
bool hotkey::hotkey_base::matches | ( | const SDL_Event & | event | ) | const |
Used to evaluate whether:
event | The SDL_Event that has triggered and is being evaluated. |
Definition at line 101 of file hotkey_item.cpp.
References active(), get_command(), hotkey::get_hotkey_command(), is_disabled(), hotkey::is_scope_active(), and matches_helper().
|
protectedpure virtual |
This is invoked by hotkey_base::matches as a helper for the concrete classes.
Implementing classes should only check their parts of the hotkey.
event | The SDL_Event being generated. |
Implemented in hotkey::hotkey_mouse, hotkey::hotkey_keyboard, and hotkey::hotkey_void.
Referenced by matches().
|
inline |
Returns whether this hotkey points to the null-command.
Definition at line 128 of file hotkey_item.hpp.
References command_.
void hotkey::hotkey_base::save | ( | config & | cfg | ) | const |
Save the hotkey into the configuration object.
cfg | The configuration object to save into. |
Definition at line 110 of file hotkey_item.cpp.
References get_command(), is_disabled(), mod_, and save_helper().
|
protectedpure virtual |
Implemented in hotkey::hotkey_mouse, hotkey::hotkey_keyboard, and hotkey::hotkey_void.
Referenced by save().
|
inline |
Definition at line 45 of file hotkey_item.hpp.
References command_.
|
inline |
Set keyboard modifiers.
mods | Bitmask of SDL_Keymod. |
Definition at line 54 of file hotkey_item.hpp.
References mod_.
|
inline |
Used to indicate that a hotkey is overridden and should be treated as a user-set hotkey.
Definition at line 98 of file hotkey_item.hpp.
References is_default_.
|
pure virtual |
Evaluates whether the hotkey bindings are valid.
Implemented in hotkey::hotkey_mouse, hotkey::hotkey_void, and hotkey::hotkey_keyboard.
|
protected |
The command that should be executed, or "null".
Definition at line 206 of file hotkey_item.hpp.
Referenced by active(), clear(), get_command(), null(), and set_command().
|
protected |
is_default_ is true if the hot-key is part of the default hot-key list defined in data/core/hotkeys.cfg.
is_default_ is false if it is not, in which case it would be defined in the user's preferences file.
Definition at line 212 of file hotkey_item.hpp.
Referenced by is_default(), and unset_default().
|
protected |
Definition at line 220 of file hotkey_item.hpp.
Referenced by disable(), enable(), and is_disabled().
|
protected |
Definition at line 225 of file hotkey_item.hpp.
Referenced by bindings_equal(), get_name(), hotkey::hotkey_keyboard::matches_helper(), hotkey::hotkey_mouse::matches_helper(), save(), and set_mods().