BigW Consortium Gitlab

Commit c3e248ec by Gabor Kiss-Vamosi

ddlist and roller group updates + updates with USE_LV_ANIMATION = 0

parent d20fe1f4
......@@ -119,7 +119,7 @@ int32_t lv_anim_path_step(const lv_anim_t *a);
* MACROS
**********************/
#endif /*LV_NO_ANIM == 0*/
#endif /*USE_LV_ANIMATION == 0*/
#ifdef __cplusplus
} /* extern "C" */
......
......@@ -124,7 +124,6 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value)
*/
void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time)
{
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
int16_t new_value;
new_value = value > ext->max_value ? ext->max_value : value;
......
......@@ -585,7 +585,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
if(ext->btn_id_pr > 0) ext->btn_id_pr--;
lv_obj_invalidate(btnm);
} else if(c == LV_GROUP_KEY_ENTER) {
} else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
if(ext->action != NULL) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE) {
......
......@@ -305,7 +305,7 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN ||
c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP ||
c == LV_GROUP_KEY_ENTER) {
c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
}
}
......
......@@ -41,7 +41,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param);
static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist);
static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time);
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en);
static void lv_ddlist_pos_current_option(lv_obj_t * ddlist);
/**********************
......@@ -50,6 +50,7 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist);
static lv_signal_func_t ancestor_signal;
static lv_signal_func_t ancestor_scrl_signal;
static lv_design_func_t ancestor_design;
/**********************
* MACROS
**********************/
......@@ -83,6 +84,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
ext->opened = 0;
ext->fix_height = 0;
ext->sel_opt_id = 0;
ext->sel_opt_id_ori = 0;
ext->option_cnt = 0;
ext->anim_time = LV_DDLIST_ANIM_TIME;
ext->sel_style = &lv_style_plain_color;
......@@ -159,7 +161,7 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
ext->option_cnt++; /*Last option in the at row*/
lv_label_set_text(ext->label, options);
lv_ddlist_refr_size(ddlist, 0);
lv_ddlist_refr_size(ddlist, false);
}
/**
......@@ -203,7 +205,7 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h)
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->fix_height = h;
lv_ddlist_refr_size(ddlist, 0);
lv_ddlist_refr_size(ddlist, false);
}
/**
......@@ -217,7 +219,7 @@ void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool fit_en)
lv_page_set_scrl_fit(ddlist, fit_en, lv_page_get_scrl_fit_ver(ddlist));
lv_ddlist_refr_size(ddlist, 0);
lv_ddlist_refr_size(ddlist, false);
}
/**
......@@ -228,6 +230,10 @@ void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool fit_en)
void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
#if USE_LV_ANIMATION == 0
anim_time = 0;
#endif
ext->anim_time = anim_time;
}
......@@ -369,27 +375,33 @@ lv_style_t * lv_ddlist_get_style(lv_obj_t *ddlist, lv_ddlist_style_t type)
/**
* Open the drop down list with or without animation
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
* @param anim_en true: use animation; false: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, bool anim)
void lv_ddlist_open(lv_obj_t * ddlist, bool anim_en)
{
#if USE_LV_ANIMATION == 0
anim_en = false;
#endif
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->opened = 1;
lv_obj_set_drag(lv_page_get_scrl(ddlist), true);
lv_ddlist_refr_size(ddlist, anim ? ext->anim_time : 0);
lv_ddlist_refr_size(ddlist, anim_en);
}
/**
* Close (Collapse) the drop down list
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
* @param anim_en true: use animation; false: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, bool anim)
void lv_ddlist_close(lv_obj_t * ddlist, bool anim_en)
{
#if USE_LV_ANIMATION == 0
anim_en = false;
#endif
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->opened = 0;
lv_obj_set_drag(lv_page_get_scrl(ddlist), false);
lv_ddlist_refr_size(ddlist, anim ? ext->anim_time : 0);
lv_ddlist_refr_size(ddlist, anim_en);
}
/**********************
......@@ -502,11 +514,13 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
if(ext->opened == false) {
ext->opened = true;
lv_ddlist_refr_size(ddlist, true);
ext->sel_opt_id_ori = ext->sel_opt_id;
}
}
else if(sign == LV_SIGNAL_DEFOCUS) {
if(ext->opened != false) {
ext->opened = false;
ext->sel_opt_id = ext->sel_opt_id_ori;
lv_ddlist_refr_size(ddlist, true);
}
}
......@@ -517,25 +531,31 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
ext->sel_opt_id ++;
lv_ddlist_pos_current_option(ddlist);
lv_obj_invalidate(ddlist);
if(ext->action != NULL) {
ext->action(ddlist);
}
}
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
if(ext->sel_opt_id > 0) {
ext->sel_opt_id --;
lv_ddlist_pos_current_option(ddlist);
lv_obj_invalidate(ddlist);
if(ext->action != NULL) {
ext->action(ddlist);
}
}
} else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ESC) {
if(ext->opened != false) ext->opened = false;
else ext->opened = true;
} else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
if(ext->opened) {
ext->sel_opt_id_ori = ext->sel_opt_id;
ext->opened = 0;
if(ext->action) ext->action(ddlist);
}
else {
ext->opened = true;
}
lv_ddlist_refr_size(ddlist, true);
}
else if(c == LV_GROUP_KEY_ESC) {
if(ext->opened) {
ext->opened = 0;
lv_ddlist_refr_size(ddlist, true);
}
}
}
else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
......@@ -618,7 +638,7 @@ static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist)
ext->action(ddlist);
}
}
lv_ddlist_refr_size(ddlist, ext->anim_time);
lv_ddlist_refr_size(ddlist, true);
return LV_RES_OK;
......@@ -627,10 +647,13 @@ static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist)
/**
* Refresh the size of drop down list according to its status (open or closed)
* @param ddlist pointer to a drop down list object
* @param anim_time animations time for open/close [ms]
* @param anim_en Change the size (open/close) with or without animation (true/false)
*/
static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time)
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
{
#if USE_LV_ANIMATION == 0
anim_en = false;
#endif
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_style_t * style = lv_obj_get_style(ddlist);
lv_coord_t new_height;
......@@ -643,7 +666,8 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time)
lv_coord_t font_h = lv_font_get_height(font);
new_height = font_h + 2 * label_style->text.line_space;
}
if(anim_time == 0) {
if(anim_en == 0) {
lv_obj_set_height(ddlist, new_height);
lv_ddlist_pos_current_option(ddlist);
} else {
......
......@@ -46,6 +46,7 @@ typedef struct
lv_action_t action; /*Pointer to function to call when an option is selected*/
uint16_t option_cnt; /*Number of options*/
uint16_t sel_opt_id; /*Index of the current option*/
uint16_t sel_opt_id_ori; /*Store the original index on focus*/
uint16_t anim_time; /*Open/Close animation time [ms]*/
uint8_t opened :1; /*1: The list is opened*/
lv_coord_t fix_height; /*Height if the ddlist is opened. (0: auto-size)*/
......@@ -205,15 +206,16 @@ lv_style_t * lv_ddlist_get_style(lv_obj_t *ddlist, lv_ddlist_style_t type);
/**
* Open the drop down list with or without animation
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
* @param anim_en true: use animation; false: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, bool anim);
/**
* Close (Collapse) the drop down list
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, bool anim);
void lv_ddlist_close_en(lv_obj_t * ddlist, bool anim);
/**********************
* MACROS
......
......@@ -324,7 +324,7 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
/**
* Signal function of the image
* @param img pointer to animage object
* @param img pointer to an image object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
......
......@@ -208,6 +208,9 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
#if USE_LV_ANIMATION == 0
anim_time = 0;
#endif
ext->anim_time = anim_time;
}
......@@ -461,6 +464,11 @@ void lv_list_down(lv_obj_t * list)
*/
void lv_list_focus(lv_obj_t *btn, bool anim_en)
{
#if USE_LV_ANIMATION == 0
anim_en = false;
#endif
lv_obj_t *list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_page_focus(list, btn, anim_en == false ? 0 :lv_list_get_anim_time(list));
......@@ -560,7 +568,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
lv_page_focus(list, btn_prev, ext->anim_time);
}
}
} else if(c == LV_GROUP_KEY_ENTER) {
} else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
/*Get the 'pressed' button*/
lv_obj_t * btn = NULL;
btn = get_next_btn(list, btn);
......
......@@ -183,12 +183,15 @@ void lv_mbox_set_action(lv_obj_t * mbox, lv_btnm_action_t action)
/**
* Set animation duration
* @param mbox pointer to a message box object
* @param time animation length in milliseconds (0: no animation)
* @param anim_time animation length in milliseconds (0: no animation)
*/
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t time)
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
{
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
ext->anim_time = time;
#if USE_LV_ANIMATION == 0
anim_time = 0;
#endif
ext->anim_time = anim_time;
}
/**
......
......@@ -109,9 +109,9 @@ void lv_mbox_set_action(lv_obj_t * mbox, lv_btnm_action_t action);
/**
* Set animation duration
* @param mbox pointer to a message box object
* @param time animation length in milliseconds (0: no animation)
* @param anim_time animation length in milliseconds (0: no animation)
*/
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t time);
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time);
/**
* Automatically delete the message box after a given time
......
......@@ -122,6 +122,9 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
*/
void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en)
{
#if USE_LV_ANIMATION == 0
anim_en = false;
#endif
lv_ddlist_set_selected(roller, sel_opt);
refr_position(roller, anim_en);
}
......@@ -293,23 +296,30 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
lv_ddlist_set_selected(roller, ext->ddlist.sel_opt_id);
refr_position(roller, false);
}
} else if(sign == LV_SIGNAL_CONTROLL) {
}
else if(sign == LV_SIGNAL_FOCUS) {
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id;
}
else if(sign == LV_SIGNAL_DEFOCUS) {
/*Revert the original state*/
if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori;
refr_position(roller, true);
}
}
else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
if(ext->ddlist.sel_opt_id +1 < ext->ddlist.option_cnt) {
lv_roller_set_selected(roller, ext->ddlist.sel_opt_id + 1, true);
if(ext->ddlist.action != NULL) {
ext->ddlist.action(roller);
}
}
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
if(ext->ddlist.sel_opt_id > 0) {
lv_roller_set_selected(roller, ext->ddlist.sel_opt_id - 1, true);
if(ext->ddlist.action != NULL) {
ext->ddlist.action(roller);
}
}
} else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
if(ext->ddlist.action) ext->ddlist.action(roller);
}
}
else if(sign == LV_SIGNAL_GET_TYPE) {
......@@ -446,6 +456,9 @@ static void draw_bg(lv_obj_t *roller, const lv_area_t *mask)
*/
static void refr_position(lv_obj_t *roller, bool anim_en)
{
#if USE_LV_ANIMATION == 0
anim_en = false;
#endif
lv_obj_t *roller_scrl = lv_page_get_scrl(roller);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
......
......@@ -202,7 +202,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
else old_val = lv_slider_get_value(sw);
/*Do not let the slider to call the callback. The Switch will do it if required*/
lv_action_t slider_cb = ext->slider.action;
lv_action_t slider_action = ext->slider.action;
ext->slider.action = NULL;
lv_res_t res;
......@@ -232,10 +232,28 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
if(lv_sw_get_state(sw)) lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_on);
else lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off);
if(slider_cb != NULL) slider_cb(sw);
if(slider_action != NULL) slider_action(sw);
ext->changed = 0;
}
else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char*)param);
if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
if(lv_sw_get_state(sw)) lv_sw_off(sw);
else lv_sw_on(sw);
if(slider_action) slider_action(sw);
}
else if(c == LV_GROUP_KEY_UP || c== LV_GROUP_KEY_RIGHT) {
lv_sw_on(sw);
if(slider_action) slider_action(sw);
}
else if(c == LV_GROUP_KEY_DOWN || c== LV_GROUP_KEY_LEFT) {
lv_sw_off(sw);
if(slider_action) slider_action(sw);
}
}
else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
......@@ -246,7 +264,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
}
/*Restore the callback*/
ext->slider.action = slider_cb;
ext->slider.action = slider_action;
return res;
}
......
......@@ -237,6 +237,9 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
*/
void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
{
#if USE_LV_ANIMATION == 0
anim_en = false;
#endif
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
lv_style_t * style = lv_obj_get_style(ext->content);
......@@ -327,6 +330,9 @@ void lv_tabview_set_sliding(lv_obj_t * tabview, bool en)
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);
#if USE_LV_ANIMATION == 0
anim_time = 0;
#endif
ext->anim_time = anim_time;
}
......
......@@ -221,6 +221,7 @@ static void lmeter_init(void)
lmeter_bg.body.padding.hor = LV_DPI / 20;
lmeter_bg.body.padding.inner = LV_DPI / 8;
lmeter_bg.line.color = LV_COLOR_WHITE;
lmeter_bg.line.width = 1;
theme.lmeter = &lmeter_bg;
#endif
......@@ -232,7 +233,7 @@ static void gauge_init(void)
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;
gauge_bg.line.width = 1;
theme.gauge = &gauge_bg;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment