nyx: lvgl: complete black theme and add options
Since, this has the side-effect to make any theme color component from 0x0B to 0xC7 work, add theme background controls in Nyx Options. Additionally, set shadow color to black and fix inactive buttons on transparent styles.
This commit is contained in:
@@ -376,25 +376,26 @@ static lv_res_t _save_nyx_options_action(lv_obj_t *btn)
|
||||
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_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.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;
|
||||
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.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_HEX(0xFFFFFF);
|
||||
btn_onoff_pr_hos_style->body.border.opa = LV_OPA_50;
|
||||
btn_onoff_pr_hos_style->body.border.width = 4;
|
||||
btn_onoff_pr_hos_style->body.radius = 0;
|
||||
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_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_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));
|
||||
@@ -408,6 +409,10 @@ typedef struct _color_test_ctxt
|
||||
{
|
||||
u32 bg;
|
||||
u16 hue;
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
|
||||
lv_obj_t *window;
|
||||
lv_obj_t *header1;
|
||||
lv_obj_t *header2;
|
||||
@@ -417,11 +422,25 @@ typedef struct _color_test_ctxt
|
||||
lv_obj_t *button;
|
||||
lv_obj_t *hue_slider;
|
||||
lv_obj_t *hue_label;
|
||||
|
||||
lv_obj_t *r_slider;
|
||||
lv_obj_t *r_label;
|
||||
lv_obj_t *g_slider;
|
||||
lv_obj_t *g_label;
|
||||
lv_obj_t *b_slider;
|
||||
lv_obj_t *b_label;
|
||||
|
||||
lv_style_t box_style;
|
||||
lv_obj_t *box;
|
||||
|
||||
lv_obj_t *btn_apply;
|
||||
lv_obj_t *btn_black;
|
||||
lv_obj_t *btn_reset;
|
||||
} color_test_ctxt;
|
||||
|
||||
color_test_ctxt color_test;
|
||||
|
||||
static lv_res_t _save_theme_color_action(lv_obj_t *btn)
|
||||
static lv_res_t _action_win_nyx_colors_save(lv_obj_t *btn)
|
||||
{
|
||||
n_cfg.theme_bg = color_test.bg;
|
||||
n_cfg.theme_color = color_test.hue;
|
||||
@@ -434,12 +453,23 @@ static lv_res_t _save_theme_color_action(lv_obj_t *btn)
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static void _show_new_nyx_color(u32 bg, u16 hue, bool update_bg)
|
||||
static void _show_new_nyx_color(bool update_bg)
|
||||
{
|
||||
lv_color_t bgc = LV_COLOR_HEX(bg);
|
||||
lv_color_t bgc_light = LV_COLOR_HEX(bg ? (bg + 0x101010) : 0x2D2D2D);
|
||||
lv_color_t bg_border = LV_COLOR_HEX(bg ? (bg + 0x202020) : 0x3D3D3D);
|
||||
lv_color_t color = lv_color_hsv_to_rgb(hue, 100, 100);
|
||||
u32 bg = color_test.bg;
|
||||
u16 hue = color_test.hue;
|
||||
|
||||
lv_color_t bgc = LV_COLOR_HEX(bg); // COLOR_HOS_BG.
|
||||
lv_color_t bgc_light = LV_COLOR_HEX(bg ? (bg + 0x101010) : 0x2D2D2D); // COLOR_HOS_BG_LIGHT.
|
||||
lv_color_t bgc_press = LV_COLOR_HEX(bg ? (bg + 0x232323) : 0x404040); // 0x505050.
|
||||
lv_color_t bg_border = LV_COLOR_HEX(bg ? (bg + 0x202020) : 0x3D3D3D); // COLOR_HOS_BG_LIGHTER.
|
||||
lv_color_t color = lv_color_hsv_to_rgb(hue, 100, 100);
|
||||
|
||||
static lv_style_t btn_tgl_pr_test;
|
||||
lv_style_copy(&btn_tgl_pr_test, lv_btn_get_style(color_test.button, LV_BTN_STATE_TGL_PR));
|
||||
btn_tgl_pr_test.body.main_color = bgc_press;
|
||||
btn_tgl_pr_test.body.grad_color = btn_tgl_pr_test.body.main_color;
|
||||
btn_tgl_pr_test.body.border.color = color;
|
||||
btn_tgl_pr_test.text.color = color;
|
||||
|
||||
if (update_bg)
|
||||
{
|
||||
@@ -466,6 +496,27 @@ static void _show_new_nyx_color(u32 bg, u16 hue, bool update_bg)
|
||||
hdr2_bg_test.body.main_color = bgc;
|
||||
hdr2_bg_test.body.grad_color = hdr2_bg_test.body.main_color;
|
||||
lv_cont_set_style(color_test.header2, &hdr2_bg_test);
|
||||
|
||||
static lv_style_t btn_tgl_rel_test;
|
||||
lv_style_copy(&btn_tgl_rel_test, lv_btn_get_style(color_test.btn_apply, LV_BTN_STATE_REL));
|
||||
btn_tgl_rel_test.body.main_color = bgc_light;
|
||||
btn_tgl_rel_test.body.grad_color = btn_tgl_rel_test.body.main_color;
|
||||
lv_btn_set_style(color_test.btn_apply, LV_BTN_STATE_REL, &btn_tgl_rel_test);
|
||||
lv_btn_set_style(color_test.btn_apply, LV_BTN_STATE_PR, &btn_tgl_pr_test);
|
||||
lv_btn_set_style(color_test.btn_black, LV_BTN_STATE_REL, &btn_tgl_rel_test);
|
||||
lv_btn_set_style(color_test.btn_black, LV_BTN_STATE_PR, &btn_tgl_pr_test);
|
||||
lv_btn_set_style(color_test.btn_reset, LV_BTN_STATE_REL, &btn_tgl_rel_test);
|
||||
lv_btn_set_style(color_test.btn_reset, LV_BTN_STATE_PR, &btn_tgl_pr_test);
|
||||
|
||||
static lv_style_t slider_bg;
|
||||
lv_style_copy(&slider_bg, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_BG));
|
||||
slider_bg.body.main_color = bg_border;
|
||||
slider_bg.body.grad_color = slider_bg.body.main_color;
|
||||
lv_slider_set_style(color_test.hue_slider, LV_SLIDER_STYLE_BG, &slider_bg);
|
||||
lv_slider_set_style(color_test.slider, LV_SLIDER_STYLE_BG, &slider_bg);
|
||||
lv_slider_set_style(color_test.r_slider, LV_SLIDER_STYLE_BG, &slider_bg);
|
||||
lv_slider_set_style(color_test.g_slider, LV_SLIDER_STYLE_BG, &slider_bg);
|
||||
lv_slider_set_style(color_test.b_slider, LV_SLIDER_STYLE_BG, &slider_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -474,29 +525,29 @@ static void _show_new_nyx_color(u32 bg, u16 hue, bool update_bg)
|
||||
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_knb;
|
||||
lv_style_copy(&slider_knb, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_KNOB));
|
||||
slider_knb.body.main_color = color;
|
||||
slider_knb.body.grad_color = slider_knb.body.main_color;
|
||||
lv_slider_set_style(color_test.hue_slider, LV_SLIDER_STYLE_KNOB, &slider_knb);
|
||||
lv_slider_set_style(color_test.slider, LV_SLIDER_STYLE_KNOB, &slider_knb);
|
||||
lv_slider_set_style(color_test.r_slider, LV_SLIDER_STYLE_KNOB, &slider_knb);
|
||||
lv_slider_set_style(color_test.g_slider, LV_SLIDER_STYLE_KNOB, &slider_knb);
|
||||
lv_slider_set_style(color_test.b_slider, LV_SLIDER_STYLE_KNOB, &slider_knb);
|
||||
|
||||
static lv_style_t slider_ind;
|
||||
lv_style_copy(&slider_ind, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_INDIC));
|
||||
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.hue_slider, LV_SLIDER_STYLE_INDIC, &slider_ind);
|
||||
lv_slider_set_style(color_test.slider, LV_SLIDER_STYLE_INDIC, &slider_ind);
|
||||
lv_slider_set_style(color_test.r_slider, LV_SLIDER_STYLE_INDIC, &slider_ind);
|
||||
lv_slider_set_style(color_test.g_slider, LV_SLIDER_STYLE_INDIC, &slider_ind);
|
||||
lv_slider_set_style(color_test.b_slider, LV_SLIDER_STYLE_INDIC, &slider_ind);
|
||||
}
|
||||
|
||||
static lv_style_t btn_tgl_pr_test;
|
||||
lv_style_copy(&btn_tgl_pr_test, lv_btn_get_style(color_test.button, LV_BTN_STATE_TGL_PR));
|
||||
btn_tgl_pr_test.body.main_color = bgc_light;
|
||||
btn_tgl_pr_test.body.grad_color = btn_tgl_pr_test.body.main_color;
|
||||
btn_tgl_pr_test.body.border.color = color;
|
||||
btn_tgl_pr_test.text.color = color;
|
||||
lv_btn_set_style(color_test.button, LV_BTN_STATE_TGL_PR, &btn_tgl_pr_test);
|
||||
|
||||
static lv_style_t slider_bg, slider_test, slider_ind;
|
||||
lv_style_copy(&slider_bg, lv_slider_get_style(color_test.slider, LV_SLIDER_STYLE_BG));
|
||||
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_bg.body.main_color = bg_border;
|
||||
slider_bg.body.grad_color = slider_bg.body.main_color;
|
||||
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_BG, &slider_bg);
|
||||
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)
|
||||
@@ -504,7 +555,9 @@ 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);
|
||||
_show_new_nyx_color(color_test.bg, color_test.hue, false);
|
||||
|
||||
_show_new_nyx_color(false);
|
||||
|
||||
char hue[8];
|
||||
s_printf(hue, "%03d", color_test.hue);
|
||||
lv_label_set_text(color_test.hue_label, hue);
|
||||
@@ -513,14 +566,87 @@ static lv_res_t _slider_hue_action(lv_obj_t *slider)
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _preset_bg_action(lv_obj_t *btn)
|
||||
static lv_res_t _slider_r_action(lv_obj_t *slider)
|
||||
{
|
||||
//! TODO: Support a range?
|
||||
if (color_test.bg)
|
||||
color_test.bg = 0;
|
||||
else
|
||||
color_test.bg = COLOR_HOS_BG;
|
||||
_show_new_nyx_color(color_test.bg, color_test.hue, true);
|
||||
if (color_test.r != lv_slider_get_value(slider))
|
||||
{
|
||||
color_test.r = lv_slider_get_value(slider);
|
||||
color_test.box_style.body.main_color = LV_COLOR_HEX((color_test.r << 16) | (color_test.g << 8) | color_test.b);
|
||||
color_test.box_style.body.grad_color = color_test.box_style.body.main_color;
|
||||
lv_obj_set_style(color_test.box, &color_test.box_style);
|
||||
|
||||
char shade[8];
|
||||
s_printf(shade, "%03d", color_test.r);
|
||||
lv_label_set_text(color_test.r_label, shade);
|
||||
}
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _slider_g_action(lv_obj_t *slider)
|
||||
{
|
||||
if (color_test.g != lv_slider_get_value(slider))
|
||||
{
|
||||
color_test.g = lv_slider_get_value(slider);
|
||||
color_test.box_style.body.main_color = LV_COLOR_HEX((color_test.r << 16) | (color_test.g << 8) | color_test.b);
|
||||
color_test.box_style.body.grad_color = color_test.box_style.body.main_color;
|
||||
lv_obj_set_style(color_test.box, &color_test.box_style);
|
||||
|
||||
char shade[8];
|
||||
s_printf(shade, "%03d", color_test.g);
|
||||
lv_label_set_text(color_test.g_label, shade);
|
||||
}
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _slider_b_action(lv_obj_t *slider)
|
||||
{
|
||||
if (color_test.b != lv_slider_get_value(slider))
|
||||
{
|
||||
color_test.b = lv_slider_get_value(slider);
|
||||
color_test.box_style.body.main_color = LV_COLOR_HEX((color_test.r << 16) | (color_test.g << 8) | color_test.b);
|
||||
color_test.box_style.body.grad_color = color_test.box_style.body.main_color;
|
||||
lv_obj_set_style(color_test.box, &color_test.box_style);
|
||||
|
||||
char shade[8];
|
||||
s_printf(shade, "%03d", color_test.b);
|
||||
lv_label_set_text(color_test.b_label, shade);
|
||||
}
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _preset_bg_apply(lv_obj_t *btn)
|
||||
{
|
||||
color_test.bg = (color_test.r << 16) | (color_test.g << 8) | color_test.b;
|
||||
|
||||
_show_new_nyx_color(true);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _preset_bg_black(lv_obj_t *btn)
|
||||
{
|
||||
color_test.bg = 0;
|
||||
|
||||
_show_new_nyx_color(true);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_res_t _preset_bg_reset(lv_obj_t *btn)
|
||||
{
|
||||
color_test.r = (n_cfg.theme_bg >> 16) & 0xFF;
|
||||
color_test.g = (n_cfg.theme_bg >> 8) & 0xFF;
|
||||
color_test.b = (n_cfg.theme_bg >> 0) & 0xFF;
|
||||
color_test.bg = n_cfg.theme_bg;
|
||||
|
||||
lv_bar_set_value(color_test.r_slider, color_test.r);
|
||||
lv_bar_set_value(color_test.g_slider, color_test.g);
|
||||
lv_bar_set_value(color_test.b_slider, color_test.b);
|
||||
|
||||
_show_new_nyx_color(true);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
@@ -532,11 +658,13 @@ static lv_res_t _preset_hue_action(lv_obj_t *btn)
|
||||
if (color_test.hue != ext->idx)
|
||||
{
|
||||
color_test.hue = ext->idx;
|
||||
_show_new_nyx_color(color_test.bg, color_test.hue, false);
|
||||
|
||||
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);
|
||||
|
||||
_show_new_nyx_color(false);
|
||||
}
|
||||
|
||||
return LV_RES_OK;
|
||||
@@ -546,31 +674,49 @@ static const u16 theme_colors[17] = {
|
||||
4, 13, 23, 33, 43, 54, 66, 89, 124, 167, 187, 200, 208, 231, 261, 291, 341
|
||||
};
|
||||
|
||||
lv_res_t _action_win_nyx_colors_close(lv_obj_t * btn)
|
||||
{
|
||||
lv_obj_set_opa_scale(status_bar.mid, LV_OPA_COVER);
|
||||
lv_obj_set_click(status_bar.mid, true);
|
||||
|
||||
return nyx_win_close_action(btn);
|
||||
}
|
||||
|
||||
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", 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);
|
||||
lv_obj_t *win = nyx_create_standard_window(SYMBOL_COPY" Nyx Color Theme", _action_win_nyx_colors_close);
|
||||
lv_win_add_btn(win, NULL, SYMBOL_SAVE" Save & Reload", _action_win_nyx_colors_save);
|
||||
color_test.window = win;
|
||||
|
||||
// Set current theme colors.
|
||||
color_test.bg = n_cfg.theme_bg;
|
||||
color_test.hue = n_cfg.theme_color;
|
||||
u32 bg = n_cfg.theme_bg ? n_cfg.theme_bg : 0x2D2D2D;
|
||||
color_test.r = (bg >> 16) & 0xFF;
|
||||
color_test.g = (bg >> 8) & 0xFF;
|
||||
color_test.b = (bg >> 0) & 0xFF;
|
||||
|
||||
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);
|
||||
lv_style_copy(&color_test.box_style, &lv_style_plain_color);
|
||||
color_test.box_style.body.main_color = LV_COLOR_HEX(color_test.bg);
|
||||
color_test.box_style.body.grad_color = color_test.box_style.body.main_color;
|
||||
color_test.box_style.body.border.color = LV_COLOR_HEX(0xFFFFFF);
|
||||
color_test.box_style.body.border.opa = LV_OPA_20;
|
||||
color_test.box_style.body.border.width = 2;
|
||||
|
||||
// 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);
|
||||
lv_obj_set_size(h1, LV_DPI * 12, LV_DPI * 14 / 13);
|
||||
color_test.header1 = h1;
|
||||
|
||||
lv_obj_t *acc_label = lv_label_create(h1, NULL);
|
||||
lv_label_set_static_text(acc_label, "Accent color:");
|
||||
|
||||
// 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_align(color_btn, acc_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 10);
|
||||
lv_obj_t *color_btn2;
|
||||
|
||||
for (u32 i = 1; i < 17; i++)
|
||||
@@ -583,44 +729,129 @@ static lv_res_t _create_window_nyx_colors(lv_obj_t *btn)
|
||||
color_btn = color_btn2;
|
||||
}
|
||||
|
||||
lv_obj_align(h1, sep, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 4);
|
||||
lv_obj_align(h1, NULL, LV_ALIGN_IN_TOP_MID, 0, LV_DPI / 5);
|
||||
|
||||
// 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;
|
||||
lv_obj_t *h_slider = lv_slider_create(win, NULL);
|
||||
lv_obj_set_width(h_slider, 1070);
|
||||
lv_obj_set_height(h_slider, LV_DPI * 4 / 10);
|
||||
lv_bar_set_range(h_slider, 0, 359);
|
||||
lv_bar_set_value(h_slider, color_test.hue);
|
||||
lv_slider_set_action(h_slider, _slider_hue_action);
|
||||
lv_obj_align(h_slider, h1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
|
||||
color_test.hue_slider = h_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);
|
||||
lv_obj_align(hue_text_label, h_slider, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 24 / 100, 0);
|
||||
char txt[8];
|
||||
s_printf(txt, "%03d", color_test.hue);
|
||||
lv_label_set_text(hue_text_label, txt);
|
||||
color_test.hue_label = hue_text_label;
|
||||
|
||||
lv_obj_t *bg_label = lv_label_create(win, NULL);
|
||||
lv_label_set_static_text(bg_label, "Theme color:");
|
||||
lv_obj_align(bg_label, h_slider, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
|
||||
|
||||
// Create red slider.
|
||||
lv_obj_t *r_slider = lv_slider_create(win, NULL);
|
||||
lv_obj_set_width(r_slider, 535);
|
||||
lv_obj_set_height(r_slider, LV_DPI * 4 / 10);
|
||||
lv_bar_set_range(r_slider, 11, 100);
|
||||
lv_bar_set_value(r_slider, color_test.r);
|
||||
lv_slider_set_action(r_slider, _slider_r_action);
|
||||
lv_obj_align(r_slider, bg_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 21);
|
||||
color_test.r_slider = r_slider;
|
||||
|
||||
// Create red label.
|
||||
lv_obj_t *r_text_label = lv_label_create(win, NULL);
|
||||
lv_obj_align(r_text_label, r_slider, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 24 / 100, 0);
|
||||
s_printf(txt, "%03d", color_test.r);
|
||||
lv_label_set_text(r_text_label, txt);
|
||||
color_test.r_label = r_text_label;
|
||||
|
||||
// Create green slider.
|
||||
lv_obj_t *g_slider = lv_slider_create(win, NULL);
|
||||
lv_obj_set_width(g_slider, 535);
|
||||
lv_obj_set_height(g_slider, LV_DPI * 4 / 10);
|
||||
lv_bar_set_range(g_slider, 11, 100);
|
||||
lv_bar_set_value(g_slider, color_test.g);
|
||||
lv_slider_set_action(g_slider, _slider_g_action);
|
||||
lv_obj_align(g_slider, r_slider, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 7);
|
||||
color_test.g_slider = g_slider;
|
||||
|
||||
// Create green label.
|
||||
lv_obj_t *g_text_label = lv_label_create(win, NULL);
|
||||
lv_obj_align(g_text_label, g_slider, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 24 / 100, 0);
|
||||
s_printf(txt, "%03d", color_test.g);
|
||||
lv_label_set_text(g_text_label, txt);
|
||||
color_test.g_label = g_text_label;
|
||||
|
||||
// Create blue slider.
|
||||
lv_obj_t *b_slider = lv_slider_create(win, NULL);
|
||||
lv_obj_set_width(b_slider, 535);
|
||||
lv_obj_set_height(b_slider, LV_DPI * 4 / 10);
|
||||
lv_bar_set_range(b_slider, 11, 100);
|
||||
lv_bar_set_value(b_slider, color_test.b);
|
||||
lv_slider_set_action(b_slider, _slider_b_action);
|
||||
lv_obj_align(b_slider, g_slider, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 7);
|
||||
color_test.b_slider = b_slider;
|
||||
|
||||
// Create blue label.
|
||||
lv_obj_t *b_text_label = lv_label_create(win, NULL);
|
||||
lv_obj_align(b_text_label, b_slider, LV_ALIGN_OUT_RIGHT_MID, LV_DPI * 24 / 100, 0);
|
||||
s_printf(txt, "%03d", color_test.b);
|
||||
lv_label_set_text(b_text_label, txt);
|
||||
color_test.b_label = b_text_label;
|
||||
|
||||
// Create theme color box.
|
||||
lv_obj_t * bg_box = lv_obj_create(win, NULL);
|
||||
lv_obj_set_size(bg_box, LV_DPI * 10 / 7, LV_DPI * 18 / 13);
|
||||
lv_obj_align(bg_box, r_text_label, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI / 4, 0);
|
||||
lv_obj_set_style(bg_box, &color_test.box_style);
|
||||
color_test.box = bg_box;
|
||||
|
||||
// Create theme color buttons.
|
||||
lv_obj_t *btn_apply = lv_btn_create(win, NULL);
|
||||
lv_obj_t *label_btn = lv_label_create(btn_apply, NULL);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_OK" Custom");
|
||||
lv_btn_set_fit(btn_apply, false, true);
|
||||
lv_obj_set_width(btn_apply, LV_DPI * 5 / 3);
|
||||
lv_btn_set_action(btn_apply, LV_BTN_ACTION_CLICK, _preset_bg_apply);
|
||||
lv_obj_align(btn_apply, bg_box, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI / 5, 0);
|
||||
color_test.btn_apply = btn_apply;
|
||||
|
||||
lv_obj_t *btn_black = lv_btn_create(win, btn_apply);
|
||||
label_btn = lv_label_create(btn_black, NULL);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_BRIGHTNESS" Black");
|
||||
lv_btn_set_action(btn_black, LV_BTN_ACTION_CLICK, _preset_bg_black);
|
||||
lv_obj_align(btn_black, btn_apply, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI / 5, 0);
|
||||
color_test.btn_black = btn_black;
|
||||
|
||||
lv_obj_t *btn_reset = lv_btn_create(win, btn_apply);
|
||||
label_btn = lv_label_create(btn_reset, NULL);
|
||||
lv_label_set_static_text(label_btn, SYMBOL_REFRESH" Reset");
|
||||
lv_obj_set_width(btn_reset, LV_DPI * 10 / 3 + LV_DPI / 5);
|
||||
lv_btn_set_action(btn_reset, LV_BTN_ACTION_CLICK, _preset_bg_reset);
|
||||
lv_obj_align(btn_reset, btn_apply, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 7);
|
||||
color_test.btn_reset = btn_reset;
|
||||
|
||||
// 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_set_size(h2, LV_DPI * 12, LV_DPI * 18 / 10);
|
||||
lv_obj_align(h2, b_slider, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
|
||||
color_test.header2 = h2;
|
||||
|
||||
lv_obj_t *lbl_sample = lv_label_create(h2, NULL);
|
||||
lv_label_set_static_text(lbl_sample, "Sample:");
|
||||
lv_label_set_static_text(lbl_sample, "Accent 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.");
|
||||
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
|
||||
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);
|
||||
lv_obj_align(lbl_test, lbl_sample, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 34);
|
||||
color_test.label = lbl_test;
|
||||
|
||||
// Create sample icons.
|
||||
@@ -628,12 +859,12 @@ static lv_res_t _create_window_nyx_colors(lv_obj_t *btn)
|
||||
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);
|
||||
lv_obj_align(lbl_icons, lbl_test, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 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_align(slider_test, lbl_test, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 5);
|
||||
lv_obj_set_click(slider_test, false);
|
||||
lv_bar_set_value(slider_test, 60);
|
||||
color_test.slider = slider_test;
|
||||
@@ -641,12 +872,17 @@ static lv_res_t _create_window_nyx_colors(lv_obj_t *btn)
|
||||
// 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_btn_set_fit(btn_test, false, true);
|
||||
lv_obj_set_width(btn_test, LV_DPI * 5 / 3);
|
||||
lv_obj_align(btn_test, lbl_test, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI / 20);
|
||||
lv_obj_set_click(btn_test, false);
|
||||
color_test.button = btn_test;
|
||||
|
||||
_show_new_nyx_color(color_test.bg, color_test.hue, false);
|
||||
_show_new_nyx_color(false);
|
||||
|
||||
lv_obj_set_opa_scale(status_bar.mid, LV_OPA_0);
|
||||
lv_obj_set_click(status_bar.mid, false);
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
@@ -1279,7 +1515,7 @@ lv_res_t create_win_nyx_options(lv_obj_t *parrent_btn)
|
||||
|
||||
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_label_set_static_text(label_txt2, "Customize #C7EA46 Theme# and #C7EA46 Accent# colors 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user