From d24debc6427034ba6d9874fc5fef799769f3c20f Mon Sep 17 00:00:00 2001 From: NaGa Date: Fri, 27 Mar 2026 20:02:53 +0100 Subject: [PATCH] nyx: deduplicate window creation functions Also rename mbox_action and fix a double lv obj deletion in partition manager. --- nyx/nyx_gui/frontend/fe_emmc_tools.c | 4 +- nyx/nyx_gui/frontend/fe_emummc_tools.c | 4 +- nyx/nyx_gui/frontend/gui.c | 49 +++++++----------- nyx/nyx_gui/frontend/gui.h | 9 ++-- nyx/nyx_gui/frontend/gui_emmc_tools.c | 8 +-- nyx/nyx_gui/frontend/gui_emummc_tools.c | 41 +++++++-------- nyx/nyx_gui/frontend/gui_info.c | 26 +++++----- nyx/nyx_gui/frontend/gui_options.c | 14 +++--- nyx/nyx_gui/frontend/gui_tools.c | 30 +++++------ .../frontend/gui_tools_partition_manager.c | 50 +++++++++---------- 10 files changed, 109 insertions(+), 126 deletions(-) diff --git a/nyx/nyx_gui/frontend/fe_emmc_tools.c b/nyx/nyx_gui/frontend/fe_emmc_tools.c index 81f45d54..12e72071 100644 --- a/nyx/nyx_gui/frontend/fe_emmc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emmc_tools.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2018 naehrwert * Copyright (c) 2018 Rajko Stojadinovic - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -123,7 +123,7 @@ static lv_obj_t *create_mbox_text(const char *text, bool button_ok) lv_mbox_set_text(mbox, text); if (button_ok) - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 51bf821c..6b34eca3 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2018 naehrwert * Copyright (c) 2018 Rajko Stojadinovic - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -377,7 +377,7 @@ int emummc_raw_derive_bis_keys() lv_obj_set_width(lb_desc, LV_HOR_RES / 9 * 4); lv_label_set_text(lb_desc, "#FFDD00 BIS keys validation failed!#\n"); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index 218328f3..9ec008e6 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -782,7 +782,7 @@ lv_res_t nyx_generic_onoff_toggle(lv_obj_t *btn) return LV_RES_OK; } -lv_res_t mbox_action(lv_obj_t *btns, const char *txt) +lv_res_t nyx_mbox_action(lv_obj_t *btns, const char *txt) { lv_obj_t *mbox = lv_mbox_get_from_btn(btns); lv_obj_t *dark_bg = lv_obj_get_parent(mbox); @@ -817,7 +817,7 @@ bool nyx_emmc_check_battery_enough() "#FFDD00 with selected operation!#\n\n" "Charge to at least #C7EA46 3650 mV#, and try again!"); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -844,7 +844,7 @@ static void _nyx_sd_card_issues_warning(void *param) "#FFDD00 This might mean detached or broken connector!#\n\n" "You might want to check\n#C7EA46 Console Info# -> #C7EA46 microSD#"); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -879,14 +879,14 @@ void nyx_window_toggle_buttons(lv_obj_t *win, bool disable) } } -lv_res_t nyx_win_close_action_custom(lv_obj_t * btn) +lv_res_t nyx_win_close_action(lv_obj_t * btn) { close_btn = NULL; return lv_win_close_action(btn); } -lv_obj_t *nyx_create_standard_window(const char *win_title) +lv_obj_t *nyx_create_standard_window(const char *win_title, lv_action_t close_action) { static lv_style_t win_bg_style; @@ -899,25 +899,10 @@ lv_obj_t *nyx_create_standard_window(const char *win_title) lv_win_set_style(win, LV_WIN_STYLE_BG, &win_bg_style); lv_obj_set_size(win, LV_HOR_RES, LV_VER_RES); - close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", nyx_win_close_action_custom); - - return win; -} - -lv_obj_t *nyx_create_window_custom_close_btn(const char *win_title, lv_action_t rel_action) -{ - static lv_style_t win_bg_style; - - lv_style_copy(&win_bg_style, &lv_style_plain); - win_bg_style.body.main_color = lv_theme_get_current()->bg->body.main_color; - win_bg_style.body.grad_color = win_bg_style.body.main_color; - - lv_obj_t *win = lv_win_create(lv_scr_act(), NULL); - lv_win_set_title(win, win_title); - lv_win_set_style(win, LV_WIN_STYLE_BG, &win_bg_style); - lv_obj_set_size(win, LV_HOR_RES, LV_VER_RES); - - close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", rel_action); + if (!close_action) + close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", nyx_win_close_action); + else + close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", close_action); return win; } @@ -967,7 +952,7 @@ static lv_res_t reload_action(lv_obj_t *btns, const char *txt) if (!lv_btnm_get_pressed(btns)) reload_nyx(); - return mbox_action(btns, txt); + return nyx_mbox_action(btns, txt); } static lv_res_t _removed_sd_action(lv_obj_t *btns, const char *txt) @@ -991,7 +976,7 @@ static lv_res_t _removed_sd_action(lv_obj_t *btns, const char *txt) break; } - return mbox_action(btns, txt); + return nyx_mbox_action(btns, txt); } static void _check_sd_card_removed(void *params) @@ -1047,7 +1032,7 @@ static void _nyx_emmc_issues_warning(void *params) "#FFDD00 This might mean hardware issues!#\n\n" "You might want to check\n#C7EA46 Console Info# -> #C7EA46 eMMC#"); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -1059,7 +1044,7 @@ static lv_res_t _reboot_ofw_action(lv_obj_t *btns, const char *txt) if (!lv_btnm_get_pressed(btns)) power_set_state(REBOOT_BYPASS_FUSES); - return mbox_action(btns, txt); + return nyx_mbox_action(btns, txt); } static lv_res_t _create_mbox_reboot_ofw() @@ -1117,7 +1102,7 @@ static lv_res_t _reboot_action(lv_obj_t *btns, const char *txt) break; } - return mbox_action(btns, txt); + return nyx_mbox_action(btns, txt); } static lv_res_t _poweroff_action(lv_obj_t *btns, const char *txt) @@ -1125,7 +1110,7 @@ static lv_res_t _poweroff_action(lv_obj_t *btns, const char *txt) if (!lv_btnm_get_pressed(btns)) power_set_state(POWER_OFF_RESET); - return mbox_action(btns, txt); + return nyx_mbox_action(btns, txt); } static lv_res_t _create_mbox_reload(lv_obj_t *btn) @@ -1481,7 +1466,7 @@ static lv_res_t _create_mbox_payloads(lv_obj_t *btn) } out_end: - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -2212,7 +2197,7 @@ static lv_res_t _create_mbox_save_changes_action(lv_obj_t *btns, const char * tx { int btn_idx = lv_btnm_get_pressed(btns); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); if (!btn_idx) _save_options_action(NULL); diff --git a/nyx/nyx_gui/frontend/gui.h b/nyx/nyx_gui/frontend/gui.h index beb5a222..d656cce0 100644 --- a/nyx/nyx_gui/frontend/gui.h +++ b/nyx/nyx_gui/frontend/gui.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -74,12 +74,11 @@ extern gui_status_bar_ctx status_bar; void reload_nyx(); lv_img_dsc_t *bmp_to_lvimg_obj(const char *path); -lv_res_t mbox_action(lv_obj_t * btns, const char * txt); bool nyx_emmc_check_battery_enough(); -lv_res_t nyx_win_close_action_custom(lv_obj_t * btn); +lv_res_t nyx_mbox_action(lv_obj_t * btns, const char * txt); +lv_res_t nyx_win_close_action(lv_obj_t * btn); void nyx_window_toggle_buttons(lv_obj_t *win, bool disable); -lv_obj_t *nyx_create_standard_window(const char *win_title); -lv_obj_t *nyx_create_window_custom_close_btn(const char *win_title, lv_action_t rel_action); +lv_obj_t *nyx_create_standard_window(const char *win_title, lv_action_t close_action); void nyx_create_onoff_button(lv_theme_t *th, lv_obj_t *parent, lv_obj_t *btn, const char *btn_name, lv_action_t action, bool transparent); lv_res_t nyx_generic_onoff_toggle(lv_obj_t *btn); void manual_system_maintenance(bool refresh); diff --git a/nyx/nyx_gui/frontend/gui_emmc_tools.c b/nyx/nyx_gui/frontend/gui_emmc_tools.c index 9dc32296..e488d989 100644 --- a/nyx/nyx_gui/frontend/gui_emmc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emmc_tools.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -54,7 +54,7 @@ static void _create_window_backup_restore(emmcPartType_t type, const char* win_l s_printf(win_label_full, "%s%s", emmc_btn_ctxt.restore ? SYMBOL_DOWNLOAD" Restore " : SYMBOL_UPLOAD" Backup ", win_label+3); - lv_obj_t *win = nyx_create_standard_window(win_label_full); + lv_obj_t *win = nyx_create_standard_window(win_label_full, NULL); //Disable buttons. nyx_window_toggle_buttons(win, true); @@ -285,9 +285,9 @@ lv_res_t create_window_backup_restore_tool(lv_obj_t *btn) emmc_btn_ctxt.restore = true; if (!emmc_btn_ctxt.restore) - win = nyx_create_standard_window(SYMBOL_SD" Backup"); + win = nyx_create_standard_window(SYMBOL_SD" Backup", NULL); else - win = nyx_create_standard_window(SYMBOL_SD" Restore"); + win = nyx_create_standard_window(SYMBOL_SD" Restore", NULL); static lv_style_t h_style; lv_style_copy(&h_style, &lv_style_transp); diff --git a/nyx/nyx_gui/frontend/gui_emummc_tools.c b/nyx/nyx_gui/frontend/gui_emummc_tools.c index ba6749da..df33127f 100644 --- a/nyx/nyx_gui/frontend/gui_emummc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emummc_tools.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2025 CTCaer + * Copyright (c) 2019-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -81,7 +81,7 @@ static emummc_part_cfg_t emummc_part_cfg; static lv_res_t _action_emummc_window_close(lv_obj_t *btn) { - nyx_win_close_action_custom(btn); + nyx_win_close_action(btn); // Delete and relaunch main emuMMC window. lv_obj_clean(emummc_parent_cont); @@ -96,9 +96,9 @@ static void _create_window_emummc() lv_obj_t *win; if (emummc_part_cfg.file_based) - win = nyx_create_window_custom_close_btn(SYMBOL_DRIVE" Create SD File emuMMC", _action_emummc_window_close); + win = nyx_create_standard_window(SYMBOL_DRIVE" Create SD File emuMMC", _action_emummc_window_close); else - win = nyx_create_window_custom_close_btn(SYMBOL_DRIVE" Create SD Partition emuMMC", _action_emummc_window_close); + win = nyx_create_standard_window(SYMBOL_DRIVE" Create SD Partition emuMMC", _action_emummc_window_close); //Disable buttons. nyx_window_toggle_buttons(win, true); @@ -183,7 +183,7 @@ static lv_res_t _create_emummc_raw_format(lv_obj_t * btns, const char * txt) int btn_idx = lv_btnm_get_pressed(btns); // Delete parent mbox. - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); // Create partition window. if (!btn_idx) @@ -348,6 +348,7 @@ static lv_res_t _create_emummc_emmc_raw_action(lv_obj_t *btns, const char *txt){ mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -784,6 +785,7 @@ static lv_res_t _create_emummc_select_raw_type_action(lv_obj_t *btns, const char break; } + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -889,8 +891,8 @@ static void _change_raw_emummc_part_type() static lv_res_t _save_emummc_cfg_mig_mbox_action(lv_obj_t *btns, const char *txt) { // Delete main emuMMC and popup windows and relaunch main emuMMC window. - lv_obj_clean(emummc_parent_cont); - mbox_action(btns, txt); + lv_obj_del(emummc_manage_window); + nyx_mbox_action(btns, txt); (*emummc_tools)(emummc_parent_cont); @@ -1181,7 +1183,7 @@ static lv_res_t _create_emummc_mig1_action(lv_obj_t * btns, const char * txt) memset(&emummc_part_cfg, 0, sizeof(emummc_part_cfg)); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1197,7 +1199,7 @@ static lv_res_t _create_emummc_mig0_action(lv_obj_t * btns, const char * txt) memset(&emummc_part_cfg, 0, sizeof(emummc_part_cfg)); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1213,7 +1215,7 @@ static lv_res_t _create_emummc_mig2_action(lv_obj_t * btns, const char * txt) memset(&emummc_part_cfg, 0, sizeof(emummc_part_cfg)); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1229,7 +1231,7 @@ static lv_res_t _create_emummc_mig3_action(lv_obj_t * btns, const char * txt) memset(&emummc_part_cfg, 0, sizeof(emummc_part_cfg)); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1245,7 +1247,7 @@ static lv_res_t _create_emummc_mig4_action(lv_obj_t * btns, const char * txt) memset(&emummc_part_cfg, 0, sizeof(emummc_part_cfg)); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1268,7 +1270,7 @@ static lv_res_t _create_emummc_migrate_action(lv_obj_t * btns, const char * txt) case 2: break; case 3: - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1328,7 +1330,7 @@ static lv_res_t _create_emummc_migrate_action(lv_obj_t * btns, const char * txt) else { s_printf(txt_buf, "No emuMMC or foreign emunand found!\n"); - lv_mbox_add_btns(mbox, mbox_btn_map3, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map3, nyx_mbox_action); } lv_mbox_set_text(mbox, txt_buf); @@ -1337,7 +1339,7 @@ static lv_res_t _create_emummc_migrate_action(lv_obj_t * btns, const char * txt) lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1508,7 +1510,7 @@ static lv_res_t _save_emummc_cfg_mbox_action(lv_obj_t *btns, const char *txt) free(emummc_img->dirlist); free(emummc_img); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); (*emummc_tools)(emummc_parent_cont); @@ -1619,12 +1621,12 @@ static lv_res_t _action_win_change_emummc_close(lv_obj_t *btn) free(emummc_img->dirlist); free(emummc_img); - return nyx_win_close_action_custom(btn); + return nyx_win_close_action(btn); } static lv_res_t _create_change_emummc_window(lv_obj_t *btn_caller) { - lv_obj_t *win = nyx_create_window_custom_close_btn(SYMBOL_SETTINGS" Change emuMMC", _action_win_change_emummc_close); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_SETTINGS" Change emuMMC", _action_win_change_emummc_close); lv_win_add_btn(win, NULL, SYMBOL_POWER" Disable", _save_disable_emummc_cfg_action); boot_storage_mount(); @@ -1969,8 +1971,7 @@ out1: lv_res_t create_tab_emummc_tools(lv_obj_t *parent) { - emummc_parent_cont = parent; - emummc_tools = &create_tab_emummc_tools; + lv_obj_t *win = nyx_create_standard_window(SYMBOL_EDIT" emuMMC Manage", NULL); boot_storage_mount(); diff --git a/nyx/nyx_gui/frontend/gui_info.c b/nyx/nyx_gui/frontend/gui_info.c index 6d196469..1868216a 100644 --- a/nyx/nyx_gui/frontend/gui_info.c +++ b/nyx/nyx_gui/frontend/gui_info.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * Copyright (c) 2018 balika011 * * This program is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ static lv_res_t _create_window_dump_done(int error, char *dump_filenames) lv_mbox_set_text(mbox, txt_buf); free(txt_buf); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); // Important. After set_text. + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); // Important. After set_text. lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -72,7 +72,7 @@ static lv_res_t _cal0_dump_window_action(lv_obj_t *btns, const char * txt) { int btn_idx = lv_btnm_get_pressed(btns); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); if (btn_idx == 1) { @@ -543,14 +543,14 @@ static lv_res_t _action_win_hw_info_status_close(lv_obj_t *btn) hw_info = NULL; } - return nyx_win_close_action_custom(btn); + return nyx_win_close_action(btn); } static lv_res_t _create_window_hw_info_status(lv_obj_t *btn) { u32 uptime_s = get_tmr_s(); - lv_obj_t *win = nyx_create_window_custom_close_btn(SYMBOL_CHIP" HW & Fuses Info", _action_win_hw_info_status_close); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_CHIP" HW & Fuses Info", _action_win_hw_info_status_close); lv_win_add_btn(win, NULL, SYMBOL_DOWNLOAD" Dump fuses", _fuse_dump_window_action); lv_win_add_btn(win, NULL, SYMBOL_INFO" CAL0 Info", _create_mbox_cal0); @@ -1329,7 +1329,7 @@ static void _ipatch_process(u32 offset, u32 value) static lv_res_t _create_window_bootrom_info_status(lv_obj_t *btn) { - lv_obj_t *win = nyx_create_standard_window(SYMBOL_CHIP" Bootrom Info"); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_CHIP" Bootrom Info", NULL); lv_win_add_btn(win, NULL, SYMBOL_DOWNLOAD" Dump Bootrom", _bootrom_dump_window_action); lv_obj_t *desc = lv_cont_create(win, NULL); @@ -1361,7 +1361,7 @@ static lv_res_t _launch_lockpick_action(lv_obj_t *btns, const char * txt) { int btn_idx = lv_btnm_get_pressed(btns); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); if (btn_idx == 1) { @@ -1583,7 +1583,7 @@ out: free (txt_buf); free (txt_buf2); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); // Important. After set_text. + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); // Important. After set_text. lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -1930,7 +1930,7 @@ out: free(txt_buf); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); // Important. After set_text. + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); // Important. After set_text. lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); return LV_RES_OK; @@ -1952,7 +1952,7 @@ static lv_res_t _create_mbox_sd_bench(lv_obj_t * btn) static lv_res_t _create_window_emmc_info_status(lv_obj_t *btn) { - lv_obj_t *win = nyx_create_standard_window(SYMBOL_CHIP" Internal eMMC Info"); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_CHIP" Internal eMMC Info", NULL); lv_win_add_btn(win, NULL, SYMBOL_CHIP" Benchmark", _create_mbox_emmc_bench); lv_obj_t *desc = lv_cont_create(win, NULL); @@ -2204,7 +2204,7 @@ out_error: emmc_errors[EMMC_ERROR_RW_RETRY]); lv_mbox_set_text(mbox, txt_buf); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -2218,7 +2218,7 @@ out_error: static lv_res_t _create_window_sdcard_info_status(lv_obj_t *btn) { - lv_obj_t *win = nyx_create_standard_window(SYMBOL_SD" microSD Card Info"); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_SD" microSD Card Info", NULL); lv_win_add_btn(win, NULL, SYMBOL_SD" Benchmark", _create_mbox_sd_bench); lv_obj_t *desc = lv_cont_create(win, NULL); @@ -2623,7 +2623,7 @@ failed: static lv_res_t _create_window_battery_status(lv_obj_t *btn) { - lv_obj_t *win = nyx_create_standard_window(SYMBOL_BATTERY_FULL" Battery Info"); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_BATTERY_FULL" Battery Info", NULL); lv_win_add_btn(win, NULL, SYMBOL_DOWNLOAD" Dump Fuel Regs", _battery_dump_window_action); lv_obj_t *desc = lv_cont_create(win, NULL); diff --git a/nyx/nyx_gui/frontend/gui_options.c b/nyx/nyx_gui/frontend/gui_options.c index b0a77094..2781b732 100644 --- a/nyx/nyx_gui/frontend/gui_options.c +++ b/nyx/nyx_gui/frontend/gui_options.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -549,7 +549,7 @@ static const u16 theme_colors[17] = { static lv_res_t _create_window_nyx_colors(lv_obj_t *btn) { - lv_obj_t *win = nyx_create_standard_window(SYMBOL_COPY" Nyx Color Theme"); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_COPY" Nyx Color Theme", NULL); lv_win_add_btn(win, NULL, SYMBOL_HINT" Toggle Background", _preset_bg_action); lv_win_add_btn(win, NULL, SYMBOL_SAVE" Save & Reload", _save_theme_color_action); color_test.window = win; @@ -723,7 +723,7 @@ static lv_res_t _action_clock_edit(lv_obj_t *btns, const char * txt) nyx_changes_made = true; } - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1159,7 +1159,7 @@ disabled_or_cal0_issue:; lv_mbox_set_text(mbox, txt_buf); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); // Important. After set_text. + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); // Important. After set_text. lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -1186,7 +1186,7 @@ static lv_res_t _action_nyx_options_save(lv_obj_t *btns, const char * txt) { int btn_idx = lv_btnm_get_pressed(btns); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); if (!btn_idx) _save_nyx_options_action(NULL); @@ -1226,7 +1226,7 @@ static lv_res_t _action_win_nyx_options_close(lv_obj_t *btn) lv_obj_set_opa_scale(status_bar.mid, LV_OPA_0); lv_obj_set_click(status_bar.mid, false); - lv_res_t res = nyx_win_close_action_custom(btn); + lv_res_t res = nyx_win_close_action(btn); _check_nyx_changes(); @@ -1237,7 +1237,7 @@ 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_window_custom_close_btn(SYMBOL_HOME" Nyx Settings", _action_win_nyx_options_close); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_HOME" Nyx Settings", _action_win_nyx_options_close); static lv_style_t h_style; lv_style_copy(&h_style, &lv_style_transp); diff --git a/nyx/nyx_gui/frontend/gui_tools.c b/nyx/nyx_gui/frontend/gui_tools.c index 332e500f..eca00b1f 100644 --- a/nyx/nyx_gui/frontend/gui_tools.c +++ b/nyx/nyx_gui/frontend/gui_tools.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2025 CTCaer + * Copyright (c) 2018-2026 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -174,7 +174,7 @@ static lv_res_t _create_mbox_autorcm_status(lv_obj_t *btn) "The boot process is now normal and you need the #FF8000 VOL+# + #FF8000 HOME# (jig) combo to enter RCM.\n"); } - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -194,8 +194,8 @@ static lv_res_t _create_mbox_hid(usb_ctxt_t *usbs) lv_obj_set_style(dark_bg, &mbox_darken); lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES); - static const char *mbox_btn_map[] = { "\251", "\262Close", "\251", "" }; - static const char *mbox_btn_map2[] = { "\251", "\222Close", "\251", "" }; + static const char *mbox_btn_map_dis[] = { "\251", "\262Close", "\251", "" }; + static const char *mbox_btn_map[] = { "\251", "\222Close", "\251", "" }; lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL); lv_mbox_set_recolor_text(mbox, true); @@ -221,14 +221,14 @@ static lv_res_t _create_mbox_hid(usb_ctxt_t *usbs) lv_label_set_static_text(lbl_tip, "Note: To end it, press #C7EA46 L3# + #C7EA46 HOME# or remove the cable."); lv_obj_set_style(lbl_tip, &hint_small_style); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map_dis, nyx_mbox_action); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); usb_device_gadget_hid(usbs); - lv_mbox_add_btns(mbox, mbox_btn_map2, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); return LV_RES_OK; } @@ -239,8 +239,8 @@ static lv_res_t _create_mbox_ums(usb_ctxt_t *usbs, u32 part) lv_obj_set_style(dark_bg, &mbox_darken); lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES); - static const char *mbox_btn_map[] = { "\251", "\262Close", "\251", "" }; - static const char *mbox_btn_map2[] = { "\251", "\222Close", "\251", "" }; + static const char *mbox_btn_map_dis[] = { "\251", "\262Close", "\251", "" }; + static const char *mbox_btn_map[] = { "\251", "\222Close", "\251", "" }; lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL); lv_mbox_set_recolor_text(mbox, true); @@ -318,7 +318,7 @@ static lv_res_t _create_mbox_ums(usb_ctxt_t *usbs, u32 part) } lv_obj_set_style(lbl_tip, &hint_small_style); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map_dis, nyx_mbox_action); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -331,7 +331,7 @@ static lv_res_t _create_mbox_ums(usb_ctxt_t *usbs, u32 part) // Restore backlight. display_backlight_brightness(h_cfg.backlight - 20, 1000); - lv_mbox_add_btns(mbox, mbox_btn_map2, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); ums_mbox = dark_bg; @@ -389,7 +389,7 @@ static lv_res_t _create_mbox_ums_error(int error) break; } - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_set_width(mbox, LV_HOR_RES / 9 * 5); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -884,7 +884,7 @@ static lv_res_t _emmc_read_only_toggle(lv_obj_t *btn) static lv_res_t _create_window_usb_tools(lv_obj_t *parent) { - lv_obj_t *win = nyx_create_standard_window(SYMBOL_USB" USB Tools"); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_USB" USB Tools", NULL); static lv_style_t h_style; lv_style_copy(&h_style, &lv_style_transp); @@ -1161,7 +1161,7 @@ out: // TODO: emusd static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn) { - lv_obj_t *win = nyx_create_standard_window(SYMBOL_COPY" Fix Archive Bit (All folders)"); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_COPY" Fix Archive Bit (All folders)", NULL); // Disable buttons. nyx_window_toggle_buttons(win, true); @@ -1345,7 +1345,7 @@ out: lv_mbox_set_text(mbox, "#FFFF00 The touchscreen calibration failed!"); out2: - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); free(txt_buf); @@ -1354,7 +1354,7 @@ out2: static lv_res_t _create_window_dump_pk12_tool(lv_obj_t *btn) { - lv_obj_t *win = nyx_create_standard_window(SYMBOL_MODULES" Dump package1/2"); + lv_obj_t *win = nyx_create_standard_window(SYMBOL_MODULES" Dump package1/2", NULL); // Disable buttons. nyx_window_toggle_buttons(win, true); diff --git a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c index c3cd8c65..25921475 100644 --- a/nyx/nyx_gui/frontend/gui_tools_partition_manager.c +++ b/nyx/nyx_gui/frontend/gui_tools_partition_manager.c @@ -939,7 +939,7 @@ static lv_res_t _action_delete_linux_installer_files(lv_obj_t * btns, const char int btn_idx = lv_btnm_get_pressed(btns); // Delete parent mbox. - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); // Flash Linux. if (!btn_idx) @@ -990,7 +990,7 @@ static lv_res_t _action_flash_linux_data(lv_obj_t * btns, const char * txt) int btn_idx = lv_btnm_get_pressed(btns); // Delete parent mbox. - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); bool succeeded = false; @@ -1182,7 +1182,7 @@ exit: } if (!succeeded) - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); else lv_mbox_add_btns(mbox, mbox_btn_map2, _action_delete_linux_installer_files); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); @@ -1385,7 +1385,7 @@ static lv_res_t _action_check_flash_linux(lv_obj_t *btn) goto exit; error: - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); exit: boot_storage_unmount(); @@ -1407,7 +1407,7 @@ static lv_res_t _action_reboot_recovery(lv_obj_t * btns, const char * txt) int btn_idx = lv_btnm_get_pressed(btns); // Delete parent mbox. - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); if (!btn_idx) { @@ -1444,7 +1444,7 @@ static lv_res_t _action_flash_android_data(lv_obj_t * btns, const char * txt) bool boot_recovery = false; // Delete parent mbox. - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); if (btn_idx) return LV_RES_INV; @@ -1706,7 +1706,7 @@ error: lv_mbox_add_btns(mbox, mbox_btn_map2, _action_reboot_recovery); } else - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); @@ -1880,7 +1880,7 @@ static lv_res_t _action_part_manager_flash_options0(lv_obj_t *btns, const char * _action_flash_android_slot_select(btns); break; case 3: - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1902,11 +1902,11 @@ static lv_res_t _action_part_manager_flash_options1(lv_obj_t *btns, const char * lv_obj_del(ums_mbox); break; case 1: - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); _action_check_flash_linux(NULL); return LV_RES_INV; case 2: - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -1928,11 +1928,11 @@ static lv_res_t _action_part_manager_flash_options2(lv_obj_t *btns, const char * lv_obj_del(ums_mbox); break; case 1: - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); _action_flash_android_slot_select(NULL); return LV_RES_INV; case 2: - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -2458,9 +2458,8 @@ error: lv_obj_del(lbl_paths[1]); exit: - if(!buttons_set){ - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); - } + if (!buttons_set) + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -2662,7 +2661,7 @@ exit: free(txt_buf); if (!buttons_set) - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true); @@ -2687,11 +2686,11 @@ static lv_res_t _create_mbox_partitioning_option0(lv_obj_t *btns, const char *tx } return LV_RES_OK; case 1: - mbox_action(btns, txt); - _create_mbox_start_partitioning(); + nyx_mbox_action(btns, txt); + _sd_create_mbox_start_partitioning(); break; case 2: - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); break; } @@ -2702,11 +2701,10 @@ static lv_res_t _create_mbox_partitioning_option1(lv_obj_t *btns, const char *tx { int btn_idx = lv_btnm_get_pressed(btns); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); if (!btn_idx) { - mbox_action(btns, txt); if (!part_info.emmc) _create_mbox_start_partitioning(); else @@ -2761,7 +2759,7 @@ static lv_res_t _create_mbox_partitioning_warn() lv_label_set_text(lbl_status, txt_buf); if (part_info.backup_possible) - lv_mbox_add_btns(mbox, mbox_btn_map2, _create_mbox_partitioning_option1); + lv_mbox_add_btns(mbox, mbox_btn_map1, _create_mbox_partitioning_option1); else lv_mbox_add_btns(mbox, mbox_btn_map, _create_mbox_partitioning_option0); } @@ -2811,7 +2809,7 @@ static lv_res_t _create_mbox_partitioning_android(lv_obj_t *btns, const char *tx { int btn_idx = lv_btnm_get_pressed(btns); - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); part_info.and_dynamic = !btn_idx; _create_mbox_partitioning_warn(); @@ -3313,7 +3311,7 @@ static lv_res_t _mbox_check_files_total_size_option(lv_obj_t *btns, const char * if (!lv_btnm_get_pressed(btns)) part_info.backup_possible = false; - mbox_action(btns, txt); + nyx_mbox_action(btns, txt); return LV_RES_INV; } @@ -3707,7 +3705,7 @@ static void _create_mbox_check_files_total_size(u8 drive) if (!part_info.backup_possible) - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); else lv_mbox_add_btns(mbox, mbox_btn_map2, _mbox_check_files_total_size_option); @@ -4042,7 +4040,7 @@ check_changes: out: free(gpt); - lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); + lv_mbox_add_btns(mbox, mbox_btn_map, nyx_mbox_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true);