consistent abbreviations

This commit is contained in:
Gabor Kiss-Vamosi 2017-11-16 10:20:30 +01:00
parent 38c799e27e
commit e3378d23d4
20 changed files with 273 additions and 270 deletions

View File

@ -38,8 +38,8 @@ typedef enum {
/*State for input devices*/
typedef enum {
LV_INDEV_EVENT_RELEASED,
LV_INDEV_EVENT_PRESSED
LV_INDEV_EVENT_REL,
LV_INDEV_EVENT_PR
}lv_indev_event_t;
/*Data read from an input device. */
@ -69,13 +69,13 @@ typedef struct _lv_indev_state_t
point_t vect_sum;
struct __LV_OBJ_T * act_obj;
struct __LV_OBJ_T * last_obj;
uint32_t press_timestamp;
uint32_t longpress_repeat_timestamp;
uint32_t pr_timestamp; /*Pressed time stamp*/
uint32_t longpr_rep_timestamp; /*Long press repeat time stamp*/
/*Flags*/
uint8_t drag_range_out :1;
uint8_t drag_in_prog :1;
uint8_t long_press_sent :1;
uint8_t long_pr_sent :1;
uint8_t wait_unil_release :1;
uint8_t reset_query :1;
uint8_t disabled :1;

View File

@ -93,9 +93,9 @@ void lv_indev_reset(lv_indev_t * indev)
*/
void lv_indev_reset_lpr(lv_indev_t * indev_proc)
{
indev_proc->state.long_press_sent = 0;
indev_proc->state.longpress_repeat_timestamp = lv_tick_get();
indev_proc->state.press_timestamp = lv_tick_get();
indev_proc->state.long_pr_sent = 0;
indev_proc->state.longpr_rep_timestamp = lv_tick_get();
indev_proc->state.pr_timestamp = lv_tick_get();
}
/**
@ -192,9 +192,9 @@ static void indev_proc_task(void * param)
i->state.last_obj = NULL;
i->state.drag_range_out = 0;
i->state.drag_in_prog = 0;
i->state.long_press_sent = 0;
i->state.press_timestamp = 0;
i->state.longpress_repeat_timestamp = 0;
i->state.long_pr_sent = 0;
i->state.pr_timestamp = 0;
i->state.longpr_rep_timestamp = 0;
i->state.vect_sum.x = 0;
i->state.vect_sum.y = 0;
i->state.reset_query = 0;
@ -226,9 +226,9 @@ static void indev_proc_task(void * param)
i->state.last_obj = NULL;
i->state.drag_range_out = 0;
i->state.drag_in_prog = 0;
i->state.long_press_sent = 0;
i->state.press_timestamp = 0;
i->state.longpress_repeat_timestamp = 0;
i->state.long_pr_sent = 0;
i->state.pr_timestamp = 0;
i->state.longpr_rep_timestamp = 0;
i->state.vect_sum.x = 0;
i->state.vect_sum.y = 0;
i->state.reset_query = 0;
@ -248,7 +248,7 @@ static void indev_proc_task(void * param)
*/
static void indev_proc_point(lv_indev_state_t * indev)
{
if(indev->event == LV_INDEV_EVENT_PRESSED){
if(indev->event == LV_INDEV_EVENT_PR){
#if LV_INDEV_TP_MARKER != 0
area_t area;
area.x1 = x - (LV_INDEV_TP_MARKER >> 1);
@ -306,8 +306,8 @@ static void indev_proc_press(lv_indev_state_t * state)
if(pr_obj != NULL) {
/* Save the time when the obj pressed.
* It is necessary to count the long press time.*/
state->press_timestamp = lv_tick_get();
state->long_press_sent = 0;
state->pr_timestamp = lv_tick_get();
state->long_pr_sent = 0;
state->drag_range_out = 0;
state->drag_in_prog = 0;
state->vect_sum.x = 0;
@ -351,26 +351,26 @@ static void indev_proc_press(lv_indev_state_t * state)
if(state->reset_query != 0) return;
/*If there is no drag then check for long press time*/
if(state->drag_in_prog == 0 && state->long_press_sent == 0) {
if(state->drag_in_prog == 0 && state->long_pr_sent == 0) {
/*Send a signal about the long press if enough time elapsed*/
if(lv_tick_elaps(state->press_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
if(lv_tick_elaps(state->pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
if(state->reset_query != 0) return;
/*Mark the signal sending to do not send it again*/
state->long_press_sent = 1;
state->long_pr_sent = 1;
/*Save the long press time stamp for the long press repeat handler*/
state->longpress_repeat_timestamp = lv_tick_get();
state->longpr_rep_timestamp = lv_tick_get();
}
}
/*Send long press repeated signal*/
if(state->drag_in_prog == 0 && state->long_press_sent == 1) {
if(state->drag_in_prog == 0 && state->long_pr_sent == 1) {
/*Send a signal about the long press repeate if enough time elapsed*/
if(lv_tick_elaps(state->longpress_repeat_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
if(lv_tick_elaps(state->longpr_rep_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
if(state->reset_query != 0) return;
state->longpress_repeat_timestamp = lv_tick_get();
state->longpr_rep_timestamp = lv_tick_get();
}
}
@ -386,8 +386,8 @@ static void disi_proc_release(lv_indev_state_t * state)
if(state->wait_unil_release != 0) {
state->act_obj = NULL;
state->last_obj = NULL;
state->press_timestamp = 0;
state->longpress_repeat_timestamp = 0;
state->pr_timestamp = 0;
state->longpr_rep_timestamp = 0;
state->wait_unil_release = 0;
}
@ -396,8 +396,8 @@ static void disi_proc_release(lv_indev_state_t * state)
state->act_obj->signal_func(state->act_obj, LV_SIGNAL_RELEASED, indev_act);
if(state->reset_query != 0) return;
state->act_obj = NULL;
state->press_timestamp = 0;
state->longpress_repeat_timestamp = 0;
state->pr_timestamp = 0;
state->longpr_rep_timestamp = 0;
}
/*The reset can be set in the signal function.

View File

@ -45,11 +45,11 @@ lv_style_t lv_style_plain;
lv_style_t lv_style_plain_color;
lv_style_t lv_style_pretty;
lv_style_t lv_style_pretty_color;
lv_style_t lv_style_btn_rel;
lv_style_t lv_style_btn_pr;
lv_style_t lv_style_btn_tgl_rel;
lv_style_t lv_style_btn_tgl_pr;
lv_style_t lv_style_btn_ina;
lv_style_t lv_style_btn_released;
lv_style_t lv_style_btn_pressed;
lv_style_t lv_style_btn_tgl_released;
lv_style_t lv_style_btn_tgl_pressed;
lv_style_t lv_style_btn_inactive;
/**********************
* MACROS
@ -148,53 +148,53 @@ void lv_style_init (void)
lv_style_transp_tight.body.padding.inner = 0;
/*Button released style*/
memcpy(&lv_style_btn_rel, &lv_style_plain, sizeof(lv_style_t));
lv_style_btn_rel.body.color_main = COLOR_MAKE(0x76, 0xa2, 0xd0);
lv_style_btn_rel.body.color_gradient = COLOR_MAKE(0x19, 0x3a, 0x5d);
lv_style_btn_rel.body.radius = LV_DPI / 15;
lv_style_btn_rel.body.padding.hor = LV_DPI / 4;
lv_style_btn_rel.body.padding.ver = LV_DPI / 6;
lv_style_btn_rel.body.padding.inner = LV_DPI / 10;
lv_style_btn_rel.body.border.color = COLOR_MAKE(0x0b, 0x19, 0x28);
lv_style_btn_rel.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
lv_style_btn_rel.body.border.opa = OPA_70;
lv_style_btn_rel.text.color = COLOR_MAKE(0xff, 0xff, 0xff);
lv_style_btn_rel.body.shadow.color = COLOR_GRAY;
lv_style_btn_rel.body.shadow.width = 0;
memcpy(&lv_style_btn_released, &lv_style_plain, sizeof(lv_style_t));
lv_style_btn_released.body.color_main = COLOR_MAKE(0x76, 0xa2, 0xd0);
lv_style_btn_released.body.color_gradient = COLOR_MAKE(0x19, 0x3a, 0x5d);
lv_style_btn_released.body.radius = LV_DPI / 15;
lv_style_btn_released.body.padding.hor = LV_DPI / 4;
lv_style_btn_released.body.padding.ver = LV_DPI / 6;
lv_style_btn_released.body.padding.inner = LV_DPI / 10;
lv_style_btn_released.body.border.color = COLOR_MAKE(0x0b, 0x19, 0x28);
lv_style_btn_released.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
lv_style_btn_released.body.border.opa = OPA_70;
lv_style_btn_released.text.color = COLOR_MAKE(0xff, 0xff, 0xff);
lv_style_btn_released.body.shadow.color = COLOR_GRAY;
lv_style_btn_released.body.shadow.width = 0;
/*Button pressed style*/
memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t));
lv_style_btn_pr.body.color_main = COLOR_MAKE(0x33, 0x62, 0x94);
lv_style_btn_pr.body.color_gradient = COLOR_MAKE(0x10, 0x26, 0x3c);
lv_style_btn_pr.text.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_pr.image.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_pr.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
memcpy(&lv_style_btn_pressed, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_pressed.body.color_main = COLOR_MAKE(0x33, 0x62, 0x94);
lv_style_btn_pressed.body.color_gradient = COLOR_MAKE(0x10, 0x26, 0x3c);
lv_style_btn_pressed.text.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_pressed.image.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_pressed.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
/*Button toggle released style*/
memcpy(&lv_style_btn_tgl_rel, &lv_style_btn_rel, sizeof(lv_style_t));
lv_style_btn_tgl_rel.body.color_main = COLOR_MAKE(0x0a, 0x11, 0x22);
lv_style_btn_tgl_rel.body.color_gradient = COLOR_MAKE(0x37, 0x62, 0x90);
lv_style_btn_tgl_rel.body.border.color = COLOR_MAKE(0x01, 0x07, 0x0d);
lv_style_btn_tgl_rel.text.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
lv_style_btn_tgl_rel.image.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
lv_style_btn_tgl_rel.line.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
memcpy(&lv_style_btn_tgl_released, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_tgl_released.body.color_main = COLOR_MAKE(0x0a, 0x11, 0x22);
lv_style_btn_tgl_released.body.color_gradient = COLOR_MAKE(0x37, 0x62, 0x90);
lv_style_btn_tgl_released.body.border.color = COLOR_MAKE(0x01, 0x07, 0x0d);
lv_style_btn_tgl_released.text.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
lv_style_btn_tgl_released.image.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
lv_style_btn_tgl_released.line.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
/*Button toggle pressed style*/
memcpy(&lv_style_btn_tgl_pr, &lv_style_btn_tgl_rel, sizeof(lv_style_t));
lv_style_btn_tgl_pr.body.color_main = COLOR_MAKE(0x02, 0x14, 0x27);
lv_style_btn_tgl_pr.body.color_gradient = COLOR_MAKE(0x2b, 0x4c, 0x70);
lv_style_btn_tgl_pr.text.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_tgl_pr.image.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_tgl_pr.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
memcpy(&lv_style_btn_tgl_pressed, &lv_style_btn_tgl_released, sizeof(lv_style_t));
lv_style_btn_tgl_pressed.body.color_main = COLOR_MAKE(0x02, 0x14, 0x27);
lv_style_btn_tgl_pressed.body.color_gradient = COLOR_MAKE(0x2b, 0x4c, 0x70);
lv_style_btn_tgl_pressed.text.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_tgl_pressed.image.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_tgl_pressed.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
/*Button inactive style*/
memcpy(&lv_style_btn_ina, &lv_style_btn_rel, sizeof(lv_style_t));
lv_style_btn_ina.body.color_main = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_ina.body.color_gradient = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_ina.body.border.color = COLOR_MAKE(0x90, 0x90, 0x90);
lv_style_btn_ina.text.color = COLOR_MAKE(0x70, 0x70, 0x70);
lv_style_btn_ina.image.color = COLOR_MAKE(0x70, 0x70, 0x70);
lv_style_btn_ina.line.color = COLOR_MAKE(0x70, 0x70, 0x70);
memcpy(&lv_style_btn_inactive, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_inactive.body.color_main = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.color_gradient = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.border.color = COLOR_MAKE(0x90, 0x90, 0x90);
lv_style_btn_inactive.text.color = COLOR_MAKE(0x70, 0x70, 0x70);
lv_style_btn_inactive.image.color = COLOR_MAKE(0x70, 0x70, 0x70);
lv_style_btn_inactive.line.color = COLOR_MAKE(0x70, 0x70, 0x70);
}

View File

@ -149,11 +149,11 @@ extern lv_style_t lv_style_plain;
extern lv_style_t lv_style_plain_color;
extern lv_style_t lv_style_pretty;
extern lv_style_t lv_style_pretty_color;
extern lv_style_t lv_style_btn_rel;
extern lv_style_t lv_style_btn_pr;
extern lv_style_t lv_style_btn_tgl_rel;
extern lv_style_t lv_style_btn_tgl_pr;;
extern lv_style_t lv_style_btn_ina;
extern lv_style_t lv_style_btn_released;
extern lv_style_t lv_style_btn_pressed;
extern lv_style_t lv_style_btn_tgl_released;
extern lv_style_t lv_style_btn_tgl_pressed;;
extern lv_style_t lv_style_btn_inactive;
/**********************
* MACROS

View File

@ -65,7 +65,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy)
ext->min_value = 0;
ext->max_value = 100;
ext->cur_value = 0;
ext->style_inicator = &lv_style_pretty_color;
ext->style_indic = &lv_style_pretty_color;
lv_obj_set_signal_func(new_bar, lv_bar_signal);
lv_obj_set_design_func(new_bar, lv_bar_design);
@ -81,7 +81,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy)
ext->min_value = ext_copy->min_value;
ext->max_value = ext_copy->max_value;
ext->cur_value = ext_copy->cur_value;
ext->style_inicator = ext_copy->style_inicator;
ext->style_indic = ext_copy->style_indic;
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_bar);
@ -178,7 +178,7 @@ void lv_bar_set_style(lv_obj_t *bar, lv_bar_style_t type, lv_style_t *style)
lv_obj_set_style(bar, style);
break;
case LV_BAR_STYLE_INDIC:
ext->style_inicator = style;
ext->style_indic = style;
lv_obj_refresh_ext_size(bar);
break;
}
@ -230,9 +230,9 @@ lv_style_t * lv_bar_get_style_indicator(lv_obj_t * bar)
{
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
if(ext->style_inicator == NULL) return lv_obj_get_style(bar);
if(ext->style_indic == NULL) return lv_obj_get_style(bar);
return ext->style_inicator;
return ext->style_indic;
}
/**
@ -247,7 +247,7 @@ lv_style_t * lv_bar_get_style(lv_obj_t *bar, lv_bar_style_t type)
switch (type) {
case LV_BAR_STYLE_BG: return lv_obj_get_style(bar);
case LV_BAR_STYLE_INDIC: return ext->style_inicator;
case LV_BAR_STYLE_INDIC: return ext->style_indic;
default: return NULL;
}

View File

@ -37,7 +37,7 @@ typedef struct
int16_t cur_value; /*Current value of the bar*/
int16_t min_value; /*Minimum value of the bar*/
int16_t max_value; /*Maximum value of the bar*/
lv_style_t *style_inicator; /*Style of the indicator*/
lv_style_t *style_indic; /*Style of the indicator*/
}lv_bar_ext_t;
typedef enum {

View File

@ -62,18 +62,18 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
dm_assert(ext);
ext->state = LV_BTN_STATE_REL;
ext->actions[LV_BTN_ACTION_PRESS] = NULL;
ext->actions[LV_BTN_ACTION_RELEASE] = NULL;
ext->actions[LV_BTN_ACTION_LONG_PRESS] = NULL;
ext->actions[LV_BTN_ACTION_LONG_PRESS_REPEATE] = NULL;
ext->actions[LV_BTN_ACTION_PR] = NULL;
ext->actions[LV_BTN_ACTION_REL] = NULL;
ext->actions[LV_BTN_ACTION_LONG_PR] = NULL;
ext->actions[LV_BTN_ACTION_LONG_PR_REPEAT] = NULL;
ext->styles[LV_BTN_STATE_REL] = &lv_style_btn_rel;
ext->styles[LV_BTN_STATE_PR] = &lv_style_btn_pr;
ext->styles[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
ext->styles[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles[LV_BTN_STATE_INA] = &lv_style_btn_ina;
ext->styles[LV_BTN_STATE_REL] = &lv_style_btn_released;
ext->styles[LV_BTN_STATE_PR] = &lv_style_btn_pressed;
ext->styles[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_released;
ext->styles[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pressed;
ext->styles[LV_BTN_STATE_INA] = &lv_style_btn_inactive;
ext->long_press_action_executed = 0;
ext->long_pr_action_executed = 0;
ext->toggle = 0;
lv_obj_set_signal_func(new_btn, lv_btn_signal);
@ -284,10 +284,10 @@ 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_TGL_PR);
}
ext->long_press_action_executed = 0;
ext->long_pr_action_executed = 0;
/*Call the press action, 'param' is the caller indev_proc*/
if(ext->actions[LV_BTN_ACTION_PRESS] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_PRESS](btn);
if(ext->actions[LV_BTN_ACTION_PR] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_PR](btn);
}
}
else if(sign == LV_SIGNAL_PRESS_LOST) {
@ -305,7 +305,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
else if(sign == LV_SIGNAL_RELEASED) {
/*If not dragged and it was not long press action then
*change state and run the action*/
if(lv_indev_is_dragging(param) == false && ext->long_press_action_executed == 0) {
if(lv_indev_is_dragging(param) == false && ext->long_pr_action_executed == 0) {
if(ext->state == LV_BTN_STATE_PR && tgl == false) {
lv_btn_set_state(btn, LV_BTN_STATE_REL);
} else if(ext->state == LV_BTN_STATE_TGL_PR && tgl == false) {
@ -316,8 +316,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_RELEASE] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_RELEASE](btn);
if(ext->actions[LV_BTN_ACTION_REL] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_REL](btn);
}
} else { /*If dragged change back the state*/
if(ext->state == LV_BTN_STATE_PR) {
@ -328,27 +328,27 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
}
}
else if(sign == LV_SIGNAL_LONG_PRESS) {
if(ext->actions[LV_BTN_ACTION_LONG_PRESS] && state != LV_BTN_STATE_INA) {
ext->long_press_action_executed = 1;
res = ext->actions[LV_BTN_ACTION_LONG_PRESS](btn);
if(ext->actions[LV_BTN_ACTION_LONG_PR] && state != LV_BTN_STATE_INA) {
ext->long_pr_action_executed = 1;
res = ext->actions[LV_BTN_ACTION_LONG_PR](btn);
}
}
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
if(ext->actions[LV_BTN_ACTION_LONG_PRESS_REPEATE] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_LONG_PRESS_REPEATE](btn);
if(ext->actions[LV_BTN_ACTION_LONG_PR_REPEAT] && state != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_LONG_PR_REPEAT](btn);
}
}
else if(sign == LV_SIGNAL_CONTROLL) {
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_RELEASE] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_RELEASE](btn);
if(ext->actions[LV_BTN_ACTION_REL] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_REL](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_RELEASE] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_RELEASE](btn);
if(ext->actions[LV_BTN_ACTION_REL] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_REL](btn);
}
} else if(c == LV_GROUP_KEY_ENTER) {
if(lv_btn_get_toggle(btn) != false) {
@ -358,8 +358,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_RELEASE] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_RELEASE](btn);
if(ext->actions[LV_BTN_ACTION_REL] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
res = ext->actions[LV_BTN_ACTION_REL](btn);
}
}
}

View File

@ -45,10 +45,10 @@ typedef enum
typedef enum
{
LV_BTN_ACTION_RELEASE,
LV_BTN_ACTION_PRESS,
LV_BTN_ACTION_LONG_PRESS,
LV_BTN_ACTION_LONG_PRESS_REPEATE,
LV_BTN_ACTION_REL,
LV_BTN_ACTION_PR,
LV_BTN_ACTION_LONG_PR,
LV_BTN_ACTION_LONG_PR_REPEAT,
LV_BTN_ACTION_NUM,
}lv_btn_action_t;
@ -62,7 +62,7 @@ typedef struct
lv_btn_state_t state; /*Current state of the button from 'lv_btn_state_t' enum*/
uint8_t toggle :1; /*1: Toggle enabled*/
uint8_t long_press_action_executed :1; /*1: Long press action executed (Handled by the library)*/
uint8_t long_pr_action_executed :1; /*1: Long press action executed (Handled by the library)*/
}lv_btn_ext_t;
typedef enum {

View File

@ -72,17 +72,17 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t));
dm_assert(ext);
ext->btn_cnt = 0;
ext->btn_id_pressed = LV_BTNM_PR_NONE;
ext->btn_id_toggled = LV_BTNM_PR_NONE;
ext->btn_id_pr = LV_BTNM_PR_NONE;
ext->btn_id_tgl = LV_BTNM_PR_NONE;
ext->button_areas = NULL;
ext->action = NULL;
ext->map_p = NULL;
ext->toggle = 0;
ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_rel;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_pr;
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_released;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_pressed;
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_released;
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pressed;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_inactive;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_btnm);
@ -101,7 +101,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
memcpy(ext->styles_btn, copy_ext->styles_btn, sizeof(ext->styles_btn));
ext->action = copy_ext->action;
ext->toggle = copy_ext->toggle;
ext->btn_id_toggled = copy_ext->btn_id_toggled;
ext->btn_id_tgl = copy_ext->btn_id_tgl;
lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy));
}
@ -235,9 +235,9 @@ void lv_btnm_set_toggle(lv_obj_t * btnm, bool en, uint16_t id)
ext->toggle = en == false ? 0 : 1;
if(ext->toggle != 0) {
if(id >= ext->btn_cnt) id = ext->btn_cnt - 1;
ext->btn_id_toggled = id;
ext->btn_id_tgl = id;
} else {
ext->btn_id_toggled = LV_BTNM_PR_NONE;
ext->btn_id_tgl = LV_BTNM_PR_NONE;
}
lv_obj_invalidate(btnm);
@ -316,7 +316,7 @@ uint16_t lv_btnm_get_toggled(lv_obj_t * btnm)
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(ext->toggle == 0) return 0;
else return ext->btn_id_toggled;}
else return ext->btn_id_tgl;}
/**
* Get a style of a button matrix
@ -397,10 +397,10 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
/*Load the style*/
if(button_is_inactive(ext->map_p[txt_i])) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_INA);
else if(btn_i != ext->btn_id_pressed && btn_i != ext->btn_id_toggled) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL);
else if(btn_i == ext->btn_id_pressed && btn_i != ext->btn_id_toggled) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR);
else if(btn_i != ext->btn_id_pressed && btn_i == ext->btn_id_toggled) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL);
else if(btn_i == ext->btn_id_pressed && btn_i == ext->btn_id_toggled) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR);
else if(btn_i != ext->btn_id_pr && btn_i != ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL);
else if(btn_i == ext->btn_id_pr && btn_i != ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR);
else if(btn_i != ext->btn_id_pr && btn_i == ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL);
else if(btn_i == ext->btn_id_pr && btn_i == ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR);
lv_draw_rect(&area_tmp, mask, btn_style);
/*Calculate the size of the text*/
@ -455,10 +455,10 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
btn_pr = get_button_from_point(btnm, &p);
/*Invalidate to old and the new areas*/;
lv_obj_get_coords(btnm, &btnm_area);
if(btn_pr != ext->btn_id_pressed) {
if(btn_pr != ext->btn_id_pr) {
lv_indev_reset_lpr(param);
if(ext->btn_id_pressed != LV_BTNM_PR_NONE) {
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_pressed]);
if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_pr]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
@ -475,12 +475,12 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
}
ext->btn_id_pressed = btn_pr;
ext->btn_id_pr = btn_pr;
}
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
if(ext->action && ext->btn_id_pressed != LV_BTNM_PR_NONE) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pressed);
if(ext->action && ext->btn_id_pr != LV_BTNM_PR_NONE) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE) {
if(button_is_repeat_disabled(ext->map_p[txt_i]) == false &&
button_is_inactive(ext->map_p[txt_i]) == false) {
@ -490,9 +490,9 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
}
}
else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pressed != LV_BTNM_PR_NONE) {
if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
if(ext->action) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pressed);
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE && button_is_inactive(ext->map_p[txt_i]) == false) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
@ -500,7 +500,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
/*Invalidate to old pressed area*/;
lv_obj_get_coords(btnm, &btnm_area);
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_pressed]);
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_pr]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
@ -509,42 +509,42 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
if(ext->toggle != 0) {
/*Invalidate to old toggled area*/;
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_toggled]);
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_tgl]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
ext->btn_id_toggled = ext->btn_id_pressed;
ext->btn_id_tgl = ext->btn_id_pr;
}
ext->btn_id_pressed = LV_BTNM_PR_NONE;
ext->btn_id_pr = LV_BTNM_PR_NONE;
}
}
else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->btn_id_pressed = LV_BTNM_PR_NONE;
ext->btn_id_pr = LV_BTNM_PR_NONE;
lv_obj_invalidate(btnm);
}
else if(sign == LV_SIGNAL_FOCUS) {
ext->btn_id_pressed = 0;
ext->btn_id_pr = 0;
lv_obj_invalidate(btnm);
}
else if(sign == LV_SIGNAL_CONTROLL) {
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
if(ext->btn_id_pressed == LV_BTNM_PR_NONE) ext->btn_id_pressed = 0;
else ext->btn_id_pressed++;
if(ext->btn_id_pressed >= ext->btn_cnt - 1) ext->btn_id_pressed = ext->btn_cnt - 1;
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
else ext->btn_id_pr++;
if(ext->btn_id_pr >= ext->btn_cnt - 1) ext->btn_id_pr = ext->btn_cnt - 1;
lv_obj_invalidate(btnm);
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
if(ext->btn_id_pressed == LV_BTNM_PR_NONE) ext->btn_id_pressed = 0;
if(ext->btn_id_pressed > 0) ext->btn_id_pressed--;
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) {
if(ext->action != NULL) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pressed);
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
if(txt_i != LV_BTNM_PR_NONE) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}

View File

@ -52,8 +52,8 @@ typedef struct
lv_btnm_action_t action; /*A function to call when a button is releases*/
lv_style_t *styles_btn[LV_BTN_STATE_NUM]; /*Styles of buttons in each state*/
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
uint16_t btn_id_pressed; /*Index of the currently pressed button or LV_BTNM_PR_NONE*/
uint16_t btn_id_toggled; /*Index of the currently toggled button or LV_BTNM_PR_NONE */
uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNM_PR_NONE*/
uint16_t btn_id_tgl; /*Index of the currently toggled button or LV_BTNM_PR_NONE */
uint8_t toggle :1; /*Enable toggling*/
}lv_btnm_ext_t;

View File

@ -127,19 +127,19 @@ void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t *style)
lv_btn_set_style(cb, LV_BTN_STYLE_TGL_PR, style);
lv_btn_set_style(cb, LV_BTN_STYLE_INA, style);
break;
case LV_CB_STYLE_RELEASED:
case LV_CB_STYLE_REL:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_REL, style);
break;
case LV_CB_STYLE_PRESSED:
case LV_CB_STYLE_PR:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_PR, style);
break;
case LV_CB_STYLE_TGL_RELEASED:
case LV_CB_STYLE_TGL_REL:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_REL, style);
break;
case LV_CB_STYLE_TGL_PRESSED:
case LV_CB_STYLE_TGL_PR:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_PR, style);
break;
case LV_CB_STYLE_INACTIVE:
case LV_CB_STYLE_INA:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_INA, style);
break;
}
@ -174,11 +174,11 @@ lv_style_t * lv_cb_get_style(lv_obj_t * cb, lv_cb_style_t type)
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
switch (type) {
case LV_CB_STYLE_RELEASED: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
case LV_CB_STYLE_PRESSED: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
case LV_CB_STYLE_TGL_RELEASED: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
case LV_CB_STYLE_TGL_PRESSED: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
case LV_CB_STYLE_INACTIVE: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
case LV_CB_STYLE_REL: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
case LV_CB_STYLE_PR: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
case LV_CB_STYLE_TGL_REL: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
case LV_CB_STYLE_TGL_PR: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
case LV_CB_STYLE_INA: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
default: return NULL;
}

View File

@ -48,11 +48,11 @@ typedef struct
typedef enum {
LV_CB_STYLE_BG,
LV_CB_STYLE_RELEASED,
LV_CB_STYLE_PRESSED,
LV_CB_STYLE_TGL_RELEASED,
LV_CB_STYLE_TGL_PRESSED,
LV_CB_STYLE_INACTIVE,
LV_CB_STYLE_REL,
LV_CB_STYLE_PR,
LV_CB_STYLE_TGL_REL,
LV_CB_STYLE_TGL_PR,
LV_CB_STYLE_INA,
}lv_cb_style_t;
/**********************
@ -98,12 +98,12 @@ static inline void lv_cb_set_inactive(lv_obj_t * cb)
}
/**
* Set a function to call when the button is pressed
* Set a function to call when the check box is clicked
* @param cb pointer to a check box object
*/
static inline void lv_cb_set_action(lv_obj_t * cb, lv_action_t action)
{
lv_btn_set_action(cb, LV_BTN_ACTION_RELEASE, action);
lv_btn_set_action(cb, LV_BTN_ACTION_REL, action);
}
@ -143,7 +143,7 @@ static inline bool lv_cb_get_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_RELEASE);
return lv_btn_get_action(cb, LV_BTN_ACTION_REL);
}

View File

@ -29,7 +29,7 @@
* STATIC PROTOTYPES
**********************/
static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_mode_t mode);
lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param);
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);
@ -69,14 +69,14 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
dm_assert(ext);
/*Initialize the allocated 'ext' */
ext->options_label = NULL;
ext->callback = NULL;
ext->label = NULL;
ext->action = NULL;
ext->opened = 0;
ext->fix_height = 0;
ext->selected_option_id = 0;
ext->sel_opt_id = 0;
ext->option_cnt = 0;
ext->anim_time = LV_DDLIST_DEF_ANIM_TIME;
ext->selected_style = &lv_style_plain_color;
ext->sel_style = &lv_style_plain_color;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_func(new_ddlist, lv_ddlist_signal);
@ -89,25 +89,25 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_drag(scrl, false);
lv_page_set_scrl_fit(new_ddlist, true, true);
ext->options_label = lv_label_create(new_ddlist, NULL);
ext->label = lv_label_create(new_ddlist, NULL);
lv_cont_set_fit(new_ddlist, true, false);
lv_page_set_release_action(new_ddlist, lv_ddlist_release_action);
lv_page_set_sb_mode(new_ddlist, LV_PAGE_SB_MODE_DRAG);
lv_page_set_style(new_ddlist, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, &lv_style_pretty);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SELECTED, &lv_style_plain_color);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, &lv_style_plain_color);
lv_ddlist_set_options(new_ddlist, "Option 1\nOption 2\nOption 3");
}
/*Copy an existing drop down list*/
else {
lv_ddlist_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->options_label = lv_label_create(new_ddlist, copy_ext->options_label);
lv_label_set_text(ext->options_label, lv_label_get_text(copy_ext->options_label));
ext->selected_option_id = copy_ext->selected_option_id;
ext->label = lv_label_create(new_ddlist, copy_ext->label);
lv_label_set_text(ext->label, lv_label_get_text(copy_ext->label));
ext->sel_opt_id = copy_ext->sel_opt_id;
ext->fix_height = copy_ext->fix_height;
ext->callback = copy_ext->callback;
ext->action = copy_ext->action;
ext->option_cnt = copy_ext->option_cnt;
ext->selected_style = copy_ext->selected_style;
ext->sel_style = copy_ext->sel_style;
ext->anim_time = copy_ext->anim_time;
/*Refresh the style with new signal function*/
@ -138,7 +138,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->options_label, options);
lv_label_set_text(ext->label, options);
lv_ddlist_refr_size(ddlist, 0);
}
@ -151,7 +151,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->selected_option_id = sel_opt < ext->option_cnt ? sel_opt : ext->option_cnt - 1;
ext->sel_opt_id = sel_opt < ext->option_cnt ? sel_opt : ext->option_cnt - 1;
/*Move the list to show the current option*/
if(ext->opened == 0) {
@ -169,7 +169,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->callback = action;
ext->action = action;
}
/**
@ -213,8 +213,8 @@ void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *s
case LV_DDLIST_STYLE_SB:
lv_page_set_style(ddlist, LV_PAGE_STYLE_SB, style);
break;
case LV_DDLIST_STYLE_SELECTED:
ext->selected_style = style;
case LV_DDLIST_STYLE_SEL:
ext->sel_style = style;
lv_obj_t *scrl = lv_page_get_scrl(ddlist);
lv_obj_refresh_ext_size(scrl); /*Because of the wider selected rectangle*/
break;
@ -233,7 +233,7 @@ void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *s
const char * lv_ddlist_get_options(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return lv_label_get_text(ext->options_label);
return lv_label_get_text(ext->label);
}
/**
@ -245,7 +245,7 @@ uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->selected_option_id;
return ext->sel_opt_id;
}
/**
@ -259,11 +259,11 @@ void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf)
uint16_t i;
uint16_t line = 0;
const char * opt_txt = lv_label_get_text(ext->options_label);
const char * opt_txt = lv_label_get_text(ext->label);
uint16_t txt_len = strlen(opt_txt);
for(i = 0; i < txt_len && line != ext->selected_option_id; i++) {
for(i = 0; i < txt_len && line != ext->sel_opt_id; i++) {
if(opt_txt[i] == '\n') line ++;
}
@ -281,7 +281,7 @@ void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf)
lv_action_t lv_ddlist_get_action(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->callback;
return ext->action;
}
/**
@ -320,7 +320,7 @@ lv_style_t * lv_ddlist_get_style(lv_obj_t *ddlist, lv_ddlist_style_t type)
switch (type) {
case LV_DDLIST_STYLE_BG: return lv_page_get_style(ddlist, LV_PAGE_STYLE_BG);
case LV_DDLIST_STYLE_SB: return lv_page_get_style(ddlist, LV_PAGE_STYLE_SB);
case LV_DDLIST_STYLE_SELECTED: return ext->selected_style;
case LV_DDLIST_STYLE_SEL: return ext->sel_style;
default: return NULL;
}
@ -388,15 +388,15 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
const font_t * font = style->text.font;
cord_t font_h = font_get_height_scale(font);
area_t rect_area;
rect_area.y1 = ext->options_label->coords.y1;
rect_area.y1 += ext->selected_option_id * (font_h + style->text.line_space);
rect_area.y1 = ext->label->coords.y1;
rect_area.y1 += ext->sel_opt_id * (font_h + style->text.line_space);
rect_area.y1 -= style->text.line_space / 2;
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space;
rect_area.x1 = ddlist->coords.x1;
rect_area.x2 = ddlist->coords.x2;
lv_draw_rect(&rect_area, mask, ext->selected_style);
lv_draw_rect(&rect_area, mask, ext->sel_style);
}
}
/*Post draw when the children are drawn*/
@ -414,7 +414,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
* @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
*/
lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
{
lv_res_t res;
/* Include the ancient signal function */
@ -442,19 +442,19 @@ lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
if(ext->selected_option_id +1 < ext->option_cnt) {
ext->selected_option_id ++;
if(ext->sel_opt_id +1 < ext->option_cnt) {
ext->sel_opt_id ++;
lv_obj_invalidate(ddlist);
if(ext->callback != NULL) {
ext->callback(ddlist);
if(ext->action != NULL) {
ext->action(ddlist);
}
}
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
if(ext->selected_option_id > 0) {
ext->selected_option_id --;
if(ext->sel_opt_id > 0) {
ext->sel_opt_id --;
lv_obj_invalidate(ddlist);
if(ext->callback != NULL) {
ext->callback(ddlist);
if(ext->action != NULL) {
ext->action(ddlist);
}
}
} else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ESC) {
@ -514,22 +514,22 @@ static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist)
lv_indev_t *indev = lv_indev_get_act();
point_t p;
lv_indev_get_point(indev, &p);
p.x -= ext->options_label->coords.x1;
p.y -= ext->options_label->coords.y1;
p.x -= ext->label->coords.x1;
p.y -= ext->label->coords.y1;
uint16_t letter_i;
letter_i = lv_label_get_letter_on(ext->options_label, &p);
letter_i = lv_label_get_letter_on(ext->label, &p);
uint16_t new_opt = 0;
const char * txt = lv_label_get_text(ext->options_label);
const char * txt = lv_label_get_text(ext->label);
uint16_t i;
for(i = 0; i < letter_i; i++) {
if(txt[i] == '\n') new_opt ++;
}
ext->selected_option_id = new_opt;
ext->sel_opt_id = new_opt;
if(ext->callback != NULL) {
ext->callback(ddlist);
if(ext->action != NULL) {
ext->action(ddlist);
}
}
lv_ddlist_refr_size(ddlist, ext->anim_time);
@ -553,7 +553,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time)
else new_height = ext->fix_height;
} else { /*Close the list*/
const font_t * font = style->text.font;
lv_style_t * label_style = lv_obj_get_style(ext->options_label);
lv_style_t * label_style = lv_obj_get_style(ext->label);
cord_t font_h = font_get_height_scale(font);
new_height = font_h + 2 * label_style->text.line_space;
}
@ -589,11 +589,11 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist)
lv_style_t * style = lv_obj_get_style(ddlist);
const font_t * font = style->text.font;
cord_t font_h = font_get_height_scale(font);
lv_style_t * label_style = lv_obj_get_style(ext->options_label);
lv_style_t * label_style = lv_obj_get_style(ext->label);
lv_obj_t * scrl = lv_page_get_scrl(ddlist);
cord_t h = lv_obj_get_height(ddlist);
cord_t line_y1 = ext->selected_option_id * (font_h + label_style->text.line_space) + ext->options_label->coords.y1 - scrl->coords.y1;
cord_t line_y1 = ext->sel_opt_id * (font_h + label_style->text.line_space) + ext->label->coords.y1 - scrl->coords.y1;
lv_obj_set_y(scrl, - line_y1 + (h - font_h) / 2);

View File

@ -41,19 +41,19 @@ typedef struct
{
lv_page_ext_t page; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * options_label; /*Label for the options*/
lv_style_t * selected_style; /*Style of the selected option*/
lv_action_t callback; /*Pointer to function to call when an option is selected*/
uint16_t option_cnt; /*Number of options*/
uint16_t selected_option_id; /*Index of the current option*/
uint16_t anim_time; /*Open/Close animation time [ms]*/
uint8_t opened :1; /*1: The list is opened*/
cord_t fix_height; /*Height if the ddlist is opened. (0: auto-size)*/
lv_obj_t *label; /*Label for the options*/
lv_style_t * sel_style; /*Style of the selected option*/
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 anim_time; /*Open/Close animation time [ms]*/
uint8_t opened :1; /*1: The list is opened*/
cord_t fix_height; /*Height if the ddlist is opened. (0: auto-size)*/
}lv_ddlist_ext_t;
typedef enum {
LV_DDLIST_STYLE_BG,
LV_DDLIST_STYLE_SELECTED,
LV_DDLIST_STYLE_SEL,
LV_DDLIST_STYLE_SB,
}lv_ddlist_style_t;

View File

@ -66,11 +66,11 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
dm_assert(ext);
ext->style_img = NULL;
ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_rel;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_pr;
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_released;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_pressed;
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_released;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_tgl_pressed;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_inactive;
ext->anim_time = LV_LIST_FOCUS_TIME;
lv_obj_set_signal_func(new_list, lv_list_signal);
@ -134,7 +134,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_RELEASE, rel_action);
lv_btn_set_action(liste, LV_BTN_ACTION_REL, rel_action);
lv_page_glue_obj(liste, true);
lv_btn_set_layout(liste, LV_CONT_LAYOUT_ROW_M);
lv_btn_set_fit(liste, false, true);
@ -192,6 +192,8 @@ void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time)
void lv_list_set_style(lv_obj_t *list, lv_list_style_t type, lv_style_t *style)
{
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
lv_btn_style_t btn_style_refr = LV_BTN_STYLE_REL;
lv_obj_t *btn;
switch (type) {
case LV_LIST_STYLE_BG:
@ -205,35 +207,36 @@ void lv_list_set_style(lv_obj_t *list, lv_list_style_t type, lv_style_t *style)
break;
case LV_LIST_STYLE_BTN_REL:
ext->styles_btn[LV_BTN_STATE_REL] = style;
btn_style_refr = LV_BTN_STYLE_REL;
break;
case LV_LIST_STYLE_BTN_PR:
ext->styles_btn[LV_BTN_STATE_PR] = style;
btn_style_refr = LV_BTN_STYLE_PR;
break;
case LV_LIST_STYLE_BTN_TGL_REL:
ext->styles_btn[LV_BTN_STATE_TGL_REL] = style;
btn_style_refr = LV_BTN_STYLE_TGL_REL;
break;
case LV_LIST_STYLE_BTN_TGL_PR:
ext->styles_btn[LV_BTN_STATE_TGL_PR] = style;
btn_style_refr = LV_BTN_STYLE_TGL_PR;
break;
case LV_LIST_STYLE_BTN_INA:
ext->styles_btn[LV_BTN_STATE_INA] = style;
btn_style_refr = LV_BTN_STYLE_INA;
break;
}
/*Refresh existing buttons' style*/
if(type == LV_LIST_STYLE_BTN_PR || type == LV_LIST_STYLE_BTN_REL ||
type == LV_LIST_STYLE_BTN_TGL_REL || type == LV_LIST_STYLE_BTN_TGL_PR ||
type == LV_LIST_STYLE_BTN_INA)
type == LV_LIST_STYLE_BTN_TGL_REL || type == LV_LIST_STYLE_BTN_TGL_PR ||
type == LV_LIST_STYLE_BTN_INA)
{
lv_obj_t * liste = get_next_btn(list, NULL);
while(liste != NULL) {
lv_btn_set_style(liste, LV_BTN_STYLE_REL, ext->styles_btn[LV_BTN_STYLE_REL]);
lv_btn_set_style(liste, LV_BTN_STYLE_PR, ext->styles_btn[LV_BTN_STYLE_PR]);
lv_btn_set_style(liste, LV_BTN_STYLE_TGL_REL, ext->styles_btn[LV_BTN_STYLE_TGL_REL]);
lv_btn_set_style(liste, LV_BTN_STYLE_TGL_PR, ext->styles_btn[LV_BTN_STYLE_TGL_PR]);
lv_btn_set_style(liste, LV_BTN_STYLE_INA, ext->styles_btn[LV_BTN_STYLE_INA]);
liste = get_next_btn(list, liste);
btn= get_next_btn(list, NULL);
while(btn != NULL) {
lv_btn_set_style(btn, btn_style_refr, ext->styles_btn[btn_style_refr]);
btn = get_next_btn(list, btn);
}
}
}
@ -533,7 +536,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_RELEASE);
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_REL);
if(rel_action != NULL) rel_action(btn);
}
}

View File

@ -72,10 +72,10 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
lv_page_set_release_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_style_t * style_label = lv_obj_get_style(ext->ddlist.options_label);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
lv_ddlist_set_fix_height(new_roller, font_get_height_scale(style_label->text.font) * 3 + style_label->text.line_space * 4);
lv_label_set_align(ext->ddlist.options_label, LV_LABEL_ALIGN_CENTER);
lv_label_set_align(ext->ddlist.label, LV_LABEL_ALIGN_CENTER);
lv_obj_set_signal_func(scrl, lv_roller_scrl_signal);
lv_obj_refresh_style(new_roller); /*To set scrollable size automatically*/
@ -131,8 +131,8 @@ void lv_roller_set_style(lv_obj_t *roller, lv_roller_style_t type, lv_style_t *s
case LV_ROLLER_STYLE_BG:
lv_obj_set_style(roller, style);
break;
case LV_ROLLER_STYLE_SELECTED:
lv_ddlist_set_style(roller, LV_DDLIST_STYLE_SELECTED, style);
case LV_ROLLER_STYLE_SEL:
lv_ddlist_set_style(roller, LV_DDLIST_STYLE_SEL, style);
break;
}
}
@ -161,7 +161,7 @@ lv_style_t * lv_roller_get_style(lv_obj_t *roller, lv_roller_style_t type)
{
switch (type) {
case LV_ROLLER_STYLE_BG: return lv_obj_get_style(roller);
case LV_ROLLER_STYLE_SELECTED: return lv_ddlist_get_style(roller, LV_DDLIST_STYLE_SELECTED);
case LV_ROLLER_STYLE_SEL: return lv_ddlist_get_style(roller, LV_DDLIST_STYLE_SEL);
default: return NULL;
}
@ -204,7 +204,7 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
rect_area.x1 = roller->coords.x1;
rect_area.x2 = roller->coords.x2;
lv_draw_rect(&rect_area, mask, ext->ddlist.selected_style);
lv_draw_rect(&rect_area, mask, ext->ddlist.sel_style);
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
@ -222,11 +222,11 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
bool area_ok;
area_ok = area_union(&mask_sel, mask, &rect_area);
if(area_ok) {
lv_style_t *sel_style = lv_roller_get_style(roller, LV_ROLLER_STYLE_SELECTED);
lv_style_t *sel_style = lv_roller_get_style(roller, LV_ROLLER_STYLE_SEL);
lv_style_t new_style;
lv_style_copy(&new_style, style);
new_style.text.color = sel_style->text.color;
lv_draw_label(&ext->ddlist.options_label->coords, &mask_sel, &new_style, lv_label_get_text(ext->ddlist.options_label), TXT_FLAG_CENTER, NULL);
lv_draw_label(&ext->ddlist.label->coords, &mask_sel, &new_style, lv_label_get_text(ext->ddlist.label), TXT_FLAG_CENTER, NULL);
}
}
@ -252,9 +252,9 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_obj_set_height(lv_page_get_scrl(roller),
lv_obj_get_height(ext->ddlist.options_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.options_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.selected_option_id);
lv_obj_get_height(ext->ddlist.label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.sel_opt_id);
refr_position(roller, false);
} else if(sign == LV_SIGNAL_CORD_CHG) {
@ -263,10 +263,10 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
lv_ddlist_set_fix_height(roller, lv_obj_get_height(roller));
lv_obj_set_height(lv_page_get_scrl(roller),
lv_obj_get_height(ext->ddlist.options_label) + lv_obj_get_height(roller));
lv_obj_get_height(ext->ddlist.label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.options_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.selected_option_id);
lv_obj_align(ext->ddlist.label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.sel_opt_id);
refr_position(roller, false);
}
}
@ -293,30 +293,30 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
int32_t id = -1;
lv_obj_t * roller = lv_obj_get_parent(roller_scrl);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.options_label);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
const font_t * font = style_label->text.font;
cord_t font_h = font_get_height_scale(font);
if(sign == LV_SIGNAL_DRAG_END) {
/*If dragged then align the list to there be an element in the middle*/
cord_t label_y1 = ext->ddlist.options_label->coords.y1 - roller->coords.y1;
cord_t label_y1 = ext->ddlist.label->coords.y1 - roller->coords.y1;
cord_t label_unit = font_h + style_label->text.line_space;
cord_t mid = (roller->coords.y2 - roller->coords.y1) / 2;
id = (mid - label_y1 + style_label->text.line_space / 2) / label_unit;
if(id < 0) id = 0;
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
ext->ddlist.selected_option_id = id;
ext->ddlist.sel_opt_id = id;
}
else if(sign == LV_SIGNAL_RELEASED) {
/*If picked an option by clicking then set it*/
if(!lv_indev_is_dragging(indev)) {
point_t p;
lv_indev_get_point(indev, &p);
p.y = p.y - ext->ddlist.options_label->coords.y1;
p.y = p.y - ext->ddlist.label->coords.y1;
id = p.y / (font_h + style_label->text.line_space);
if(id < 0) id = 0;
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
ext->ddlist.selected_option_id = id;
ext->ddlist.sel_opt_id = id;
}
}
@ -393,12 +393,12 @@ static void refr_position(lv_obj_t *roller, bool anim_en)
{
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.options_label);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
const font_t * font = style_label->text.font;
cord_t font_h = font_get_height_scale(font);
cord_t h = lv_obj_get_height(roller);
int32_t id = ext->ddlist.selected_option_id;
cord_t line_y1 = id * (font_h + style_label->text.line_space) + ext->ddlist.options_label->coords.y1 - roller_scrl->coords.y1;
int32_t id = ext->ddlist.sel_opt_id;
cord_t line_y1 = id * (font_h + style_label->text.line_space) + ext->ddlist.label->coords.y1 - roller_scrl->coords.y1;
cord_t new_y = - line_y1 + (h - font_h) / 2;
if(ext->ddlist.anim_time == 0 || anim_en == false) {

View File

@ -34,7 +34,7 @@ typedef struct {
typedef enum {
LV_ROLLER_STYLE_BG,
LV_ROLLER_STYLE_SELECTED,
LV_ROLLER_STYLE_SEL,
}lv_roller_style_t;
/**********************

View File

@ -17,7 +17,7 @@
/*********************
* DEFINES
*********************/
#define LV_SLIDER_SIZE_MIN (2 << LV_ANTIALIAS) /*hpad and vpad cannot make the bar or indicator smaller then this [px]*/
#define LV_SLIDER_SIZE_MIN (2 << LV_ANTIALIAS) /*hpad and vpad cannot make the bar or indicator smaller then this [px]*/
#define LV_SLIDER_NOT_PRESSED INT16_MIN
/**********************
* TYPEDEFS

View File

@ -61,13 +61,13 @@ typedef struct
typedef enum {
LV_TABVIEW_STYLE_BG,
LV_TABVIEW_STYLE_INDIC,
LV_TABVIEW_STYLE_BTN_BG,
LV_TABVIEW_STYLE_BTN_REL,
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_INDIC,
}lv_tabview_style_t;
/**********************

View File

@ -58,8 +58,8 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
ext->header = NULL;
ext->title = NULL;
ext->style_header = &lv_style_plain_color;
ext->style_btn_rel = &lv_style_btn_rel;
ext->style_btn_pr = &lv_style_btn_pr;
ext->style_btn_rel = &lv_style_btn_released;
ext->style_btn_pr = &lv_style_btn_pressed;
ext->btn_size = ( LV_DPI) / 2;
/*Init the new window object*/
@ -141,7 +141,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_RELEASE, rel_action);
lv_btn_set_action(btn, LV_BTN_ACTION_REL, rel_action);
lv_obj_t * img = lv_img_create(btn, NULL);
lv_obj_set_click(img, false);