2022-02-25 15:22:58 +00:00
|
|
|
#include "../infrared_app.h"
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SubmenuIndexUniversalTV,
|
|
|
|
SubmenuIndexUniversalAudio,
|
|
|
|
SubmenuIndexUniversalAirConditioner,
|
|
|
|
} SubmenuIndex;
|
|
|
|
|
|
|
|
static void submenu_callback(void* context, uint32_t index) {
|
2022-02-25 15:22:58 +00:00
|
|
|
InfraredApp* app = static_cast<InfraredApp*>(context);
|
|
|
|
InfraredAppEvent event;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
event.type = InfraredAppEvent::Type::MenuSelected;
|
2021-06-02 15:16:05 +00:00
|
|
|
event.payload.menu_index = index;
|
|
|
|
|
|
|
|
app->get_view_manager()->send_event(&event);
|
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
void InfraredAppSceneUniversal::on_enter(InfraredApp* app) {
|
|
|
|
InfraredAppViewManager* view_manager = app->get_view_manager();
|
2021-06-02 15:16:05 +00:00
|
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
|
|
|
2022-04-06 10:40:29 +00:00
|
|
|
submenu_add_item(submenu, "TVs", SubmenuIndexUniversalTV, submenu_callback, app);
|
2021-06-09 13:04:49 +00:00
|
|
|
submenu_set_selected_item(submenu, submenu_item_selected);
|
|
|
|
submenu_item_selected = 0;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
view_manager->switch_to(InfraredAppViewManager::ViewId::Submenu);
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
bool InfraredAppSceneUniversal::on_event(InfraredApp* app, InfraredAppEvent* event) {
|
2021-06-02 15:16:05 +00:00
|
|
|
bool consumed = false;
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
if(event->type == InfraredAppEvent::Type::MenuSelected) {
|
2021-06-09 13:04:49 +00:00
|
|
|
submenu_item_selected = event->payload.menu_index;
|
2021-06-02 15:16:05 +00:00
|
|
|
switch(event->payload.menu_index) {
|
|
|
|
case SubmenuIndexUniversalTV:
|
2022-02-25 15:22:58 +00:00
|
|
|
app->switch_to_next_scene(InfraredApp::Scene::UniversalTV);
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
|
|
|
case SubmenuIndexUniversalAudio:
|
2022-02-25 15:22:58 +00:00
|
|
|
// app->switch_to_next_scene(InfraredApp::Scene::UniversalAudio);
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
|
|
|
case SubmenuIndexUniversalAirConditioner:
|
2022-02-25 15:22:58 +00:00
|
|
|
// app->switch_to_next_scene(InfraredApp::Scene::UniversalAirConditioner);
|
2021-06-02 15:16:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
consumed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
2022-02-25 15:22:58 +00:00
|
|
|
void InfraredAppSceneUniversal::on_exit(InfraredApp* app) {
|
|
|
|
InfraredAppViewManager* view_manager = app->get_view_manager();
|
2021-06-02 15:16:05 +00:00
|
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
|
|
|
2022-01-21 17:32:03 +00:00
|
|
|
submenu_reset(submenu);
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|