nyx: fix missing labels in launch if a previous label was big

This commit is contained in:
CTCaer 2021-08-28 18:07:32 +03:00
parent 49943ee46f
commit 9ba867f19e

View file

@ -1339,8 +1339,13 @@ out_end:
return LV_RES_OK; return LV_RES_OK;
} }
typedef struct _launch_menu_entries_t
{
lv_obj_t *btn[16];
lv_obj_t *label[16];
} launch_menu_entries_t;
static lv_obj_t *launch_ctxt[16]; static launch_menu_entries_t launch_ctxt;
static lv_obj_t *launch_bg = NULL; static lv_obj_t *launch_bg = NULL;
static bool launch_bg_done = false; static bool launch_bg_done = false;
@ -1358,7 +1363,7 @@ static lv_res_t _win_launch_close_action(lv_obj_t * btn)
// Cleanup icons. // Cleanup icons.
for (u32 i = 0; i < 8; i++) for (u32 i = 0; i < 8; i++)
{ {
lv_obj_t *btn = launch_ctxt[i * 2]; lv_obj_t *btn = launch_ctxt.btn[i];
lv_btn_ext_t *ext = lv_obj_get_ext_attr(btn); lv_btn_ext_t *ext = lv_obj_get_ext_attr(btn);
if (ext->idx) if (ext->idx)
{ {
@ -1549,7 +1554,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
// Icons must be <= 192 x 192. // Icons must be <= 192 x 192.
// Create first Button. // Create first Button.
btn_boot_entry = lv_btn_create(win, NULL); btn_boot_entry = lv_btn_create(win, NULL);
launch_ctxt[0] = btn_boot_entry; launch_ctxt.btn[0] = btn_boot_entry;
lv_obj_set_size(btn_boot_entry, 200, 200); lv_obj_set_size(btn_boot_entry, 200, 200);
lv_obj_set_pos(btn_boot_entry, launch_button_pos[0].btn_x, launch_button_pos[0].btn_y); lv_obj_set_pos(btn_boot_entry, launch_button_pos[0].btn_x, launch_button_pos[0].btn_y);
lv_obj_set_opa_scale(btn_boot_entry, LV_OPA_0); lv_obj_set_opa_scale(btn_boot_entry, LV_OPA_0);
@ -1560,7 +1565,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
boot_entry_label = lv_label_create(boot_entry_lbl_cont, NULL); boot_entry_label = lv_label_create(boot_entry_lbl_cont, NULL);
lv_obj_set_style(boot_entry_label, &hint_small_style_white); lv_obj_set_style(boot_entry_label, &hint_small_style_white);
lv_label_set_text(boot_entry_label, ""); lv_label_set_text(boot_entry_label, "");
launch_ctxt[1] = boot_entry_label; launch_ctxt.label[0] = boot_entry_label;
lv_cont_set_fit(boot_entry_lbl_cont, false, false); lv_cont_set_fit(boot_entry_lbl_cont, false, false);
lv_cont_set_layout(boot_entry_lbl_cont, LV_LAYOUT_CENTER); lv_cont_set_layout(boot_entry_lbl_cont, LV_LAYOUT_CENTER);
@ -1569,16 +1574,16 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
lv_obj_set_style(boot_entry_lbl_cont, &btn_label_home_transp); lv_obj_set_style(boot_entry_lbl_cont, &btn_label_home_transp);
// Create the rest of the buttons. // Create the rest of the buttons.
for (u32 btn_idx = 2; btn_idx < 16; btn_idx += 2) for (u32 btn_idx = 1; btn_idx < 8; btn_idx++)
{ {
btn_boot_entry = lv_btn_create(win, btn_boot_entry); btn_boot_entry = lv_btn_create(win, btn_boot_entry);
launch_ctxt[btn_idx] = btn_boot_entry; launch_ctxt.btn[btn_idx] = btn_boot_entry;
lv_obj_set_pos(btn_boot_entry, launch_button_pos[btn_idx >> 1].btn_x, launch_button_pos[btn_idx >> 1].btn_y); lv_obj_set_pos(btn_boot_entry, launch_button_pos[btn_idx].btn_x, launch_button_pos[btn_idx].btn_y);
boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont); boot_entry_lbl_cont = lv_cont_create(win, boot_entry_lbl_cont);
boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label); boot_entry_label = lv_label_create(boot_entry_lbl_cont, boot_entry_label);
lv_obj_set_pos(boot_entry_lbl_cont, launch_button_pos[btn_idx >> 1].lbl_x, launch_button_pos[btn_idx >> 1].lbl_y); lv_obj_set_pos(boot_entry_lbl_cont, launch_button_pos[btn_idx].lbl_x, launch_button_pos[btn_idx].lbl_y);
launch_ctxt[btn_idx + 1] = boot_entry_label; launch_ctxt.label[btn_idx] = boot_entry_label;
} }
// Create colorized icon style based on its parrent style. // Create colorized icon style based on its parrent style.
@ -1618,7 +1623,7 @@ ini_parsing:
if (ini_parse_success) if (ini_parse_success)
{ {
// Iterate to all boot entries and load icons. // Iterate to all boot entries and load icons.
u32 i = 1; u32 entry_idx = 1;
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link) LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
{ {
@ -1672,7 +1677,7 @@ ini_parsing:
} }
// Enable button. // Enable button.
lv_obj_set_opa_scale(launch_ctxt[curr_btn_idx], LV_OPA_COVER); lv_obj_set_opa_scale(launch_ctxt.btn[curr_btn_idx], LV_OPA_COVER);
// Default to switch logo if no icon found at all. // Default to switch logo if no icon found at all.
if (!bmp) if (!bmp)
@ -1686,7 +1691,7 @@ ini_parsing:
//Set icon. //Set icon.
if (bmp) if (bmp)
{ {
img = lv_img_create(launch_ctxt[curr_btn_idx], NULL); img = lv_img_create(launch_ctxt.btn[curr_btn_idx], NULL);
if (img_colorize) if (img_colorize)
lv_img_set_style(img, &img_style); lv_img_set_style(img, &img_style);
@ -1695,7 +1700,7 @@ ini_parsing:
} }
// Add button mask/radius and align icon. // Add button mask/radius and align icon.
lv_obj_t *btn = lv_btn_create(launch_ctxt[curr_btn_idx], NULL); lv_obj_t *btn = lv_btn_create(launch_ctxt.btn[curr_btn_idx], NULL);
lv_obj_set_size(btn, 200, 200); lv_obj_set_size(btn, 200, 200);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_home_transp_rel); lv_btn_set_style(btn, LV_BTN_STYLE_REL, &btn_home_transp_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_home_transp_pr); lv_btn_set_style(btn, LV_BTN_STYLE_PR, &btn_home_transp_pr);
@ -1704,9 +1709,9 @@ ini_parsing:
// Set autoboot index. // Set autoboot index.
ext = lv_obj_get_ext_attr(btn); ext = lv_obj_get_ext_attr(btn);
ext->idx = i; ext->idx = entry_idx;
ext = lv_obj_get_ext_attr(launch_ctxt[curr_btn_idx]); // Redundancy. ext = lv_obj_get_ext_attr(launch_ctxt.btn[curr_btn_idx]); // Redundancy.
ext->idx = i; ext->idx = entry_idx;
// Set action. // Set action.
if (!more_cfg) if (!more_cfg)
@ -1715,26 +1720,27 @@ ini_parsing:
lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_more_cfg_action); lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, _launch_more_cfg_action);
// Set button's label text. // Set button's label text.
lv_label_set_text(launch_ctxt[curr_btn_idx + 1], ini_sec->name); lv_label_set_text(launch_ctxt.label[curr_btn_idx], ini_sec->name);
lv_obj_set_opa_scale(launch_ctxt[curr_btn_idx + 1], LV_OPA_COVER); lv_obj_set_opa_scale(launch_ctxt.label[curr_btn_idx], LV_OPA_COVER);
// Set rolling text if name is big. // Set rolling text if name is big.
if (strlen(ini_sec->name) > 22) if (strlen(ini_sec->name) > 22)
lv_label_set_long_mode(boot_entry_label, LV_LABEL_LONG_ROLL); lv_label_set_long_mode(launch_ctxt.label[curr_btn_idx], LV_LABEL_LONG_ROLL);
i++; entry_idx++;
curr_btn_idx += 2; curr_btn_idx++;
if (curr_btn_idx >= (max_entries * 2)) // Check if we exceed max buttons.
if (curr_btn_idx >= max_entries)
break; break;
} }
} }
// Reiterate the loop with more cfgs if combined. // Reiterate the loop with more cfgs if combined.
if (combined_cfg && (curr_btn_idx < 16) && !more_cfg) if (combined_cfg && (curr_btn_idx < 8) && !more_cfg)
goto ini_parsing; goto ini_parsing;
} }
if (curr_btn_idx < 2) if (curr_btn_idx < 1)
no_boot_entries = true; no_boot_entries = true;
sd_unmount(); sd_unmount();