From 39a32fc83d3b82dbac6488abd05432708bd63e4c Mon Sep 17 00:00:00 2001 From: CTCaer Date: Thu, 30 Apr 2020 14:55:15 +0300 Subject: [PATCH] nyx: Add Nyx Options (Theme, Homescreen, Time) --- nyx/nyx_gui/frontend/gui.c | 6 + nyx/nyx_gui/frontend/gui_options.c | 460 +++++++++++++++++++++++++++++ nyx/nyx_gui/frontend/gui_options.h | 1 + 3 files changed, 467 insertions(+) diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index 46271ac..318b1bd 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -1721,6 +1721,12 @@ static void _create_tab_home(lv_theme_t *th, lv_obj_t *parent) // lv_obj_set_pos(btn_quick_launch, 343, 448); // lv_btn_set_action(btn_quick_launch, LV_BTN_ACTION_CLICK, NULL); + lv_obj_t *btn_nyx_options = lv_btn_create(parent, NULL); + _create_text_button(th, NULL, btn_nyx_options, SYMBOL_SETTINGS" Nyx Options", NULL); + //lv_obj_set_width(btn_nyx_options, 256); + lv_btn_set_action(btn_nyx_options, LV_BTN_ACTION_CLICK, create_win_nyx_options); + lv_obj_align(btn_nyx_options, NULL, LV_ALIGN_IN_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI / 12); + // Payloads button. lv_obj_t *btn_payloads = lv_btn_create(parent, btn_launch); label_btn = lv_label_create(btn_payloads, label_btn); diff --git a/nyx/nyx_gui/frontend/gui_options.c b/nyx/nyx_gui/frontend/gui_options.c index 9c7eb36..67d0f5a 100644 --- a/nyx/nyx_gui/frontend/gui_options.c +++ b/nyx/nyx_gui/frontend/gui_options.c @@ -14,6 +14,8 @@ * along with this program. If not, see . */ +#include + #include "gui.h" #include "../config/config.h" #include "../config/ini.h" @@ -22,6 +24,7 @@ #include "../mem/heap.h" #include "../storage/nx_sd.h" #include "../utils/list.h" +#include "../utils/sprintf.h" #include "../utils/types.h" extern hekate_config h_cfg; @@ -281,6 +284,463 @@ static lv_res_t _data_verification_action(lv_obj_t *ddlist) return LV_RES_OK; } +void create_flat_button(lv_obj_t *parent, lv_obj_t *btn, lv_color_t color, lv_action_t action) +{ + lv_style_t *btn_onoff_rel_hos_style = malloc(sizeof(lv_style_t)); + lv_style_t *btn_onoff_pr_hos_style = malloc(sizeof(lv_style_t)); + lv_style_copy(btn_onoff_rel_hos_style, lv_theme_get_current()->btn.rel); + btn_onoff_rel_hos_style->body.main_color = color; + btn_onoff_rel_hos_style->body.grad_color = btn_onoff_rel_hos_style->body.main_color; + btn_onoff_rel_hos_style->body.padding.hor = 0; + btn_onoff_rel_hos_style->body.radius = 0; + + lv_style_copy(btn_onoff_pr_hos_style, lv_theme_get_current()->btn.pr); + btn_onoff_pr_hos_style->body.main_color = color; + btn_onoff_pr_hos_style->body.grad_color = btn_onoff_pr_hos_style->body.main_color; + btn_onoff_pr_hos_style->body.padding.hor = 0; + btn_onoff_pr_hos_style->body.border.color = LV_COLOR_GRAY; + btn_onoff_pr_hos_style->body.border.width = 4; + btn_onoff_pr_hos_style->body.radius = 0; + + lv_btn_set_style(btn, LV_BTN_STYLE_REL, btn_onoff_rel_hos_style); + lv_btn_set_style(btn, LV_BTN_STYLE_PR, btn_onoff_pr_hos_style); + lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, btn_onoff_rel_hos_style); + lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, btn_onoff_pr_hos_style); + + lv_btn_set_fit(btn, false, true); + lv_obj_set_width(btn, lv_obj_get_height(btn)); + lv_btn_set_toggle(btn, true); + + if (action) + lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, action); +} + +typedef struct _color_test_ctxt +{ + u16 hue; + lv_obj_t *label; + lv_obj_t *icons; + lv_obj_t *slider; + lv_obj_t *button; + lv_obj_t *hue_slider; + lv_obj_t *hue_label; +} color_test_ctxt; + +color_test_ctxt color_test; + +static lv_res_t _save_theme_color_action(lv_obj_t *btn) +{ + n_cfg.themecolor = color_test.hue; + + // Save nyx config. + create_nyx_config_entry(); + + reload_nyx(); + + return LV_RES_OK; +} + +static void _test_nyx_color(u16 hue) +{ + lv_color_t color = lv_color_hsv_to_rgb(hue, 100, 100); + static lv_style_t btn_tgl_test; + lv_style_copy(&btn_tgl_test, lv_btn_get_style(color_test.button, LV_BTN_STATE_TGL_PR)); + btn_tgl_test.body.border.color = color; + btn_tgl_test.text.color = color; + lv_btn_set_style(color_test.button, LV_BTN_STATE_TGL_PR, &btn_tgl_test); + + static lv_style_t txt_test; + lv_style_copy(&txt_test, lv_label_get_style(color_test.label)); + txt_test.text.color = color; + lv_obj_set_style(color_test.label, &txt_test); + lv_obj_set_style(color_test.icons, &txt_test); + + static lv_style_t slider_test, slider_ind; + lv_style_copy(&slider_test, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_KNOB)); + lv_style_copy(&slider_ind, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_INDIC)); + slider_test.body.main_color = color; + slider_test.body.grad_color = slider_test.body.main_color; + slider_ind.body.main_color = lv_color_hsv_to_rgb(hue, 100, 72); + slider_ind.body.grad_color = slider_ind.body.main_color; + lv_slider_set_style(color_test.slider, LV_SLIDER_STYLE_KNOB, &slider_test); + lv_slider_set_style(color_test.slider, LV_SLIDER_STYLE_INDIC, &slider_ind); +} + +static lv_res_t _slider_hue_action(lv_obj_t *slider) +{ + if (color_test.hue != lv_slider_get_value(slider)) + { + color_test.hue = lv_slider_get_value(slider); + _test_nyx_color(color_test.hue); + char hue[8]; + s_printf(hue, "%03d", color_test.hue); + lv_label_set_text(color_test.hue_label, hue); + } + + return LV_RES_OK; +} + +static lv_res_t _preset_hue_action(lv_obj_t *btn) +{ + lv_btn_ext_t *ext = lv_obj_get_ext_attr(btn); + + if (color_test.hue != ext->idx) + { + color_test.hue = ext->idx; + _test_nyx_color(color_test.hue); + char hue[8]; + s_printf(hue, "%03d", color_test.hue); + lv_label_set_text(color_test.hue_label, hue); + lv_bar_set_value(color_test.hue_slider, color_test.hue); + } + + return LV_RES_OK; +} + +const u16 theme_colors[17] = { + 4, 13, 23, 33, 43, 54, 66, 89, 124, 167, 187, 200, 208, 231, 261, 291, 341 +}; + +static lv_res_t _create_window_nyx_colors(lv_obj_t *btn) +{ + lv_obj_t *win = nyx_create_standard_window(SYMBOL_COPY" Choose a Nyx Color Theme"); + lv_win_add_btn(win, NULL, SYMBOL_SAVE" Save & Reload", _save_theme_color_action); + + // Set current color. + color_test.hue = n_cfg.themecolor; + + lv_obj_t *sep = lv_label_create(win, NULL); + lv_label_set_static_text(sep, ""); + lv_obj_align(sep, NULL, LV_ALIGN_IN_TOP_MID, 0, 0); + + // Create container to keep content inside. + lv_obj_t *h1 = lv_cont_create(win, NULL); + lv_obj_set_size(h1, LV_HOR_RES - (LV_DPI * 8 / 10), LV_VER_RES / 7); + + // Create color preset buttons. + lv_obj_t *color_btn = lv_btn_create(h1, NULL); + lv_btn_ext_t *ext = lv_obj_get_ext_attr(color_btn); + ext->idx = theme_colors[0]; + create_flat_button(h1, color_btn, lv_color_hsv_to_rgb(theme_colors[0], 100, 100), _preset_hue_action); + lv_obj_t *color_btn2; + + for (u32 i = 1; i < 17; i++) + { + color_btn2 = lv_btn_create(h1, NULL); + ext = lv_obj_get_ext_attr(color_btn2); + ext->idx = theme_colors[i]; + create_flat_button(h1, color_btn2, lv_color_hsv_to_rgb(theme_colors[i], 100, 100), _preset_hue_action); + lv_obj_align(color_btn2, color_btn, LV_ALIGN_OUT_RIGHT_MID, 0, 0); + color_btn = color_btn2; + } + + lv_obj_align(h1, sep, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 4); + + // Create hue slider. + lv_obj_t * slider = lv_slider_create(win, NULL); + lv_obj_set_width(slider, 1070); + lv_obj_set_height(slider, LV_DPI * 4 / 10); + lv_bar_set_range(slider, 0, 359); + lv_bar_set_value(slider, color_test.hue); + lv_slider_set_action(slider, _slider_hue_action); + lv_obj_align(slider, h1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + color_test.hue_slider = slider; + + // Create hue label. + lv_obj_t *hue_text_label = lv_label_create(win, NULL); + lv_obj_align(hue_text_label, slider, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 24 / 100, 0); + char hue[8]; + s_printf(hue, "%03d", color_test.hue); + lv_label_set_text(hue_text_label, hue); + color_test.hue_label = hue_text_label; + + // Create sample text. + lv_obj_t *h2 = lv_cont_create(win, NULL); + lv_obj_set_size(h2, LV_HOR_RES - (LV_DPI * 8 / 10), LV_VER_RES / 3); + lv_obj_align(h2, slider, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI); + + lv_obj_t *lbl_sample = lv_label_create(h2, NULL); + lv_label_set_static_text(lbl_sample, "Sample:"); + + lv_obj_t *lbl_test = lv_label_create(h2, NULL); + lv_label_set_long_mode(lbl_test, LV_LABEL_LONG_BREAK); + lv_label_set_static_text(lbl_test, + "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris " + "nisi ut aliquip ex ea commodo consequat."); + lv_obj_set_width(lbl_test, lv_obj_get_width(h2) - LV_DPI * 6 / 10); + lv_obj_align(lbl_test, lbl_sample, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5); + color_test.label = lbl_test; + + // Create sample icons. + lv_obj_t *lbl_icons = lv_label_create(h2, NULL); + lv_label_set_static_text(lbl_icons, + SYMBOL_BRIGHTNESS SYMBOL_CHARGE SYMBOL_FILE SYMBOL_DRIVE SYMBOL_FILE_CODE + SYMBOL_EDIT SYMBOL_HINT SYMBOL_DRIVE SYMBOL_KEYBOARD SYMBOL_POWER); + lv_obj_align(lbl_icons, lbl_test, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI * 2 / 5); + color_test.icons = lbl_icons; + + // Create sample slider. + lv_obj_t *slider_test = lv_slider_create(h2, NULL); + lv_obj_align(slider_test, lbl_test, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI * 2 / 5); + lv_obj_set_click(slider_test, false); + lv_bar_set_value(slider_test, 60); + color_test.slider = slider_test; + + // Create sample button. + lv_obj_t *btn_test = lv_btn_create(h2, NULL); + lv_btn_set_state(btn_test, LV_BTN_STATE_TGL_PR); + lv_obj_align(btn_test, lbl_test, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI / 5); + lv_label_create(btn_test, NULL); + lv_obj_set_click(btn_test, false); + color_test.button = btn_test; + + _test_nyx_color(color_test.hue); + + return LV_RES_OK; +} + +lv_obj_t *epoch_ta; +static lv_res_t _create_mbox_clock_edit_action(lv_obj_t * btns, const char * txt) +{ + int btn_idx = lv_btnm_get_pressed(btns); + + if (btn_idx == 1) + n_cfg.timeoff = strtol(lv_ta_get_text(epoch_ta), NULL, 16); + + mbox_action(btns, txt); + + return LV_RES_INV; +} + +static lv_res_t _create_mbox_clock_edit(lv_obj_t *btn) +{ + lv_style_t *darken; + darken = malloc(sizeof(lv_style_t)); + lv_style_copy(darken, &lv_style_plain); + darken->body.main_color = LV_COLOR_BLACK; + darken->body.grad_color = darken->body.main_color; + darken->body.opa = LV_OPA_30; + + lv_obj_t *dark_bg = lv_obj_create(lv_scr_act(), NULL); + lv_obj_set_style(dark_bg, darken); + lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES); + + static const char * mbox_btn_map[] = { "\211", "\222Done", "\222Cancel", "\211", "" }; + lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL); + lv_mbox_set_recolor_text(mbox, true); + lv_obj_set_width(mbox, LV_HOR_RES / 9 * 6); + + lv_mbox_set_text(mbox, "Type the #C7EA46 epoch# offset in HEX s32:"); + + lv_obj_t *ta = lv_ta_create(mbox, NULL); + lv_obj_set_size(ta, LV_HOR_RES / 5, LV_VER_RES / 10); + lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -LV_DPI / 10, LV_DPI / 10); + lv_ta_set_cursor_type(ta, LV_CURSOR_LINE); + lv_ta_set_one_line(ta, true); + epoch_ta = ta; + + static char epoch_off[16]; + s_printf(epoch_off, "%X", n_cfg.timeoff); + lv_ta_set_text(ta, epoch_off); + lv_ta_set_max_length(ta, 8); + + lv_obj_t *kb = lv_kb_create(mbox, NULL); + lv_obj_set_size(kb, 2 * LV_HOR_RES / 3, LV_VER_RES / 3); + lv_obj_align(kb, ta, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI); + lv_kb_set_mode(kb, LV_KB_MODE_HEX); + lv_kb_set_ta(kb, ta); + lv_kb_set_cursor_manage(kb, true); + + lv_mbox_add_btns(mbox, mbox_btn_map, _create_mbox_clock_edit_action); // Important. After set_text. + + lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_top(mbox, true); + + return LV_RES_OK; +} + +static lv_res_t _home_screen_action(lv_obj_t *ddlist) +{ + n_cfg.home_screen = lv_ddlist_get_selected(ddlist); + + return LV_RES_OK; +} + +static lv_res_t _save_nyx_options_action(lv_obj_t *btn) +{ + static const char * mbox_btn_map[] = {"\211", "\222OK!", "\211", ""}; + lv_obj_t * mbox = lv_mbox_create(lv_scr_act(), NULL); + lv_mbox_set_recolor_text(mbox, true); + + int res = !create_nyx_config_entry(); + + if (res) + lv_mbox_set_text(mbox, "#FF8000 Nyx Configuration#\n\n#96FF00 The configuration was saved to sd card!#"); + else + lv_mbox_set_text(mbox, "#FF8000 Nyx Configuration#\n\n#FFDD00 Failed to save the configuration#\n#FFDD00 to sd card!#"); + lv_mbox_add_btns(mbox, mbox_btn_map, NULL); + lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_top(mbox, true); + + return LV_RES_OK; +} + +lv_res_t create_win_nyx_options(lv_obj_t *parrent_btn) +{ + lv_theme_t *th = lv_theme_get_current(); + + lv_obj_t *win = nyx_create_standard_window(SYMBOL_HOME" Nyx Options"); + + static lv_style_t h_style; + lv_style_copy(&h_style, &lv_style_transp); + h_style.body.padding.inner = 0; + h_style.body.padding.hor = LV_DPI - (LV_DPI / 4); + h_style.body.padding.ver = LV_DPI / 6; + + // Create containers to keep content inside. + lv_obj_t * sw_h2 = lv_cont_create(win, NULL); + lv_cont_set_style(sw_h2, &h_style); + lv_cont_set_fit(sw_h2, false, true); + lv_obj_set_width(sw_h2, (LV_HOR_RES / 9) * 4); + lv_obj_set_click(sw_h2, false); + lv_cont_set_layout(sw_h2, LV_LAYOUT_OFF); + + lv_obj_t * sw_h3 = lv_cont_create(win, NULL); + lv_cont_set_style(sw_h3, &h_style); + lv_cont_set_fit(sw_h3, false, true); + lv_obj_set_width(sw_h3, (LV_HOR_RES / 9) * 4); + lv_obj_set_click(sw_h3, false); + lv_cont_set_layout(sw_h3, LV_LAYOUT_OFF); + lv_obj_align(sw_h3, sw_h2, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI * 11 / 25, 0); + + lv_obj_t * l_cont = lv_cont_create(sw_h2, NULL); + lv_cont_set_style(l_cont, &lv_style_transp_tight); + lv_cont_set_fit(l_cont, true, true); + lv_obj_set_click(l_cont, false); + lv_cont_set_layout(l_cont, LV_LAYOUT_OFF); + lv_obj_set_opa_scale(l_cont, LV_OPA_40); + + lv_obj_t *label_sep = lv_label_create(sw_h2, NULL); + lv_label_set_static_text(label_sep, ""); + + lv_obj_t *btn = lv_btn_create(sw_h2, NULL); + lv_obj_t *label_btn = lv_label_create(btn, NULL); + lv_btn_set_fit(btn, true, true); + lv_label_set_static_text(label_btn, SYMBOL_COPY" Color Theme"); + lv_obj_align(btn, label_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, -LV_DPI / 5 + 3); + lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _create_window_nyx_colors); + + lv_obj_t *label_txt2 = lv_label_create(sw_h2, NULL); + lv_label_set_recolor(label_txt2, true); + lv_label_set_static_text(label_txt2, "Select a color for all #00FFC8 highlights# in Nyx.\n"); + lv_obj_set_style(label_txt2, &hint_small_style); + lv_obj_align(label_txt2, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 3 - 8); + + lv_obj_t *line_sep = lv_line_create(sw_h2, NULL); + static const lv_point_t line_pp[] = { {0, 0}, { LV_HOR_RES - (LV_DPI - (LV_DPI / 4)) * 2, 0} }; + lv_line_set_points(line_sep, line_pp, 2); + lv_line_set_style(line_sep, th->line.decor); + lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4); + + lv_obj_t *label_txt = lv_label_create(l_cont, NULL); + lv_label_set_static_text(label_txt, SYMBOL_HOME" Home Screen"); + lv_obj_set_style(label_txt, th->label.prim); + lv_obj_align(label_txt, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4); + + lv_obj_t *ddlist = lv_ddlist_create(l_cont, NULL); + lv_obj_set_top(ddlist, true); + lv_ddlist_set_draw_arrow(ddlist, true); + lv_ddlist_set_options(ddlist, + "Main menu \n" + "All Configs\n" + "Launch\n" + "More Configs"); + lv_ddlist_set_selected(ddlist, n_cfg.home_screen); + lv_ddlist_set_action(ddlist, _home_screen_action); + lv_obj_align(ddlist, label_txt, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 2 / 3, 0); + + label_txt2 = lv_label_create(l_cont, NULL); + lv_label_set_recolor(label_txt2, true); + lv_label_set_static_text(label_txt2, + "Select what screen to show on Nyx boot.\n" + "#FF8000 All Configs:# #C7EA46 Combines More configs into Launch empty slots.#\n" + "#FF8000 Launch / More Configs:# #C7EA46 Uses the classic divided view.#"); + lv_obj_set_style(label_txt2, &hint_small_style); + lv_obj_align(label_txt2, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4); + + line_sep = lv_line_create(sw_h2, line_sep); + lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4); + + lv_obj_t *btn2 = lv_btn_create(sw_h2, NULL); + lv_obj_t *label_btn2 = lv_label_create(btn2, NULL); + lv_btn_set_fit(btn2, true, true); + lv_label_set_static_text(label_btn2, SYMBOL_CLOCK" Clock (HOS)"); + lv_obj_align(btn2, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4); + lv_btn_set_action(btn2, LV_BTN_ACTION_CLICK, _create_mbox_clock_edit); //TODO: Add support. + lv_btn_set_state(btn2, LV_BTN_STATE_INA); //TODO: Add support. + + lv_obj_t *btn4 = lv_btn_create(sw_h2, btn2); + label_btn2 = lv_label_create(btn4, NULL); + lv_label_set_static_text(label_btn2, " "SYMBOL_EDIT" Manually "); + lv_obj_align(btn4, btn2, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 8, 0); + lv_btn_set_action(btn4, LV_BTN_ACTION_CLICK, _create_mbox_clock_edit); + lv_btn_set_state(btn4, LV_BTN_STATE_REL); + + label_txt2 = lv_label_create(sw_h2, NULL); + lv_label_set_recolor(label_txt2, true); + lv_label_set_static_text(label_txt2, + "#FF8000 Clock (HOS):# #C7EA46 Change clock offset based on what HOS uses.#\n" + "#FF8000 Manually:# #C7EA46 Edit the clock offset manually.#"); + lv_obj_set_style(label_txt2, &hint_small_style); + lv_obj_align(label_txt2, btn2, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4); + + label_sep = lv_label_create(sw_h3, NULL); + lv_label_set_static_text(label_sep, ""); + + // Create Backup/Restore Verification list. + label_txt = lv_label_create(sw_h3, NULL); + lv_label_set_static_text(label_txt, SYMBOL_MODULES_ALT" Data Verification"); + lv_obj_set_style(label_txt, th->label.prim); + lv_obj_align(label_txt, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 4); + + lv_obj_t *ddlist2 = lv_ddlist_create(sw_h3, NULL); + lv_obj_set_top(ddlist2, true); + lv_ddlist_set_draw_arrow(ddlist2, true); + lv_ddlist_set_options(ddlist2, + "Off (Fastest)\n" + "Sparse (Fast) \n" + "Full (Slow)\n" + "Full (Hashes)"); + lv_ddlist_set_selected(ddlist2, n_cfg.verification); + lv_obj_align(ddlist2, label_txt, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 3 / 8, 0); + lv_ddlist_set_action(ddlist2, _data_verification_action); + + label_txt2 = lv_label_create(sw_h3, NULL); + lv_label_set_static_text(label_txt2, "Set the type of data verification done for backup and restore.\n" + "Can be canceled without losing the backup/restore.\n"); + lv_obj_set_style(label_txt2, &hint_small_style); + lv_obj_align(label_txt2, label_txt, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 4); + + line_sep = lv_line_create(sw_h3, line_sep); + lv_obj_align(line_sep, label_txt2, LV_ALIGN_OUT_BOTTOM_LEFT, -(LV_DPI / 4), LV_DPI / 4); + + lv_obj_t *btn5 = lv_btn_create(sw_h3, NULL); + lv_obj_t *label_btn5 = lv_label_create(btn5, NULL); + lv_btn_set_fit(btn5, true, true); + lv_label_set_static_text(label_btn5, SYMBOL_EDIT" Save Options"); + lv_obj_align(btn5, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI * 31 / 21, LV_DPI * 6 / 8); + lv_btn_set_action(btn5, LV_BTN_ACTION_CLICK, _save_nyx_options_action); + + lv_obj_set_top(l_cont, true); // Set the ddlist container at top. + lv_obj_set_parent(ddlist, l_cont); // Reorder ddlist. + lv_obj_set_top(ddlist, true); + lv_obj_set_top(ddlist2, true); + + return LV_RES_OK; +} + void create_tab_options(lv_theme_t *th, lv_obj_t *parent) { lv_page_set_scrl_layout(parent, LV_LAYOUT_PRETTY); diff --git a/nyx/nyx_gui/frontend/gui_options.h b/nyx/nyx_gui/frontend/gui_options.h index a19eec7..56d11ca 100644 --- a/nyx/nyx_gui/frontend/gui_options.h +++ b/nyx/nyx_gui/frontend/gui_options.h @@ -19,6 +19,7 @@ #include "../libs/lvgl/lvgl.h" +lv_res_t create_win_nyx_options(lv_obj_t *parrent_btn); void create_tab_options(lv_theme_t *th, lv_obj_t *parent); #endif