set keys again both for new guis and new scenes
This commit is contained in:
parent
17ee1f06d0
commit
8f0ceeb72b
5 changed files with 32 additions and 32 deletions
|
@ -48,10 +48,21 @@ void register_gui(
|
||||||
// Can be overwritten by scenes to have their own gui_list.
|
// Can be overwritten by scenes to have their own gui_list.
|
||||||
main_gui_list.insert(main_gui_list.end(), {std::string(a_name)});
|
main_gui_list.insert(main_gui_list.end(), {std::string(a_name)});
|
||||||
|
|
||||||
// Whenever a new gui is registered, a new gui command could have been defined.
|
setKeysForAllRegisteredGUIsAndScenes();
|
||||||
// But this new gui command could have been already been used before in the key definition of another gui. The command at this time was 0, which is undefined.
|
|
||||||
// So we have to set the keys again for all guis that have been registered before.
|
}
|
||||||
// Loop over all registered guis and call setKeys()
|
|
||||||
|
void setKeysForAllRegisteredGUIsAndScenes() {
|
||||||
|
// Whenever a new gui or scene is registered, a new gui or scene command could have been defined in the gui or scene.
|
||||||
|
// But this new command could have already been used before in the key definition of another gui or scene. The command at this time was 0, which is undefined.
|
||||||
|
// So we have to set the keys again for all guis and scenes that have been registered before.
|
||||||
|
// 1. set again the defaultKeys
|
||||||
|
register_scene_defaultKeys();
|
||||||
|
// 2. loop over all registered scenes and call setKeys()
|
||||||
|
for (std::map<std::string, scene_definition>::iterator it = registered_scenes.begin(); it != registered_scenes.end(); ++it) {
|
||||||
|
it->second.this_scene_setKeys();
|
||||||
|
}
|
||||||
|
// 3. loop over all registered guis and call setKeys()
|
||||||
for (std::map<std::string, gui_definition>::iterator it = registered_guis_byName_map.begin(); it != registered_guis_byName_map.end(); ++it) {
|
for (std::map<std::string, gui_definition>::iterator it = registered_guis_byName_map.begin(); it != registered_guis_byName_map.end(); ++it) {
|
||||||
if (it->second.this_gui_setKeys != NULL) {
|
if (it->second.this_gui_setKeys != NULL) {
|
||||||
it->second.this_gui_setKeys();
|
it->second.this_gui_setKeys();
|
||||||
|
|
|
@ -50,3 +50,5 @@ void register_gui(
|
||||||
key_commands_short a_key_commands_short = NULL,
|
key_commands_short a_key_commands_short = NULL,
|
||||||
key_commands_long a_key_commands_long = NULL
|
key_commands_long a_key_commands_long = NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void setKeysForAllRegisteredGUIsAndScenes();
|
|
@ -8,18 +8,6 @@
|
||||||
// scenes
|
// scenes
|
||||||
#include "scenes/scene__default.h"
|
#include "scenes/scene__default.h"
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work
|
|
||||||
struct scene_definition {
|
|
||||||
scene_setKeys this_scene_setKeys;
|
|
||||||
scene_start_sequence this_scene_start_sequence;
|
|
||||||
scene_end_sequence this_scene_end_sequence;
|
|
||||||
key_repeatModes this_key_repeatModes;
|
|
||||||
key_commands_short this_key_commands_short;
|
|
||||||
key_commands_long this_key_commands_long;
|
|
||||||
gui_list this_gui_list;
|
|
||||||
uint16_t this_activate_scene_command;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::map<std::string, scene_definition> registered_scenes;
|
std::map<std::string, scene_definition> registered_scenes;
|
||||||
t_scene_list scenes_on_sceneSelectionGUI;
|
t_scene_list scenes_on_sceneSelectionGUI;
|
||||||
|
|
||||||
|
@ -51,21 +39,7 @@ void register_scene(
|
||||||
// Can be overwritten in main.cpp
|
// Can be overwritten in main.cpp
|
||||||
scenes_on_sceneSelectionGUI.insert(scenes_on_sceneSelectionGUI.end(), {std::string(a_scene_name)});
|
scenes_on_sceneSelectionGUI.insert(scenes_on_sceneSelectionGUI.end(), {std::string(a_scene_name)});
|
||||||
|
|
||||||
// Whenever a new scene is registered, normally a new scene command has been defined immediately before (e.g. see register_scene_TV()).
|
setKeysForAllRegisteredGUIsAndScenes();
|
||||||
// But this new scene command could have been already been used before in the key definition of another scene or a gui. The command at this time was 0, which is undefined.
|
|
||||||
// So we have to set the keys again for all scenes and guis that have been registered before.
|
|
||||||
// 1. set again the defaultKeys
|
|
||||||
register_scene_defaultKeys();
|
|
||||||
// 2. loop over all registered scenes and call setKeys()
|
|
||||||
for (std::map<std::string, scene_definition>::iterator it = registered_scenes.begin(); it != registered_scenes.end(); ++it) {
|
|
||||||
it->second.this_scene_setKeys();
|
|
||||||
}
|
|
||||||
// 3. loop over all registered guis and call setKeys()
|
|
||||||
for (std::map<std::string, gui_definition>::iterator it = registered_guis_byName_map.begin(); it != registered_guis_byName_map.end(); ++it) {
|
|
||||||
if (it->second.this_gui_setKeys != NULL) {
|
|
||||||
it->second.this_gui_setKeys();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,20 @@ typedef void (*scene_end_sequence)(void);
|
||||||
typedef t_gui_list *gui_list;
|
typedef t_gui_list *gui_list;
|
||||||
typedef t_scene_list *scene_list;
|
typedef t_scene_list *scene_list;
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work
|
||||||
|
struct scene_definition {
|
||||||
|
scene_setKeys this_scene_setKeys;
|
||||||
|
scene_start_sequence this_scene_start_sequence;
|
||||||
|
scene_end_sequence this_scene_end_sequence;
|
||||||
|
key_repeatModes this_key_repeatModes;
|
||||||
|
key_commands_short this_key_commands_short;
|
||||||
|
key_commands_long this_key_commands_long;
|
||||||
|
gui_list this_gui_list;
|
||||||
|
uint16_t this_activate_scene_command;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern std::map<std::string, scene_definition> registered_scenes;
|
||||||
|
|
||||||
void register_scene(
|
void register_scene(
|
||||||
std::string a_scene_name,
|
std::string a_scene_name,
|
||||||
scene_setKeys a_scene_setKeys,
|
scene_setKeys a_scene_setKeys,
|
||||||
|
|
|
@ -104,7 +104,6 @@ int main(int argc, char *argv[]) {
|
||||||
register_keyboardCommands();
|
register_keyboardCommands();
|
||||||
|
|
||||||
// Register the GUIs. They will be displayed in the order they have been registered.
|
// Register the GUIs. They will be displayed in the order they have been registered.
|
||||||
// GUIs must be registered before the scenes, because only the scenes re-register key bindings to commands which have been defined after the key binding (see register_scene())
|
|
||||||
register_gui_sceneSelection();
|
register_gui_sceneSelection();
|
||||||
register_gui_irReceiver();
|
register_gui_irReceiver();
|
||||||
register_gui_settings();
|
register_gui_settings();
|
||||||
|
|
Loading…
Reference in a new issue