2024-03-10 09:41:50 -04:00
|
|
|
#include <map>
|
2024-02-12 13:57:51 -05:00
|
|
|
#include <string>
|
|
|
|
#include <list>
|
2024-03-10 09:41:50 -04:00
|
|
|
#include <map>
|
2024-02-12 13:57:51 -05:00
|
|
|
#include <lvgl.h>
|
2024-02-12 14:51:34 -05:00
|
|
|
#include "guiRegistry.h"
|
2024-03-10 14:27:46 -04:00
|
|
|
#include "applicationInternal/gui/guiBase.h"
|
|
|
|
#include "applicationInternal/hardware/hardwarePresenter.h"
|
2024-03-25 17:08:51 -04:00
|
|
|
#include "scenes/scene__defaultKeys.h"
|
2024-02-12 13:57:51 -05:00
|
|
|
|
2024-03-10 09:41:50 -04:00
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
// this is a map of the registered_guis that can be accessed by name
|
|
|
|
std::map<std::string, gui_definition> registered_guis_byName_map;
|
2024-02-12 13:57:51 -05:00
|
|
|
|
2024-03-10 09:41:50 -04:00
|
|
|
// ------------------------------------------------------------------------------------
|
2024-02-12 13:57:51 -05:00
|
|
|
|
|
|
|
|
2024-03-10 09:41:50 -04:00
|
|
|
void register_gui(std::string a_name, create_tab_content a_create_tab_content, notify_tab_before_delete a_notify_tab_before_delete) {
|
|
|
|
|
|
|
|
if (registered_guis_byName_map.count(a_name) > 0) {
|
|
|
|
Serial.printf("ERROR!!!: you cannot register two guis having the same name '%s'\r\n", a_name.c_str());
|
|
|
|
return;
|
2024-02-12 13:57:51 -05:00
|
|
|
}
|
|
|
|
|
2024-03-10 09:41:50 -04:00
|
|
|
gui_definition new_gui_definition = gui_definition{a_name, a_create_tab_content, a_notify_tab_before_delete};
|
|
|
|
|
|
|
|
// put the gui_definition in a map that can be accessed by name
|
|
|
|
registered_guis_byName_map[a_name] = new_gui_definition;
|
|
|
|
|
2024-03-25 17:08:51 -04:00
|
|
|
// By default, put all registered guis in the sequence of guis to be shown of the default scene
|
|
|
|
// Can be overwritten by scenes to have their own gui_list.
|
|
|
|
main_gui_list.insert(main_gui_list.end(), {std::string(a_name)});
|
2024-03-10 09:41:50 -04:00
|
|
|
|
2024-02-12 13:57:51 -05:00
|
|
|
}
|