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 overriden 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 43 of file hotkey_item.hpp.
|
inline |
Initialises a new empty hotkey that will be disabled.
Definition at line 49 of file hotkey_item.hpp.
|
inlinevirtual |
Definition at line 185 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 108 of file hotkey_item.cpp.
References bindings_equal_helper(), get_command(), hotkey::get_hotkey_command(), mod_, and hotkey::hotkey_command::scope.
Referenced by hotkey::add_hotkey().
|
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_mouse, hotkey::hotkey_void, and hotkey::hotkey_keyboard.
Referenced by bindings_equal().
|
inline |
Unbind this hotkey by linking it to the null-command.
Definition at line 126 of file hotkey_item.hpp.
References command_.
|
inline |
Definition at line 114 of file hotkey_item.hpp.
References is_disabled_.
|
inline |
Definition at line 118 of file hotkey_item.hpp.
References is_disabled_.
|
inline |
Returns the string name of the HOTKEY_COMMAND.
Definition at line 70 of file hotkey_item.hpp.
References command_.
Referenced by bindings_equal(), matches(), 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 73 of file hotkey_item.cpp.
References filesystem::ends_with(), 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 86 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 96 of file hotkey_item.hpp.
References is_default_.
|
inline |
Definition at line 110 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 129 of file hotkey_item.cpp.
References active(), get_command(), hotkey::get_hotkey_command(), is_disabled(), hotkey::is_scope_active(), matches_helper(), mod_, and hotkey::sdl_get_mods().
|
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_void, and hotkey::hotkey_keyboard.
Referenced by matches().
|
inline |
Returns whether this hotkey points to the null-command.
Definition at line 135 of file hotkey_item.hpp.
References command_.
Save the hotkey into the configuration object.
cfg | The configuration object to save into. |
Definition at line 145 of file hotkey_item.cpp.
References get_command(), is_disabled(), mod_, and save_helper().
Implemented in hotkey::hotkey_mouse, hotkey::hotkey_void, and hotkey::hotkey_keyboard.
Referenced by save().
|
inline |
Definition at line 52 of file hotkey_item.hpp.
References command_.
Set keyboard modifiers.
mods | Bitmask of SDLMod. |
Definition at line 61 of file hotkey_item.hpp.
References mod_.
|
inline |
Used to indicate that a hotkey is overriden and should be treated as a user-set hotkey.
Definition at line 105 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 213 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 219 of file hotkey_item.hpp.
Referenced by is_default(), and unset_default().
|
protected |
Definition at line 227 of file hotkey_item.hpp.
Referenced by disable(), enable(), and is_disabled().
|
protected |
Definition at line 232 of file hotkey_item.hpp.
Referenced by bindings_equal(), get_name(), matches(), save(), and set_mods().