From 49e4f4f24697efb6f56da90b2d104636852aa05b Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Fri, 28 Jul 2023 00:26:58 +0200 Subject: [PATCH] Add DSi style main menu --- .../xtreme_app_scene_interface_mainmenu.c | 1 + applications/services/gui/modules/menu.c | 57 +++++++++++++++++++ lib/xtreme/xtreme.h | 1 + 3 files changed, 59 insertions(+) diff --git a/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_mainmenu.c b/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_mainmenu.c index fc2d81bfa..6934eb72c 100644 --- a/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_mainmenu.c +++ b/applications/main/xtreme_app/scenes/xtreme_app_scene_interface_mainmenu.c @@ -17,6 +17,7 @@ void xtreme_app_scene_interface_mainmenu_var_item_list_callback(void* context, u const char* const menu_style_names[MenuStyleCount] = { "List", "Wii", + "DSi", }; static void xtreme_app_scene_interface_mainmenu_menu_style_changed(VariableItem* item) { XtremeApp* app = variable_item_get_context(item); diff --git a/applications/services/gui/modules/menu.c b/applications/services/gui/modules/menu.c index 449fd2d24..f7257543c 100644 --- a/applications/services/gui/modules/menu.c +++ b/applications/services/gui/modules/menu.c @@ -154,6 +154,47 @@ static void menu_draw_callback(Canvas* canvas, void* _model) { furi_string_free(name); break; } + case MenuStyleDsi: { + for(int8_t i = -2; i <= 2; i++) { + shift_position = (position + items_count + i) % items_count; + item = MenuItemArray_get(model->items, shift_position); + size_t width = 24; + size_t height = 26; + size_t pos_x = 64; + size_t pos_y = 36; + if(i == 0) { + width += 6; + height += 6; + elements_bold_rounded_frame(canvas, pos_x - width / 2, pos_y - height / 2, width, height + 4); + canvas_set_font(canvas, FontBatteryPercent); + canvas_draw_str_aligned(canvas, pos_x, pos_y + height / 2 + 1, AlignCenter, AlignBottom, "START"); + + canvas_draw_rframe(canvas, 0, 0, 128, 18, 3); + canvas_draw_line(canvas, 60, 18, 64, 26); + canvas_draw_line(canvas, 64, 26, 68, 18); + canvas_set_color(canvas, ColorWhite); + canvas_draw_line(canvas, 60, 17, 68, 17); + canvas_draw_box(canvas, 62, 20, 5, 2); + canvas_set_color(canvas, ColorBlack); + + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned(canvas, pos_x, pos_y - height / 2 - 7, AlignCenter, AlignBottom, item->label); + } else { + pos_x += (width + 6) * i; + pos_y += 2; + elements_slightly_rounded_frame(canvas, pos_x - width / 2, pos_y - height / 2, width, height); + } + if(item->icon) { + canvas_draw_icon_animation( + canvas, + pos_x - item->icon->icon->width / 2, + pos_y - item->icon->icon->height / 2, + item->icon); + } + } + elements_scrollbar_horizontal(canvas, 0, 64, 128, position, items_count); + break; + } default: break; } @@ -351,6 +392,7 @@ void menu_set_selected_item(Menu* menu, uint32_t index) { } static void menu_process_up(Menu* menu) { + if(XTREME_SETTINGS()->menu_style == MenuStyleDsi) return; with_view_model( menu->view, MenuModel * model, @@ -390,6 +432,7 @@ static void menu_process_up(Menu* menu) { } static void menu_process_down(Menu* menu) { + if(XTREME_SETTINGS()->menu_style == MenuStyleDsi) return; with_view_model( menu->view, MenuModel * model, @@ -453,6 +496,13 @@ static void menu_process_left(Menu* menu) { } model->scroll_counter = 0; break; + case MenuStyleDsi: + if(model->position > 0) { + model->position--; + } else { + model->position = count - 1; + } + break; default: break; } @@ -495,6 +545,13 @@ static void menu_process_right(Menu* menu) { } model->scroll_counter = 0; break; + case MenuStyleDsi: + if(model->position < count - 1) { + model->position++; + } else { + model->position = 0; + } + break; default: break; } diff --git a/lib/xtreme/xtreme.h b/lib/xtreme/xtreme.h index 103ec0443..13c9abfe5 100644 --- a/lib/xtreme/xtreme.h +++ b/lib/xtreme/xtreme.h @@ -28,6 +28,7 @@ typedef enum { typedef enum { MenuStyleList, MenuStyleWii, + MenuStyleDsi, MenuStyleCount, } MenuStyle;