1
0
mirror of https://github.com/CTCaer/hekate.git synced 2024-12-24 12:14:11 +00:00

nyx: Refactor launch icon colorization

The Switch and Payload icons will be colorized by default, because they are system icons.

Users can still replace them with icons named `icon_switch_custom.bmp` and `icon_payload_custom.bmp` that do not get colorized.
This commit is contained in:
CTCaer 2020-05-03 01:57:15 +03:00
parent 54c36a7e46
commit 8edc9971f9
7 changed files with 46 additions and 10 deletions

View File

@ -4,6 +4,10 @@ The background for Nyx, must be a 1280 x 720 32-bit BMP. Alpha blending is taken
The icons supported are 192 x 192 32-bit BMP. You can utilize transparency at will and make nice mixes with the button background.
Additionally, using the `icon={sd path}`, the icon will get colorized if the name ends in `_hue.bmp`. That only works nicely if the icon is a white layout with transparency.
The default system icons (`icon_switch.bmp` and `icon_payload.bmp`) can be replaced with white layouts that have transparency. They can also be replaced with normal icons if the following exist: `icon_switch_custom.bmp` or/and `icon_payload_custom.bmp`
## How to configure

View File

@ -1503,6 +1503,12 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
launch_ctxt[btn_idx + 1] = boot_entry_label;
}
// Create colorized icon style based on its parrent style.
static lv_style_t img_style;
lv_style_copy(&img_style, &lv_style_plain);
img_style.image.color = lv_color_hsv_to_rgb(n_cfg.themecolor, 100, 100);
img_style.image.intense = LV_OPA_COVER;
// Parse ini boot entries and set buttons/icons.
char *tmp_path = malloc(1024);
u32 curr_btn_idx = 0; // Active buttons.
@ -1510,6 +1516,10 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
if (sd_mount())
{
// Check if we use custom system icons.
bool icon_sw_custom = !f_stat("bootloader/res/icon_switch_custom.bmp", NULL);
bool icon_pl_custom = !f_stat("bootloader/res/icon_payload_custom.bmp", NULL);
// Choose what to parse.
bool ini_parse_success = false;
if (!more_cfg)
@ -1539,6 +1549,7 @@ ini_parsing:
icon_path = NULL;
u32 payload = 0;
bool img_colorize = false;
lv_img_dsc_t *bmp = NULL;
lv_obj_t *img = NULL;
@ -1568,32 +1579,43 @@ ini_parsing:
if (!strcmp(ini_sec->name, "Lakka"))
bmp = icon_lakka;
else if (payload)
{
bmp = icon_payload;
if (!icon_pl_custom)
img_colorize = true;
}
}
}
else
{
bmp = bmp_to_lvimg_obj(icon_path);
// Check if colorization is enabled.
if (bmp && strlen(icon_path) > 8 && !memcmp(icon_path + strlen(icon_path) - 8, "_hue", 4))
img_colorize = true;
}
// Enable button.
lv_obj_set_opa_scale(launch_ctxt[curr_btn_idx], LV_OPA_COVER);
// Default to switch logo if no icon found at all.
if (!bmp)
{
bmp = icon_switch;
if (!icon_sw_custom)
img_colorize = true;
}
//Set icon.
if (bmp)
{
img = lv_img_create(launch_ctxt[curr_btn_idx], NULL);
if (icon_path && strlen(icon_path) > 13 && !memcmp(icon_path + strlen(icon_path) - 13, "_colorize", 9)) {
static lv_style_t style;
lv_style_copy(&style, &lv_style_plain);
style.image.color = lv_color_hsv_to_rgb(n_cfg.themecolor, 100, 100);
style.image.intense = LV_OPA_COVER;
lv_img_set_style(img, &style);
}
if (img_colorize)
lv_img_set_style(img, &img_style);
lv_img_set_src(img, bmp);
}

View File

@ -361,8 +361,18 @@ void nyx_init_load_res()
f_read(&fp, (void *)NYX_RES_ADDR, f_size(&fp), NULL);
f_close(&fp);
icon_switch = bmp_to_lvimg_obj("bootloader/res/icon_switch.bmp");
icon_payload = bmp_to_lvimg_obj("bootloader/res/icon_payload.bmp");
// If no custom switch icon exists, load normal.
if (f_stat("bootloader/res/icon_switch_custom.bmp", NULL))
icon_switch = bmp_to_lvimg_obj("bootloader/res/icon_switch.bmp");
else
icon_switch = bmp_to_lvimg_obj("bootloader/res/icon_switch_custom.bmp");
// If no custom payload icon exists, load normal.
if (f_stat("bootloader/res/icon_payload_custom.bmp", NULL))
icon_payload = bmp_to_lvimg_obj("bootloader/res/icon_payload.bmp");
else
icon_payload = bmp_to_lvimg_obj("bootloader/res/icon_payload_custom.bmp");
icon_lakka = bmp_to_lvimg_obj("bootloader/res/icon_lakka.bmp");
hekate_bg = bmp_to_lvimg_obj("bootloader/res/background.bmp");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB