From b9b735ce9fba14ba949ebed0e83e795a3fe73118 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 19 Dec 2017 22:00:32 +0100 Subject: [PATCH] minor updates --- lv_core/lv_obj.c | 13 ++++++++---- lv_core/lv_obj.h | 2 +- lv_objx/lv_btn.c | 18 ++++++++-------- lv_objx/lv_btn.h | 2 +- lv_objx/lv_btnm.c | 31 ++++++++++++++++------------ lv_objx/lv_cb.c | 4 ++-- lv_objx/lv_cb.h | 4 ++-- lv_objx/lv_gauge.c | 7 +++---- lv_objx/lv_gauge.h | 20 ++++++++++++++++++ lv_objx/lv_kb.c | 18 +++++++++------- lv_objx/lv_kb.h | 17 ++++++++++++--- lv_objx/lv_led.c | 2 +- lv_objx/lv_led.h | 15 +++++++------- lv_objx/lv_list.c | 4 ++-- lv_objx/lv_lmeter.c | 2 +- lv_objx/lv_roller.c | 6 +++--- lv_objx/lv_roller.h | 2 +- lv_objx/lv_sw.c | 4 ++-- lv_objx/lv_sw.h | 4 ++-- lv_objx/lv_tabview.c | 8 ++----- lv_objx/lv_tabview.h | 5 ++--- lv_objx/lv_win.c | 2 +- lv_themes/lv_theme_alien.c | 6 +++--- lv_themes/lv_theme_default.c | 17 +++++++++------ lv_themes/lv_theme_material.c | 39 +++++++++++++++++++---------------- lv_themes/lv_theme_mono.c | 6 +++++- lv_themes/lv_theme_night.c | 12 ++++++++--- lv_themes/lv_theme_templ.c | 1 + 28 files changed, 163 insertions(+), 108 deletions(-) diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index 8d60dfee5..bb4cecbf1 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -10,6 +10,7 @@ #include "lv_indev.h" #include "lv_refr.h" #include "lv_group.h" +#include "../lv_themes/lv_theme.h" #include "../lv_draw/lv_draw.h" #include "../lv_draw/lv_draw_rbasic.h" #include "../lv_misc/lv_anim.h" @@ -130,9 +131,13 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy) new_obj->coords.y2 = LV_VER_RES - 1; new_obj->ext_size = 0; - /*Set appearance*/ - new_obj->style_p = &lv_style_scr; - + /*Set the default styles*/ + lv_theme_t *th = lv_theme_get_current(); + if(th) { + new_obj->style_p = th->bg; + } else { + new_obj->style_p = &lv_style_scr; + } /*Set virtual functions*/ lv_obj_set_signal_func(new_obj, lv_obj_signal); lv_obj_set_design_func(new_obj, lv_obj_design); @@ -254,7 +259,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy) /** * Delete 'obj' and all of its children * @param obj pointer to an object to delete - * @preturn LV_RES_INV beacuse the object is deleted + * @return LV_RES_INV because the object is deleted */ lv_res_t lv_obj_del(lv_obj_t * obj) { diff --git a/lv_core/lv_obj.h b/lv_core/lv_obj.h index a621a2096..8c68934d1 100644 --- a/lv_core/lv_obj.h +++ b/lv_core/lv_obj.h @@ -209,7 +209,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy); /** * Delete 'obj' and all of its children * @param obj pointer to an object to delete - * @preturn LV_RES_INV beacuse the object is deleted + * @return LV_RES_INV because the object is deleted */ lv_res_t lv_obj_del(lv_obj_t * obj); diff --git a/lv_objx/lv_btn.c b/lv_objx/lv_btn.c index 280b41582..8fbe91e2a 100644 --- a/lv_objx/lv_btn.c +++ b/lv_objx/lv_btn.c @@ -64,7 +64,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy) ext->state = LV_BTN_STATE_REL; ext->actions[LV_BTN_ACTION_PR] = NULL; - ext->actions[LV_BTN_ACTION_REL] = NULL; + ext->actions[LV_BTN_ACTION_CLICK] = NULL; ext->actions[LV_BTN_ACTION_LONG_PR] = NULL; ext->actions[LV_BTN_ACTION_LONG_PR_REPEAT] = NULL; @@ -333,8 +333,8 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) lv_btn_set_state(btn, LV_BTN_STATE_REL); } - if(ext->actions[LV_BTN_ACTION_REL] && state != LV_BTN_STATE_INA) { - res = ext->actions[LV_BTN_ACTION_REL](btn); + if(ext->actions[LV_BTN_ACTION_CLICK] && state != LV_BTN_STATE_INA) { + res = ext->actions[LV_BTN_ACTION_CLICK](btn); } } else { /*If dragged change back the state*/ if(ext->state == LV_BTN_STATE_PR) { @@ -359,13 +359,13 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) char c = *((char*)param); if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) { if(lv_btn_get_toggle(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL); - if(ext->actions[LV_BTN_ACTION_REL] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) { - res = ext->actions[LV_BTN_ACTION_REL](btn); + if(ext->actions[LV_BTN_ACTION_CLICK] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) { + res = ext->actions[LV_BTN_ACTION_CLICK](btn); } } else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) { if(lv_btn_get_toggle(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_REL); - if(ext->actions[LV_BTN_ACTION_REL] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) { - res = ext->actions[LV_BTN_ACTION_REL](btn); + if(ext->actions[LV_BTN_ACTION_CLICK] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) { + res = ext->actions[LV_BTN_ACTION_CLICK](btn); } } else if(c == LV_GROUP_KEY_ENTER) { if(lv_btn_get_toggle(btn) != false) { @@ -374,8 +374,8 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) else if(state == LV_BTN_STATE_TGL_REL) lv_btn_set_state(btn, LV_BTN_STATE_REL); else if(state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_PR); } - if(ext->actions[LV_BTN_ACTION_REL] && state != LV_BTN_STATE_INA) { - res = ext->actions[LV_BTN_ACTION_REL](btn); + if(ext->actions[LV_BTN_ACTION_CLICK] && state != LV_BTN_STATE_INA) { + res = ext->actions[LV_BTN_ACTION_CLICK](btn); } } } diff --git a/lv_objx/lv_btn.h b/lv_objx/lv_btn.h index 5d949beee..f0e83bd0c 100644 --- a/lv_objx/lv_btn.h +++ b/lv_objx/lv_btn.h @@ -45,7 +45,7 @@ typedef enum typedef enum { - LV_BTN_ACTION_REL, + LV_BTN_ACTION_CLICK, LV_BTN_ACTION_PR, LV_BTN_ACTION_LONG_PR, LV_BTN_ACTION_LONG_PR_REPEAT, diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 10af76b06..de6baf08a 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -150,10 +150,10 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) create_buttons(btnm, map); /*Set size and positions of the buttons*/ - lv_style_t * btnms = lv_obj_get_style(btnm); - lv_coord_t max_w = lv_obj_get_width(btnm) - 2 * btnms->body.padding.hor; - lv_coord_t max_h = lv_obj_get_height(btnm) - 2 * btnms->body.padding.ver; - lv_coord_t act_y = btnms->body.padding.ver; + lv_style_t * style_bg = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG); + lv_coord_t max_w = lv_obj_get_width(btnm) - 2 * style_bg->body.padding.hor; + lv_coord_t max_h = lv_obj_get_height(btnm) - 2 * style_bg->body.padding.ver; + lv_coord_t act_y = style_bg->body.padding.ver; /*Count the lines to calculate button height*/ uint8_t line_cnt = 1; @@ -162,7 +162,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) if(strcmp(map[li], "\n") == 0) line_cnt ++; } - lv_coord_t btn_h = max_h - ((line_cnt - 1) * btnms->body.padding.inner); + lv_coord_t btn_h = max_h - ((line_cnt - 1) * style_bg->body.padding.inner); btn_h = btn_h / line_cnt; btn_h --; /*-1 because e.g. height = 100 means 101 pixels (0..100)*/ @@ -189,11 +189,11 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) /*Only deal with the non empty lines*/ if(btn_cnt != 0) { /*Calculate the width of all units*/ - lv_coord_t all_unit_w = max_w - ((btn_cnt-1) * btnms->body.padding.inner); + lv_coord_t all_unit_w = max_w - ((btn_cnt-1) * style_bg->body.padding.inner); /*Set the button size and positions and set the texts*/ uint16_t i; - lv_coord_t act_x = btnms->body.padding.hor; + lv_coord_t act_x = style_bg->body.padding.hor; lv_coord_t act_unit_w; unit_act_cnt = 0; for(i = 0; i < btn_cnt; i++) { @@ -204,12 +204,17 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) act_unit_w --; /*-1 because e.g. width = 100 means 101 pixels (0..100)*/ /*Always recalculate act_x because of rounding errors */ - act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * btnms->body.padding.inner + btnms->body.padding.hor; + act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * style_bg->body.padding.inner + style_bg->body.padding.hor; - lv_area_set(&ext->button_areas[btn_i], act_x, - act_y, - act_x + act_unit_w, - act_y + btn_h); + /* Set the button's area. + * If inner padding is zero then use the prev. button x2 as x1 to avoid rounding errors*/ + if(style_bg->body.padding.inner == 0 && act_x != style_bg->body.padding.hor) { + lv_area_set(&ext->button_areas[btn_i], ext->button_areas[btn_i - 1].x2, act_y, + act_x + act_unit_w, act_y + btn_h); + } else { + lv_area_set(&ext->button_areas[btn_i], act_x, act_y, + act_x + act_unit_w, act_y + btn_h); + } unit_act_cnt += get_button_width(map_p_tmp[i]); @@ -217,7 +222,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) btn_i ++; } } - act_y += btn_h + btnms->body.padding.inner; + act_y += btn_h + style_bg->body.padding.inner; if(strlen(map_p_tmp[btn_cnt]) == 0) break; /*Break on end of map*/ map_p_tmp = &map_p_tmp[btn_cnt + 1]; /*Set the map to the next line*/ i_tot ++; /*Skip the '\n'*/ diff --git a/lv_objx/lv_cb.c b/lv_objx/lv_cb.c index ea93972ff..285545a8e 100644 --- a/lv_objx/lv_cb.c +++ b/lv_objx/lv_cb.c @@ -292,10 +292,10 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param) if(res != LV_RES_OK) return res; lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb); - lv_style_t * style = lv_obj_get_style(cb); if(sign == LV_SIGNAL_STYLE_CHG) { - lv_obj_set_size(ext->bullet, lv_font_get_height_scale(style->text.font), lv_font_get_height_scale(style->text.font)); + lv_style_t * label_style = lv_label_get_style(ext->label); + lv_obj_set_size(ext->bullet, lv_font_get_height_scale(label_style->text.font), lv_font_get_height_scale(label_style->text.font)); lv_btn_set_state(ext->bullet, lv_btn_get_state(cb)); } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || diff --git a/lv_objx/lv_cb.h b/lv_objx/lv_cb.h index e85ff2636..f93357229 100644 --- a/lv_objx/lv_cb.h +++ b/lv_objx/lv_cb.h @@ -103,7 +103,7 @@ static inline void lv_cb_set_inactive(lv_obj_t * cb) */ static inline void lv_cb_set_action(lv_obj_t * cb, lv_action_t action) { - lv_btn_set_action(cb, LV_BTN_ACTION_REL, action); + lv_btn_set_action(cb, LV_BTN_ACTION_CLICK, action); } @@ -143,7 +143,7 @@ static inline bool lv_cb_is_checked(lv_obj_t * cb) */ static inline lv_action_t lv_cb_get_action(lv_obj_t * cb) { - return lv_btn_get_action(cb, LV_BTN_ACTION_REL); + return lv_btn_get_action(cb, LV_BTN_ACTION_CLICK); } diff --git a/lv_objx/lv_gauge.c b/lv_objx/lv_gauge.c index 5e43ceedc..6dd022949 100644 --- a/lv_objx/lv_gauge.c +++ b/lv_objx/lv_gauge.c @@ -86,6 +86,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy) if(copy == NULL) { lv_gauge_set_scale(new_gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT, LV_GAUGE_DEF_LABEL_COUNT); lv_gauge_set_needle_count(new_gauge, 1, NULL); + lv_gauge_set_critical_value(new_gauge, 80); lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI); /*Set the default styles*/ @@ -168,6 +169,7 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value) lv_obj_invalidate(gauge); } + /** * Set the scale settings of a gauge * @param gauge pointer to a gauge object @@ -260,8 +262,6 @@ static bool lv_gauge_design(lv_obj_t * gauge, const lv_area_t * mask, lv_design_ /*Draw the ancestor line meter with max value to show the rainbow like line colors*/ uint16_t line_cnt_tmp = ext->lmeter.line_cnt; - int16_t value_tmp = ext->lmeter.cur_value; - ext->lmeter.cur_value = ext->lmeter.max_value; ancestor_design(gauge, mask, mode); /*To draw lines*/ /*Temporally modify the line meter to draw thicker and longer lines where labels are*/ @@ -269,13 +269,12 @@ static bool lv_gauge_design(lv_obj_t * gauge, const lv_area_t * mask, lv_design_ lv_style_copy(&style_tmp, style); ext->lmeter.line_cnt = ext->label_count; /*Only to labels*/ style_tmp.line.width = style_tmp.line.width * 2; /*Ticker lines*/ - style_tmp.body.padding.hor = style_tmp.body.padding.hor * 2; /*Longer lines*/ + style_tmp.body.padding.hor = style_tmp.body.padding.hor * 2; /*Longer lines*/ gauge->style_p = &style_tmp; ancestor_design(gauge, mask, mode); /*To draw lines*/ ext->lmeter.line_cnt = line_cnt_tmp; /*Restore the parameters*/ - ext->lmeter.cur_value = value_tmp; gauge->style_p = style_ori_p; /*Restore the ORIGINAL style pointer*/ lv_gauge_draw_needle(gauge, mask); diff --git a/lv_objx/lv_gauge.h b/lv_objx/lv_gauge.h index fe111d9c1..51dbfde44 100644 --- a/lv_objx/lv_gauge.h +++ b/lv_objx/lv_gauge.h @@ -88,6 +88,16 @@ static inline void lv_gauge_set_range(lv_obj_t *gauge, int16_t min, int16_t max) lv_lmeter_set_range(gauge, min, max); } +/** + * Set a critical value on the scale. After this value 'line.color' scale lines will be drawn + * @param gauge pointer to a gauge object + * @param value the critical value + */ +static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int16_t value) +{ + lv_lmeter_set_value(gauge, value); +} + /** * Set the scale settings of a gauge * @param gauge pointer to a gauge object @@ -146,6 +156,16 @@ static inline int16_t lv_gauge_get_max_value(lv_obj_t * lmeter) return lv_lmeter_get_max_value(lmeter); } +/** + * Get a critical value on the scale. + * @param gauge pointer to a gauge object + * @return the critical value + */ +static inline int16_t lv_gauge_get_critical_value(lv_obj_t * gauge) +{ + return lv_lmeter_get_value(gauge); +} + /** * Set the number of labels (and the thicker lines too) * @param gauge pointer to a gauge object diff --git a/lv_objx/lv_kb.c b/lv_objx/lv_kb.c index 5d3f02166..5b116fa22 100644 --- a/lv_objx/lv_kb.c +++ b/lv_objx/lv_kb.c @@ -90,7 +90,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy) ext->ta = NULL; ext->mode = LV_KB_MODE_TEXT; ext->cursor_mng = 0; - ext->close_action = NULL; + ext->hide_action = NULL; ext->ok_action = NULL; /*The signal and design functions are not copied so set them here*/ @@ -122,7 +122,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy) ext->ta = copy_ext->ta; ext->mode = copy_ext->mode; ext->cursor_mng = copy_ext->cursor_mng; - ext->close_action = copy_ext->close_action; + ext->hide_action = copy_ext->hide_action; ext->ok_action = copy_ext->ok_action; /*Refresh the style with new signal function*/ @@ -153,7 +153,7 @@ void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta) ext->ta = ta; - if(ext->cursor_mng) { + if(ext->ta && ext->cursor_mng) { cur_type = lv_ta_get_cursor_type(ext->ta); lv_ta_set_cursor_type(ext->ta, cur_type & (~LV_CURSOR_HIDDEN)); } @@ -206,10 +206,10 @@ void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action) * @param kb pointer to Keyboard object * @param action a callback with 'lv_action_t' type */ -void lv_kb_set_close_action(lv_obj_t * kb, lv_action_t action) +void lv_kb_set_hide_action(lv_obj_t * kb, lv_action_t action) { lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb); - ext->close_action = action; + ext->hide_action = action; } /** @@ -296,10 +296,10 @@ lv_action_t lv_kb_get_ok_action(lv_obj_t * kb) * @param kb pointer to Keyboard object * @return the close callback */ -lv_action_t lv_kb_get_close_action(lv_obj_t * kb) +lv_action_t lv_kb_get_hide_action(lv_obj_t * kb) { lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb); - return ext->close_action; + return ext->hide_action; } /** @@ -374,10 +374,12 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt) return LV_RES_OK; } else if(strcmp(txt, SYMBOL_CLOSE) == 0) { - if(ext->close_action) ext->close_action(kb); + lv_kb_set_ta(kb, NULL); /*De-assign the text area*/ + if(ext->hide_action) ext->hide_action(kb); else lv_obj_del(kb); return LV_RES_INV; } else if(strcmp(txt, SYMBOL_OK) == 0) { + lv_kb_set_ta(kb, NULL); /*De-assign the text area*/ if(ext->ok_action) ext->ok_action(kb); else lv_obj_del(kb); return LV_RES_INV; diff --git a/lv_objx/lv_kb.h b/lv_objx/lv_kb.h index 4ec4a2351..dcf0a8917 100644 --- a/lv_objx/lv_kb.h +++ b/lv_objx/lv_kb.h @@ -41,7 +41,7 @@ typedef struct { lv_kb_mode_t mode; /*Key map type*/ uint8_t cursor_mng :1; /*1: automatically show/hide cursor when a text area is assigned or left*/ lv_action_t ok_action; /*Called when the "Ok" button is clicked*/ - lv_action_t close_action; /*Called when the "Hide" button is clicked*/ + lv_action_t hide_action; /*Called when the "Hide" button is clicked*/ }lv_kb_ext_t; typedef enum { @@ -102,7 +102,18 @@ void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action); * @param kb pointer to Keyboard object * @param action a callback with 'lv_action_t' type */ -void lv_kb_set_close_action(lv_obj_t * kb, lv_action_t action); +void lv_kb_set_hide_action(lv_obj_t * kb, lv_action_t action); + +/** + * Set a new map for the keyboard + * @param kb pointer to a Keyboard object + * @param map pointer to a string array to describe the map. + * See 'lv_btnm_set_map()' for more info. + */ +static inline void lv_kb_set_map(lv_obj_t *kb, const char ** map) +{ + lv_btnm_set_map(kb, map); +} /** * Set a style of a keyboard @@ -149,7 +160,7 @@ lv_action_t lv_kb_get_ok_action(lv_obj_t * kb); * @param kb pointer to Keyboard object * @return the close callback */ -lv_action_t lv_kb_get_close_action(lv_obj_t * kb); +lv_action_t lv_kb_get_hide_action(lv_obj_t * kb); /** * Get a style of a keyboard diff --git a/lv_objx/lv_led.c b/lv_objx/lv_led.c index 6d94a54dc..fd592f632 100644 --- a/lv_objx/lv_led.c +++ b/lv_objx/lv_led.c @@ -133,7 +133,7 @@ void lv_led_off(lv_obj_t * led) * Toggle the state of a LED * @param led pointer to a LED object */ -void lv_led_tgl(lv_obj_t * led) +void lv_led_toggle(lv_obj_t * led) { uint8_t bright = lv_led_get_bright(led); if(bright > (LV_LED_BRIGHT_OFF + LV_LED_BRIGHT_ON) >> 1) lv_led_off(led); diff --git a/lv_objx/lv_led.h b/lv_objx/lv_led.h index 641b6c8b4..218dec3a4 100644 --- a/lv_objx/lv_led.h +++ b/lv_objx/lv_led.h @@ -69,14 +69,7 @@ void lv_led_off(lv_obj_t * led); * Toggle the state of a LED * @param led pointer to a LED object */ -void lv_led_tgl(lv_obj_t * led); - -/** - * Get the brightness of a LEd object - * @param led pointer to LED object - * @return bright 0 (max. dark) ... 255 (max. light) - */ -uint8_t lv_led_get_bright(lv_obj_t * led); +void lv_led_toggle(lv_obj_t * led); /** * Set the style of a led @@ -88,6 +81,12 @@ static inline void lv_led_set_style(lv_obj_t *led, lv_style_t *style) lv_obj_set_style(led, style); } +/** + * Get the brightness of a LEd object + * @param led pointer to LED object + * @return bright 0 (max. dark) ... 255 (max. light) + */ +uint8_t lv_led_get_bright(lv_obj_t * led); /** * Get the style of an led object diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index 0de02664c..4b331e404 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -155,7 +155,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l lv_btn_set_style(liste, LV_BTN_STYLE_TGL_PR, ext->styles_btn[LV_BTN_STATE_TGL_PR]); lv_btn_set_style(liste, LV_BTN_STYLE_INA, ext->styles_btn[LV_BTN_STATE_INA]); - lv_btn_set_action(liste, LV_BTN_ACTION_REL, rel_action); + lv_btn_set_action(liste, LV_BTN_ACTION_CLICK, rel_action); lv_page_glue_obj(liste, true); lv_btn_set_layout(liste, LV_LAYOUT_ROW_M); lv_btn_set_fit(liste, false, true); @@ -565,7 +565,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) if(btn != NULL) { lv_action_t rel_action; - rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_REL); + rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_CLICK); if(rel_action != NULL) rel_action(btn); } } diff --git a/lv_objx/lv_lmeter.c b/lv_objx/lv_lmeter.c index 10a726f05..c2299175d 100644 --- a/lv_objx/lv_lmeter.c +++ b/lv_objx/lv_lmeter.c @@ -277,7 +277,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig p1.x = x_out+ x_ofs; p1.y = y_out + y_ofs; - if(i > level) style_tmp.line.color = style->line.color; + if(i >= level) style_tmp.line.color = style->line.color; else { style_tmp.line.color = lv_color_mix(style->body.grad_color, style->body.main_color, (255 * i) / ext->line_cnt); } diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index c1c3e436c..564cb6352 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -74,7 +74,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy) lv_page_set_rel_action(new_roller, NULL); /*Roller don't uses it (like ddlist)*/ lv_page_set_scrl_fit(new_roller, true, false); /*Height is specified directly*/ lv_ddlist_open(new_roller, false); - lv_roller_set_row_count(new_roller, 3); + lv_roller_set_visible_row_count(new_roller, 3); lv_label_set_align(ext->ddlist.label, LV_LABEL_ALIGN_CENTER); lv_obj_set_signal_func(scrl, lv_roller_scrl_signal); @@ -122,11 +122,11 @@ void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en) * @param roller pointer to a roller object * @param row_cnt number of desired visible rows */ -void lv_roller_set_row_count(lv_obj_t *roller, uint8_t row_cnt) +void lv_roller_set_visible_row_count(lv_obj_t *roller, uint8_t row_cnt) { lv_roller_ext_t *ext = lv_obj_get_ext_attr(roller); lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label); - lv_ddlist_set_fix_height(roller, lv_font_get_height_scale(style_label->text.font) * row_cnt + style_label->text.line_space * (row_cnt + 1)); + lv_ddlist_set_fix_height(roller, lv_font_get_height_scale(style_label->text.font) * row_cnt + style_label->text.line_space * (row_cnt)); } /** diff --git a/lv_objx/lv_roller.h b/lv_objx/lv_roller.h index dd09a07ed..a843d1e42 100644 --- a/lv_objx/lv_roller.h +++ b/lv_objx/lv_roller.h @@ -76,7 +76,7 @@ void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en); * @param roller pointer to a roller object * @param row_cnt number of desired visible rows */ -void lv_roller_set_row_count(lv_obj_t *roller, uint8_t row_cnt); +void lv_roller_set_visible_row_count(lv_obj_t *roller, uint8_t row_cnt); /** * Enable or disable the horizontal fit to the content diff --git a/lv_objx/lv_sw.c b/lv_objx/lv_sw.c index 8e0617440..88ca97259 100644 --- a/lv_objx/lv_sw.c +++ b/lv_objx/lv_sw.c @@ -105,7 +105,7 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy) * Turn ON the switch * @param sw pointer to a switch object */ -void lv_sw_set_on(lv_obj_t *sw) +void lv_sw_on(lv_obj_t *sw) { lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw); lv_slider_set_value(sw, 1); @@ -116,7 +116,7 @@ void lv_sw_set_on(lv_obj_t *sw) * Turn OFF the switch * @param sw pointer to a switch object */ -void lv_sw_set_off(lv_obj_t *sw) +void lv_sw_off(lv_obj_t *sw) { lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw); lv_slider_set_value(sw, 0); diff --git a/lv_objx/lv_sw.h b/lv_objx/lv_sw.h index 9c96aa3de..255ce0b55 100644 --- a/lv_objx/lv_sw.h +++ b/lv_objx/lv_sw.h @@ -68,13 +68,13 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy); * Turn ON the switch * @param sw pointer to a switch object */ -void lv_sw_set_on(lv_obj_t *sw); +void lv_sw_on(lv_obj_t *sw); /** * Turn OFF the switch * @param sw pointer to a switch object */ -void lv_sw_set_off(lv_obj_t *sw); +void lv_sw_off(lv_obj_t *sw); /** * Set a function which will be called when the switch is toggled by the user diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index 3d19d183a..6727f6a2e 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -324,10 +324,10 @@ void lv_tabview_set_sliding(lv_obj_t * tabview, bool en) * @param tabview pointer to Tab view object * @param anim_time_ms time of animation in milliseconds */ -void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time_ms) +void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time) { lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview); - ext->anim_time = anim_time_ms; + ext->anim_time = anim_time; } /** @@ -361,9 +361,6 @@ void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t case LV_TABVIEW_STYLE_BTN_TGL_PR: lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_PR, style); break; - case LV_TABVIEW_STYLE_BTN_INA: - lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_INA, style); - break; case LV_TABVIEW_STYLE_INDIC: lv_obj_set_style(ext->indic, style); lv_obj_set_height(ext->indic, style->body.padding.inner); @@ -470,7 +467,6 @@ lv_style_t * lv_tabview_get_style(lv_obj_t *tabview, lv_tabview_style_t type) case LV_TABVIEW_STYLE_BTN_PR: return lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_PR); case LV_TABVIEW_STYLE_BTN_TGL_REL: return lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_REL); case LV_TABVIEW_STYLE_BTN_TGL_PR: return lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_PR); - case LV_TABVIEW_STYLE_BTN_INA: return lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_INA); default: return NULL; } diff --git a/lv_objx/lv_tabview.h b/lv_objx/lv_tabview.h index 123f15dd4..f76a56acc 100644 --- a/lv_objx/lv_tabview.h +++ b/lv_objx/lv_tabview.h @@ -68,7 +68,6 @@ typedef enum { LV_TABVIEW_STYLE_BTN_PR, LV_TABVIEW_STYLE_BTN_TGL_REL, LV_TABVIEW_STYLE_BTN_TGL_PR, - LV_TABVIEW_STYLE_BTN_INA, }lv_tabview_style_t; /********************** @@ -126,9 +125,9 @@ void lv_tabview_set_sliding(lv_obj_t * tabview, bool en); /** * Set the animation time of tab view when a new tab is loaded * @param tabview pointer to Tab view object - * @param anim_time_ms time of animation in milliseconds + * @param anim_time time of animation in milliseconds */ -void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time_ms); +void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time); /** * Set the style of a tab view diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index e7e2d4ad4..a0fb9c873 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -157,7 +157,7 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const char * img_path, lv_action_t rel lv_btn_set_style(btn, LV_BTN_STYLE_REL, ext->style_btn_rel); lv_btn_set_style(btn, LV_BTN_STYLE_PR, ext->style_btn_pr); lv_obj_set_size(btn, ext->btn_size, ext->btn_size); - lv_btn_set_action(btn, LV_BTN_ACTION_REL, rel_action); + lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, rel_action); lv_obj_t * img = lv_img_create(btn, NULL); lv_obj_set_click(img, false); diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index a2548da2a..b8b9957ed 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -365,13 +365,13 @@ static void gauge_init(void) static lv_style_t gauge_bg; lv_style_copy(&gauge_bg, &def); gauge_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 70); - gauge_bg.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 80); + gauge_bg.body.grad_color = gauge_bg.body.main_color; gauge_bg.body.padding.hor = LV_DPI / 12; /*Scale line length*/ gauge_bg.body.padding.ver = LV_DPI / 10; /*Needle center size*/ gauge_bg.body.padding.inner = LV_DPI / 8; /*Label - scale distance*/ gauge_bg.body.border.color = LV_COLOR_HEX3(0x777); - gauge_bg.line.color = LV_COLOR_HEX3(0x555); - gauge_bg.line.width = 2; + gauge_bg.line.color = lv_color_hsv_to_rgb(_hue, 80, 75); + gauge_bg.line.width = 3; gauge_bg.text.color = lv_color_hsv_to_rgb(_hue, 10, 90); gauge_bg.text.font = _font; diff --git a/lv_themes/lv_theme_default.c b/lv_themes/lv_theme_default.c index 4651ecdd7..c0e00c82e 100644 --- a/lv_themes/lv_theme_default.c +++ b/lv_themes/lv_theme_default.c @@ -178,8 +178,8 @@ static void lmeter_init(void) lv_style_copy(&lmeter, &lv_style_pretty_color); lmeter.line.color = LV_COLOR_HEX3(0xddd); lmeter.line.width = 2; - lmeter.body.main_color = color_mix(lmeter.body.main_color , LV_COLOR_WHITE, LV_OPA_50); - lmeter.body.grad_color = color_mix(lmeter.body.grad_color , LV_COLOR_BLACK, LV_OPA_50); + lmeter.body.main_color = lv_color_mix(lmeter.body.main_color, LV_COLOR_WHITE, LV_OPA_50); + lmeter.body.grad_color = lv_color_mix(lmeter.body.grad_color, LV_COLOR_BLACK, LV_OPA_50); theme.lmeter = &lmeter; #endif @@ -188,9 +188,15 @@ static void lmeter_init(void) static void gauge_init(void) { #if USE_LV_GAUGE != 0 + static lv_style_t gauge; + lv_style_copy(&gauge, &lmeter); + gauge.line.color = lmeter.body.grad_color; + gauge.line.width = 3; + gauge.body.main_color = LV_COLOR_HEX3(0x888); + gauge.body.grad_color = lmeter.body.main_color; + gauge.text.color = LV_COLOR_HEX3(0x888); - - theme.gauge = &lmeter; + theme.gauge = &gauge; #endif } @@ -286,9 +292,8 @@ static void list_init(void) { #if USE_LV_LIST != 0 - theme.list.bg = &lv_style_pretty; - theme.list.scrl = &lv_style_transp; + theme.list.scrl = &lv_style_transp_fit; theme.list.sb = &sb; theme.list.btn.rel = &lv_style_btn_rel; theme.list.btn.pr = &lv_style_btn_pr; diff --git a/lv_themes/lv_theme_material.c b/lv_themes/lv_theme_material.c index 5ccfe0fa1..65f860c76 100644 --- a/lv_themes/lv_theme_material.c +++ b/lv_themes/lv_theme_material.c @@ -61,9 +61,10 @@ static void basic_init(void) panel.body.main_color = LV_COLOR_WHITE; panel.body.grad_color = LV_COLOR_WHITE; panel.body.border.width = 1; - panel.body.border.color = LV_COLOR_HEX3(0x999); + panel.body.border.color = LV_COLOR_HEX3(0xbbb); panel.body.border.opa = LV_OPA_COVER; panel.body.shadow.color = DEF_SHADOW_COLOR; + panel.body.shadow.type = LV_SHADOW_BOTTOM; panel.body.shadow.width = 4; panel.body.padding.hor = LV_DPI / 8; panel.body.padding.ver = LV_DPI / 8; @@ -95,7 +96,7 @@ static void btn_init(void) static lv_style_t rel, pr, tgl_rel, tgl_pr, ina; lv_style_copy(&rel, &def); - rel.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 75); + rel.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70); rel.body.grad_color = rel.body.main_color; rel.body.radius = DEF_RADIUS; rel.body.padding.hor = LV_DPI / 6; @@ -108,17 +109,17 @@ static void btn_init(void) lv_style_copy(&pr, &rel); - pr.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 65); + pr.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 60); pr.body.grad_color = pr.body.main_color; pr.body.shadow.width = 4; lv_style_copy(&tgl_rel, &rel); - tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 55); + tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 50); tgl_rel.body.grad_color = tgl_rel.body.main_color; tgl_rel.body.shadow.width = 4; lv_style_copy(&tgl_pr, &tgl_rel); - tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 45); + tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 40); tgl_pr.body.grad_color = tgl_pr.body.main_color; tgl_pr.body.shadow.width = 2; @@ -218,7 +219,7 @@ static void bar_init(void) bar_bg.body.padding.ver = LV_DPI / 12; lv_style_copy(&bar_indic, &bar_bg); - bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 85, 75); + bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 85, 70); bar_indic.body.grad_color = bar_indic.body.main_color; bar_indic.body.padding.hor = 0; bar_indic.body.padding.ver = 0; @@ -297,13 +298,14 @@ static void gauge_init(void) static lv_style_t gauge; lv_style_copy(&gauge, &def); - gauge.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 90); - gauge.body.grad_color = lv_color_hsv_to_rgb(_hue, 95, 80); + gauge.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 60); + gauge.body.grad_color = gauge.body.main_color; gauge.body.padding.hor = LV_DPI / 16; /*Scale line length*/ gauge.body.padding.inner = LV_DPI / 8; gauge.body.border.color = LV_COLOR_HEX3(0x999); gauge.text.color = LV_COLOR_HEX3(0x333); gauge.line.width = 3; + gauge.line.color = lv_color_hsv_to_rgb(_hue, 95, 70); theme.gauge = &gauge; #endif @@ -380,7 +382,7 @@ static void btnm_init(void) pr.body.empty = 0; lv_style_copy(&tgl_rel, &pr); - tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 75); + tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70); tgl_rel.body.grad_color = tgl_rel.body.main_color; tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 5, 95); @@ -425,13 +427,14 @@ static void mbox_init(void) { #if USE_LV_MBOX static lv_style_t pr, rel; + lv_style_copy(&rel, &lv_style_transp); rel.glass = 0; rel.text.font = _font; - rel.text.color = lv_color_hsv_to_rgb(_hue, 85, 85); + rel.text.color = lv_color_hsv_to_rgb(_hue, 85, 75); lv_style_copy(&pr, theme.btnm.btn.pr); - pr.text.color = lv_color_hsv_to_rgb(_hue, 85, 65); + pr.text.color = lv_color_hsv_to_rgb(_hue, 85, 60); theme.mbox.bg = theme.panel; theme.mbox.btn.bg = &lv_style_transp; @@ -501,13 +504,13 @@ static void list_init(void) pr.text.font = _font; lv_style_copy(&tgl_rel, &pr); - tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 75); + tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70); tgl_rel.body.grad_color = tgl_rel.body.main_color; tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 5, 95); lv_style_copy(&tgl_pr, &tgl_rel); - tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 65); + tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 60); tgl_pr.body.grad_color = tgl_pr.body.main_color; tgl_pr.body.border.width = 0; @@ -538,7 +541,7 @@ static void ddlist_init(void) lv_style_copy(&sel, &bg); - sel.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 75); + sel.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70); sel.body.grad_color = sel.body.main_color; sel.body.border.width = 0; sel.body.shadow.width = 0; @@ -564,7 +567,7 @@ static void roller_init(void) roller_bg.glass = 0; lv_style_copy(&roller_sel, &roller_bg); - roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 95, 75); + roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 90, 70); theme.roller.bg = &roller_bg; @@ -578,7 +581,7 @@ static void tabview_init(void) static lv_style_t indic, btn_bg, rel, pr, tgl_rel, tgl_pr; lv_style_copy(&indic, &def); - indic.body.main_color = lv_color_hsv_to_rgb(_hue, 95, 75); + indic.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70); indic.body.grad_color = indic.body.main_color; indic.body.radius = 0; indic.body.border.width = 0; @@ -620,7 +623,7 @@ static void tabview_init(void) lv_style_copy(&tgl_rel, &lv_style_transp); tgl_rel.glass = 0; tgl_rel.text.font = _font; - tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 95, 95); + tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 90, 70); lv_style_copy(&tgl_pr, &def); tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 15, 85); @@ -628,7 +631,7 @@ static void tabview_init(void) tgl_pr.body.border.width = 0; tgl_pr.body.empty = 0; tgl_pr.body.radius = 0; - tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 95, 95); + tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 90, 60); theme.tabview.bg = theme.bg; theme.tabview.indic = &indic; diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index 05602bdcb..1838942e9 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -229,9 +229,13 @@ static void lmeter_init(void) static void gauge_init(void) { #if USE_LV_GAUGE != 0 + static lv_style_t gauge_bg; + lv_style_copy(&gauge_bg, theme.lmeter); + gauge_bg.line.color = LV_COLOR_BLACK; + gauge_bg.line.width = 3; - theme.gauge = theme.lmeter; + theme.gauge = &gauge_bg; #endif } diff --git a/lv_themes/lv_theme_night.c b/lv_themes/lv_theme_night.c index 9a0830208..1d374fb02 100644 --- a/lv_themes/lv_theme_night.c +++ b/lv_themes/lv_theme_night.c @@ -266,9 +266,15 @@ static void lmeter_init(void) static void gauge_init(void) { #if USE_LV_GAUGE != 0 + static lv_style_t gauge_bg; + lv_style_copy(&gauge_bg, &def); + gauge_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 70); + gauge_bg.body.grad_color = gauge_bg.body.main_color; + gauge_bg.line.color = lv_color_hsv_to_rgb(_hue, 80, 75); + gauge_bg.line.width = 3; + gauge_bg.text.color = LV_COLOR_HEX3(0xddd); - - theme.gauge = &lmeter_bg; + theme.gauge = &gauge_bg; #endif } @@ -335,7 +341,7 @@ static void btnm_init(void) btnm_bg.body.padding.hor = 2; btnm_bg.body.padding.ver = 2; btnm_bg.body.padding.inner = 0; - btnm_bg.body.border.width = 1<< LV_AA;//LV_BORDER_RIGHT; + btnm_bg.body.border.width = 1; lv_style_copy(&rel, &btn_rel); rel.body.border.part = LV_BORDER_RIGHT; diff --git a/lv_themes/lv_theme_templ.c b/lv_themes/lv_theme_templ.c index ba75f6bde..0c3be09c6 100644 --- a/lv_themes/lv_theme_templ.c +++ b/lv_themes/lv_theme_templ.c @@ -45,6 +45,7 @@ static lv_font_t * _font; static void basic_init(void) { lv_style_copy(&def, &lv_style_pretty); /*Initialize the default style*/ + def.text.font = _font; theme.bg = &def; theme.panel = &def;