summaryrefslogtreecommitdiff
path: root/src/ui/screen_menu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/screen_menu.cpp')
-rw-r--r--src/ui/screen_menu.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/ui/screen_menu.cpp b/src/ui/screen_menu.cpp
index 8c402532..7134a452 100644
--- a/src/ui/screen_menu.cpp
+++ b/src/ui/screen_menu.cpp
@@ -26,7 +26,16 @@
namespace ui {
namespace screens {
-static void item_click_cb(lv_event_t* ev) {
+static void now_playing_click_cb(lv_event_t* ev) {
+ events::Ui().Dispatch(internal::ShowNowPlaying{});
+}
+
+static void settings_click_callback(lv_event_t* ev) {
+ std::shared_ptr<Screen> settings{new Settings()};
+ events::Ui().Dispatch(internal::ShowSettingsPage{.screen = settings});
+}
+
+static void index_click_cb(lv_event_t* ev) {
if (ev->user_data == NULL) {
return;
}
@@ -36,27 +45,26 @@ static void item_click_cb(lv_event_t* ev) {
events::Ui().Dispatch(internal::IndexSelected{.index = *index});
}
-Menu::Menu(std::vector<database::IndexInfo> indexes) : indexes_(indexes) {
- lv_obj_set_layout(content_, LV_LAYOUT_FLEX);
- lv_obj_set_flex_flow(content_, LV_FLEX_FLOW_COLUMN);
- lv_obj_set_flex_align(content_, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER,
- LV_FLEX_ALIGN_CENTER);
-
- widgets::TopBar::Configuration config{
- .show_back_button = false,
- .title = "",
- };
- CreateTopBar(content_, config);
-
+Menu::Menu(std::vector<database::IndexInfo> indexes)
+ : MenuScreen(" ", false), indexes_(indexes) {
lv_obj_t* list = lv_list_create(content_);
- lv_obj_set_size(list, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));
- lv_obj_center(list);
+ lv_obj_set_size(list, lv_pct(100), lv_pct(100));
+
+ lv_obj_t* now_playing = lv_list_add_btn(list, NULL, "Now Playing");
+ lv_obj_add_event_cb(now_playing, now_playing_click_cb, LV_EVENT_CLICKED,
+ NULL);
+ lv_group_add_obj(group_, now_playing);
for (database::IndexInfo& index : indexes_) {
lv_obj_t* item = lv_list_add_btn(list, NULL, index.name.c_str());
- lv_obj_add_event_cb(item, item_click_cb, LV_EVENT_CLICKED, &index);
+ lv_obj_add_event_cb(item, index_click_cb, LV_EVENT_CLICKED, &index);
lv_group_add_obj(group_, item);
}
+
+ lv_obj_t* settings = lv_list_add_btn(list, NULL, "Settings");
+ lv_obj_add_event_cb(settings, settings_click_callback, LV_EVENT_CLICKED,
+ NULL);
+ lv_group_add_obj(group_, settings);
}
Menu::~Menu() {}