mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
Formatting all source file (*.c) in accordance with project coding style, using the astyle tool and the rules file _astylerc-c.
This commit is contained in:
parent
6038064e71
commit
8e9335d49f
@ -58,17 +58,17 @@ lv_group_t * lv_group_create(void)
|
||||
*/
|
||||
void lv_group_del(lv_group_t * group)
|
||||
{
|
||||
/*Defocus the the currently focused object*/
|
||||
/*Defocus the the currently focused object*/
|
||||
if(group->obj_focus != NULL) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
LL_READ(group->obj_ll, obj) {
|
||||
(*obj)->group_p = NULL;
|
||||
}
|
||||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
LL_READ(group->obj_ll, obj) {
|
||||
(*obj)->group_p = NULL;
|
||||
}
|
||||
|
||||
lv_ll_clear(&(group->obj_ll));
|
||||
lv_mem_free(group);
|
||||
@ -102,16 +102,16 @@ void lv_group_remove_obj(lv_obj_t * obj)
|
||||
{
|
||||
lv_group_t * g = obj->group_p;
|
||||
if(g == NULL) return;
|
||||
if(g->obj_focus == NULL) return; /*Just to be sure (Not possible if there is at least one object in the group)*/
|
||||
if(g->obj_focus == NULL) return; /*Just to be sure (Not possible if there is at least one object in the group)*/
|
||||
|
||||
if(*g->obj_focus == obj) {
|
||||
lv_group_focus_next(g);
|
||||
lv_group_focus_next(g);
|
||||
}
|
||||
|
||||
/* If the focuses object is still the same then it was the only object in the group but it will be deleted.
|
||||
* Set the `obj_focus` to NULL to get back to the initial state of the group with zero objects*/
|
||||
if(*g->obj_focus == obj) {
|
||||
g->obj_focus = NULL;
|
||||
g->obj_focus = NULL;
|
||||
}
|
||||
|
||||
/*Search the object and remove it from its group */
|
||||
@ -146,7 +146,7 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
||||
|
||||
g->obj_focus = i;
|
||||
|
||||
if(g->obj_focus != NULL){
|
||||
if(g->obj_focus != NULL) {
|
||||
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*g->obj_focus);
|
||||
}
|
||||
@ -175,7 +175,7 @@ void lv_group_focus_next(lv_group_t * group)
|
||||
if(obj_next == NULL) obj_next = lv_ll_get_head(&group->obj_ll);
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus){
|
||||
if(group->obj_focus) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
|
||||
@ -203,7 +203,7 @@ void lv_group_focus_prev(lv_group_t * group)
|
||||
if(obj_next == NULL) obj_next = lv_ll_get_tail(&group->obj_ll);
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus != NULL){
|
||||
if(group->obj_focus != NULL) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
|
||||
@ -241,7 +241,7 @@ void lv_group_send_data(lv_group_t * group, uint32_t c)
|
||||
* @param group pointer to a group
|
||||
* @param style_mod_func the style modifier function pointer
|
||||
*/
|
||||
void lv_group_set_style_mod_cb(lv_group_t * group,lv_group_style_mod_func_t style_mod_func)
|
||||
void lv_group_set_style_mod_cb(lv_group_t * group, lv_group_style_mod_func_t style_mod_func)
|
||||
{
|
||||
group->style_mod = style_mod_func;
|
||||
if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus);
|
||||
|
@ -45,7 +45,7 @@ static void indev_drag_throw(lv_indev_proc_t * state);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_indev_t *indev_act;
|
||||
static lv_indev_t * indev_act;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -110,10 +110,10 @@ void lv_indev_reset_lpr(lv_indev_t * indev)
|
||||
*/
|
||||
void lv_indev_enable(lv_hal_indev_type_t type, bool enable)
|
||||
{
|
||||
lv_indev_t *i = lv_indev_next(NULL);
|
||||
lv_indev_t * i = lv_indev_next(NULL);
|
||||
|
||||
while (i) {
|
||||
if (i->driver.type == type) i->proc.disabled = enable == false ? 1 : 0;
|
||||
while(i) {
|
||||
if(i->driver.type == type) i->proc.disabled = enable == false ? 1 : 0;
|
||||
i = lv_indev_next(i);
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ void lv_indev_enable(lv_hal_indev_type_t type, bool enable)
|
||||
* @param indev pointer to an input device
|
||||
* @param cur_obj pointer to an object to be used as cursor
|
||||
*/
|
||||
void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)
|
||||
void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
|
||||
{
|
||||
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) return;
|
||||
|
||||
@ -138,7 +138,7 @@ void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)
|
||||
* @param indev pointer to an input device
|
||||
* @param group point to a group
|
||||
*/
|
||||
void lv_indev_set_group(lv_indev_t *indev, lv_group_t *group)
|
||||
void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group)
|
||||
{
|
||||
if(indev->driver.type == LV_INDEV_TYPE_KEYPAD) indev->group = group;
|
||||
}
|
||||
@ -150,7 +150,7 @@ void lv_indev_set_group(lv_indev_t *indev, lv_group_t *group)
|
||||
* @param indev pointer to an input device
|
||||
* @param group point to a group
|
||||
*/
|
||||
void lv_indev_set_button_points(lv_indev_t *indev, lv_point_t *points)
|
||||
void lv_indev_set_button_points(lv_indev_t * indev, lv_point_t * points)
|
||||
{
|
||||
if(indev->driver.type == LV_INDEV_TYPE_BUTTON) indev->btn_points = points;
|
||||
}
|
||||
@ -210,7 +210,7 @@ uint32_t lv_indev_get_inactive_time(lv_indev_t * indev)
|
||||
|
||||
if(indev) return t = lv_tick_elaps(indev->last_activity_time);
|
||||
|
||||
lv_indev_t *i;
|
||||
lv_indev_t * i;
|
||||
t = UINT16_MAX;
|
||||
i = lv_indev_next(NULL);
|
||||
while(i) {
|
||||
@ -266,12 +266,10 @@ static void indev_proc_task(void * param)
|
||||
}
|
||||
|
||||
if(i->driver.type == LV_INDEV_TYPE_POINTER) {
|
||||
indev_pointer_proc(i,&data);
|
||||
}
|
||||
else if(i->driver.type == LV_INDEV_TYPE_KEYPAD) {
|
||||
indev_pointer_proc(i, &data);
|
||||
} else if(i->driver.type == LV_INDEV_TYPE_KEYPAD) {
|
||||
indev_keypad_proc(i, &data);
|
||||
}
|
||||
else if(i->driver.type == LV_INDEV_TYPE_BUTTON) {
|
||||
} else if(i->driver.type == LV_INDEV_TYPE_BUTTON) {
|
||||
indev_button_proc(i, &data);
|
||||
}
|
||||
/*Handle reset query if it happened in during processing*/
|
||||
@ -294,24 +292,23 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
{
|
||||
/*Move the cursor if set and moved*/
|
||||
if(i->cursor != NULL &&
|
||||
(i->proc.last_point.x != data->point.x ||
|
||||
i->proc.last_point.y != data->point.y))
|
||||
{
|
||||
(i->proc.last_point.x != data->point.x ||
|
||||
i->proc.last_point.y != data->point.y)) {
|
||||
lv_obj_set_pos(i->cursor, data->point.x, data->point.y);
|
||||
}
|
||||
|
||||
i->proc.act_point.x = data->point.x;
|
||||
i->proc.act_point.y = data->point.y;
|
||||
|
||||
if(i->proc.state == LV_INDEV_STATE_PR){
|
||||
#if LV_INDEV_POINT_MARKER != 0
|
||||
if(i->proc.state == LV_INDEV_STATE_PR) {
|
||||
#if LV_INDEV_POINT_MARKER != 0
|
||||
lv_area_t area;
|
||||
area.x1 = i->proc.act_point.x - (LV_INDEV_POINT_MARKER >> 1);
|
||||
area.y1 = i->proc.act_point.y - (LV_INDEV_POINT_MARKER >> 1);
|
||||
area.x2 = i->proc.act_point.x + ((LV_INDEV_POINT_MARKER >> 1) | 0x1);
|
||||
area.y2 = i->proc.act_point.y + ((LV_INDEV_POINT_MARKER >> 1) | 0x1);
|
||||
lv_rfill(&area, NULL, LV_COLOR_MAKE(0xFF, 0, 0), LV_OPA_COVER);
|
||||
#endif
|
||||
#endif
|
||||
indev_proc_press(&i->proc);
|
||||
} else {
|
||||
indev_proc_release(&i->proc);
|
||||
@ -333,16 +330,14 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
|
||||
/*Key press happened*/
|
||||
if(data->state == LV_INDEV_STATE_PR &&
|
||||
i->proc.last_state == LV_INDEV_STATE_REL)
|
||||
{
|
||||
i->proc.last_state == LV_INDEV_STATE_REL) {
|
||||
i->proc.pr_timestamp = lv_tick_get();
|
||||
}
|
||||
/*Pressing*/
|
||||
else if(data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_PR) {
|
||||
if(data->key == LV_GROUP_KEY_ENTER &&
|
||||
i->proc.long_pr_sent == 0 &&
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME)
|
||||
{
|
||||
i->proc.long_pr_sent == 0 &&
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
|
||||
|
||||
lv_group_send_data(i->group, LV_GROUP_KEY_ENTER_LONG);
|
||||
i->proc.long_pr_sent = 1;
|
||||
@ -350,24 +345,21 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Release happened*/
|
||||
else if(data->state == LV_INDEV_STATE_REL && i->proc.last_state == LV_INDEV_STATE_PR)
|
||||
{
|
||||
else if(data->state == LV_INDEV_STATE_REL && i->proc.last_state == LV_INDEV_STATE_PR) {
|
||||
/*The user might clear the key it was released. Always release the pressed key*/
|
||||
data->key = i->proc.last_key;
|
||||
|
||||
if(data->key == LV_GROUP_KEY_NEXT) {
|
||||
lv_group_focus_next(i->group);
|
||||
}
|
||||
else if(data->key == LV_GROUP_KEY_PREV) {
|
||||
lv_group_focus_next(i->group);
|
||||
} else if(data->key == LV_GROUP_KEY_PREV) {
|
||||
lv_group_focus_prev(i->group);
|
||||
}
|
||||
else if(data->key == LV_GROUP_KEY_ENTER && i->proc.long_pr_sent) {
|
||||
} else if(data->key == LV_GROUP_KEY_ENTER && i->proc.long_pr_sent) {
|
||||
/*Do nothing. Don't send the ENTER if ENTER_LONG was sent*/
|
||||
} else {
|
||||
lv_group_send_data(i->group, data->key);
|
||||
lv_group_send_data(i->group, data->key);
|
||||
}
|
||||
|
||||
if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/
|
||||
if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/
|
||||
|
||||
i->proc.pr_timestamp = 0;
|
||||
i->proc.long_pr_sent = 0;
|
||||
@ -392,8 +384,8 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
|
||||
/*Still the same point is pressed*/
|
||||
if(i->proc.last_point.x == i->proc.act_point.x &&
|
||||
i->proc.last_point.y == i->proc.act_point.y &&
|
||||
data->state == LV_INDEV_STATE_PR) {
|
||||
i->proc.last_point.y == i->proc.act_point.y &&
|
||||
data->state == LV_INDEV_STATE_PR) {
|
||||
#if LV_INDEV_POINT_MARKER != 0
|
||||
lv_area_t area;
|
||||
area.x1 = i->proc.act_point.x - (LV_INDEV_POINT_MARKER >> 1);
|
||||
@ -463,15 +455,15 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
/*Search for 'top' attribute*/
|
||||
lv_obj_t * i = pr_obj;
|
||||
lv_obj_t * last_top = NULL;
|
||||
while(i != NULL){
|
||||
if(i->top != 0) last_top = i;
|
||||
i = lv_obj_get_parent(i);
|
||||
while(i != NULL) {
|
||||
if(i->top != 0) last_top = i;
|
||||
i = lv_obj_get_parent(i);
|
||||
}
|
||||
|
||||
if(last_top != NULL) {
|
||||
/*Move the last_top object to the foreground*/
|
||||
lv_obj_t * par = lv_obj_get_parent(last_top);
|
||||
/*After list change it will be the new head*/
|
||||
/*Move the last_top object to the foreground*/
|
||||
lv_obj_t * par = lv_obj_get_parent(last_top);
|
||||
/*After list change it will be the new head*/
|
||||
lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top);
|
||||
lv_obj_invalidate(last_top);
|
||||
}
|
||||
@ -604,13 +596,13 @@ static lv_obj_t * indev_search_obj(const lv_indev_proc_t * indev, lv_obj_t * obj
|
||||
/*If then the children was not ok, and this obj is clickable
|
||||
* and it or its parent is not hidden then save this object*/
|
||||
if(found_p == NULL && lv_obj_get_click(obj) != false) {
|
||||
lv_obj_t * hidden_i = obj;
|
||||
while(hidden_i != NULL) {
|
||||
if(lv_obj_get_hidden(hidden_i) == true) break;
|
||||
hidden_i = lv_obj_get_parent(hidden_i);
|
||||
}
|
||||
/*No parent found with hidden == true*/
|
||||
if(hidden_i == NULL) found_p = obj;
|
||||
lv_obj_t * hidden_i = obj;
|
||||
while(hidden_i != NULL) {
|
||||
if(lv_obj_get_hidden(hidden_i) == true) break;
|
||||
hidden_i = lv_obj_get_parent(hidden_i);
|
||||
}
|
||||
/*No parent found with hidden == true*/
|
||||
if(hidden_i == NULL) found_p = obj;
|
||||
}
|
||||
|
||||
}
|
||||
@ -627,12 +619,12 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
lv_obj_t * drag_obj = state->act_obj;
|
||||
|
||||
/*If drag parent is active check recursively the drag_parent attribute*/
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
|
||||
if(drag_obj == NULL) return;
|
||||
if(drag_obj == NULL) return;
|
||||
|
||||
if(lv_obj_get_drag(drag_obj) == false) return;
|
||||
|
||||
@ -643,17 +635,16 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
|
||||
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
|
||||
if(LV_MATH_ABS(state->drag_sum.x) >= LV_INDEV_DRAG_LIMIT ||
|
||||
LV_MATH_ABS(state->drag_sum.y) >= LV_INDEV_DRAG_LIMIT)
|
||||
{
|
||||
state->drag_range_out = 1;
|
||||
}
|
||||
LV_MATH_ABS(state->drag_sum.y) >= LV_INDEV_DRAG_LIMIT) {
|
||||
state->drag_range_out = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*If the drag limit is stepped over then handle the dragging*/
|
||||
if(state->drag_range_out != 0) {
|
||||
/*Set new position if the vector is not zero*/
|
||||
if(state->vect.x != 0 ||
|
||||
state->vect.y != 0) {
|
||||
state->vect.y != 0) {
|
||||
/*Get the coordinates of the object and modify them*/
|
||||
lv_coord_t act_x = lv_obj_get_x(drag_obj);
|
||||
lv_coord_t act_y = lv_obj_get_y(drag_obj);
|
||||
@ -688,33 +679,32 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
*/
|
||||
static void indev_drag_throw(lv_indev_proc_t * state)
|
||||
{
|
||||
if(state->drag_in_prog == 0) return;
|
||||
if(state->drag_in_prog == 0) return;
|
||||
|
||||
/*Set new position if the vector is not zero*/
|
||||
lv_obj_t * drag_obj = state->last_obj;
|
||||
|
||||
/*If drag parent is active check recursively the drag_parent attribute*/
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
|
||||
if(drag_obj == NULL) return;
|
||||
if(drag_obj == NULL) return;
|
||||
|
||||
/*Return if the drag throw is not enabled*/
|
||||
if(lv_obj_get_drag_throw(drag_obj) == false ){
|
||||
state->drag_in_prog = 0;
|
||||
if(lv_obj_get_drag_throw(drag_obj) == false) {
|
||||
state->drag_in_prog = 0;
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
return;
|
||||
}
|
||||
|
||||
/*Reduce the vectors*/
|
||||
state->vect.x = state->vect.x * (100 -LV_INDEV_DRAG_THROW) / 100;
|
||||
state->vect.y = state->vect.y * (100 -LV_INDEV_DRAG_THROW) / 100;
|
||||
state->vect.x = state->vect.x * (100 - LV_INDEV_DRAG_THROW) / 100;
|
||||
state->vect.y = state->vect.y * (100 - LV_INDEV_DRAG_THROW) / 100;
|
||||
|
||||
if(state->vect.x != 0 ||
|
||||
state->vect.y != 0)
|
||||
{
|
||||
state->vect.y != 0) {
|
||||
/*Get the coordinates and modify them*/
|
||||
lv_coord_t act_x = lv_obj_get_x(drag_obj) + state->vect.x;
|
||||
lv_coord_t act_y = lv_obj_get_y(drag_obj) + state->vect.y;
|
||||
@ -722,7 +712,7 @@ static void indev_drag_throw(lv_indev_proc_t * state)
|
||||
|
||||
/*If non of the coordinates are changed then do not continue throwing*/
|
||||
if((lv_obj_get_x(drag_obj) != act_x || state->vect.x == 0) &&
|
||||
(lv_obj_get_y(drag_obj) != act_y || state->vect.y == 0)) {
|
||||
(lv_obj_get_y(drag_obj) != act_y || state->vect.y == 0)) {
|
||||
state->drag_in_prog = 0;
|
||||
state->vect.x = 0;
|
||||
state->vect.y = 0;
|
||||
|
371
lv_core/lv_obj.c
371
lv_core/lv_obj.c
@ -124,27 +124,27 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->par = NULL; /*Screens has no a parent*/
|
||||
lv_ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
||||
|
||||
/*Set coordinates to full screen size*/
|
||||
new_obj->coords.x1 = 0;
|
||||
new_obj->coords.y1 = 0;
|
||||
new_obj->coords.x2 = LV_HOR_RES - 1;
|
||||
new_obj->coords.y2 = LV_VER_RES - 1;
|
||||
new_obj->ext_size = 0;
|
||||
/*Set coordinates to full screen size*/
|
||||
new_obj->coords.x1 = 0;
|
||||
new_obj->coords.y1 = 0;
|
||||
new_obj->coords.x2 = LV_HOR_RES - 1;
|
||||
new_obj->coords.y2 = LV_VER_RES - 1;
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
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);
|
||||
/*Set virtual functions*/
|
||||
lv_obj_set_signal_func(new_obj, lv_obj_signal);
|
||||
lv_obj_set_design_func(new_obj, lv_obj_design);
|
||||
|
||||
/*Set free data*/
|
||||
/*Set free data*/
|
||||
#ifdef LV_OBJ_FREE_NUM_TYPE
|
||||
new_obj->free_num = 0;
|
||||
new_obj->free_num = 0;
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_PTR != 0
|
||||
@ -154,20 +154,19 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
#if USE_LV_GROUP
|
||||
new_obj->group_p = NULL;
|
||||
#endif
|
||||
/*Set attributes*/
|
||||
new_obj->click = 0;
|
||||
new_obj->drag = 0;
|
||||
new_obj->drag_throw = 0;
|
||||
new_obj->drag_parent = 0;
|
||||
new_obj->hidden = 0;
|
||||
new_obj->top = 0;
|
||||
/*Set attributes*/
|
||||
new_obj->click = 0;
|
||||
new_obj->drag = 0;
|
||||
new_obj->drag_throw = 0;
|
||||
new_obj->drag_parent = 0;
|
||||
new_obj->hidden = 0;
|
||||
new_obj->top = 0;
|
||||
new_obj->protect = LV_PROTECT_NONE;
|
||||
|
||||
new_obj->ext_attr = NULL;
|
||||
}
|
||||
new_obj->ext_attr = NULL;
|
||||
}
|
||||
/*parent != NULL create normal obj. on a parent*/
|
||||
else
|
||||
{
|
||||
else {
|
||||
new_obj = lv_ll_ins_head(&(parent)->child_ll);
|
||||
|
||||
new_obj->par = parent; /*Set the parent*/
|
||||
@ -177,9 +176,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->coords.x1 = parent->coords.x1;
|
||||
new_obj->coords.y1 = parent->coords.y1;
|
||||
new_obj->coords.x2 = parent->coords.x1 +
|
||||
LV_OBJ_DEF_WIDTH;
|
||||
LV_OBJ_DEF_WIDTH;
|
||||
new_obj->coords.y2 = parent->coords.y1 +
|
||||
LV_OBJ_DEF_HEIGHT;
|
||||
LV_OBJ_DEF_HEIGHT;
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Set appearance*/
|
||||
@ -213,8 +212,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
}
|
||||
|
||||
if(copy != NULL) {
|
||||
lv_area_copy(&new_obj->coords, ©->coords);
|
||||
new_obj->ext_size = copy->ext_size;
|
||||
lv_area_copy(&new_obj->coords, ©->coords);
|
||||
new_obj->ext_size = copy->ext_size;
|
||||
|
||||
/*Set free data*/
|
||||
#ifdef LV_OBJ_FREE_NUM_TYPE
|
||||
@ -223,7 +222,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
#if LV_OBJ_FREE_PTR != 0
|
||||
new_obj->free_ptr = copy->free_ptr;
|
||||
#endif
|
||||
/*Set attributes*/
|
||||
/*Set attributes*/
|
||||
new_obj->click = copy->click;
|
||||
new_obj->drag = copy->drag;
|
||||
new_obj->drag_throw = copy->drag_throw;
|
||||
@ -241,7 +240,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
|
||||
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
|
||||
}
|
||||
|
||||
|
||||
@ -266,9 +265,9 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
/*Delete from the group*/
|
||||
#if USE_LV_GROUP
|
||||
#if USE_LV_GROUP
|
||||
if(obj->group_p != NULL) lv_group_remove_obj(obj);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Remove the animations from this object*/
|
||||
#if USE_LV_ANIMATION
|
||||
@ -293,19 +292,19 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||
/*Remove the object from parent's children list*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
if(par == NULL) { /*It is a screen*/
|
||||
lv_ll_rem(&scr_ll, obj);
|
||||
lv_ll_rem(&scr_ll, obj);
|
||||
} else {
|
||||
lv_ll_rem(&(par->child_ll), obj);
|
||||
lv_ll_rem(&(par->child_ll), obj);
|
||||
}
|
||||
|
||||
/* Reset all input devices if
|
||||
* the currently pressed object is deleted*/
|
||||
lv_indev_t * indev = lv_indev_next(NULL);
|
||||
while(indev) {
|
||||
if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) {
|
||||
lv_indev_reset(indev);
|
||||
}
|
||||
indev = lv_indev_next(indev);
|
||||
if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) {
|
||||
lv_indev_reset(indev);
|
||||
}
|
||||
indev = lv_indev_next(indev);
|
||||
}
|
||||
|
||||
/* All children deleted.
|
||||
@ -318,7 +317,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||
|
||||
/*Send a signal to the parent to notify it about the child delete*/
|
||||
if(par != NULL) {
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
|
||||
return LV_RES_INV;
|
||||
@ -328,9 +327,9 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||
* Delete all children of an object
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_clean(lv_obj_t *obj)
|
||||
void lv_obj_clean(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t *child = lv_obj_get_child(obj, NULL);
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
|
||||
while(child) {
|
||||
lv_obj_del(child);
|
||||
@ -344,14 +343,13 @@ void lv_obj_clean(lv_obj_t *obj)
|
||||
*/
|
||||
void lv_obj_invalidate(lv_obj_t * obj)
|
||||
{
|
||||
if(lv_obj_get_hidden(obj)) return;
|
||||
if(lv_obj_get_hidden(obj)) return;
|
||||
|
||||
/*Invalidate the object only if it belongs to the 'act_scr'*/
|
||||
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
|
||||
if(obj_scr == lv_scr_act() ||
|
||||
obj_scr == lv_layer_top() ||
|
||||
obj_scr == lv_layer_sys())
|
||||
{
|
||||
obj_scr == lv_layer_top() ||
|
||||
obj_scr == lv_layer_sys()) {
|
||||
/*Truncate recursively to the parents*/
|
||||
lv_area_t area_trunc;
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
@ -367,8 +365,8 @@ void lv_obj_invalidate(lv_obj_t * obj)
|
||||
/*Check through all parents*/
|
||||
while(par != NULL) {
|
||||
union_ok = lv_area_union(&area_trunc, &area_trunc, &par->coords);
|
||||
if(union_ok == false) break; /*If no common parts with parent break;*/
|
||||
if(lv_obj_get_hidden(par)) return; /*If the parent is hidden then the child is hidden and won't be drawn*/
|
||||
if(union_ok == false) break; /*If no common parts with parent break;*/
|
||||
if(lv_obj_get_hidden(par)) return; /*If the parent is hidden then the child is hidden and won't be drawn*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
@ -514,9 +512,9 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
|
||||
/* Do nothing if the size is not changed */
|
||||
/* It is very important else recursive resizing can
|
||||
* occur without size change*/
|
||||
if(lv_obj_get_width(obj) == w && lv_obj_get_height(obj) == h) {
|
||||
return;
|
||||
}
|
||||
if(lv_obj_get_width(obj) == w && lv_obj_get_height(obj) == h) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*Invalidate the original area*/
|
||||
lv_obj_invalidate(obj);
|
||||
@ -569,7 +567,7 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h)
|
||||
* @param x_mod x coordinate shift after alignment
|
||||
* @param y_mod y coordinate shift after alignment
|
||||
*/
|
||||
void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
|
||||
void lv_obj_align(lv_obj_t * obj, lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
|
||||
{
|
||||
lv_coord_t new_x = lv_obj_get_x(obj);
|
||||
lv_coord_t new_y = lv_obj_get_y(obj);
|
||||
@ -578,8 +576,7 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, lv_coord_t x
|
||||
base = lv_obj_get_parent(obj);
|
||||
}
|
||||
|
||||
switch(align)
|
||||
{
|
||||
switch(align) {
|
||||
case LV_ALIGN_CENTER:
|
||||
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
@ -588,7 +585,7 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, lv_coord_t x
|
||||
case LV_ALIGN_IN_TOP_LEFT:
|
||||
new_x = 0;
|
||||
new_y = 0;
|
||||
break;
|
||||
break;
|
||||
case LV_ALIGN_IN_TOP_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
new_y = 0;
|
||||
@ -602,7 +599,7 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, lv_coord_t x
|
||||
case LV_ALIGN_IN_BOTTOM_LEFT:
|
||||
new_x = 0;
|
||||
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
break;
|
||||
case LV_ALIGN_IN_BOTTOM_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
@ -616,72 +613,72 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, lv_coord_t x
|
||||
case LV_ALIGN_IN_LEFT_MID:
|
||||
new_x = 0;
|
||||
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_RIGHT_MID:
|
||||
new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_LEFT:
|
||||
new_x = 0;
|
||||
new_y = -lv_obj_get_height(obj);
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
new_y = - lv_obj_get_height(obj);
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
new_y = - lv_obj_get_height(obj);
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_LEFT:
|
||||
new_x = 0;
|
||||
new_y = lv_obj_get_height(base);
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
new_y = lv_obj_get_height(base);
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
new_y = lv_obj_get_height(base);
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_TOP:
|
||||
new_x = - lv_obj_get_width(obj);
|
||||
new_y = 0;
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_MID:
|
||||
new_x = - lv_obj_get_width(obj);
|
||||
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_BOTTOM:
|
||||
new_x = - lv_obj_get_width(obj);
|
||||
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_TOP:
|
||||
new_x = lv_obj_get_width(base);
|
||||
new_y = 0;
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_MID:
|
||||
new_x = lv_obj_get_width(base);
|
||||
new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
||||
new_x = lv_obj_get_width(base);
|
||||
new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/*Bring together the coordination system of base and obj*/
|
||||
@ -692,10 +689,10 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, lv_coord_t x
|
||||
lv_coord_t par_abs_y = par->coords.y1;
|
||||
new_x += x_mod + base_abs_x;
|
||||
new_y += y_mod + base_abs_y;
|
||||
new_x -= par_abs_x;
|
||||
new_y -= par_abs_y;
|
||||
new_x -= par_abs_x;
|
||||
new_y -= par_abs_y;
|
||||
|
||||
lv_obj_set_pos(obj, new_x, new_y);
|
||||
lv_obj_set_pos(obj, new_x, new_y);
|
||||
}
|
||||
|
||||
/*---------------------
|
||||
@ -755,11 +752,11 @@ void lv_obj_report_style_mod(lv_style_t * style)
|
||||
*/
|
||||
void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
||||
{
|
||||
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
|
||||
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
|
||||
|
||||
obj->hidden = en == false ? 0 : 1;
|
||||
|
||||
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
|
||||
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
|
||||
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
@ -873,9 +870,9 @@ void lv_obj_set_design_func(lv_obj_t * obj, lv_design_func_t fp)
|
||||
*/
|
||||
void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size)
|
||||
{
|
||||
obj->ext_attr = lv_mem_realloc(obj->ext_attr, ext_size);
|
||||
obj->ext_attr = lv_mem_realloc(obj->ext_attr, ext_size);
|
||||
|
||||
return (void*)obj->ext_attr;
|
||||
return (void *)obj->ext_attr;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -884,10 +881,10 @@ void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size)
|
||||
*/
|
||||
void lv_obj_refresh_ext_size(lv_obj_t * obj)
|
||||
{
|
||||
obj->ext_size = 0;
|
||||
obj->signal_func(obj, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
obj->ext_size = 0;
|
||||
obj->signal_func(obj, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
#ifdef LV_OBJ_FREE_NUM_TYPE
|
||||
@ -925,74 +922,74 @@ void lv_obj_set_free_ptr(lv_obj_t * obj, void * free_p)
|
||||
* @param delay delay before the animation in milliseconds
|
||||
* @param cb a function to call when the animation is ready
|
||||
*/
|
||||
void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t delay, void (*cb) (lv_obj_t *))
|
||||
void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t delay, void (*cb)(lv_obj_t *))
|
||||
{
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
|
||||
/*Get the direction*/
|
||||
bool out = (type & LV_ANIM_DIR_MASK) == LV_ANIM_IN ? false : true;
|
||||
type = type & (~LV_ANIM_DIR_MASK);
|
||||
/*Get the direction*/
|
||||
bool out = (type & LV_ANIM_DIR_MASK) == LV_ANIM_IN ? false : true;
|
||||
type = type & (~LV_ANIM_DIR_MASK);
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = obj;
|
||||
a.time = time;
|
||||
a.act_time = (int32_t)-delay;
|
||||
a.end_cb = (void(*)(void*))cb;
|
||||
a.path = lv_anim_path_linear;
|
||||
a.playback_pause = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 0;
|
||||
a.repeat = 0;
|
||||
lv_anim_t a;
|
||||
a.var = obj;
|
||||
a.time = time;
|
||||
a.act_time = (int32_t) - delay;
|
||||
a.end_cb = (void(*)(void *))cb;
|
||||
a.path = lv_anim_path_linear;
|
||||
a.playback_pause = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 0;
|
||||
a.repeat = 0;
|
||||
|
||||
/*Init to ANIM_IN*/
|
||||
switch(type) {
|
||||
case LV_ANIM_FLOAT_LEFT:
|
||||
a.fp = (void(*)(void *, int32_t))lv_obj_set_x;
|
||||
a.start = -lv_obj_get_width(obj);
|
||||
a.end = lv_obj_get_x(obj);
|
||||
break;
|
||||
case LV_ANIM_FLOAT_RIGHT:
|
||||
a.fp = (void(*)(void *, int32_t))lv_obj_set_x;
|
||||
a.start = lv_obj_get_width(par);
|
||||
a.end = lv_obj_get_x(obj);
|
||||
break;
|
||||
case LV_ANIM_FLOAT_TOP:
|
||||
a.fp = (void(*)(void * , int32_t))lv_obj_set_y;
|
||||
a.start = -lv_obj_get_height(obj);
|
||||
a.end = lv_obj_get_y(obj);
|
||||
break;
|
||||
case LV_ANIM_FLOAT_BOTTOM:
|
||||
a.fp = (void(*)(void * , int32_t))lv_obj_set_y;
|
||||
a.start = lv_obj_get_height(par);
|
||||
a.end = lv_obj_get_y(obj);
|
||||
break;
|
||||
case LV_ANIM_GROW_H:
|
||||
a.fp = (void(*)(void * , int32_t))lv_obj_set_width;
|
||||
a.start = 0;
|
||||
a.end = lv_obj_get_width(obj);
|
||||
break;
|
||||
case LV_ANIM_GROW_V:
|
||||
a.fp = (void(*)(void * , int32_t))lv_obj_set_height;
|
||||
a.start = 0;
|
||||
a.end = lv_obj_get_height(obj);
|
||||
break;
|
||||
/*Init to ANIM_IN*/
|
||||
switch(type) {
|
||||
case LV_ANIM_FLOAT_LEFT:
|
||||
a.fp = (void(*)(void *, int32_t))lv_obj_set_x;
|
||||
a.start = -lv_obj_get_width(obj);
|
||||
a.end = lv_obj_get_x(obj);
|
||||
break;
|
||||
case LV_ANIM_FLOAT_RIGHT:
|
||||
a.fp = (void(*)(void *, int32_t))lv_obj_set_x;
|
||||
a.start = lv_obj_get_width(par);
|
||||
a.end = lv_obj_get_x(obj);
|
||||
break;
|
||||
case LV_ANIM_FLOAT_TOP:
|
||||
a.fp = (void(*)(void *, int32_t))lv_obj_set_y;
|
||||
a.start = -lv_obj_get_height(obj);
|
||||
a.end = lv_obj_get_y(obj);
|
||||
break;
|
||||
case LV_ANIM_FLOAT_BOTTOM:
|
||||
a.fp = (void(*)(void *, int32_t))lv_obj_set_y;
|
||||
a.start = lv_obj_get_height(par);
|
||||
a.end = lv_obj_get_y(obj);
|
||||
break;
|
||||
case LV_ANIM_GROW_H:
|
||||
a.fp = (void(*)(void *, int32_t))lv_obj_set_width;
|
||||
a.start = 0;
|
||||
a.end = lv_obj_get_width(obj);
|
||||
break;
|
||||
case LV_ANIM_GROW_V:
|
||||
a.fp = (void(*)(void *, int32_t))lv_obj_set_height;
|
||||
a.start = 0;
|
||||
a.end = lv_obj_get_height(obj);
|
||||
break;
|
||||
case LV_ANIM_NONE:
|
||||
a.fp = NULL;
|
||||
a.start = 0;
|
||||
a.end = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*Swap start and end in case of ANIM OUT*/
|
||||
if(out != false) {
|
||||
int32_t tmp = a.start;
|
||||
a.start = a.end;
|
||||
a.end = tmp;
|
||||
}
|
||||
/*Swap start and end in case of ANIM OUT*/
|
||||
if(out != false) {
|
||||
int32_t tmp = a.start;
|
||||
a.start = a.end;
|
||||
a.end = tmp;
|
||||
}
|
||||
|
||||
lv_anim_create(&a);
|
||||
lv_anim_create(&a);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1046,8 +1043,7 @@ lv_obj_t * lv_obj_get_screen(lv_obj_t * obj)
|
||||
do {
|
||||
act_p = par;
|
||||
par = lv_obj_get_parent(act_p);
|
||||
}
|
||||
while(par != NULL);
|
||||
} while(par != NULL);
|
||||
|
||||
return act_p;
|
||||
}
|
||||
@ -1075,13 +1071,13 @@ lv_obj_t * lv_obj_get_parent(lv_obj_t * obj)
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child)
|
||||
{
|
||||
if(child == NULL) {
|
||||
return lv_ll_get_head(&obj->child_ll);
|
||||
} else {
|
||||
return lv_ll_get_next(&obj->child_ll, child);
|
||||
}
|
||||
if(child == NULL) {
|
||||
return lv_ll_get_head(&obj->child_ll);
|
||||
} else {
|
||||
return lv_ll_get_next(&obj->child_ll, child);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1109,12 +1105,12 @@ lv_obj_t * lv_obj_get_child_back(lv_obj_t * obj, lv_obj_t * child)
|
||||
*/
|
||||
uint16_t lv_obj_count_children(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
uint16_t cnt = 0;
|
||||
lv_obj_t * i;
|
||||
uint16_t cnt = 0;
|
||||
|
||||
LL_READ(obj->child_ll, i) cnt++;
|
||||
LL_READ(obj->child_ll, i) cnt++;
|
||||
|
||||
return cnt;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/*---------------------
|
||||
@ -1212,7 +1208,7 @@ lv_style_t * lv_obj_get_style(lv_obj_t * obj)
|
||||
style_act = par->style_p;
|
||||
#else
|
||||
/*Is a parent is focused then use then focused style*/
|
||||
lv_group_t *g = lv_obj_get_group(par);
|
||||
lv_group_t * g = lv_obj_get_group(par);
|
||||
if(lv_group_get_focused(g) == par) {
|
||||
style_act = lv_group_mod_style(g, par->style_p);
|
||||
} else {
|
||||
@ -1355,7 +1351,7 @@ lv_design_func_t lv_obj_get_design_func(lv_obj_t * obj)
|
||||
*/
|
||||
void * lv_obj_get_ext_attr(lv_obj_t * obj)
|
||||
{
|
||||
return obj->ext_attr;
|
||||
return obj->ext_attr;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1464,8 +1460,8 @@ static bool lv_obj_design(lv_obj_t * obj, const lv_area_t * mask_p, lv_design_m
|
||||
if(lv_area_is_in(mask_p, &area_tmp) == false) return false;
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
lv_draw_rect(&obj->coords, mask_p, style);
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
lv_draw_rect(&obj->coords, mask_p, style);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1488,14 +1484,11 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
if(sign == LV_SIGNAL_CHILD_CHG) {
|
||||
/*Return 'invalid' if the child change signal is not enabled*/
|
||||
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) res = LV_RES_INV;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
if(style->body.shadow.width > obj->ext_size) obj->ext_size = style->body.shadow.width;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_obj_refresh_ext_size(obj);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
buf->type[0] = "lv_obj";
|
||||
}
|
||||
@ -1567,49 +1560,49 @@ static void refresh_childen_style(lv_obj_t * obj)
|
||||
*/
|
||||
static void delete_children(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * i_next;
|
||||
i = lv_ll_get_head(&(obj->child_ll));
|
||||
while(i != NULL) {
|
||||
/*Get the next object before delete this*/
|
||||
i_next = lv_ll_get_next(&(obj->child_ll), i);
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * i_next;
|
||||
i = lv_ll_get_head(&(obj->child_ll));
|
||||
while(i != NULL) {
|
||||
/*Get the next object before delete this*/
|
||||
i_next = lv_ll_get_next(&(obj->child_ll), i);
|
||||
|
||||
/*Call the recursive del to the child too*/
|
||||
delete_children(i);
|
||||
/*Call the recursive del to the child too*/
|
||||
delete_children(i);
|
||||
|
||||
/*Set i to the next node*/
|
||||
i = i_next;
|
||||
}
|
||||
/*Set i to the next node*/
|
||||
i = i_next;
|
||||
}
|
||||
|
||||
/*Remove the animations from this object*/
|
||||
/*Remove the animations from this object*/
|
||||
#if USE_LV_ANIMATION
|
||||
lv_anim_del(obj, NULL);
|
||||
lv_anim_del(obj, NULL);
|
||||
#endif
|
||||
|
||||
/*Delete from the group*/
|
||||
/*Delete from the group*/
|
||||
#if USE_LV_GROUP
|
||||
if(obj->group_p != NULL) lv_group_remove_obj(obj);
|
||||
if(obj->group_p != NULL) lv_group_remove_obj(obj);
|
||||
#endif
|
||||
|
||||
/* Reset the input devices if
|
||||
* the currently pressed object is deleted*/
|
||||
lv_indev_t * indev = lv_indev_next(NULL);
|
||||
while(indev) {
|
||||
if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) {
|
||||
lv_indev_reset(indev);
|
||||
}
|
||||
indev = lv_indev_next(indev);
|
||||
}
|
||||
/* Reset the input devices if
|
||||
* the currently pressed object is deleted*/
|
||||
lv_indev_t * indev = lv_indev_next(NULL);
|
||||
while(indev) {
|
||||
if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) {
|
||||
lv_indev_reset(indev);
|
||||
}
|
||||
indev = lv_indev_next(indev);
|
||||
}
|
||||
|
||||
/*Remove the object from parent's children list*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
lv_ll_rem(&(par->child_ll), obj);
|
||||
/*Remove the object from parent's children list*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
lv_ll_rem(&(par->child_ll), obj);
|
||||
|
||||
/* Clean up the object specific data*/
|
||||
obj->signal_func(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||
/* Clean up the object specific data*/
|
||||
obj->signal_func(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||
|
||||
/*Delete the base objects*/
|
||||
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);
|
||||
lv_mem_free(obj); /*Free the object itself*/
|
||||
/*Delete the base objects*/
|
||||
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);
|
||||
lv_mem_free(obj); /*Free the object itself*/
|
||||
|
||||
}
|
||||
|
@ -21,11 +21,10 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
lv_area_t area;
|
||||
uint8_t joined;
|
||||
}lv_join_t;
|
||||
} lv_join_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
@ -49,7 +48,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p);
|
||||
static lv_join_t inv_buf[LV_INV_FIFO_SIZE];
|
||||
static uint16_t inv_buf_p;
|
||||
static void (*monitor_cb)(uint32_t, uint32_t); /*Monitor the rendering time*/
|
||||
static void (*round_cb)(lv_area_t*); /*If set then called to modify invalidated areas for special display controllers*/
|
||||
static void (*round_cb)(lv_area_t *); /*If set then called to modify invalidated areas for special display controllers*/
|
||||
static uint32_t px_num;
|
||||
|
||||
/**********************
|
||||
@ -68,7 +67,7 @@ void lv_refr_init(void)
|
||||
inv_buf_p = 0;
|
||||
memset(inv_buf, 0, sizeof(inv_buf));
|
||||
|
||||
lv_task_t* task;
|
||||
lv_task_t * task;
|
||||
task = lv_task_create(lv_refr_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
|
||||
lv_task_ready(task); /*Be sure the screen will be refreshed immediately on start up*/
|
||||
}
|
||||
@ -100,20 +99,20 @@ void lv_inv_area(const lv_area_t * area_p)
|
||||
if(suc != false) {
|
||||
if(round_cb) round_cb(&com_area);
|
||||
|
||||
/*Save only if this area is not in one of the saved areas*/
|
||||
uint16_t i;
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
if(lv_area_is_in(&com_area, &inv_buf[i].area) != false) return;
|
||||
}
|
||||
/*Save only if this area is not in one of the saved areas*/
|
||||
uint16_t i;
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
if(lv_area_is_in(&com_area, &inv_buf[i].area) != false) return;
|
||||
}
|
||||
|
||||
/*Save the area*/
|
||||
if(inv_buf_p < LV_INV_FIFO_SIZE) {
|
||||
lv_area_copy(&inv_buf[inv_buf_p].area,&com_area);
|
||||
} else {/*If no place for the area add the screen*/
|
||||
inv_buf_p = 0;
|
||||
lv_area_copy(&inv_buf[inv_buf_p].area,&scr_area);
|
||||
if(inv_buf_p < LV_INV_FIFO_SIZE) {
|
||||
lv_area_copy(&inv_buf[inv_buf_p].area, &com_area);
|
||||
} else {/*If no place for the area add the screen*/
|
||||
inv_buf_p = 0;
|
||||
lv_area_copy(&inv_buf[inv_buf_p].area, &scr_area);
|
||||
}
|
||||
inv_buf_p ++;
|
||||
inv_buf_p ++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +133,7 @@ void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t))
|
||||
* Special display controllers may require special coordinate rounding
|
||||
* @param cb pointer to the a function which will modify the area
|
||||
*/
|
||||
void lv_refr_set_round_cb(void(*cb)(lv_area_t*))
|
||||
void lv_refr_set_round_cb(void(*cb)(lv_area_t *))
|
||||
{
|
||||
round_cb = cb;
|
||||
}
|
||||
@ -211,17 +210,16 @@ static void lv_refr_join_area(void)
|
||||
|
||||
/*Check if the areas are on each other*/
|
||||
if(lv_area_is_on(&inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area) == false)
|
||||
{
|
||||
&inv_buf[join_from].area) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lv_area_join(&joined_area, &inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area);
|
||||
&inv_buf[join_from].area);
|
||||
|
||||
/*Join two area only if the joined area size is smaller*/
|
||||
if(lv_area_get_size(&joined_area) <
|
||||
(lv_area_get_size(&inv_buf[join_in].area) + lv_area_get_size(&inv_buf[join_from].area))) {
|
||||
(lv_area_get_size(&inv_buf[join_in].area) + lv_area_get_size(&inv_buf[join_from].area))) {
|
||||
lv_area_copy(&inv_buf[join_in].area, &joined_area);
|
||||
|
||||
/*Mark 'join_form' is joined into 'join_in'*/
|
||||
@ -360,8 +358,7 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
|
||||
lv_obj_t * found_p = NULL;
|
||||
|
||||
/*If this object is fully cover the draw area check the children too */
|
||||
if(lv_area_is_in(area_p, &obj->coords) && obj->hidden == 0)
|
||||
{
|
||||
if(lv_area_is_in(area_p, &obj->coords) && obj->hidden == 0) {
|
||||
LL_READ(obj->child_ll, i) {
|
||||
found_p = lv_refr_get_top_obj(area_p, i);
|
||||
|
||||
@ -375,7 +372,7 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
|
||||
if(found_p == NULL) {
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->body.opa == LV_OPA_COVER &&
|
||||
obj->design_func(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
obj->design_func(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
found_p = obj;
|
||||
}
|
||||
}
|
||||
@ -470,32 +467,31 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
lv_obj_get_coords(obj, &obj_area);
|
||||
union_ok = lv_area_union(&obj_mask, mask_ori_p, &obj_area);
|
||||
if(union_ok != false) {
|
||||
lv_area_t mask_child; /*Mask from obj and its child*/
|
||||
lv_obj_t * child_p;
|
||||
lv_area_t child_area;
|
||||
LL_READ_BACK(obj->child_ll, child_p)
|
||||
{
|
||||
lv_obj_get_coords(child_p, &child_area);
|
||||
ext_size = child_p->ext_size;
|
||||
child_area.x1 -= ext_size;
|
||||
child_area.y1 -= ext_size;
|
||||
child_area.x2 += ext_size;
|
||||
child_area.y2 += ext_size;
|
||||
/* Get the union (common parts) of original mask (from obj)
|
||||
* and its child */
|
||||
union_ok = lv_area_union(&mask_child, &obj_mask, &child_area);
|
||||
lv_area_t mask_child; /*Mask from obj and its child*/
|
||||
lv_obj_t * child_p;
|
||||
lv_area_t child_area;
|
||||
LL_READ_BACK(obj->child_ll, child_p) {
|
||||
lv_obj_get_coords(child_p, &child_area);
|
||||
ext_size = child_p->ext_size;
|
||||
child_area.x1 -= ext_size;
|
||||
child_area.y1 -= ext_size;
|
||||
child_area.x2 += ext_size;
|
||||
child_area.y2 += ext_size;
|
||||
/* Get the union (common parts) of original mask (from obj)
|
||||
* and its child */
|
||||
union_ok = lv_area_union(&mask_child, &obj_mask, &child_area);
|
||||
|
||||
/*If the parent and the child has common area then refresh the child */
|
||||
if(union_ok) {
|
||||
/*Refresh the next children*/
|
||||
lv_refr_obj(child_p, &mask_child);
|
||||
}
|
||||
}
|
||||
/*If the parent and the child has common area then refresh the child */
|
||||
if(union_ok) {
|
||||
/*Refresh the next children*/
|
||||
lv_refr_obj(child_p, &mask_child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If all the children are redrawn make 'post draw' design */
|
||||
if(style->body.opa != LV_OPA_TRANSP) {
|
||||
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
}
|
||||
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,9 +29,9 @@
|
||||
typedef struct {
|
||||
lv_style_t style_start; /*Save not only pointers because can be same as 'style_anim' then it will be modified too*/
|
||||
lv_style_t style_end;
|
||||
lv_style_t *style_anim;
|
||||
lv_style_t * style_anim;
|
||||
void (*end_cb)(void *);
|
||||
}lv_style_anim_dsc_t;
|
||||
} lv_style_anim_dsc_t;
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -39,7 +39,7 @@ typedef struct {
|
||||
**********************/
|
||||
#if USE_LV_ANIMATION
|
||||
static void style_animator(lv_style_anim_dsc_t * dsc, int32_t val);
|
||||
static void style_animation_common_end_cb(void *ptr);
|
||||
static void style_animation_common_end_cb(void * ptr);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -70,7 +70,7 @@ lv_style_t lv_style_btn_ina;
|
||||
/**
|
||||
* Init the basic styles
|
||||
*/
|
||||
void lv_style_init (void)
|
||||
void lv_style_init(void)
|
||||
{
|
||||
/* Not White/Black/Gray colors are created by HSV model with
|
||||
* HUE = 210*/
|
||||
@ -232,7 +232,7 @@ void lv_style_anim_create(lv_style_anim_t * anim)
|
||||
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = (void*)dsc;
|
||||
a.var = (void *)dsc;
|
||||
a.start = 0;
|
||||
a.end = LV_STYLE_ANIM_RES;
|
||||
a.fp = (lv_anim_fp_t)style_animator;
|
||||
@ -310,9 +310,9 @@ static void style_animator(lv_style_anim_dsc_t * dsc, int32_t val)
|
||||
* It called the user defined call back and free the allocated memories
|
||||
* @param ptr the 'animated variable' set by lv_style_anim_create()
|
||||
*/
|
||||
static void style_animation_common_end_cb(void *ptr)
|
||||
static void style_animation_common_end_cb(void * ptr)
|
||||
{
|
||||
lv_style_anim_dsc_t *dsc = ptr; /*To avoid casting*/
|
||||
lv_style_anim_dsc_t * dsc = ptr; /*To avoid casting*/
|
||||
|
||||
if(dsc->end_cb) dsc->end_cb(dsc);
|
||||
|
||||
|
@ -36,27 +36,27 @@ typedef enum {
|
||||
|
||||
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
/*Simple VDB*/
|
||||
static volatile lv_vdb_state_t vdb_state = LV_VDB_STATE_ACTIVE;
|
||||
/*Simple VDB*/
|
||||
static volatile lv_vdb_state_t vdb_state = LV_VDB_STATE_ACTIVE;
|
||||
# if LV_VDB_ADR == 0
|
||||
/*If the buffer address is not specified simply allocate it*/
|
||||
static lv_color_t vdb_buf[LV_VDB_SIZE];
|
||||
static lv_vdb_t vdb = {.buf = vdb_buf};
|
||||
/*If the buffer address is not specified simply allocate it*/
|
||||
static lv_color_t vdb_buf[LV_VDB_SIZE];
|
||||
static lv_vdb_t vdb = {.buf = vdb_buf};
|
||||
# else
|
||||
/*If the buffer address is specified use that address*/
|
||||
static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR};
|
||||
/*If the buffer address is specified use that address*/
|
||||
static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR};
|
||||
# endif
|
||||
#else
|
||||
/*Double VDB*/
|
||||
static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_FREE};
|
||||
/*Double VDB*/
|
||||
static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_FREE};
|
||||
# if LV_VDB_ADR == 0
|
||||
/*If the buffer address is not specified simply allocate it*/
|
||||
static lv_color_t vdb_buf1[LV_VDB_SIZE];
|
||||
static lv_color_t vdb_buf2[LV_VDB_SIZE];
|
||||
static lv_vdb_t vdb[2] = {{.buf = vdb_buf1}, {.buf = vdb_buf2}};
|
||||
/*If the buffer address is not specified simply allocate it*/
|
||||
static lv_color_t vdb_buf1[LV_VDB_SIZE];
|
||||
static lv_color_t vdb_buf2[LV_VDB_SIZE];
|
||||
static lv_vdb_t vdb[2] = {{.buf = vdb_buf1}, {.buf = vdb_buf2}};
|
||||
# else
|
||||
/*If the buffer address is specified use that address*/
|
||||
static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *)LV_VDB_ADR}, {.buf = (lv_color_t *)LV_VDB2_ADR}};
|
||||
/*If the buffer address is specified use that address*/
|
||||
static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *)LV_VDB_ADR}, {.buf = (lv_color_t *)LV_VDB2_ADR}};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -120,7 +120,7 @@ void lv_vdb_flush(void)
|
||||
#endif
|
||||
|
||||
/*Flush the rendered content to the display*/
|
||||
lv_disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf);
|
||||
lv_disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf);
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,11 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
CMD_STATE_WAIT,
|
||||
CMD_STATE_PAR,
|
||||
CMD_STATE_IN,
|
||||
}cmd_state_t;
|
||||
} cmd_state_t;
|
||||
|
||||
|
||||
/**********************
|
||||
@ -77,8 +76,8 @@ static void (*fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_colo
|
||||
static void (*letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa) = lv_vletter;
|
||||
# if USE_LV_IMG
|
||||
static void (*map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa) = lv_vmap;
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa) = lv_vmap;
|
||||
# endif /*USE_LV_IMG*/
|
||||
#elif USE_LV_REAL_DRAW != 0
|
||||
/* px_fp used only by shadow drawing and anti aliasing
|
||||
@ -88,8 +87,8 @@ static void (*fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_colo
|
||||
static void (*letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa) = lv_rletter;
|
||||
# if USE_LV_IMG
|
||||
static void (*map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa) = lv_rmap;
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa) = lv_rmap;
|
||||
# endif /*USE_LV_IMG*/
|
||||
#else
|
||||
/*Invalid settings. Compiler error will be thrown*/
|
||||
@ -97,8 +96,8 @@ static void (*px_fp)(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_colo
|
||||
static void (*fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = NULL;
|
||||
static void (*letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa) = NULL;
|
||||
static void (*map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa) = NULL;
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa) = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
@ -125,7 +124,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty
|
||||
lv_draw_shadow(coords, mask, style);
|
||||
}
|
||||
#endif
|
||||
if(style->body.empty == 0){
|
||||
if(style->body.empty == 0) {
|
||||
lv_draw_rect_main_mid(coords, mask, style);
|
||||
|
||||
if(style->body.radius != 0) {
|
||||
@ -212,21 +211,20 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo
|
||||
/*Calc. the next point of edge1*/
|
||||
y1_tmp = edge1.y;
|
||||
do {
|
||||
if (edge1.x == tri[1].x && edge1.y == tri[1].y) {
|
||||
if(edge1.x == tri[1].x && edge1.y == tri[1].y) {
|
||||
|
||||
dx1 = LV_MATH_ABS(tri[1].x - tri[2].x);
|
||||
sx1 = tri[1].x < tri[2].x ? 1 : -1;
|
||||
dy1 = LV_MATH_ABS(tri[1].y - tri[2].y);
|
||||
sy1 = tri[1].y < tri[2].y ? 1 : -1;
|
||||
err1 = (dx1 > dy1 ? dx1 : -dy1) / 2;
|
||||
}
|
||||
else if (edge1.x == tri[2].x && edge1.y == tri[2].y) return;
|
||||
} else if(edge1.x == tri[2].x && edge1.y == tri[2].y) return;
|
||||
err_tmp1 = err1;
|
||||
if (err_tmp1 >-dx1) {
|
||||
if(err_tmp1 > -dx1) {
|
||||
err1 -= dy1;
|
||||
edge1.x += sx1;
|
||||
}
|
||||
if (err_tmp1 < dy1) {
|
||||
if(err_tmp1 < dy1) {
|
||||
err1 += dx1;
|
||||
edge1.y += sy1;
|
||||
}
|
||||
@ -235,13 +233,13 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo
|
||||
/*Calc. the next point of edge2*/
|
||||
y2_tmp = edge2.y;
|
||||
do {
|
||||
if (edge2.x == tri[2].x && edge2.y == tri[2].y) return;
|
||||
if(edge2.x == tri[2].x && edge2.y == tri[2].y) return;
|
||||
err_tmp2 = err2;
|
||||
if (err_tmp2 > -dx2) {
|
||||
if(err_tmp2 > -dx2) {
|
||||
err2 -= dy2;
|
||||
edge2.x += sx2;
|
||||
}
|
||||
if (err_tmp2 < dy2) {
|
||||
if(err_tmp2 < dy2) {
|
||||
err2 += dx2;
|
||||
edge2.y += sy2;
|
||||
}
|
||||
@ -260,8 +258,8 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo
|
||||
* @param offset text offset in x and y direction (NULL if unused)
|
||||
*
|
||||
*/
|
||||
void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style,
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset)
|
||||
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style,
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset)
|
||||
{
|
||||
|
||||
const lv_font_t * font = style->text.font;
|
||||
@ -286,7 +284,7 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
/*Align the line to middle if enabled*/
|
||||
if(flag & LV_TXT_FLAG_CENTER) {
|
||||
line_length = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
font, style->text.letter_space, flag);
|
||||
pos.x += (w - line_length) / 2;
|
||||
}
|
||||
|
||||
@ -329,7 +327,7 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
continue;
|
||||
} else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */
|
||||
cmd_state = CMD_STATE_WAIT;
|
||||
}else if(cmd_state == CMD_STATE_IN) { /*Command end */
|
||||
} else if(cmd_state == CMD_STATE_IN) { /*Command end */
|
||||
cmd_state = CMD_STATE_WAIT;
|
||||
continue;
|
||||
}
|
||||
@ -343,7 +341,7 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
char buf[LABEL_RECOLOR_PAR_LENGTH + 1];
|
||||
memcpy(buf, &txt[par_start], LABEL_RECOLOR_PAR_LENGTH);
|
||||
buf[LABEL_RECOLOR_PAR_LENGTH] = '\0';
|
||||
int r,g,b;
|
||||
int r, g, b;
|
||||
r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]);
|
||||
g = (hex_char_to_num(buf[2]) << 4) + hex_char_to_num(buf[3]);
|
||||
b = (hex_char_to_num(buf[4]) << 4) + hex_char_to_num(buf[5]);
|
||||
@ -374,7 +372,7 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
/*Align to middle*/
|
||||
if(flag & LV_TXT_FLAG_CENTER) {
|
||||
line_length = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
font, style->text.letter_space, flag);
|
||||
pos.x += (w - line_length) / 2;
|
||||
}
|
||||
/*Go the next line position*/
|
||||
@ -392,7 +390,7 @@ void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_sty
|
||||
* @param opa opacity of the image (0..255)
|
||||
*/
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, const void * src)
|
||||
const lv_style_t * style, const void * src)
|
||||
{
|
||||
|
||||
if(src == NULL) {
|
||||
@ -401,7 +399,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t * u8_p = (uint8_t*) src;
|
||||
const uint8_t * u8_p = (uint8_t *) src;
|
||||
if(u8_p[0] >= 'A' && u8_p[0] <= 'Z') { /*It will be a path of a file*/
|
||||
#if USE_LV_FILESYSTEM
|
||||
lv_fs_file_t file;
|
||||
@ -421,10 +419,17 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
|
||||
uint8_t px_size = 0;
|
||||
switch(img_data.header.format) {
|
||||
case LV_IMG_FORMAT_FILE_RAW_RGB332: px_size = 1; break;
|
||||
case LV_IMG_FORMAT_FILE_RAW_RGB565: px_size = 2; break;
|
||||
case LV_IMG_FORMAT_FILE_RAW_RGB888: px_size = 4; break;
|
||||
default: return;
|
||||
case LV_IMG_FORMAT_FILE_RAW_RGB332:
|
||||
px_size = 1;
|
||||
break;
|
||||
case LV_IMG_FORMAT_FILE_RAW_RGB565:
|
||||
px_size = 2;
|
||||
break;
|
||||
case LV_IMG_FORMAT_FILE_RAW_RGB888:
|
||||
px_size = 4;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if(img_data.header.alpha_byte) { /*Correction with the alpha byte*/
|
||||
@ -461,7 +466,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
res = lv_fs_read(&file, buf, useful_data, &br);
|
||||
|
||||
map_fp(&line, &mask_com, (uint8_t *)buf, style->image.opa, img_data.header.chroma_keyed, img_data.header.alpha_byte,
|
||||
style->image.color, style->image.intense);
|
||||
style->image.color, style->image.intense);
|
||||
|
||||
lv_fs_tell(&file, &act_pos);
|
||||
lv_fs_seek(&file, act_pos + next_row);
|
||||
@ -477,8 +482,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const lv_img_t * img_var = src;
|
||||
lv_area_t mask_com; /*Common area of mask and coords*/
|
||||
bool union_ok;
|
||||
@ -531,7 +535,7 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
lv_coord_t sy = p1.y < p2.y ? 1 : -1;
|
||||
lv_coord_t err = (dx > dy ? dx : -dy) / 2;
|
||||
lv_coord_t e2;
|
||||
bool hor = dx > dy ? true : false; /*Rather horizontal or vertical*/
|
||||
bool hor = dx > dy ? true : false; /*Rather horizontal or vertical*/
|
||||
lv_coord_t last_x = p1.x;
|
||||
lv_coord_t last_y = p1.y;
|
||||
lv_point_t act_point;
|
||||
@ -544,10 +548,10 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
uint16_t width_half = 0;
|
||||
uint16_t width_1 = 0;
|
||||
static const uint8_t width_corr_array[] = {
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66,
|
||||
67, 67, 67, 68, 68, 68, 69, 69, 69, 70, 70, 71, 71, 72, 72, 72, 73, 73, 74,
|
||||
74, 75, 75, 76, 77, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 84, 84, 85,
|
||||
86, 86, 87, 88, 88, 89, 90, 91,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 66, 66, 66, 66, 66,
|
||||
67, 67, 67, 68, 68, 68, 69, 69, 69, 70, 70, 71, 71, 72, 72, 72, 73, 73, 74,
|
||||
74, 75, 75, 76, 77, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 84, 84, 85,
|
||||
86, 86, 87, 88, 88, 89, 90, 91,
|
||||
};
|
||||
|
||||
if(hor == false) {
|
||||
@ -574,7 +578,7 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
}
|
||||
|
||||
/*Special case draw a horizontal line*/
|
||||
if(p1.y == p2.y ) {
|
||||
if(p1.y == p2.y) {
|
||||
lv_area_t act_area;
|
||||
act_area.x1 = p1.x;
|
||||
act_area.x2 = p2.x;
|
||||
@ -592,7 +596,7 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
}
|
||||
|
||||
/*Special case draw a vertical line*/
|
||||
if(p1.x == p2.x ) {
|
||||
if(p1.x == p2.x) {
|
||||
lv_area_t act_area;
|
||||
act_area.x1 = p1.x - width_half;
|
||||
act_area.x2 = p2.x + width_half + width_1;
|
||||
@ -609,7 +613,7 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
}
|
||||
|
||||
|
||||
while(1){
|
||||
while(1) {
|
||||
if(hor == true && last_y != act_point.y) {
|
||||
lv_area_t act_area;
|
||||
lv_area_t draw_area;
|
||||
@ -647,7 +651,7 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (hor == false && last_x != act_point.x) {
|
||||
if(hor == false && last_x != act_point.x) {
|
||||
lv_area_t act_area;
|
||||
lv_area_t draw_area;
|
||||
act_area.x1 = last_x - width_half;
|
||||
@ -687,13 +691,13 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
}
|
||||
|
||||
/*Calc. the next point of the line*/
|
||||
if (act_point.x == p2.x && act_point.y == p2.y) break;
|
||||
if(act_point.x == p2.x && act_point.y == p2.y) break;
|
||||
e2 = err;
|
||||
if (e2 >-dx) {
|
||||
if(e2 > -dx) {
|
||||
err -= dy;
|
||||
act_point.x += sx;
|
||||
}
|
||||
if (e2 < dy) {
|
||||
if(e2 < dy) {
|
||||
err += dx;
|
||||
act_point.y += sy;
|
||||
}
|
||||
@ -737,7 +741,7 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
#endif
|
||||
|
||||
}
|
||||
if (hor == false) {
|
||||
if(hor == false) {
|
||||
lv_area_t act_area;
|
||||
lv_area_t draw_area;
|
||||
act_area.x1 = last_x - width_half;
|
||||
@ -802,13 +806,13 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma
|
||||
/*If the radius is too big then there is no body*/
|
||||
if(radius > height / 2) return;
|
||||
|
||||
lv_area_t work_area;
|
||||
work_area.x1 = coords->x1;
|
||||
work_area.x2 = coords->x2;
|
||||
lv_area_t work_area;
|
||||
work_area.x1 = coords->x1;
|
||||
work_area.x2 = coords->x2;
|
||||
|
||||
if(mcolor.full == gcolor.full) {
|
||||
work_area.y1 = coords->y1 + radius;
|
||||
work_area.y2 = coords->y2 - radius;
|
||||
work_area.y1 = coords->y1 + radius;
|
||||
work_area.y2 = coords->y2 - radius;
|
||||
|
||||
if(style->body.radius != 0) {
|
||||
#if LV_ANTIALIAS
|
||||
@ -820,33 +824,32 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma
|
||||
#endif
|
||||
}
|
||||
|
||||
fill_fp(&work_area, mask, mcolor, opa);
|
||||
fill_fp(&work_area, mask, mcolor, opa);
|
||||
} else {
|
||||
lv_coord_t row;
|
||||
lv_coord_t row_start = coords->y1 + radius;
|
||||
lv_coord_t row_end = coords->y2 - radius;
|
||||
lv_color_t act_color;
|
||||
lv_coord_t row;
|
||||
lv_coord_t row_start = coords->y1 + radius;
|
||||
lv_coord_t row_end = coords->y2 - radius;
|
||||
lv_color_t act_color;
|
||||
|
||||
if(style->body.radius != 0) {
|
||||
#if LV_ANTIALIAS
|
||||
row_start += 2;
|
||||
row_start += 2;
|
||||
row_end -= 2;
|
||||
#else
|
||||
row_start += 1;
|
||||
row_end -= 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if(row_start < 0) row_start = 0;
|
||||
|
||||
for(row = row_start; row <= row_end; row ++)
|
||||
{
|
||||
work_area.y1 = row;
|
||||
work_area.y2 = row;
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - work_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
for(row = row_start; row <= row_end; row ++) {
|
||||
work_area.y1 = row;
|
||||
work_area.y2 = row;
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - work_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
|
||||
fill_fp(&work_area, mask, act_color, opa);
|
||||
}
|
||||
fill_fp(&work_area, mask, act_color, opa);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -897,24 +900,24 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
|
||||
/*Init the areas*/
|
||||
lv_area_set(&mid_bot_area, lb_origo.x + LV_CIRC_OCT4_X(cir),
|
||||
lb_origo.y + LV_CIRC_OCT4_Y(cir),
|
||||
rb_origo.x + LV_CIRC_OCT1_X(cir),
|
||||
rb_origo.y + LV_CIRC_OCT1_Y(cir));
|
||||
lb_origo.y + LV_CIRC_OCT4_Y(cir),
|
||||
rb_origo.x + LV_CIRC_OCT1_X(cir),
|
||||
rb_origo.y + LV_CIRC_OCT1_Y(cir));
|
||||
|
||||
lv_area_set(&edge_bot_area, lb_origo.x + LV_CIRC_OCT3_X(cir),
|
||||
lb_origo.y + LV_CIRC_OCT3_Y(cir),
|
||||
rb_origo.x + LV_CIRC_OCT2_X(cir),
|
||||
rb_origo.y + LV_CIRC_OCT2_Y(cir));
|
||||
lb_origo.y + LV_CIRC_OCT3_Y(cir),
|
||||
rb_origo.x + LV_CIRC_OCT2_X(cir),
|
||||
rb_origo.y + LV_CIRC_OCT2_Y(cir));
|
||||
|
||||
lv_area_set(&mid_top_area, lt_origo.x + LV_CIRC_OCT5_X(cir),
|
||||
lt_origo.y + LV_CIRC_OCT5_Y(cir),
|
||||
rt_origo.x + LV_CIRC_OCT8_X(cir),
|
||||
rt_origo.y + LV_CIRC_OCT8_Y(cir));
|
||||
lt_origo.y + LV_CIRC_OCT5_Y(cir),
|
||||
rt_origo.x + LV_CIRC_OCT8_X(cir),
|
||||
rt_origo.y + LV_CIRC_OCT8_Y(cir));
|
||||
|
||||
lv_area_set(&edge_top_area, lt_origo.x + LV_CIRC_OCT6_X(cir),
|
||||
lt_origo.y + LV_CIRC_OCT6_Y(cir),
|
||||
rt_origo.x + LV_CIRC_OCT7_X(cir),
|
||||
rt_origo.y + LV_CIRC_OCT7_Y(cir));
|
||||
lt_origo.y + LV_CIRC_OCT6_Y(cir),
|
||||
rt_origo.x + LV_CIRC_OCT7_X(cir),
|
||||
rt_origo.y + LV_CIRC_OCT7_Y(cir));
|
||||
#if LV_ANTIALIAS
|
||||
/*Store some internal states for anti-aliasing*/
|
||||
lv_coord_t out_y_seg_start = 0;
|
||||
@ -976,7 +979,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
|
||||
/* If a new row coming draw the previous
|
||||
* The y coordinate can remain the same so wait for a new*/
|
||||
if(mid_bot_area.y1 != LV_CIRC_OCT4_Y(cir) + lb_origo.y ) mid_bot_refr = 1;
|
||||
if(mid_bot_area.y1 != LV_CIRC_OCT4_Y(cir) + lb_origo.y) mid_bot_refr = 1;
|
||||
|
||||
if(edge_bot_area.y1 != LV_CIRC_OCT2_Y(cir) + lb_origo.y) edge_bot_refr = 1;
|
||||
|
||||
@ -985,7 +988,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
if(edge_top_area.y1 != LV_CIRC_OCT7_Y(cir) + lt_origo.y) edge_top_refr = 1;
|
||||
|
||||
/*Draw the areas which are not disabled*/
|
||||
if(edge_top_refr != 0){
|
||||
if(edge_top_refr != 0) {
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
else {
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_top_area.y1) * 255) / height;
|
||||
@ -1022,26 +1025,26 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
fill_fp(&edge_bot_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
/*Save the current coordinates*/
|
||||
/*Save the current coordinates*/
|
||||
lv_area_set(&mid_bot_area, lb_origo.x + LV_CIRC_OCT4_X(cir),
|
||||
lb_origo.y + LV_CIRC_OCT4_Y(cir),
|
||||
rb_origo.x + LV_CIRC_OCT1_X(cir),
|
||||
rb_origo.y + LV_CIRC_OCT1_Y(cir));
|
||||
lb_origo.y + LV_CIRC_OCT4_Y(cir),
|
||||
rb_origo.x + LV_CIRC_OCT1_X(cir),
|
||||
rb_origo.y + LV_CIRC_OCT1_Y(cir));
|
||||
|
||||
lv_area_set(&edge_bot_area, lb_origo.x + LV_CIRC_OCT3_X(cir),
|
||||
lb_origo.y + LV_CIRC_OCT3_Y(cir),
|
||||
rb_origo.x + LV_CIRC_OCT2_X(cir),
|
||||
rb_origo.y + LV_CIRC_OCT2_Y(cir));
|
||||
lb_origo.y + LV_CIRC_OCT3_Y(cir),
|
||||
rb_origo.x + LV_CIRC_OCT2_X(cir),
|
||||
rb_origo.y + LV_CIRC_OCT2_Y(cir));
|
||||
|
||||
lv_area_set(&mid_top_area, lt_origo.x + LV_CIRC_OCT5_X(cir),
|
||||
lt_origo.y + LV_CIRC_OCT5_Y(cir),
|
||||
rt_origo.x + LV_CIRC_OCT8_X(cir),
|
||||
rt_origo.y + LV_CIRC_OCT8_Y(cir));
|
||||
lt_origo.y + LV_CIRC_OCT5_Y(cir),
|
||||
rt_origo.x + LV_CIRC_OCT8_X(cir),
|
||||
rt_origo.y + LV_CIRC_OCT8_Y(cir));
|
||||
|
||||
lv_area_set(&edge_top_area, lt_origo.x + LV_CIRC_OCT6_X(cir),
|
||||
lt_origo.y + LV_CIRC_OCT6_Y(cir),
|
||||
rt_origo.x + LV_CIRC_OCT7_X(cir),
|
||||
rt_origo.y + LV_CIRC_OCT7_Y(cir));
|
||||
lt_origo.y + LV_CIRC_OCT6_Y(cir),
|
||||
rt_origo.x + LV_CIRC_OCT7_X(cir),
|
||||
rt_origo.y + LV_CIRC_OCT7_Y(cir));
|
||||
|
||||
lv_circ_next(&cir, &cir_tmp);
|
||||
}
|
||||
@ -1051,39 +1054,39 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&edge_top_area, mask, act_color, opa);
|
||||
fill_fp(&edge_top_area, mask, act_color, opa);
|
||||
|
||||
if(edge_top_area.y1 != mid_top_area.y1) {
|
||||
if(edge_top_area.y1 != mid_top_area.y1) {
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
else {
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - mid_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&mid_top_area, mask, act_color, opa);
|
||||
}
|
||||
}
|
||||
fill_fp(&mid_top_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
else {
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - mid_bot_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&mid_bot_area, mask, act_color, opa);
|
||||
fill_fp(&mid_bot_area, mask, act_color, opa);
|
||||
|
||||
if(edge_bot_area.y1 != mid_bot_area.y1) {
|
||||
if(edge_bot_area.y1 != mid_bot_area.y1) {
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
else {
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_bot_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&edge_bot_area, mask, act_color, opa);
|
||||
}
|
||||
fill_fp(&edge_bot_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
/*The first and the last line is not drawn*/
|
||||
edge_top_area.x1 = coords->x1 + radius + 2;
|
||||
/*The first and the last line is not drawn*/
|
||||
edge_top_area.x1 = coords->x1 + radius + 2;
|
||||
edge_top_area.x2 = coords->x2 - radius - 2;
|
||||
edge_top_area.y1 = coords->y1;
|
||||
edge_top_area.y2 = coords->y1;
|
||||
@ -1349,7 +1352,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
lv_coord_t tmp_in;
|
||||
lv_coord_t radius_in = radius - bwidth;
|
||||
|
||||
if(radius_in < 0){
|
||||
if(radius_in < 0) {
|
||||
radius_in = 0;
|
||||
}
|
||||
|
||||
@ -1371,7 +1374,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
lv_coord_t in_x_last = radius - bwidth;
|
||||
#endif
|
||||
|
||||
while( cir_out.y <= cir_out.x) {
|
||||
while(cir_out.y <= cir_out.x) {
|
||||
|
||||
/*Calculate the actual width to avoid overwriting pixels*/
|
||||
if(cir_in.y < cir_in.x) {
|
||||
@ -1429,65 +1432,65 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
}
|
||||
|
||||
/*New step in y on the inner circle*/
|
||||
if(in_x_last != cir_in.x) {
|
||||
in_y_seg_end = cir_out.y;
|
||||
lv_coord_t seg_size = in_y_seg_end - in_y_seg_start;
|
||||
lv_point_t aa_p;
|
||||
if(in_x_last != cir_in.x) {
|
||||
in_y_seg_end = cir_out.y;
|
||||
lv_coord_t seg_size = in_y_seg_end - in_y_seg_start;
|
||||
lv_point_t aa_p;
|
||||
|
||||
aa_p.x = in_x_last;
|
||||
aa_p.y = in_y_seg_start;
|
||||
aa_p.x = in_x_last;
|
||||
aa_p.y = in_y_seg_start;
|
||||
|
||||
lv_coord_t i;
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa;
|
||||
lv_coord_t i;
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa;
|
||||
|
||||
if(seg_size > CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD) { /*Use non-linear opa mapping on the first segment*/
|
||||
aa_opa = style->body.border.opa - antialias_get_opa_circ(seg_size, i, style->body.border.opa);
|
||||
} else {
|
||||
aa_opa = antialias_get_opa(seg_size, i, style->body.border.opa);
|
||||
}
|
||||
if(seg_size > CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD) { /*Use non-linear opa mapping on the first segment*/
|
||||
aa_opa = style->body.border.opa - antialias_get_opa_circ(seg_size, i, style->body.border.opa);
|
||||
} else {
|
||||
aa_opa = antialias_get_opa(seg_size, i, style->body.border.opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
/*Be sure the pixels on the middle are not drawn twice*/
|
||||
if(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) {
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
/*Be sure the pixels on the middle are not drawn twice*/
|
||||
if(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) {
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
}
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
in_x_last = cir_in.x;
|
||||
in_y_seg_start = in_y_seg_end;
|
||||
in_x_last = cir_in.x;
|
||||
in_y_seg_start = in_y_seg_end;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -1502,7 +1505,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
|
||||
circ_area.x1 = rb_origo.x + LV_CIRC_OCT2_X(cir_out);
|
||||
circ_area.x2 = rb_origo.x + LV_CIRC_OCT2_X(cir_out);
|
||||
circ_area.y1 = rb_origo.y + LV_CIRC_OCT2_Y(cir_out)- act_w1;
|
||||
circ_area.y1 = rb_origo.y + LV_CIRC_OCT2_Y(cir_out) - act_w1;
|
||||
circ_area.y2 = rb_origo.y + LV_CIRC_OCT2_Y(cir_out);
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
}
|
||||
@ -1809,8 +1812,7 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
if(col_rel < -swidth) { /*Outside of the blurred area. */
|
||||
if(line_rel == -swidth) line_ready = true; /*If no data even on the very first line then it wont't be anything else in this line*/
|
||||
break; /*Break anyway because only smaller 'col_rel' values will come */
|
||||
}
|
||||
else if (col_rel > swidth) px_opa_sum += line_1d_blur[0]; /*Inside the not blurred area*/
|
||||
} else if(col_rel > swidth) px_opa_sum += line_1d_blur[0]; /*Inside the not blurred area*/
|
||||
else px_opa_sum += line_1d_blur[swidth - col_rel]; /*On the 1D blur (+ swidth to align to the center)*/
|
||||
}
|
||||
|
||||
@ -1839,18 +1841,18 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
for(d = 1; d < col; d++) {
|
||||
|
||||
if(point_rt.x != point_lt.x) {
|
||||
px_fp(point_lt.x,point_lt.y , mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
px_fp(point_lt.x, point_lt.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
}
|
||||
|
||||
if(point_rb.x != point_lb.x && point_lt.y != point_lb.y) {
|
||||
px_fp(point_lb.x,point_lb.y , mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
px_fp(point_lb.x, point_lb.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
}
|
||||
|
||||
if(point_lt.y != point_lb.y) {
|
||||
px_fp(point_rb.x,point_rb.y , mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
px_fp(point_rb.x, point_rb.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
}
|
||||
|
||||
px_fp(point_rt.x,point_rt.y , mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
px_fp(point_rt.x, point_rt.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
|
||||
|
||||
point_rb.x++;
|
||||
@ -1897,7 +1899,7 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
}
|
||||
|
||||
int16_t col;
|
||||
#if LV_COMPILER_VLA_SUPPORTED
|
||||
#if LV_COMPILER_VLA_SUPPORTED
|
||||
lv_opa_t line_1d_blur[swidth];
|
||||
#else
|
||||
# if LV_HOR_RES > LV_VER_RES
|
||||
@ -1931,7 +1933,7 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
point_r.y = ofs_r.y + curve_x[col];
|
||||
|
||||
lv_opa_t px_opa;
|
||||
int16_t diff = col == 0 ? 0 : curve_x[col-1] - curve_x[col];
|
||||
int16_t diff = col == 0 ? 0 : curve_x[col - 1] - curve_x[col];
|
||||
uint16_t d;
|
||||
for(d = 0; d < swidth; d++) {
|
||||
/*When stepping a pixel in y calculate the average with the pixel from the prev. column to make a blur */
|
||||
@ -2026,18 +2028,18 @@ static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area
|
||||
|
||||
static uint16_t lv_draw_cont_radius_corr(uint16_t r, lv_coord_t w, lv_coord_t h)
|
||||
{
|
||||
if(r >= (w >> 1)){
|
||||
r = (w >> 1);
|
||||
if(r != 0) r--;
|
||||
}
|
||||
if(r >= (h >> 1)) {
|
||||
r = (h >> 1);
|
||||
if(r != 0) r--;
|
||||
}
|
||||
if(r >= (w >> 1)) {
|
||||
r = (w >> 1);
|
||||
if(r != 0) r--;
|
||||
}
|
||||
if(r >= (h >> 1)) {
|
||||
r = (h >> 1);
|
||||
if(r != 0) r--;
|
||||
}
|
||||
|
||||
if(r > 0) r -= LV_ANTIALIAS;
|
||||
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
|
||||
#if LV_ANTIALIAS != 0
|
||||
@ -2071,7 +2073,8 @@ static lv_opa_t antialias_get_opa(lv_coord_t seg, lv_coord_t px_id, lv_opa_t lin
|
||||
static const lv_opa_t seg8[8] = {16, 48, 80, 112, 143, 175, 207, 239};
|
||||
|
||||
static const lv_opa_t * seg_map[] = {seg1, seg2, seg3, seg4,
|
||||
seg5, seg6, seg7, seg8};
|
||||
seg5, seg6, seg7, seg8
|
||||
};
|
||||
|
||||
if(seg == 0) return LV_OPA_TRANSP;
|
||||
else if(seg < 8) return (uint32_t)((uint32_t)seg_map[seg - 1][px_id] * line_opa) >> 8;
|
||||
@ -2097,8 +2100,8 @@ static lv_opa_t antialias_get_opa_circ(lv_coord_t seg, lv_coord_t px_id, lv_opa_
|
||||
else if(seg == 1) return LV_OPA_80;
|
||||
else {
|
||||
|
||||
uint8_t id = (uint32_t) ((uint32_t)px_id * (sizeof(opa_map) - 1)) / (seg - 1);
|
||||
return (uint32_t) ((uint32_t) opa_map[id] * opa) >> 8;
|
||||
uint8_t id = (uint32_t)((uint32_t)px_id * (sizeof(opa_map) - 1)) / (seg - 1);
|
||||
return (uint32_t)((uint32_t) opa_map[id] * opa) >> 8;
|
||||
|
||||
}
|
||||
|
||||
@ -2121,13 +2124,20 @@ static uint8_t hex_char_to_num(char hex)
|
||||
if(hex >= 'a') hex -= 'a' - 'A'; /*Convert to upper case*/
|
||||
|
||||
switch(hex) {
|
||||
case 'A': return 10;
|
||||
case 'B': return 11;
|
||||
case 'C': return 12;
|
||||
case 'D': return 13;
|
||||
case 'E': return 14;
|
||||
case 'F': return 15;
|
||||
default: return 0;
|
||||
case 'A':
|
||||
return 10;
|
||||
case 'B':
|
||||
return 11;
|
||||
case 'C':
|
||||
return 12;
|
||||
case 'D':
|
||||
return 13;
|
||||
case 'E':
|
||||
return 14;
|
||||
case 'F':
|
||||
return 15;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -83,8 +83,8 @@ void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
union_ok = lv_area_union(&masked_area, cords_p, &scr_area);
|
||||
}
|
||||
|
||||
if(union_ok != false){
|
||||
lv_disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
|
||||
if(union_ok != false) {
|
||||
lv_disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,33 +98,47 @@ void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
* @param opa opacity of letter (ignored, only for compatibility with lv_vletter)
|
||||
*/
|
||||
void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
(void)opa; /*Opa is used only for compatibility with lv_vletter*/
|
||||
|
||||
static uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
|
||||
static uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
|
||||
static uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
|
||||
68, 85, 102, 119,
|
||||
136, 153, 170, 187,
|
||||
204, 221, 238, 255};
|
||||
68, 85, 102, 119,
|
||||
136, 153, 170, 187,
|
||||
204, 221, 238, 255
|
||||
};
|
||||
|
||||
if(font_p == NULL) return;
|
||||
|
||||
uint8_t letter_w = lv_font_get_width(font_p, letter);
|
||||
uint8_t letter_h = lv_font_get_height(font_p);
|
||||
uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/
|
||||
uint8_t *bpp_opa_table;
|
||||
uint8_t * bpp_opa_table;
|
||||
uint8_t mask_init;
|
||||
uint8_t mask;
|
||||
|
||||
switch(bpp) {
|
||||
case 1: bpp_opa_table = bpp1_opa_table; mask_init = 0x80; break;
|
||||
case 2: bpp_opa_table = bpp2_opa_table; mask_init = 0xC0; break;
|
||||
case 4: bpp_opa_table = bpp4_opa_table; mask_init = 0xF0; break;
|
||||
case 8: bpp_opa_table = NULL; mask_init = 0xFF; break; /*No opa table, pixel value will be used directly*/
|
||||
default: return; /*Invalid bpp. Can't render the letter*/
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
mask_init = 0x80;
|
||||
break;
|
||||
case 2:
|
||||
bpp_opa_table = bpp2_opa_table;
|
||||
mask_init = 0xC0;
|
||||
break;
|
||||
case 4:
|
||||
bpp_opa_table = bpp4_opa_table;
|
||||
mask_init = 0xF0;
|
||||
break;
|
||||
case 8:
|
||||
bpp_opa_table = NULL;
|
||||
mask_init = 0xFF;
|
||||
break; /*No opa table, pixel value will be used directly*/
|
||||
default:
|
||||
return; /*Invalid bpp. Can't render the letter*/
|
||||
}
|
||||
|
||||
const uint8_t * map_p = lv_font_get_bitmap(font_p, letter);
|
||||
@ -133,7 +147,7 @@ void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
|
||||
/*If the letter is completely out of mask don't draw it */
|
||||
if(pos_p->x + letter_w < mask_p->x1 || pos_p->x > mask_p->x2 ||
|
||||
pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
|
||||
lv_coord_t col, row;
|
||||
uint8_t col_bit;
|
||||
@ -166,8 +180,7 @@ void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
if(col_bit < 8 - bpp) {
|
||||
col_bit += bpp;
|
||||
mask = mask >> bpp;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
col_bit = 0;
|
||||
col_byte_cnt ++;
|
||||
mask = mask_init;
|
||||
@ -200,8 +213,8 @@ void lv_rletter_set_background(lv_color_t color)
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa)
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa)
|
||||
{
|
||||
if(alpha_byte) return; /*Pixel level opacity i not supported in real map drawing*/
|
||||
|
||||
@ -223,7 +236,7 @@ void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
if(recolor_opa == LV_OPA_TRANSP && chroma_key == false) {
|
||||
lv_coord_t mask_w = lv_area_get_width(&masked_a) - 1;
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
lv_disp_map(masked_a.x1, row, masked_a.x1 + mask_w, row, (lv_color_t*)map_p);
|
||||
lv_disp_map(masked_a.x1, row, masked_a.x1 + mask_w, row, (lv_color_t *)map_p);
|
||||
map_p += map_width * sizeof(lv_color_t); /*Next row on the map*/
|
||||
}
|
||||
} else {
|
||||
|
@ -65,21 +65,20 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
|
||||
|
||||
/*Pixel out of the mask*/
|
||||
if(x < mask_p->x1 || x > mask_p->x2 ||
|
||||
y < mask_p->y1 || y > mask_p->y2) {
|
||||
y < mask_p->y1 || y > mask_p->y2) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
|
||||
/*Make the coordinates relative to VDB*/
|
||||
x-=vdb_p->area.x1;
|
||||
y-=vdb_p->area.y1;
|
||||
x -= vdb_p->area.x1;
|
||||
y -= vdb_p->area.y1;
|
||||
lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
|
||||
if(opa == LV_OPA_COVER) {
|
||||
*vdb_px_p = color;
|
||||
}
|
||||
else {
|
||||
*vdb_px_p = lv_color_mix(color,*vdb_px_p, opa);
|
||||
} else {
|
||||
*vdb_px_p = lv_color_mix(color, *vdb_px_p, opa);
|
||||
}
|
||||
|
||||
}
|
||||
@ -93,7 +92,7 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
lv_area_t res_a;
|
||||
bool union_ok;
|
||||
@ -133,15 +132,14 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
/*Use hw fill if present*/
|
||||
if(lv_disp_is_mem_fill_supported()) {
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
|
||||
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
}
|
||||
/*Use hw blend if present and the area is not too small*/
|
||||
else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT &&
|
||||
lv_disp_is_mem_blend_supported())
|
||||
{
|
||||
lv_disp_is_mem_blend_supported()) {
|
||||
/*Fill a one line sized buffer with a color and blend this later*/
|
||||
if(color_array_tmp[0].full != color.full || last_width != w) {
|
||||
uint16_t i;
|
||||
@ -153,7 +151,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
|
||||
/*Blend the filled line to every line VDB line-by-line*/
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
|
||||
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
@ -178,7 +176,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
last_width = w;
|
||||
}
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
|
||||
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
@ -205,32 +203,46 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
|
||||
static uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
|
||||
static uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
|
||||
static uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
|
||||
68, 85, 102, 119,
|
||||
136, 153, 170, 187,
|
||||
204, 221, 238, 255};
|
||||
68, 85, 102, 119,
|
||||
136, 153, 170, 187,
|
||||
204, 221, 238, 255
|
||||
};
|
||||
|
||||
if(font_p == NULL) return;
|
||||
|
||||
uint8_t letter_w = lv_font_get_width(font_p, letter);
|
||||
uint8_t letter_h = lv_font_get_height(font_p);
|
||||
uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/
|
||||
uint8_t *bpp_opa_table;
|
||||
uint8_t * bpp_opa_table;
|
||||
uint8_t mask_init;
|
||||
uint8_t mask;
|
||||
|
||||
switch(bpp) {
|
||||
case 1: bpp_opa_table = bpp1_opa_table; mask_init = 0x80; break;
|
||||
case 2: bpp_opa_table = bpp2_opa_table; mask_init = 0xC0; break;
|
||||
case 4: bpp_opa_table = bpp4_opa_table; mask_init = 0xF0; break;
|
||||
case 8: bpp_opa_table = NULL; mask_init = 0xFF; break; /*No opa table, pixel value will be used directly*/
|
||||
default: return; /*Invalid bpp. Can't render the letter*/
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
mask_init = 0x80;
|
||||
break;
|
||||
case 2:
|
||||
bpp_opa_table = bpp2_opa_table;
|
||||
mask_init = 0xC0;
|
||||
break;
|
||||
case 4:
|
||||
bpp_opa_table = bpp4_opa_table;
|
||||
mask_init = 0xF0;
|
||||
break;
|
||||
case 8:
|
||||
bpp_opa_table = NULL;
|
||||
mask_init = 0xFF;
|
||||
break; /*No opa table, pixel value will be used directly*/
|
||||
default:
|
||||
return; /*Invalid bpp. Can't render the letter*/
|
||||
}
|
||||
|
||||
const uint8_t * map_p = lv_font_get_bitmap(font_p, letter);
|
||||
@ -239,7 +251,7 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
|
||||
/*If the letter is completely out of mask don't draw it */
|
||||
if(pos_p->x + letter_w < mask_p->x1 || pos_p->x > mask_p->x2 ||
|
||||
pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
lv_coord_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
@ -260,7 +272,7 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
|
||||
/*Set a pointer on VDB to the first pixel of the letter*/
|
||||
vdb_buf_tmp += ((pos_p->y - vdb_p->area.y1) * vdb_width)
|
||||
+ pos_p->x - vdb_p->area.x1;
|
||||
+ pos_p->x - vdb_p->area.x1;
|
||||
|
||||
/*If the letter is partially out of mask the move there on VDB*/
|
||||
vdb_buf_tmp += (row_start * vdb_width) + col_start;
|
||||
@ -280,8 +292,8 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
*vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, bpp == 8 ? letter_px : bpp_opa_table[letter_px]);
|
||||
} else {
|
||||
*vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, bpp == 8 ?
|
||||
(uint16_t)((uint16_t)letter_px * opa) >> 8 :
|
||||
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8);
|
||||
(uint16_t)((uint16_t)letter_px * opa) >> 8 :
|
||||
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,8 +302,7 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
if(col_bit < 8 - bpp) {
|
||||
col_bit += bpp;
|
||||
mask = mask >> bpp;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
col_bit = 0;
|
||||
col_byte_cnt ++;
|
||||
mask = mask_init;
|
||||
@ -390,19 +401,18 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
/*Calculate with the pixel level alpha*/
|
||||
if(alpha_byte) {
|
||||
#if LV_COLOR_DEPTH == 8
|
||||
px_color.full = px_color_p[0];
|
||||
px_color.full = px_color_p[0];
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
/*Because of Alpha byte 16 bit color can start on odd address which can cause crash*/
|
||||
px_color.full = px_color_p[0] + (px_color_p[1] << 8);
|
||||
/*Because of Alpha byte 16 bit color can start on odd address which can cause crash*/
|
||||
px_color.full = px_color_p[0] + (px_color_p[1] << 8);
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
px_color = *((lv_color_t*)px_color_p);
|
||||
px_color = *((lv_color_t *)px_color_p);
|
||||
#endif
|
||||
lv_opa_t px_opa = *(px_color_p + LV_IMG_PX_SIZE_ALPHA_BYTE - 1);
|
||||
if(px_opa == LV_OPA_TRANSP) continue;
|
||||
else if(px_opa != LV_OPA_COVER) opa_result = (uint32_t)((uint32_t)px_opa * opa_result) >> 8;
|
||||
}
|
||||
else {
|
||||
px_color = *((lv_color_t*)px_color_p);
|
||||
} else {
|
||||
px_color = *((lv_color_t *)px_color_p);
|
||||
}
|
||||
|
||||
/*Handle chroma key*/
|
||||
@ -483,7 +493,7 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
|
||||
|
||||
/*Copy the first row to all other rows*/
|
||||
lv_color_t * mem_first = &mem[fill_area->x1];
|
||||
lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t);
|
||||
lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t);
|
||||
mem += mem_width;
|
||||
|
||||
for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) {
|
||||
|
@ -30,8 +30,8 @@
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_disp_t *disp_list = NULL;
|
||||
static lv_disp_t *active;
|
||||
static lv_disp_t * disp_list = NULL;
|
||||
static lv_disp_t * active;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -47,7 +47,7 @@ static lv_disp_t *active;
|
||||
* After it you can set the fields.
|
||||
* @param driver pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_disp_drv_init(lv_disp_drv_t *driver)
|
||||
void lv_disp_drv_init(lv_disp_drv_t * driver)
|
||||
{
|
||||
driver->disp_fill = NULL;
|
||||
driver->disp_map = NULL;
|
||||
@ -65,18 +65,18 @@ void lv_disp_drv_init(lv_disp_drv_t *driver)
|
||||
* @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable)
|
||||
* @return pointer to the new display or NULL on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver)
|
||||
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
{
|
||||
lv_disp_t *node;
|
||||
lv_disp_t * node;
|
||||
|
||||
node = lv_mem_alloc(sizeof(lv_disp_t));
|
||||
if (!node) return NULL;
|
||||
if(!node) return NULL;
|
||||
|
||||
memcpy(&node->driver,driver, sizeof(lv_disp_drv_t));
|
||||
memcpy(&node->driver, driver, sizeof(lv_disp_drv_t));
|
||||
node->next = NULL;
|
||||
|
||||
/* Set first display as active by default */
|
||||
if (disp_list == NULL) {
|
||||
if(disp_list == NULL) {
|
||||
disp_list = node;
|
||||
active = node;
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
@ -144,7 +144,7 @@ void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t col
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_p pointer to an array of colors
|
||||
*/
|
||||
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p)
|
||||
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t * color_p)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.disp_flush != NULL) active->driver.disp_flush(x1, y1, x2, y2, color_p);
|
||||
|
@ -22,7 +22,7 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_indev_t *indev_list = NULL;
|
||||
static lv_indev_t * indev_list = NULL;
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -42,7 +42,7 @@ static lv_indev_t *indev_list = NULL;
|
||||
* After it you can set the fields.
|
||||
* @param driver pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_indev_drv_init(lv_indev_drv_t *driver)
|
||||
void lv_indev_drv_init(lv_indev_drv_t * driver)
|
||||
{
|
||||
driver->read = NULL;
|
||||
driver->type = LV_INDEV_TYPE_NONE;
|
||||
@ -54,12 +54,12 @@ void lv_indev_drv_init(lv_indev_drv_t *driver)
|
||||
* @param driver pointer to an initialized 'lv_indev_drv_t' variable (can be local variable)
|
||||
* @return pointer to the new input device or NULL on error
|
||||
*/
|
||||
lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver)
|
||||
lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
|
||||
{
|
||||
lv_indev_t *node;
|
||||
lv_indev_t * node;
|
||||
|
||||
node = lv_mem_alloc(sizeof(lv_indev_t));
|
||||
if (!node) return NULL;
|
||||
if(!node) return NULL;
|
||||
|
||||
memset(node, 0, sizeof(lv_indev_t));
|
||||
memcpy(&node->driver, driver, sizeof(lv_indev_drv_t));
|
||||
@ -70,11 +70,11 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver)
|
||||
node->group = NULL;
|
||||
node->btn_points = NULL;
|
||||
|
||||
if (indev_list == NULL) {
|
||||
if(indev_list == NULL) {
|
||||
indev_list = node;
|
||||
} else {
|
||||
lv_indev_t *last = indev_list;
|
||||
while (last->next)
|
||||
lv_indev_t * last = indev_list;
|
||||
while(last->next)
|
||||
last = last->next;
|
||||
|
||||
last->next = node;
|
||||
@ -105,7 +105,7 @@ lv_indev_t * lv_indev_next(lv_indev_t * indev)
|
||||
* @param data input device will write its data here
|
||||
* @return false: no more data; true: there more data to read (buffered)
|
||||
*/
|
||||
bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t *data)
|
||||
bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
bool cont = false;
|
||||
|
||||
|
@ -68,17 +68,17 @@ uint32_t lv_tick_get(void)
|
||||
*/
|
||||
uint32_t lv_tick_elaps(uint32_t prev_tick)
|
||||
{
|
||||
uint32_t act_time = lv_tick_get();
|
||||
uint32_t act_time = lv_tick_get();
|
||||
|
||||
/*If there is no overflow in sys_time simple subtract*/
|
||||
if(act_time >= prev_tick) {
|
||||
prev_tick = act_time - prev_tick;
|
||||
} else {
|
||||
prev_tick = UINT32_MAX - prev_tick + 1;
|
||||
prev_tick += act_time;
|
||||
}
|
||||
/*If there is no overflow in sys_time simple subtract*/
|
||||
if(act_time >= prev_tick) {
|
||||
prev_tick = act_time - prev_tick;
|
||||
} else {
|
||||
prev_tick = UINT32_MAX - prev_tick + 1;
|
||||
prev_tick += act_time;
|
||||
}
|
||||
|
||||
return prev_tick;
|
||||
return prev_tick;
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -28,7 +28,7 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void anim_task (void * param);
|
||||
static void anim_task(void * param);
|
||||
static bool anim_ready_handler(lv_anim_t * a);
|
||||
|
||||
/**********************
|
||||
@ -131,7 +131,7 @@ uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end)
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_linear(const lv_anim_t *a)
|
||||
int32_t lv_anim_path_linear(const lv_anim_t * a)
|
||||
{
|
||||
/*Calculate the current step*/
|
||||
|
||||
@ -143,7 +143,7 @@ int32_t lv_anim_path_linear(const lv_anim_t *a)
|
||||
/* Get the new value which will be proportional to the current element of 'path_p'
|
||||
* and the 'start' and 'end' values*/
|
||||
int32_t new_value;
|
||||
new_value = (int32_t) step * (a->end - a->start);
|
||||
new_value = (int32_t) step * (a->end - a->start);
|
||||
new_value = new_value >> LV_ANIM_RES_SHIFT;
|
||||
new_value += a->start;
|
||||
|
||||
@ -156,7 +156,7 @@ int32_t lv_anim_path_linear(const lv_anim_t *a)
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_step(const lv_anim_t *a)
|
||||
int32_t lv_anim_path_step(const lv_anim_t * a)
|
||||
{
|
||||
if(a->act_time >= a->time) return a->end;
|
||||
else return a->start;
|
||||
@ -170,7 +170,7 @@ int32_t lv_anim_path_step(const lv_anim_t *a)
|
||||
* Periodically handle the animations.
|
||||
* @param param unused
|
||||
*/
|
||||
static void anim_task (void * param)
|
||||
static void anim_task(void * param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
@ -224,7 +224,7 @@ static bool anim_ready_handler(lv_anim_t * a)
|
||||
* - no repeat, play back is enabled and play back is ready */
|
||||
if((a->repeat == 0 && a->playback == 0) ||
|
||||
(a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) {
|
||||
void (*cb) (void *) = a->end_cb;
|
||||
void (*cb)(void *) = a->end_cb;
|
||||
void * p = a->var;
|
||||
lv_ll_rem(&anim_ll, a);
|
||||
lv_mem_free(a);
|
||||
@ -244,7 +244,7 @@ static bool anim_ready_handler(lv_anim_t * a)
|
||||
if(a->playback_now == 0) a->act_time = - a->playback_pause;
|
||||
|
||||
/*Toggle the play back state*/
|
||||
a->playback_now = a->playback_now == 0 ? 1: 0;
|
||||
a->playback_now = a->playback_now == 0 ? 1 : 0;
|
||||
/*Swap the start and end values*/
|
||||
int32_t tmp;
|
||||
tmp = a->start;
|
||||
|
@ -56,7 +56,7 @@ void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2
|
||||
*/
|
||||
void lv_area_set_width(lv_area_t * area_p, lv_coord_t w)
|
||||
{
|
||||
area_p->x2 = area_p->x1 + w - 1;
|
||||
area_p->x2 = area_p->x1 + w - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ void lv_area_set_width(lv_area_t * area_p, lv_coord_t w)
|
||||
*/
|
||||
void lv_area_set_height(lv_area_t * area_p, lv_coord_t h)
|
||||
{
|
||||
area_p->y2 = area_p->y1 + h - 1;
|
||||
area_p->y2 = area_p->y1 + h - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,12 +77,12 @@ void lv_area_set_height(lv_area_t * area_p, lv_coord_t h)
|
||||
*/
|
||||
void lv_area_set_pos(lv_area_t * area_p, lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
lv_coord_t w = lv_area_get_width(area_p);
|
||||
lv_coord_t h = lv_area_get_height(area_p);
|
||||
area_p->x1 = x;
|
||||
area_p->y1 = y;
|
||||
lv_area_set_width(area_p, w);
|
||||
lv_area_set_height(area_p, h);
|
||||
lv_coord_t w = lv_area_get_width(area_p);
|
||||
lv_coord_t h = lv_area_get_height(area_p);
|
||||
area_p->x1 = x;
|
||||
area_p->y1 = y;
|
||||
lv_area_set_width(area_p, w);
|
||||
lv_area_set_height(area_p, h);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ uint32_t lv_area_get_size(const lv_area_t * area_p)
|
||||
uint32_t size;
|
||||
|
||||
size = (uint32_t)(area_p->x2 - area_p->x1 + 1) *
|
||||
(area_p->y2 - area_p->y1 + 1);
|
||||
(area_p->y2 - area_p->y1 + 1);
|
||||
|
||||
return size;
|
||||
}
|
||||
@ -118,8 +118,7 @@ bool lv_area_union(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t *
|
||||
/*If x1 or y1 greater then x2 or y2 then the areas union is empty*/
|
||||
bool union_ok = true;
|
||||
if((res_p->x1 > res_p->x2) ||
|
||||
(res_p->y1 > res_p->y2))
|
||||
{
|
||||
(res_p->y1 > res_p->y2)) {
|
||||
union_ok = false;
|
||||
}
|
||||
|
||||
@ -150,8 +149,7 @@ bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p)
|
||||
bool is_on = false;
|
||||
|
||||
if((p_p->x >= a_p->x1 && p_p->x <= a_p->x2) &&
|
||||
((p_p->y >= a_p->y1 && p_p->y <= a_p->y2)))
|
||||
{
|
||||
((p_p->y >= a_p->y1 && p_p->y <= a_p->y2))) {
|
||||
is_on = true;
|
||||
}
|
||||
|
||||
@ -167,10 +165,9 @@ bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p)
|
||||
bool lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
if((a1_p->x1 <= a2_p->x2) &&
|
||||
(a1_p->x2 >= a2_p->x1) &&
|
||||
(a1_p->y1 <= a2_p->y2) &&
|
||||
(a1_p->y2 >= a2_p->y1))
|
||||
{
|
||||
(a1_p->x2 >= a2_p->x1) &&
|
||||
(a1_p->y1 <= a2_p->y2) &&
|
||||
(a1_p->y2 >= a2_p->y1)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -189,10 +186,9 @@ bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p)
|
||||
bool is_in = false;
|
||||
|
||||
if(ain_p->x1 >= aholder_p->x1 &&
|
||||
ain_p->y1 >= aholder_p->y1 &&
|
||||
ain_p->x2 <= aholder_p->x2 &&
|
||||
ain_p->y2 <= aholder_p->y2)
|
||||
{
|
||||
ain_p->y1 >= aholder_p->y1 &&
|
||||
ain_p->x2 <= aholder_p->x2 &&
|
||||
ain_p->y2 <= aholder_p->y2) {
|
||||
is_in = true;
|
||||
}
|
||||
|
||||
|
@ -66,11 +66,11 @@ void lv_circ_next(lv_point_t * c, lv_coord_t * tmp)
|
||||
{
|
||||
c->y++;
|
||||
|
||||
if (*tmp <= 0) {
|
||||
(*tmp) += 2 * c->y + 1; // Change in decision criterion for y -> y+1
|
||||
if(*tmp <= 0) {
|
||||
(*tmp) += 2 * c->y + 1; // Change in decision criterion for y -> y+1
|
||||
} else {
|
||||
c->x--;
|
||||
(*tmp) += 2 * (c->y - c->x) + 1; // Change for y -> y+1, x -> x-1
|
||||
c->x--;
|
||||
(*tmp) += 2 * (c->y - c->x) + 1; // Change for y -> y+1, x -> x-1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,7 @@ lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)
|
||||
|
||||
uint8_t region, remainder, p, q, t;
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
if(s == 0) {
|
||||
r = v;
|
||||
g = v;
|
||||
b = v;
|
||||
@ -68,25 +67,36 @@ lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)
|
||||
q = (v * (255 - ((s * remainder) >> 8))) >> 8;
|
||||
t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
|
||||
|
||||
switch (region)
|
||||
{
|
||||
switch(region) {
|
||||
case 0:
|
||||
r = v; g = t; b = p;
|
||||
r = v;
|
||||
g = t;
|
||||
b = p;
|
||||
break;
|
||||
case 1:
|
||||
r = q; g = v; b = p;
|
||||
r = q;
|
||||
g = v;
|
||||
b = p;
|
||||
break;
|
||||
case 2:
|
||||
r = p; g = v; b = t;
|
||||
r = p;
|
||||
g = v;
|
||||
b = t;
|
||||
break;
|
||||
case 3:
|
||||
r = p; g = q; b = v;
|
||||
r = p;
|
||||
g = q;
|
||||
b = v;
|
||||
break;
|
||||
case 4:
|
||||
r = t; g = p; b = v;
|
||||
r = t;
|
||||
g = p;
|
||||
b = v;
|
||||
break;
|
||||
default:
|
||||
r = v; g = p; b = q;
|
||||
r = v;
|
||||
g = p;
|
||||
b = q;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -110,23 +120,21 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b)
|
||||
rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b);
|
||||
|
||||
hsv.v = rgbMax;
|
||||
if (hsv.v == 0)
|
||||
{
|
||||
if(hsv.v == 0) {
|
||||
hsv.h = 0;
|
||||
hsv.s = 0;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
hsv.s = 255 * (long)(rgbMax - rgbMin) / hsv.v;
|
||||
if (hsv.s == 0)
|
||||
{
|
||||
if(hsv.s == 0) {
|
||||
hsv.h = 0;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
if (rgbMax == r)
|
||||
if(rgbMax == r)
|
||||
hsv.h = 0 + 43 * (g - b) / (rgbMax - rgbMin);
|
||||
else if (rgbMax == g)
|
||||
else if(rgbMax == g)
|
||||
hsv.h = 85 + 43 * (b - r) / (rgbMax - rgbMin);
|
||||
else
|
||||
hsv.h = 171 + 43 * (r - g) / (rgbMax - rgbMin);
|
||||
|
@ -22,7 +22,7 @@ typedef struct {
|
||||
uint32_t glyph_index;
|
||||
uint32_t unicode;
|
||||
uint8_t w_px;
|
||||
}asd_glyph_dsc_t;
|
||||
} asd_glyph_dsc_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
@ -179,7 +179,7 @@ void lv_font_init(void)
|
||||
* @param dsc_get_fp the font descriptor get function
|
||||
* @param parent add this font as charter set extension of 'parent'
|
||||
*/
|
||||
void lv_font_add(lv_font_t *child, lv_font_t *parent)
|
||||
void lv_font_add(lv_font_t * child, lv_font_t * parent)
|
||||
{
|
||||
if(parent == NULL) return;
|
||||
|
||||
@ -240,13 +240,13 @@ uint8_t lv_font_get_bpp(const lv_font_t * font, uint32_t letter)
|
||||
{
|
||||
const lv_font_t * font_i = font;
|
||||
while(font_i != NULL) {
|
||||
if(letter >= font_i->unicode_first && letter <= font_i->unicode_last) {
|
||||
return font_i->bpp;
|
||||
if(letter >= font_i->unicode_first && letter <= font_i->unicode_last) {
|
||||
return font_i->bpp;
|
||||
}
|
||||
font_i = font_i->next_page;
|
||||
}
|
||||
font_i = font_i->next_page;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,7 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static const char * lv_fs_get_real_path(const char * path);
|
||||
static lv_fs_drv_t* lv_fs_get_drv(char letter);
|
||||
static lv_fs_drv_t * lv_fs_get_drv(char letter);
|
||||
|
||||
|
||||
/**********************
|
||||
@ -57,7 +57,7 @@ void lv_fs_init(void)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_open (lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mode)
|
||||
lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
file_p->drv = NULL;
|
||||
file_p->file_d = NULL;
|
||||
@ -106,7 +106,7 @@ lv_fs_res_t lv_fs_open (lv_fs_file_t * file_p, const char * path, lv_fs_mode_t m
|
||||
* @param file_p pointer to a lv_fs_file_t variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_close (lv_fs_file_t * file_p)
|
||||
lv_fs_res_t lv_fs_close(lv_fs_file_t * file_p)
|
||||
{
|
||||
if(file_p->drv == NULL) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
@ -131,7 +131,7 @@ lv_fs_res_t lv_fs_close (lv_fs_file_t * file_p)
|
||||
* @param path path of the file to delete
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_remove (const char * path)
|
||||
lv_fs_res_t lv_fs_remove(const char * path)
|
||||
{
|
||||
if(path == NULL) return LV_FS_RES_INV_PARAM;
|
||||
lv_fs_drv_t * drv = NULL;
|
||||
@ -141,15 +141,15 @@ lv_fs_res_t lv_fs_remove (const char * path)
|
||||
drv = lv_fs_get_drv(letter);
|
||||
if(drv == NULL) return LV_FS_RES_NOT_EX;
|
||||
if(drv->ready != NULL) {
|
||||
if(drv->ready() == false) return LV_FS_RES_HW_ERR;
|
||||
if(drv->ready() == false) return LV_FS_RES_HW_ERR;
|
||||
}
|
||||
|
||||
if(drv->remove == NULL) return LV_FS_RES_NOT_IMP;
|
||||
if(drv->remove == NULL) return LV_FS_RES_NOT_IMP;
|
||||
|
||||
const char * real_path = lv_fs_get_real_path(path);
|
||||
lv_fs_res_t res = drv->remove(real_path);
|
||||
const char * real_path = lv_fs_get_real_path(path);
|
||||
lv_fs_res_t res = drv->remove(real_path);
|
||||
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,7 +160,7 @@ lv_fs_res_t lv_fs_remove (const char * path)
|
||||
* @param br the number of real read bytes (Bytes Read). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_read (lv_fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
lv_fs_res_t lv_fs_read(lv_fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
if(br != NULL) *br = 0;
|
||||
if(file_p->drv == NULL) return LV_FS_RES_INV_PARAM;
|
||||
@ -181,7 +181,7 @@ lv_fs_res_t lv_fs_read (lv_fs_file_t * file_p, void * buf, uint32_t btr, uint32_
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_write (lv_fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
lv_fs_res_t lv_fs_write(lv_fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
if(bw != NULL) *bw = 0;
|
||||
|
||||
@ -206,7 +206,7 @@ lv_fs_res_t lv_fs_write (lv_fs_file_t * file_p, const void * buf, uint32_t btw,
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_seek (lv_fs_file_t * file_p, uint32_t pos)
|
||||
lv_fs_res_t lv_fs_seek(lv_fs_file_t * file_p, uint32_t pos)
|
||||
{
|
||||
if(file_p->drv == NULL) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
@ -227,7 +227,7 @@ lv_fs_res_t lv_fs_seek (lv_fs_file_t * file_p, uint32_t pos)
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return LV_FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
lv_fs_res_t lv_fs_tell (lv_fs_file_t * file_p, uint32_t * pos)
|
||||
lv_fs_res_t lv_fs_tell(lv_fs_file_t * file_p, uint32_t * pos)
|
||||
{
|
||||
if(file_p->drv == NULL) {
|
||||
pos = 0;
|
||||
@ -250,7 +250,7 @@ lv_fs_res_t lv_fs_tell (lv_fs_file_t * file_p, uint32_t * pos)
|
||||
* @param size pointer to a variable to store the size
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_size (lv_fs_file_t * file_p, uint32_t * size)
|
||||
lv_fs_res_t lv_fs_size(lv_fs_file_t * file_p, uint32_t * size)
|
||||
{
|
||||
if(file_p->drv == NULL) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
@ -308,7 +308,7 @@ lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path)
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_dir_read (lv_fs_dir_t * rddir_p, char * fn)
|
||||
lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t * rddir_p, char * fn)
|
||||
{
|
||||
if(rddir_p->drv == NULL || rddir_p->dir_d == NULL) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
@ -328,7 +328,7 @@ lv_fs_res_t lv_fs_dir_read (lv_fs_dir_t * rddir_p, char * fn)
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_dir_close (lv_fs_dir_t * rddir_p)
|
||||
lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t * rddir_p)
|
||||
{
|
||||
if(rddir_p->drv == NULL || rddir_p->dir_d == NULL) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
@ -357,7 +357,7 @@ lv_fs_res_t lv_fs_dir_close (lv_fs_dir_t * rddir_p)
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_free (char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
lv_fs_res_t lv_fs_free(char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
lv_fs_drv_t * drv = lv_fs_get_drv(letter);
|
||||
|
||||
@ -388,11 +388,11 @@ lv_fs_res_t lv_fs_free (char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
*/
|
||||
void lv_fs_add_drv(lv_fs_drv_t * drv_p)
|
||||
{
|
||||
/*Save the new driver*/
|
||||
lv_fs_drv_t* new_drv;
|
||||
new_drv = lv_ll_ins_head(&drv_ll);
|
||||
lv_mem_assert(new_drv);
|
||||
memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
|
||||
/*Save the new driver*/
|
||||
lv_fs_drv_t * new_drv;
|
||||
new_drv = lv_ll_ins_head(&drv_ll);
|
||||
lv_mem_assert(new_drv);
|
||||
memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
|
||||
|
||||
}
|
||||
|
||||
@ -401,19 +401,19 @@ void lv_fs_add_drv(lv_fs_drv_t * drv_p)
|
||||
* @param buf buffer to store the letters ('\0' added after the last letter)
|
||||
* @return the buffer
|
||||
*/
|
||||
char * lv_fs_get_letters(char * buf)
|
||||
char * lv_fs_get_letters(char * buf)
|
||||
{
|
||||
lv_fs_drv_t* drv;
|
||||
uint8_t i = 0;
|
||||
lv_fs_drv_t * drv;
|
||||
uint8_t i = 0;
|
||||
|
||||
LL_READ(drv_ll, drv) {
|
||||
buf[i] = drv->letter;
|
||||
i++;
|
||||
}
|
||||
LL_READ(drv_ll, drv) {
|
||||
buf[i] = drv->letter;
|
||||
i++;
|
||||
}
|
||||
|
||||
buf[i] = '\0';
|
||||
buf[i] = '\0';
|
||||
|
||||
return buf;
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
@ -497,11 +497,11 @@ const char * lv_fs_get_last(const char * path)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Leave the driver letters and / or \ letters from beginning of the path
|
||||
* @param path path string (E.g. S:/folder/file.txt)
|
||||
* @return pointer to the beginning of the real path (E.g. folder/file.txt)
|
||||
*/
|
||||
/**
|
||||
* Leave the driver letters and / or \ letters from beginning of the path
|
||||
* @param path path string (E.g. S:/folder/file.txt)
|
||||
* @return pointer to the beginning of the real path (E.g. folder/file.txt)
|
||||
*/
|
||||
static const char * lv_fs_get_real_path(const char * path)
|
||||
{
|
||||
/* Example path: "S:/folder/file.txt"
|
||||
@ -510,10 +510,9 @@ static const char * lv_fs_get_real_path(const char * path)
|
||||
path ++; /*Ignore the driver letter*/
|
||||
|
||||
while(*path != '\0') {
|
||||
if(*path == ':' || *path == '\\' || *path == '/'){
|
||||
if(*path == ':' || *path == '\\' || *path == '/') {
|
||||
path ++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -526,9 +525,9 @@ static const char * lv_fs_get_real_path(const char * path)
|
||||
* @param letter the driver letter
|
||||
* @return pointer to a driver or NULL if not found
|
||||
*/
|
||||
static lv_fs_drv_t* lv_fs_get_drv(char letter)
|
||||
static lv_fs_drv_t * lv_fs_get_drv(char letter)
|
||||
{
|
||||
lv_fs_drv_t* drv;
|
||||
lv_fs_drv_t * drv;
|
||||
|
||||
LL_READ(drv_ll, drv) {
|
||||
if(drv->letter == letter) {
|
||||
|
@ -27,8 +27,8 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* prev);
|
||||
static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* next);
|
||||
static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * prev);
|
||||
static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * next);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -67,7 +67,7 @@ void lv_ll_init(lv_ll_t * ll_p, uint32_t n_size)
|
||||
*/
|
||||
void * lv_ll_ins_head(lv_ll_t * ll_p)
|
||||
{
|
||||
lv_ll_node_t* n_new;
|
||||
lv_ll_node_t * n_new;
|
||||
|
||||
n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE);
|
||||
|
||||
@ -96,15 +96,14 @@ void * lv_ll_ins_head(lv_ll_t * ll_p)
|
||||
*/
|
||||
void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act)
|
||||
{
|
||||
lv_ll_node_t* n_new;
|
||||
lv_ll_node_t* n_prev;
|
||||
lv_ll_node_t * n_new;
|
||||
lv_ll_node_t * n_prev;
|
||||
|
||||
if(NULL == ll_p || NULL == n_act) return NULL;
|
||||
|
||||
if(lv_ll_get_head(ll_p) == n_act) {
|
||||
n_new = lv_ll_ins_head(ll_p);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE);
|
||||
lv_mem_assert(n_new);
|
||||
|
||||
@ -125,7 +124,7 @@ void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act)
|
||||
*/
|
||||
void * lv_ll_ins_tail(lv_ll_t * ll_p)
|
||||
{
|
||||
lv_ll_node_t* n_new;
|
||||
lv_ll_node_t * n_new;
|
||||
|
||||
n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE);
|
||||
|
||||
@ -159,25 +158,20 @@ void lv_ll_rem(lv_ll_t * ll_p, void * node_p)
|
||||
ll_p->head = lv_ll_get_next(ll_p, node_p);
|
||||
if(ll_p->head == NULL) {
|
||||
ll_p->tail = NULL;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
node_set_prev(ll_p, ll_p->head, NULL);
|
||||
}
|
||||
}
|
||||
else if(lv_ll_get_tail(ll_p) == node_p) {
|
||||
} else if(lv_ll_get_tail(ll_p) == node_p) {
|
||||
/*The new tail will be the node before 'n_act'*/
|
||||
ll_p->tail = lv_ll_get_prev(ll_p, node_p);
|
||||
if(ll_p->tail == NULL) {
|
||||
ll_p->head = NULL;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
node_set_next(ll_p, ll_p->tail, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_ll_node_t* n_prev = lv_ll_get_prev(ll_p, node_p);
|
||||
lv_ll_node_t* n_next = lv_ll_get_next(ll_p, node_p);
|
||||
} else {
|
||||
lv_ll_node_t * n_prev = lv_ll_get_prev(ll_p, node_p);
|
||||
lv_ll_node_t * n_next = lv_ll_get_next(ll_p, node_p);
|
||||
|
||||
node_set_next(ll_p, n_prev, n_next);
|
||||
node_set_prev(ll_p, n_next, n_prev);
|
||||
@ -190,20 +184,20 @@ void lv_ll_rem(lv_ll_t * ll_p, void * node_p)
|
||||
*/
|
||||
void lv_ll_clear(lv_ll_t * ll_p)
|
||||
{
|
||||
void * i;
|
||||
void * i_next;
|
||||
void * i;
|
||||
void * i_next;
|
||||
|
||||
i = lv_ll_get_head(ll_p);
|
||||
i_next = NULL;
|
||||
i = lv_ll_get_head(ll_p);
|
||||
i_next = NULL;
|
||||
|
||||
while(i != NULL) {
|
||||
i_next = lv_ll_get_next(ll_p, i);
|
||||
while(i != NULL) {
|
||||
i_next = lv_ll_get_next(ll_p, i);
|
||||
|
||||
lv_ll_rem(ll_p, i);
|
||||
lv_mem_free(i);
|
||||
lv_ll_rem(ll_p, i);
|
||||
lv_mem_free(i);
|
||||
|
||||
i = i_next;
|
||||
}
|
||||
i = i_next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,7 +267,7 @@ void * lv_ll_get_next(lv_ll_t * ll_p, void * n_act)
|
||||
void * next = NULL;
|
||||
|
||||
if(ll_p != NULL) {
|
||||
lv_ll_node_t* n_act_d = n_act;
|
||||
lv_ll_node_t * n_act_d = n_act;
|
||||
memcpy(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *));
|
||||
}
|
||||
|
||||
@ -291,7 +285,7 @@ void * lv_ll_get_prev(lv_ll_t * ll_p, void * n_act)
|
||||
void * prev = NULL;
|
||||
|
||||
if(ll_p != NULL) {
|
||||
lv_ll_node_t* n_act_d = n_act;
|
||||
lv_ll_node_t * n_act_d = n_act;
|
||||
memcpy(&prev, n_act_d + LL_PREV_P_OFFSET(ll_p), sizeof(void *));
|
||||
}
|
||||
|
||||
@ -342,9 +336,9 @@ void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after)
|
||||
* @param act pointer to a node which prev. node pointer should be set
|
||||
* @param prev pointer to a node which should be the previous node before 'act'
|
||||
*/
|
||||
static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* prev)
|
||||
static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * prev)
|
||||
{
|
||||
memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, sizeof(lv_ll_node_t*));
|
||||
memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, sizeof(lv_ll_node_t *));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,8 +347,8 @@ static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* prev)
|
||||
* @param act pointer to a node which next node pointer should be set
|
||||
* @param next pointer to a node which should be the next node before 'act'
|
||||
*/
|
||||
static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t* act, lv_ll_node_t* next)
|
||||
static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * next)
|
||||
{
|
||||
memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, sizeof(lv_ll_node_t*));
|
||||
memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, sizeof(lv_ll_node_t *));
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ char * lv_math_num_to_str(int32_t num, char * buf)
|
||||
uint32_t output = 0;
|
||||
int8_t i;
|
||||
|
||||
for(i = 31; i >= 0; i--){
|
||||
for(i = 31; i >= 0; i--) {
|
||||
if((output & 0xF) >= 5)
|
||||
output += 3;
|
||||
if(((output & 0xF0) >> 4) >= 5)
|
||||
|
@ -26,21 +26,18 @@
|
||||
**********************/
|
||||
|
||||
/*The size of this union must be 4 bytes (uint32_t)*/
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t used:1; //1: if the entry is used
|
||||
uint32_t d_size:31; //Size off the data (1 means 4 bytes)
|
||||
};
|
||||
uint32_t header; //The header (used + d_size)
|
||||
}lv_mem_header_t;
|
||||
typedef union {
|
||||
struct {
|
||||
uint32_t used: 1; //1: if the entry is used
|
||||
uint32_t d_size: 31; //Size off the data (1 means 4 bytes)
|
||||
};
|
||||
uint32_t header; //The header (used + d_size)
|
||||
} lv_mem_header_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
lv_mem_header_t header;
|
||||
uint8_t first_data; /*First data byte in the allocated data (Just for easily create a pointer)*/
|
||||
}lv_mem_ent_t;
|
||||
} lv_mem_ent_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
@ -93,7 +90,7 @@ void * lv_mem_alloc(uint32_t size)
|
||||
}
|
||||
|
||||
/*Round the size up to 4*/
|
||||
if(size & 0x3 ) {
|
||||
if(size & 0x3) {
|
||||
size = size & (~0x3);
|
||||
size += 4;
|
||||
}
|
||||
@ -112,8 +109,8 @@ void * lv_mem_alloc(uint32_t size)
|
||||
if(e != NULL) {
|
||||
alloc = ent_alloc(e, size);
|
||||
}
|
||||
//End if there is not next entry OR the alloc. is successful
|
||||
}while(e != NULL && alloc == NULL);
|
||||
//End if there is not next entry OR the alloc. is successful
|
||||
} while(e != NULL && alloc == NULL);
|
||||
|
||||
#if LV_MEM_ADD_JUNK
|
||||
if(alloc != NULL) memset(alloc, 0xaa, size);
|
||||
@ -123,9 +120,9 @@ void * lv_mem_alloc(uint32_t size)
|
||||
/*Allocate a header too to store the size*/
|
||||
alloc = LV_MEM_CUSTOM_ALLOC(size + sizeof(lv_mem_header_t));
|
||||
if(alloc != NULL) {
|
||||
((lv_mem_ent_t*) alloc)->header.d_size = size;
|
||||
((lv_mem_ent_t*) alloc)->header.used = 1;
|
||||
alloc = &((lv_mem_ent_t*) alloc)->first_data;
|
||||
((lv_mem_ent_t *) alloc)->header.d_size = size;
|
||||
((lv_mem_ent_t *) alloc)->header.used = 1;
|
||||
alloc = &((lv_mem_ent_t *) alloc)->first_data;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -143,7 +140,7 @@ void lv_mem_free(const void * data)
|
||||
|
||||
|
||||
#if LV_MEM_ADD_JUNK
|
||||
memset((void*)data, 0xbb, lv_mem_get_size(data));
|
||||
memset((void *)data, 0xbb, lv_mem_get_size(data));
|
||||
#endif
|
||||
|
||||
/*e points to the header*/
|
||||
@ -321,12 +318,10 @@ static lv_mem_ent_t * ent_get_next(lv_mem_ent_t * act_e)
|
||||
lv_mem_ent_t * next_e = NULL;
|
||||
|
||||
if(act_e == NULL) { /*NULL means: get the first entry*/
|
||||
next_e = (lv_mem_ent_t * ) work_mem;
|
||||
}
|
||||
else /*Get the next entry */
|
||||
{
|
||||
next_e = (lv_mem_ent_t *) work_mem;
|
||||
} else { /*Get the next entry */
|
||||
uint8_t * data = &act_e->first_data;
|
||||
next_e = (lv_mem_ent_t * )&data[act_e->header.d_size];
|
||||
next_e = (lv_mem_ent_t *)&data[act_e->header.d_size];
|
||||
|
||||
if(&next_e->first_data >= &work_mem[LV_MEM_SIZE]) next_e = NULL;
|
||||
}
|
||||
@ -350,7 +345,7 @@ static void * ent_alloc(lv_mem_ent_t * e, uint32_t size)
|
||||
/*Truncate the entry to the desired size */
|
||||
ent_trunc(e, size),
|
||||
|
||||
e->header.used = 1;
|
||||
e->header.used = 1;
|
||||
|
||||
/*Save the allocated data*/
|
||||
alloc = &e->first_data;
|
||||
@ -367,7 +362,7 @@ static void * ent_alloc(lv_mem_ent_t * e, uint32_t size)
|
||||
static void ent_trunc(lv_mem_ent_t * e, uint32_t size)
|
||||
{
|
||||
/*Round the size up to 4*/
|
||||
if(size & 0x3 ) {
|
||||
if(size & 0x3) {
|
||||
size = size & (~0x3);
|
||||
size += 4;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_task_exec (lv_task_t* lv_task_p);
|
||||
static bool lv_task_exec(lv_task_t * lv_task_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -61,57 +61,57 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
|
||||
static uint32_t handler_start = 0;
|
||||
static uint32_t busy_time = 0;
|
||||
|
||||
if(lv_task_run == false) return;
|
||||
if(lv_task_run == false) return;
|
||||
|
||||
handler_start = lv_tick_get();
|
||||
handler_start = lv_tick_get();
|
||||
|
||||
/* Run all task from the highest to the lowest priority
|
||||
* If a lower priority task is executed check task again from the highest priority
|
||||
* but on the priority of executed tasks don't run tasks before the executed*/
|
||||
lv_task_t * task_interruper = NULL;
|
||||
/* Run all task from the highest to the lowest priority
|
||||
* If a lower priority task is executed check task again from the highest priority
|
||||
* but on the priority of executed tasks don't run tasks before the executed*/
|
||||
lv_task_t * task_interruper = NULL;
|
||||
lv_task_t * next;
|
||||
bool end_flag;
|
||||
do {
|
||||
end_flag = true;
|
||||
lv_task_t * act = lv_ll_get_head(&lv_task_ll);
|
||||
while(act){
|
||||
/* The task might be deleted if it runs only once ('once = 1')
|
||||
* So get next element until the current is surely valid*/
|
||||
next = lv_ll_get_next(&lv_task_ll, act);
|
||||
bool end_flag;
|
||||
do {
|
||||
end_flag = true;
|
||||
lv_task_t * act = lv_ll_get_head(&lv_task_ll);
|
||||
while(act) {
|
||||
/* The task might be deleted if it runs only once ('once = 1')
|
||||
* So get next element until the current is surely valid*/
|
||||
next = lv_ll_get_next(&lv_task_ll, act);
|
||||
|
||||
/*Here is the interrupter task. Don't execute it again.*/
|
||||
if(act == task_interruper) {
|
||||
task_interruper = NULL; /*From this point only task after the interrupter comes, so the interrupter is not interesting anymore*/
|
||||
act = next;
|
||||
continue; /*Load the next task*/
|
||||
}
|
||||
/*Here is the interrupter task. Don't execute it again.*/
|
||||
if(act == task_interruper) {
|
||||
task_interruper = NULL; /*From this point only task after the interrupter comes, so the interrupter is not interesting anymore*/
|
||||
act = next;
|
||||
continue; /*Load the next task*/
|
||||
}
|
||||
|
||||
/*Just try to run the tasks with highest priority.*/
|
||||
if(act->prio == LV_TASK_PRIO_HIGHEST) {
|
||||
lv_task_exec(act);
|
||||
}
|
||||
/*Tasks with higher priority then the interrupted shall be run in every case*/
|
||||
else if(task_interruper) {
|
||||
if(act->prio > task_interruper->prio) {
|
||||
if(lv_task_exec(act)) {
|
||||
task_interruper = act; /*Check all tasks again from the highest priority */
|
||||
end_flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* It is no interrupter task or we already reached it earlier.
|
||||
* Just run the remaining tasks*/
|
||||
else {
|
||||
if(lv_task_exec(act)) {
|
||||
task_interruper = act; /*Check all tasks again from the highest priority */
|
||||
end_flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
act = next; /*Load the next task*/
|
||||
}
|
||||
} while(!end_flag);
|
||||
/*Just try to run the tasks with highest priority.*/
|
||||
if(act->prio == LV_TASK_PRIO_HIGHEST) {
|
||||
lv_task_exec(act);
|
||||
}
|
||||
/*Tasks with higher priority then the interrupted shall be run in every case*/
|
||||
else if(task_interruper) {
|
||||
if(act->prio > task_interruper->prio) {
|
||||
if(lv_task_exec(act)) {
|
||||
task_interruper = act; /*Check all tasks again from the highest priority */
|
||||
end_flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* It is no interrupter task or we already reached it earlier.
|
||||
* Just run the remaining tasks*/
|
||||
else {
|
||||
if(lv_task_exec(act)) {
|
||||
task_interruper = act; /*Check all tasks again from the highest priority */
|
||||
end_flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
act = next; /*Load the next task*/
|
||||
}
|
||||
} while(!end_flag);
|
||||
|
||||
busy_time += lv_tick_elaps(handler_start);
|
||||
uint32_t idle_period_time = lv_tick_elaps(idle_period_start);
|
||||
@ -134,24 +134,23 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
|
||||
* @param param free parameter
|
||||
* @return pointer to the new task
|
||||
*/
|
||||
lv_task_t* lv_task_create(void (*task) (void *), uint32_t period, lv_task_prio_t prio, void * param)
|
||||
lv_task_t * lv_task_create(void (*task)(void *), uint32_t period, lv_task_prio_t prio, void * param)
|
||||
{
|
||||
lv_task_t* new_lv_task = NULL;
|
||||
lv_task_t* tmp;
|
||||
lv_task_t * new_lv_task = NULL;
|
||||
lv_task_t * tmp;
|
||||
|
||||
/*Create task lists in order of priority from high to low*/
|
||||
tmp = lv_ll_get_head(&lv_task_ll);
|
||||
if(NULL == tmp) { /*First task*/
|
||||
new_lv_task = lv_ll_ins_head(&lv_task_ll);
|
||||
}
|
||||
else{
|
||||
do{
|
||||
if(tmp->prio <= prio){
|
||||
} else {
|
||||
do {
|
||||
if(tmp->prio <= prio) {
|
||||
new_lv_task = lv_ll_ins_prev(&lv_task_ll, tmp);
|
||||
break;
|
||||
}
|
||||
tmp = lv_ll_get_next(&lv_task_ll,tmp);
|
||||
}while(tmp != NULL);
|
||||
tmp = lv_ll_get_next(&lv_task_ll, tmp);
|
||||
} while(tmp != NULL);
|
||||
|
||||
if(tmp == NULL) { /*Only too high priority tasks were found*/
|
||||
new_lv_task = lv_ll_ins_tail(&lv_task_ll);
|
||||
@ -175,7 +174,7 @@ lv_task_t* lv_task_create(void (*task) (void *), uint32_t period, lv_task_prio_t
|
||||
* Delete a lv_task
|
||||
* @param lv_task_p pointer to task created by lv_task_p
|
||||
*/
|
||||
void lv_task_del(lv_task_t* lv_task_p)
|
||||
void lv_task_del(lv_task_t * lv_task_p)
|
||||
{
|
||||
lv_ll_rem(&lv_task_ll, lv_task_p);
|
||||
|
||||
@ -187,7 +186,7 @@ void lv_task_del(lv_task_t* lv_task_p)
|
||||
* @param lv_task_p pointer to a lv_task
|
||||
* @param prio the new priority
|
||||
*/
|
||||
void lv_task_set_prio(lv_task_t* lv_task_p, lv_task_prio_t prio)
|
||||
void lv_task_set_prio(lv_task_t * lv_task_p, lv_task_prio_t prio)
|
||||
{
|
||||
/*Find the tasks with new priority*/
|
||||
lv_task_t * i;
|
||||
@ -212,7 +211,7 @@ void lv_task_set_prio(lv_task_t* lv_task_p, lv_task_prio_t prio)
|
||||
* @param lv_task_p pointer to a lv_task
|
||||
* @param period the new period
|
||||
*/
|
||||
void lv_task_set_period(lv_task_t* lv_task_p, uint32_t period)
|
||||
void lv_task_set_period(lv_task_t * lv_task_p, uint32_t period)
|
||||
{
|
||||
lv_task_p->period = period;
|
||||
}
|
||||
@ -221,7 +220,7 @@ void lv_task_set_period(lv_task_t* lv_task_p, uint32_t period)
|
||||
* Make a lv_task ready. It will not wait its period.
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
*/
|
||||
void lv_task_ready(lv_task_t* lv_task_p)
|
||||
void lv_task_ready(lv_task_t * lv_task_p)
|
||||
{
|
||||
lv_task_p->last_run = lv_tick_get() - lv_task_p->period - 1;
|
||||
}
|
||||
@ -240,7 +239,7 @@ void lv_task_once(lv_task_t * lv_task_p)
|
||||
* It will be called the previously set period milliseconds later.
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
*/
|
||||
void lv_task_reset(lv_task_t* lv_task_p)
|
||||
void lv_task_reset(lv_task_t * lv_task_p)
|
||||
{
|
||||
lv_task_p->last_run = lv_tick_get();
|
||||
}
|
||||
@ -251,7 +250,7 @@ void lv_task_reset(lv_task_t* lv_task_p)
|
||||
*/
|
||||
void lv_task_enable(bool en)
|
||||
{
|
||||
lv_task_run = en;
|
||||
lv_task_run = en;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,7 +272,7 @@ uint8_t lv_task_get_idle(void)
|
||||
* @param lv_task_p pointer to lv_task
|
||||
* @return true: execute, false: not executed
|
||||
*/
|
||||
static bool lv_task_exec (lv_task_t* lv_task_p)
|
||||
static bool lv_task_exec(lv_task_t * lv_task_p)
|
||||
{
|
||||
bool exec = false;
|
||||
|
||||
|
@ -24,8 +24,7 @@
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static int16_t sin0_90_table[] =
|
||||
{
|
||||
static int16_t sin0_90_table[] = {
|
||||
0, 572, 1144, 1715, 2286, 2856, 3425, 3993, 4560, 5126,
|
||||
5690, 6252, 6813, 7371, 7927, 8481, 9032, 9580, 10126, 10668,
|
||||
11207, 11743, 12275, 12803, 13328, 13848, 14364, 14876, 15383, 15886,
|
||||
@ -58,14 +57,12 @@ int16_t lv_trigo_sin(int16_t angle)
|
||||
|
||||
if(angle < 0) angle = 360 + angle;
|
||||
|
||||
if(angle < 90){
|
||||
if(angle < 90) {
|
||||
ret = sin0_90_table[angle];
|
||||
} else if(angle >= 90 && angle < 180)
|
||||
{
|
||||
} else if(angle >= 90 && angle < 180) {
|
||||
angle = 179 - angle;
|
||||
ret = sin0_90_table[angle];
|
||||
} else if(angle >= 180 && angle < 270)
|
||||
{
|
||||
} else if(angle >= 180 && angle < 270) {
|
||||
angle = angle - 180;
|
||||
ret = - sin0_90_table[angle];
|
||||
} else { /*angle >=270*/
|
||||
|
@ -47,7 +47,7 @@ static bool is_break_char(uint32_t letter);
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks
|
||||
*/
|
||||
void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag)
|
||||
lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag)
|
||||
{
|
||||
|
||||
size_res->x = 0;
|
||||
@ -64,14 +64,14 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
|
||||
uint8_t letter_height = lv_font_get_height(font);
|
||||
|
||||
/*Calc. the height and longest line*/
|
||||
while (text[line_start] != '\0') {
|
||||
while(text[line_start] != '\0') {
|
||||
new_line_start += lv_txt_get_next_line(&text[line_start], font, letter_space, max_width, flag);
|
||||
size_res->y += letter_height ;
|
||||
size_res->y += line_space;
|
||||
|
||||
/*Calculate the the longest line*/
|
||||
act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start,
|
||||
font, letter_space, flag);
|
||||
font, letter_space, flag);
|
||||
|
||||
size_res->x = LV_MATH_MAX(act_line_length, size_res->x);
|
||||
line_start = new_line_start;
|
||||
@ -97,7 +97,7 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
|
||||
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
|
||||
*/
|
||||
uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t max_width, lv_txt_flag_t flag)
|
||||
lv_coord_t letter_space, lv_coord_t max_width, lv_txt_flag_t flag)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
@ -140,7 +140,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
* Hence do nothing here*/
|
||||
}
|
||||
/*If already a break character is found, then break there*/
|
||||
if(last_break != NO_BREAK_FOUND ) {
|
||||
if(last_break != NO_BREAK_FOUND) {
|
||||
i = last_break;
|
||||
} else {
|
||||
/* Now this character is out of the area so it will be first character of the next line*/
|
||||
@ -200,7 +200,7 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
|
||||
}
|
||||
|
||||
|
||||
width -= letter_space; /*Trim the last letter space. Important if the text is center aligned */
|
||||
width -= letter_space; /*Trim the last letter space. Important if the text is center aligned */
|
||||
|
||||
/*Trim closing spaces. Important when the text is aligned to the middle */
|
||||
for(i = length - 1; i > 0; i--) {
|
||||
@ -229,26 +229,26 @@ bool lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c)
|
||||
bool ret = false;
|
||||
|
||||
if(c == (uint32_t)LV_TXT_COLOR_CMD[0]) {
|
||||
if(*state == LV_TXT_CMD_STATE_WAIT) { /*Start char*/
|
||||
*state = LV_TXT_CMD_STATE_PAR;
|
||||
ret = true;
|
||||
} else if(*state == LV_TXT_CMD_STATE_PAR) { /*Other start char in parameter is escaped cmd. char */
|
||||
*state = LV_TXT_CMD_STATE_WAIT;
|
||||
}else if(*state == LV_TXT_CMD_STATE_IN) { /*Command end */
|
||||
*state = LV_TXT_CMD_STATE_WAIT;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
if(*state == LV_TXT_CMD_STATE_WAIT) { /*Start char*/
|
||||
*state = LV_TXT_CMD_STATE_PAR;
|
||||
ret = true;
|
||||
} else if(*state == LV_TXT_CMD_STATE_PAR) { /*Other start char in parameter is escaped cmd. char */
|
||||
*state = LV_TXT_CMD_STATE_WAIT;
|
||||
} else if(*state == LV_TXT_CMD_STATE_IN) { /*Command end */
|
||||
*state = LV_TXT_CMD_STATE_WAIT;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*Skip the color parameter and wait the space after it*/
|
||||
if(*state == LV_TXT_CMD_STATE_PAR) {
|
||||
if(c == ' ') {
|
||||
*state = LV_TXT_CMD_STATE_IN; /*After the parameter the text is in the command*/
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
/*Skip the color parameter and wait the space after it*/
|
||||
if(*state == LV_TXT_CMD_STATE_PAR) {
|
||||
if(c == ' ') {
|
||||
*state = LV_TXT_CMD_STATE_IN; /*After the parameter the text is in the command*/
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,7 +268,7 @@ void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
|
||||
#endif
|
||||
/*Copy the second part into the end to make place to text to insert*/
|
||||
uint32_t i;
|
||||
for(i = new_len; i >= pos + ins_len; i--){
|
||||
for(i = new_len; i >= pos + ins_len; i--) {
|
||||
txt_buf[i] = txt_buf[i - ins_len];
|
||||
}
|
||||
|
||||
@ -293,8 +293,8 @@ void lv_txt_cut(char * txt, uint32_t pos, uint32_t len)
|
||||
|
||||
/*Copy the second part into the end to make place to text to insert*/
|
||||
uint32_t i;
|
||||
for(i = pos; i <= old_len - len; i++){
|
||||
txt[i] = txt[i+len];
|
||||
for(i = pos; i <= old_len - len; i++) {
|
||||
txt[i] = txt[i + len];
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,26 +323,24 @@ uint32_t lv_txt_unicode_to_utf8(uint32_t letter_uni)
|
||||
if(letter_uni < 128) return letter_uni;
|
||||
uint8_t bytes[4];
|
||||
|
||||
if (letter_uni < 0x0800) {
|
||||
bytes[0] = ((letter_uni>>6) & 0x1F) | 0xC0;
|
||||
bytes[1] = ((letter_uni>>0) & 0x3F) | 0x80;
|
||||
if(letter_uni < 0x0800) {
|
||||
bytes[0] = ((letter_uni >> 6) & 0x1F) | 0xC0;
|
||||
bytes[1] = ((letter_uni >> 0) & 0x3F) | 0x80;
|
||||
bytes[2] = 0;
|
||||
bytes[3] = 0;
|
||||
}
|
||||
else if (letter_uni < 0x010000) {
|
||||
bytes[0] = ((letter_uni>>12) & 0x0F) | 0xE0;
|
||||
bytes[1] = ((letter_uni>>6) & 0x3F) | 0x80;
|
||||
bytes[2] = ((letter_uni>>0) & 0x3F) | 0x80;
|
||||
} else if(letter_uni < 0x010000) {
|
||||
bytes[0] = ((letter_uni >> 12) & 0x0F) | 0xE0;
|
||||
bytes[1] = ((letter_uni >> 6) & 0x3F) | 0x80;
|
||||
bytes[2] = ((letter_uni >> 0) & 0x3F) | 0x80;
|
||||
bytes[3] = 0;
|
||||
}
|
||||
else if (letter_uni < 0x110000) {
|
||||
bytes[0] = ((letter_uni>>18) & 0x07) | 0xF0;
|
||||
bytes[1] = ((letter_uni>>12) & 0x3F) | 0x80;
|
||||
bytes[2] = ((letter_uni>>6) & 0x3F) | 0x80;
|
||||
bytes[3] = ((letter_uni>>0) & 0x3F) | 0x80;
|
||||
} else if(letter_uni < 0x110000) {
|
||||
bytes[0] = ((letter_uni >> 18) & 0x07) | 0xF0;
|
||||
bytes[1] = ((letter_uni >> 12) & 0x3F) | 0x80;
|
||||
bytes[2] = ((letter_uni >> 6) & 0x3F) | 0x80;
|
||||
bytes[3] = ((letter_uni >> 0) & 0x3F) | 0x80;
|
||||
}
|
||||
|
||||
uint32_t *res_p = (uint32_t *)bytes;
|
||||
uint32_t * res_p = (uint32_t *)bytes;
|
||||
return *res_p;
|
||||
}
|
||||
|
||||
@ -437,7 +435,7 @@ uint32_t lv_txt_utf8_next(const char * txt, uint32_t * i)
|
||||
uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i)
|
||||
{
|
||||
#if LV_TXT_UTF8 == 0
|
||||
if(i == NULL) return *(txt- 1); /*Get the prev. char */
|
||||
if(i == NULL) return *(txt - 1); /*Get the prev. char */
|
||||
|
||||
(*i)--;
|
||||
uint8_t letter = txt[*i] ;
|
||||
@ -454,7 +452,7 @@ uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i)
|
||||
|
||||
c_size = lv_txt_utf8_size(txt[*i]);
|
||||
if(c_size == 0) {
|
||||
if(*i != 0) (*i)--;
|
||||
if(*i != 0)(*i)--;
|
||||
else return 0;
|
||||
}
|
||||
cnt++;
|
||||
|
@ -26,8 +26,8 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_ufs_ent_t* lv_ufs_ent_get(const char * fn);
|
||||
static lv_ufs_ent_t* lv_ufs_ent_new(const char * fn);
|
||||
static lv_ufs_ent_t * lv_ufs_ent_get(const char * fn);
|
||||
static lv_ufs_ent_t * lv_ufs_ent_new(const char * fn);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -95,15 +95,15 @@ bool lv_ufs_ready(void)
|
||||
* @return LV_FS_RES_OK: no error, the file is opened
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_open (void * file_p, const char * fn, lv_fs_mode_t mode)
|
||||
lv_fs_res_t lv_ufs_open(void * file_p, const char * fn, lv_fs_mode_t mode)
|
||||
{
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_ent_t* ent = lv_ufs_ent_get(fn);
|
||||
lv_ufs_ent_t * ent = lv_ufs_ent_get(fn);
|
||||
|
||||
fp->ent = NULL;
|
||||
|
||||
/*If the file not exists ...*/
|
||||
if( ent == NULL) {
|
||||
if(ent == NULL) {
|
||||
if((mode & LV_FS_MODE_WR) != 0) { /*Create the file if opened for write*/
|
||||
ent = lv_ufs_ent_new(fn);
|
||||
if(ent == NULL) return LV_FS_RES_FULL; /*No space for the new file*/
|
||||
@ -154,7 +154,7 @@ lv_fs_res_t lv_ufs_create_const(const char * fn, const void * const_p, uint32_t
|
||||
res = lv_ufs_open(&file, fn, LV_FS_MODE_WR);
|
||||
if(res != LV_FS_RES_OK) return res;
|
||||
|
||||
lv_ufs_ent_t* ent = file.ent;
|
||||
lv_ufs_ent_t * ent = file.ent;
|
||||
|
||||
if(ent->data_d != NULL) return LV_FS_RES_DENIED;
|
||||
|
||||
@ -174,7 +174,7 @@ lv_fs_res_t lv_ufs_create_const(const char * fn, const void * const_p, uint32_t
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_close (void * file_p)
|
||||
lv_fs_res_t lv_ufs_close(void * file_p)
|
||||
{
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
@ -196,8 +196,8 @@ lv_fs_res_t lv_ufs_close (void * file_p)
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_remove(const char * fn)
|
||||
{
|
||||
lv_ufs_ent_t* ent = lv_ufs_ent_get(fn);
|
||||
if(ent == NULL) return LV_FS_RES_DENIED; /*File not exists*/
|
||||
lv_ufs_ent_t * ent = lv_ufs_ent_get(fn);
|
||||
if(ent == NULL) return LV_FS_RES_DENIED; /*File not exists*/
|
||||
|
||||
/*Can not be deleted is opened*/
|
||||
if(ent->oc != 0) return LV_FS_RES_DENIED;
|
||||
@ -205,7 +205,7 @@ lv_fs_res_t lv_ufs_remove(const char * fn)
|
||||
lv_ll_rem(&file_ll, ent);
|
||||
lv_mem_free(ent->fn_d);
|
||||
ent->fn_d = NULL;
|
||||
if(ent->const_data == 0){
|
||||
if(ent->const_data == 0) {
|
||||
lv_mem_free(ent->data_d);
|
||||
ent->data_d = NULL;
|
||||
}
|
||||
@ -224,11 +224,11 @@ lv_fs_res_t lv_ufs_remove(const char * fn)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
lv_fs_res_t lv_ufs_read(void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_ent_t * ent = fp->ent;
|
||||
*br = 0;
|
||||
|
||||
if(ent->data_d == NULL || ent->size == 0) { /*Don't read empty files*/
|
||||
@ -239,15 +239,15 @@ lv_fs_res_t lv_ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
|
||||
/*No error, read the file*/
|
||||
if(fp->rwp + btr > ent->size) { /*Check too much bytes read*/
|
||||
*br = ent->size - fp->rwp;
|
||||
*br = ent->size - fp->rwp;
|
||||
} else {
|
||||
*br = btr;
|
||||
*br = btr;
|
||||
}
|
||||
|
||||
/*Read the data*/
|
||||
uint8_t * data8_p;
|
||||
if(ent->const_data == 0) {
|
||||
data8_p = (uint8_t*) ent->data_d;
|
||||
data8_p = (uint8_t *) ent->data_d;
|
||||
} else {
|
||||
data8_p = ent->data_d;
|
||||
}
|
||||
@ -269,19 +269,19 @@ lv_fs_res_t lv_ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
lv_fs_res_t lv_ufs_write(void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
*bw = 0;
|
||||
|
||||
if(fp->aw == 0) return LV_FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_ent_t * ent = fp->ent;
|
||||
|
||||
/*Reallocate data array if it necessary*/
|
||||
uint32_t new_size = fp->rwp + btw;
|
||||
if(new_size > ent->size) {
|
||||
uint8_t* new_data = lv_mem_realloc(ent->data_d, new_size);
|
||||
uint8_t * new_data = lv_mem_realloc(ent->data_d, new_size);
|
||||
if(new_data == NULL) return LV_FS_RES_FULL; /*Cannot allocate the new memory*/
|
||||
|
||||
ent->data_d = new_data;
|
||||
@ -289,7 +289,7 @@ lv_fs_res_t lv_ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_
|
||||
}
|
||||
|
||||
/*Write the file*/
|
||||
uint8_t * data8_p = (uint8_t*) ent->data_d;
|
||||
uint8_t * data8_p = (uint8_t *) ent->data_d;
|
||||
data8_p += fp->rwp;
|
||||
memcpy(data8_p, buf, btw);
|
||||
*bw = btw;
|
||||
@ -305,10 +305,10 @@ lv_fs_res_t lv_ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_seek (void * file_p, uint32_t pos)
|
||||
lv_fs_res_t lv_ufs_seek(void * file_p, uint32_t pos)
|
||||
{
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_ent_t * ent = fp->ent;
|
||||
|
||||
/*Simply move the rwp before EOF*/
|
||||
if(pos < ent->size) {
|
||||
@ -316,7 +316,7 @@ lv_fs_res_t lv_ufs_seek (void * file_p, uint32_t pos)
|
||||
} else { /*Expand the file size*/
|
||||
if(fp->aw == 0) return LV_FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
uint8_t* new_data = lv_mem_realloc(ent->data_d, pos);
|
||||
uint8_t * new_data = lv_mem_realloc(ent->data_d, pos);
|
||||
if(new_data == NULL) return LV_FS_RES_FULL; /*Out of memory*/
|
||||
|
||||
ent->data_d = new_data;
|
||||
@ -334,7 +334,7 @@ lv_fs_res_t lv_ufs_seek (void * file_p, uint32_t pos)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_tell (void * file_p, uint32_t * pos_p)
|
||||
lv_fs_res_t lv_ufs_tell(void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
@ -349,10 +349,10 @@ lv_fs_res_t lv_ufs_tell (void * file_p, uint32_t * pos_p)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_trunc (void * file_p)
|
||||
lv_fs_res_t lv_ufs_trunc(void * file_p)
|
||||
{
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_ent_t * ent = fp->ent;
|
||||
|
||||
if(fp->aw == 0) return LV_FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
@ -372,10 +372,10 @@ lv_fs_res_t lv_ufs_trunc (void * file_p)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv__fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_size (void * file_p, uint32_t * size_p)
|
||||
lv_fs_res_t lv_ufs_size(void * file_p, uint32_t * size_p)
|
||||
{
|
||||
lv_ufs_file_t * fp = file_p; /*Convert type*/
|
||||
lv_ufs_ent_t* ent = fp->ent;
|
||||
lv_ufs_ent_t * ent = fp->ent;
|
||||
|
||||
*size_p = ent->size;
|
||||
|
||||
@ -415,7 +415,7 @@ lv_fs_res_t lv_ufs_dir_read(void * dir_p, char * fn)
|
||||
}
|
||||
|
||||
if(ufs_dir_p->last_ent != NULL) {
|
||||
strcpy(fn, ufs_dir_p->last_ent->fn_d);
|
||||
strcpy(fn, ufs_dir_p->last_ent->fn_d);
|
||||
} else {
|
||||
fn[0] = '\0';
|
||||
}
|
||||
@ -440,7 +440,7 @@ lv_fs_res_t lv_ufs_dir_close(void * rddir_p)
|
||||
* @param free_p pointer to store the free site [kB]
|
||||
* @return LV_FS_RES_OK or any error from 'lv_fs_res_t'
|
||||
*/
|
||||
lv_fs_res_t lv_ufs_free (uint32_t * total_p, uint32_t * free_p)
|
||||
lv_fs_res_t lv_ufs_free(uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
@ -465,9 +465,9 @@ lv_fs_res_t lv_ufs_free (uint32_t * total_p, uint32_t * free_p)
|
||||
* @return pointer to the dynamically allocated entry with 'fn' filename.
|
||||
* NULL if no entry found with that name.
|
||||
*/
|
||||
static lv_ufs_ent_t* lv_ufs_ent_get(const char * fn)
|
||||
static lv_ufs_ent_t * lv_ufs_ent_get(const char * fn)
|
||||
{
|
||||
lv_ufs_ent_t* fp;
|
||||
lv_ufs_ent_t * fp;
|
||||
|
||||
LL_READ(file_ll, fp) {
|
||||
if(strcmp(fp->fn_d, fn) == 0) {
|
||||
@ -484,9 +484,9 @@ static lv_ufs_ent_t* lv_ufs_ent_get(const char * fn)
|
||||
* @return pointer to the dynamically allocated new entry.
|
||||
* NULL if no space for the entry.
|
||||
*/
|
||||
static lv_ufs_ent_t* lv_ufs_ent_new(const char * fn)
|
||||
static lv_ufs_ent_t * lv_ufs_ent_new(const char * fn)
|
||||
{
|
||||
lv_ufs_ent_t* new_ent = NULL;
|
||||
lv_ufs_ent_t * new_ent = NULL;
|
||||
new_ent = lv_ll_ins_head(&file_ll); /*Create a new file*/
|
||||
if(new_ent == NULL) {
|
||||
return NULL;
|
||||
|
110
lv_objx/lv_bar.c
110
lv_objx/lv_bar.c
@ -74,21 +74,21 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Init the new bar object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_click(new_bar, false);
|
||||
lv_obj_set_size(new_bar, LV_DPI * 2, LV_DPI / 3);
|
||||
lv_bar_set_value(new_bar, ext->cur_value);
|
||||
lv_obj_set_size(new_bar, LV_DPI * 2, LV_DPI / 3);
|
||||
lv_bar_set_value(new_bar, ext->cur_value);
|
||||
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_bar_set_style(new_bar, LV_BAR_STYLE_BG, th->bar.bg);
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_bar_set_style(new_bar, LV_BAR_STYLE_BG, th->bar.bg);
|
||||
lv_bar_set_style(new_bar, LV_BAR_STYLE_INDIC, th->bar.indic);
|
||||
} else {
|
||||
} else {
|
||||
lv_obj_set_style(new_bar, &lv_style_pretty);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lv_bar_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
|
||||
ext->min_value = ext_copy->min_value;
|
||||
ext->max_value = ext_copy->max_value;
|
||||
ext->cur_value = ext_copy->cur_value;
|
||||
lv_bar_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
|
||||
ext->min_value = ext_copy->min_value;
|
||||
ext->max_value = ext_copy->max_value;
|
||||
ext->cur_value = ext_copy->cur_value;
|
||||
ext->style_indic = ext_copy->style_indic;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_bar);
|
||||
@ -109,12 +109,12 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
void lv_bar_set_value(lv_obj_t * bar, int16_t value)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
if(ext->cur_value == value) return;
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
if(ext->cur_value == value) return;
|
||||
|
||||
ext->cur_value = value > ext->max_value ? ext->max_value : value;
|
||||
ext->cur_value = value > ext->max_value ? ext->max_value : value;
|
||||
ext->cur_value = ext->cur_value < ext->min_value ? ext->min_value : ext->cur_value;
|
||||
lv_obj_invalidate(bar);
|
||||
lv_obj_invalidate(bar);
|
||||
}
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
@ -127,7 +127,7 @@ 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);
|
||||
if(ext->cur_value == value) return;
|
||||
if(ext->cur_value == value) return;
|
||||
|
||||
int16_t new_value;
|
||||
new_value = value > ext->max_value ? ext->max_value : value;
|
||||
@ -160,20 +160,20 @@ void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time)
|
||||
*/
|
||||
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
if(ext->min_value == min && ext->max_value == max) return;
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
if(ext->min_value == min && ext->max_value == max) return;
|
||||
|
||||
ext->max_value = max;
|
||||
ext->min_value = min;
|
||||
if(ext->cur_value > max) {
|
||||
ext->cur_value = max;
|
||||
lv_bar_set_value(bar, ext->cur_value);
|
||||
}
|
||||
ext->max_value = max;
|
||||
ext->min_value = min;
|
||||
if(ext->cur_value > max) {
|
||||
ext->cur_value = max;
|
||||
lv_bar_set_value(bar, ext->cur_value);
|
||||
}
|
||||
if(ext->cur_value < min) {
|
||||
ext->cur_value = min;
|
||||
lv_bar_set_value(bar, ext->cur_value);
|
||||
}
|
||||
lv_obj_invalidate(bar);
|
||||
lv_obj_invalidate(bar);
|
||||
}
|
||||
|
||||
|
||||
@ -183,11 +183,11 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_bar_set_style(lv_obj_t *bar, lv_bar_style_t type, lv_style_t *style)
|
||||
void lv_bar_set_style(lv_obj_t * bar, lv_bar_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_BAR_STYLE_BG:
|
||||
lv_obj_set_style(bar, style);
|
||||
break;
|
||||
@ -209,8 +209,8 @@ void lv_bar_set_style(lv_obj_t *bar, lv_bar_style_t type, lv_style_t *style)
|
||||
*/
|
||||
int16_t lv_bar_get_value(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
return ext->cur_value;
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
return ext->cur_value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,14 +241,17 @@ int16_t lv_bar_get_max_value(lv_obj_t * bar)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_bar_get_style(lv_obj_t *bar, lv_bar_style_t type)
|
||||
lv_style_t * lv_bar_get_style(lv_obj_t * bar, lv_bar_style_t type)
|
||||
{
|
||||
lv_bar_ext_t *ext = lv_obj_get_ext_attr(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
switch (type) {
|
||||
case LV_BAR_STYLE_BG: return lv_obj_get_style(bar);
|
||||
case LV_BAR_STYLE_INDIC: return ext->style_indic;
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_BAR_STYLE_BG:
|
||||
return lv_obj_get_style(bar);
|
||||
case LV_BAR_STYLE_INDIC:
|
||||
return ext->style_indic;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -272,33 +275,33 @@ lv_style_t * lv_bar_get_style(lv_obj_t *bar, lv_bar_style_t type)
|
||||
static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return ancestor_design_f(bar, mask, mode);;
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return ancestor_design_f(bar, mask, mode);;
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(bar, mask, mode);
|
||||
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
lv_style_t *style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
|
||||
lv_area_t indic_area;
|
||||
lv_area_copy(&indic_area, &bar->coords);
|
||||
indic_area.x1 += style_indic->body.padding.hor;
|
||||
indic_area.x2 -= style_indic->body.padding.hor;
|
||||
indic_area.y1 += style_indic->body.padding.ver;
|
||||
indic_area.y2 -= style_indic->body.padding.ver;
|
||||
lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
|
||||
lv_area_t indic_area;
|
||||
lv_area_copy(&indic_area, &bar->coords);
|
||||
indic_area.x1 += style_indic->body.padding.hor;
|
||||
indic_area.x2 -= style_indic->body.padding.hor;
|
||||
indic_area.y1 += style_indic->body.padding.ver;
|
||||
indic_area.y2 -= style_indic->body.padding.ver;
|
||||
|
||||
lv_coord_t w = lv_area_get_width(&indic_area);
|
||||
lv_coord_t w = lv_area_get_width(&indic_area);
|
||||
lv_coord_t h = lv_area_get_height(&indic_area);
|
||||
|
||||
if(w >= h) {
|
||||
indic_area.x2 = (int32_t) ((int32_t)w * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
|
||||
if(w >= h) {
|
||||
indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
|
||||
indic_area.x2 = indic_area.x1 + indic_area.x2;
|
||||
} else {
|
||||
indic_area.y1 = (int32_t) ((int32_t)h * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
|
||||
} else {
|
||||
indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
|
||||
indic_area.y1 = indic_area.y2 - indic_area.y1;
|
||||
}
|
||||
}
|
||||
|
||||
/*Draw the indicator*/
|
||||
/*Draw the indicator*/
|
||||
lv_draw_rect(&indic_area, mask, style_indic);
|
||||
}
|
||||
return true;
|
||||
@ -322,8 +325,7 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
||||
if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
|
||||
if(style_indic->body.shadow.width > bar->ext_size) bar->ext_size = style_indic->body.shadow.width;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
|
@ -88,8 +88,8 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
lv_obj_set_click(new_btn, true); /*Be sure the button is clickable*/
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->btn.rel);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.pr);
|
||||
@ -102,13 +102,13 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy 'copy'*/
|
||||
else {
|
||||
lv_btn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->state = copy_ext->state;
|
||||
lv_btn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->state = copy_ext->state;
|
||||
ext->toggle = copy_ext->toggle;
|
||||
memcpy(ext->actions, copy_ext->actions, sizeof(ext->actions));
|
||||
memcpy(ext->actions, copy_ext->actions, sizeof(ext->actions));
|
||||
memcpy(ext->styles, copy_ext->styles, sizeof(ext->styles));
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_btn);
|
||||
}
|
||||
|
||||
@ -153,11 +153,20 @@ void lv_btn_toggle(lv_obj_t * btn)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
switch(ext->state) {
|
||||
case LV_BTN_STATE_REL: lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL); break;
|
||||
case LV_BTN_STATE_PR: lv_btn_set_state(btn, LV_BTN_STATE_TGL_PR); break;
|
||||
case LV_BTN_STATE_TGL_REL: lv_btn_set_state(btn, LV_BTN_STATE_REL); break;
|
||||
case LV_BTN_STATE_TGL_PR: lv_btn_set_state(btn, LV_BTN_STATE_PR); break;
|
||||
default: break;
|
||||
case LV_BTN_STATE_REL:
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
break;
|
||||
case LV_BTN_STATE_PR:
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TGL_PR);
|
||||
break;
|
||||
case LV_BTN_STATE_TGL_REL:
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
break;
|
||||
case LV_BTN_STATE_TGL_PR:
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_PR);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,11 +189,11 @@ void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_btn_set_style(lv_obj_t *btn, lv_btn_style_t type, lv_style_t *style)
|
||||
void lv_btn_set_style(lv_obj_t * btn, lv_btn_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_btn_ext_t *ext = lv_obj_get_ext_attr(btn);
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_BTN_STYLE_REL:
|
||||
ext->styles[LV_BTN_STATE_REL] = style;
|
||||
break;
|
||||
@ -253,17 +262,23 @@ lv_action_t lv_btn_get_action(lv_obj_t * btn, lv_btn_action_t type)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_btn_get_style(lv_obj_t *btn, lv_btn_style_t type)
|
||||
lv_style_t * lv_btn_get_style(lv_obj_t * btn, lv_btn_style_t type)
|
||||
{
|
||||
lv_btn_ext_t *ext = lv_obj_get_ext_attr(btn);
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
|
||||
switch (type) {
|
||||
case LV_BTN_STYLE_REL: return ext->styles[LV_BTN_STATE_REL];
|
||||
case LV_BTN_STYLE_PR: return ext->styles[LV_BTN_STATE_PR];
|
||||
case LV_BTN_STYLE_TGL_REL: return ext->styles[LV_BTN_STATE_TGL_REL];
|
||||
case LV_BTN_STYLE_TGL_PR: return ext->styles[LV_BTN_STATE_TGL_PR];
|
||||
case LV_BTN_STYLE_INA: return ext->styles[LV_BTN_STATE_INA];
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_BTN_STYLE_REL:
|
||||
return ext->styles[LV_BTN_STATE_REL];
|
||||
case LV_BTN_STYLE_PR:
|
||||
return ext->styles[LV_BTN_STATE_PR];
|
||||
case LV_BTN_STYLE_TGL_REL:
|
||||
return ext->styles[LV_BTN_STATE_TGL_REL];
|
||||
case LV_BTN_STYLE_TGL_PR:
|
||||
return ext->styles[LV_BTN_STATE_TGL_PR];
|
||||
case LV_BTN_STYLE_INA:
|
||||
return ext->styles[LV_BTN_STATE_INA];
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -306,20 +321,17 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
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) {
|
||||
} else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
/*Refresh the state*/
|
||||
if(ext->state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
else if(ext->state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
/*When the button begins to drag revert pressed states to released*/
|
||||
if(lv_indev_is_dragging(param) != false) {
|
||||
if(ext->state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
else if(ext->state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} 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_pr_action_executed == 0) {
|
||||
@ -343,20 +355,17 @@ 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_REL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS) {
|
||||
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) {
|
||||
} else if(sign == LV_SIGNAL_LONG_PRESS) {
|
||||
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_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);
|
||||
} 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_CLICK] && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
|
||||
@ -380,14 +389,12 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
}
|
||||
}
|
||||
ext->long_pr_action_executed = 0;
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_ENTER_LONG) {
|
||||
} else if(c == LV_GROUP_KEY_ENTER_LONG) {
|
||||
if(ext->actions[LV_BTN_ACTION_LONG_PR] && state != LV_BTN_STATE_INA) {
|
||||
res = ext->actions[LV_BTN_ACTION_LONG_PR](btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
|
@ -42,8 +42,9 @@ static void create_buttons(lv_obj_t * btnm, const char ** map);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static const char * lv_btnm_def_map[] = {"Btn1","Btn2", "Btn3","\n",
|
||||
"\002Btn4","Btn5", ""};
|
||||
static const char * lv_btnm_def_map[] = {"Btn1", "Btn2", "Btn3", "\n",
|
||||
"\002Btn4", "Btn5", ""
|
||||
};
|
||||
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
@ -92,11 +93,11 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Init the new button matrix object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_btnm, LV_HOR_RES / 2, LV_VER_RES / 4);
|
||||
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
|
||||
lv_obj_set_size(new_btnm, LV_HOR_RES / 2, LV_VER_RES / 4);
|
||||
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->btnm.bg);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->btnm.btn.rel);
|
||||
@ -141,101 +142,101 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
{
|
||||
if(map == NULL) return;
|
||||
if(map == NULL) return;
|
||||
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
ext->map_p = map;
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
ext->map_p = map;
|
||||
|
||||
/*Analyze the map and create the required number of buttons*/
|
||||
create_buttons(btnm, map);
|
||||
/*Analyze the map and create the required number of buttons*/
|
||||
create_buttons(btnm, map);
|
||||
|
||||
/*Set size and positions of the buttons*/
|
||||
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;
|
||||
/*Set size and positions of the buttons*/
|
||||
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;
|
||||
uint8_t li;
|
||||
for(li = 0; strlen(map[li]) != 0; li++) {
|
||||
if(strcmp(map[li], "\n") == 0) line_cnt ++;
|
||||
}
|
||||
/*Count the lines to calculate button height*/
|
||||
uint8_t line_cnt = 1;
|
||||
uint8_t li;
|
||||
for(li = 0; strlen(map[li]) != 0; li++) {
|
||||
if(strcmp(map[li], "\n") == 0) line_cnt ++;
|
||||
}
|
||||
|
||||
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)*/
|
||||
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)*/
|
||||
|
||||
/* Count the units and the buttons in a line
|
||||
* (A button can be 1,2,3... unit wide)*/
|
||||
uint16_t unit_cnt; /*Number of units in a row*/
|
||||
/* Count the units and the buttons in a line
|
||||
* (A button can be 1,2,3... unit wide)*/
|
||||
uint16_t unit_cnt; /*Number of units in a row*/
|
||||
uint16_t unit_act_cnt; /*Number of units currently put in a row*/
|
||||
uint16_t btn_cnt; /*Number of buttons in a row*/
|
||||
uint16_t i_tot = 0; /*Act. index in the str map*/
|
||||
uint16_t btn_i = 0; /*Act. index of button areas*/
|
||||
const char ** map_p_tmp = map;
|
||||
uint16_t btn_cnt; /*Number of buttons in a row*/
|
||||
uint16_t i_tot = 0; /*Act. index in the str map*/
|
||||
uint16_t btn_i = 0; /*Act. index of button areas*/
|
||||
const char ** map_p_tmp = map;
|
||||
|
||||
/*Count the units and the buttons in a line*/
|
||||
while(1) {
|
||||
unit_cnt = 0;
|
||||
btn_cnt = 0;
|
||||
/*Count the buttons in a line*/
|
||||
while(strcmp(map_p_tmp[btn_cnt], "\n") != 0 &&
|
||||
strlen(map_p_tmp[btn_cnt]) != 0) { /*Check a line*/
|
||||
unit_cnt += get_button_width(map_p_tmp[btn_cnt]);
|
||||
btn_cnt ++;
|
||||
}
|
||||
/*Count the units and the buttons in a line*/
|
||||
while(1) {
|
||||
unit_cnt = 0;
|
||||
btn_cnt = 0;
|
||||
/*Count the buttons in a line*/
|
||||
while(strcmp(map_p_tmp[btn_cnt], "\n") != 0 &&
|
||||
strlen(map_p_tmp[btn_cnt]) != 0) { /*Check a line*/
|
||||
unit_cnt += get_button_width(map_p_tmp[btn_cnt]);
|
||||
btn_cnt ++;
|
||||
}
|
||||
|
||||
/*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) * style_bg->body.padding.inner);
|
||||
/*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) * style_bg->body.padding.inner);
|
||||
|
||||
/*Set the button size and positions and set the texts*/
|
||||
uint16_t i;
|
||||
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++) {
|
||||
/* one_unit_w = all_unit_w / unit_cnt
|
||||
* act_unit_w = one_unit_w * button_width
|
||||
* do this two operations but the multiply first to divide a greater number */
|
||||
act_unit_w = (all_unit_w * get_button_width(map_p_tmp[i])) / unit_cnt;
|
||||
act_unit_w --; /*-1 because e.g. width = 100 means 101 pixels (0..100)*/
|
||||
/*Set the button size and positions and set the texts*/
|
||||
uint16_t i;
|
||||
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++) {
|
||||
/* one_unit_w = all_unit_w / unit_cnt
|
||||
* act_unit_w = one_unit_w * button_width
|
||||
* do this two operations but the multiply first to divide a greater number */
|
||||
act_unit_w = (all_unit_w * get_button_width(map_p_tmp[i])) / unit_cnt;
|
||||
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 * style_bg->body.padding.inner + style_bg->body.padding.hor;
|
||||
/*Always recalculate act_x because of rounding errors */
|
||||
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * style_bg->body.padding.inner + style_bg->body.padding.hor;
|
||||
|
||||
/* 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) {
|
||||
/* 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 {
|
||||
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);
|
||||
}
|
||||
act_x + act_unit_w, act_y + btn_h);
|
||||
}
|
||||
|
||||
unit_act_cnt += get_button_width(map_p_tmp[i]);
|
||||
unit_act_cnt += get_button_width(map_p_tmp[i]);
|
||||
|
||||
i_tot ++;
|
||||
btn_i ++;
|
||||
}
|
||||
}
|
||||
act_y += btn_h + style_bg->body.padding.inner;
|
||||
i_tot ++;
|
||||
btn_i ++;
|
||||
}
|
||||
}
|
||||
act_y += btn_h + style_bg->body.padding.inner;
|
||||
|
||||
/*If no vertical padding then make sure the last row is at the bottom of 'btnm'*/
|
||||
if(style_bg->body.padding.ver == 0 &&
|
||||
act_y + btn_h * 2 > max_h) { /*Last row?*/
|
||||
btn_h = max_h - act_y - 1;
|
||||
}
|
||||
/*If no vertical padding then make sure the last row is at the bottom of 'btnm'*/
|
||||
if(style_bg->body.padding.ver == 0 &&
|
||||
act_y + btn_h * 2 > max_h) { /*Last row?*/
|
||||
btn_h = max_h - act_y - 1;
|
||||
}
|
||||
|
||||
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'*/
|
||||
}
|
||||
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'*/
|
||||
}
|
||||
|
||||
lv_obj_invalidate(btnm);
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -246,7 +247,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t action)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
ext->action = action;
|
||||
ext->action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -276,11 +277,11 @@ void lv_btnm_set_toggle(lv_obj_t * btnm, bool en, uint16_t id)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_btnm_set_style(lv_obj_t *btnm, lv_btnm_style_t type, lv_style_t *style)
|
||||
void lv_btnm_set_style(lv_obj_t * btnm, lv_btnm_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_btnm_ext_t *ext = lv_obj_get_ext_attr(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_BTNM_STYLE_BG:
|
||||
lv_obj_set_style(btnm, style);
|
||||
break;
|
||||
@ -319,7 +320,7 @@ void lv_btnm_set_style(lv_obj_t *btnm, lv_btnm_style_t type, lv_style_t *style)
|
||||
const char ** lv_btnm_get_map(lv_obj_t * btnm)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
return ext->map_p;
|
||||
return ext->map_p;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +331,7 @@ const char ** lv_btnm_get_map(lv_obj_t * btnm)
|
||||
lv_btnm_action_t lv_btnm_get_action(lv_obj_t * btnm)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
return ext->action;
|
||||
return ext->action;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -343,7 +344,8 @@ 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_tgl;}
|
||||
else return ext->btn_id_tgl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a style of a button matrix
|
||||
@ -351,18 +353,25 @@ uint16_t lv_btnm_get_toggled(lv_obj_t * btnm)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_btnm_get_style(lv_obj_t *btnm, lv_btnm_style_t type)
|
||||
lv_style_t * lv_btnm_get_style(lv_obj_t * btnm, lv_btnm_style_t type)
|
||||
{
|
||||
lv_btnm_ext_t *ext = lv_obj_get_ext_attr(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
switch (type) {
|
||||
case LV_BTNM_STYLE_BG: return lv_obj_get_style(btnm);
|
||||
case LV_BTNM_STYLE_BTN_REL: return ext->styles_btn[LV_BTN_STATE_REL];
|
||||
case LV_BTNM_STYLE_BTN_PR: return ext->styles_btn[LV_BTN_STATE_PR];
|
||||
case LV_BTNM_STYLE_BTN_TGL_REL: return ext->styles_btn[LV_BTN_STATE_TGL_REL];
|
||||
case LV_BTNM_STYLE_BTN_TGL_PR: return ext->styles_btn[LV_BTN_STATE_TGL_PR];
|
||||
case LV_BTNM_STYLE_BTN_INA: return ext->styles_btn[LV_BTN_STATE_INA];
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_BTNM_STYLE_BG:
|
||||
return lv_obj_get_style(btnm);
|
||||
case LV_BTNM_STYLE_BTN_REL:
|
||||
return ext->styles_btn[LV_BTN_STATE_REL];
|
||||
case LV_BTNM_STYLE_BTN_PR:
|
||||
return ext->styles_btn[LV_BTN_STATE_PR];
|
||||
case LV_BTNM_STYLE_BTN_TGL_REL:
|
||||
return ext->styles_btn[LV_BTN_STATE_TGL_REL];
|
||||
case LV_BTNM_STYLE_BTN_TGL_PR:
|
||||
return ext->styles_btn[LV_BTN_STATE_TGL_PR];
|
||||
case LV_BTNM_STYLE_BTN_INA:
|
||||
return ext->styles_btn[LV_BTN_STATE_INA];
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -387,82 +396,82 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return ancestor_design_f(btnm, mask, mode);
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if (mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(btnm, mask, mode);
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(btnm, mask, mode);
|
||||
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
lv_style_t * bg_style = lv_obj_get_style(btnm);
|
||||
lv_style_t * btn_style;
|
||||
|
||||
lv_area_t area_btnm;
|
||||
lv_area_t area_btnm;
|
||||
lv_obj_get_coords(btnm, &area_btnm);
|
||||
|
||||
lv_area_t area_tmp;
|
||||
lv_coord_t btn_w;
|
||||
lv_coord_t btn_h;
|
||||
bool border_mod = false;
|
||||
lv_area_t area_tmp;
|
||||
lv_coord_t btn_w;
|
||||
lv_coord_t btn_h;
|
||||
bool border_mod = false;
|
||||
|
||||
uint16_t btn_i = 0;
|
||||
uint16_t txt_i = 0;
|
||||
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i ++, txt_i ++) {
|
||||
uint16_t btn_i = 0;
|
||||
uint16_t txt_i = 0;
|
||||
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i ++, txt_i ++) {
|
||||
/*Search the next valid text in the map*/
|
||||
while(strcmp(ext->map_p[txt_i], "\n") == 0) txt_i ++;
|
||||
|
||||
/*Skip hidden buttons*/
|
||||
if(button_is_hidden(ext->map_p[txt_i])) continue;
|
||||
|
||||
lv_area_copy(&area_tmp, &ext->button_areas[btn_i]);
|
||||
area_tmp.x1 += area_btnm.x1;
|
||||
area_tmp.y1 += area_btnm.y1;
|
||||
area_tmp.x2 += area_btnm.x1;
|
||||
area_tmp.y2 += area_btnm.y1;
|
||||
lv_area_copy(&area_tmp, &ext->button_areas[btn_i]);
|
||||
area_tmp.x1 += area_btnm.x1;
|
||||
area_tmp.y1 += area_btnm.y1;
|
||||
area_tmp.x2 += area_btnm.x1;
|
||||
area_tmp.y2 += area_btnm.y1;
|
||||
|
||||
btn_w = lv_area_get_width(&area_tmp);
|
||||
btn_h = lv_area_get_height(&area_tmp);
|
||||
btn_w = lv_area_get_width(&area_tmp);
|
||||
btn_h = lv_area_get_height(&area_tmp);
|
||||
|
||||
/*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_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);
|
||||
/*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_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);
|
||||
else btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL); /*Not possible option, just to be sure*/
|
||||
|
||||
/*On the right buttons clear the border if only right borders are drawn*/
|
||||
if(ext->map_p[txt_i + 1][0] == '\0' || ext->map_p[txt_i + 1][0] == '\n') {
|
||||
if(btn_style->body.border.part == LV_BORDER_RIGHT) {
|
||||
btn_style->body.border.part = LV_BORDER_NONE;
|
||||
border_mod = true;
|
||||
}
|
||||
}
|
||||
/*On the right buttons clear the border if only right borders are drawn*/
|
||||
if(ext->map_p[txt_i + 1][0] == '\0' || ext->map_p[txt_i + 1][0] == '\n') {
|
||||
if(btn_style->body.border.part == LV_BORDER_RIGHT) {
|
||||
btn_style->body.border.part = LV_BORDER_NONE;
|
||||
border_mod = true;
|
||||
}
|
||||
}
|
||||
|
||||
lv_draw_rect(&area_tmp, mask, btn_style);
|
||||
lv_draw_rect(&area_tmp, mask, btn_style);
|
||||
|
||||
if(border_mod) {
|
||||
border_mod = false;
|
||||
if(border_mod) {
|
||||
border_mod = false;
|
||||
btn_style->body.border.part = LV_BORDER_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Calculate the size of the text*/
|
||||
const lv_font_t * font = btn_style->text.font;
|
||||
lv_point_t txt_size;
|
||||
lv_txt_get_size(&txt_size, ext->map_p[txt_i], font,
|
||||
btn_style->text.letter_space, btn_style->text.line_space,
|
||||
lv_area_get_width(&area_btnm), LV_TXT_FLAG_NONE);
|
||||
/*Calculate the size of the text*/
|
||||
const lv_font_t * font = btn_style->text.font;
|
||||
lv_point_t txt_size;
|
||||
lv_txt_get_size(&txt_size, ext->map_p[txt_i], font,
|
||||
btn_style->text.letter_space, btn_style->text.line_space,
|
||||
lv_area_get_width(&area_btnm), LV_TXT_FLAG_NONE);
|
||||
|
||||
area_tmp.x1 += (btn_w - txt_size.x) / 2;
|
||||
area_tmp.y1 += (btn_h - txt_size.y) / 2;
|
||||
area_tmp.x2 = area_tmp.x1 + txt_size.x;
|
||||
area_tmp.y2 = area_tmp.y1 + txt_size.y;
|
||||
area_tmp.x1 += (btn_w - txt_size.x) / 2;
|
||||
area_tmp.y1 += (btn_h - txt_size.y) / 2;
|
||||
area_tmp.x2 = area_tmp.x1 + txt_size.x;
|
||||
area_tmp.y2 = area_tmp.y1 + txt_size.y;
|
||||
|
||||
|
||||
if(btn_style->glass) btn_style = bg_style;
|
||||
lv_draw_label(&area_tmp, mask, btn_style, ext->map_p[txt_i], LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
if(btn_style->glass) btn_style = bg_style;
|
||||
lv_draw_label(&area_tmp, mask, btn_style, ext->map_p[txt_i], LV_TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -488,11 +497,9 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
lv_point_t p;
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_mem_free(ext->button_areas);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
|
||||
lv_btnm_set_map(btnm, ext->map_p);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
uint16_t btn_pr;
|
||||
/*Search the pressed area*/
|
||||
lv_indev_get_point(param, &p);
|
||||
@ -527,13 +534,12 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
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) {
|
||||
button_is_inactive(ext->map_p[txt_i]) == false) {
|
||||
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
|
||||
if(ext->action) {
|
||||
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr);
|
||||
@ -565,17 +571,14 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
ext->btn_id_pr = LV_BTNM_PR_NONE;
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
|
||||
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
|
||||
ext->btn_id_pr = LV_BTNM_PR_NONE;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
ext->btn_id_pr = 0;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char*)param);
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT) {
|
||||
if(ext->btn_id_pr == LV_BTNM_PR_NONE) ext->btn_id_pr = 0;
|
||||
else ext->btn_id_pr++;
|
||||
@ -596,9 +599,8 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
for(area_below = ext->btn_id_pr; area_below < ext->btn_cnt; area_below ++) {
|
||||
if(ext->button_areas[area_below].y1 > ext->button_areas[ext->btn_id_pr].y1 &&
|
||||
pr_center >= ext->button_areas[area_below].x1 &&
|
||||
pr_center <= ext->button_areas[area_below].x2 + style->body.padding.hor)
|
||||
{
|
||||
pr_center >= ext->button_areas[area_below].x1 &&
|
||||
pr_center <= ext->button_areas[area_below].x2 + style->body.padding.hor) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -617,9 +619,8 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
for(area_above = ext->btn_id_pr; area_above >= 0; area_above --) {
|
||||
if(ext->button_areas[area_above].y1 < ext->button_areas[ext->btn_id_pr].y1 &&
|
||||
pr_center >= ext->button_areas[area_above].x1 - style->body.padding.hor &&
|
||||
pr_center <= ext->button_areas[area_above].x2)
|
||||
{
|
||||
pr_center >= ext->button_areas[area_above].x1 - style->body.padding.hor &&
|
||||
pr_center <= ext->button_areas[area_above].x2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -627,15 +628,14 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
}
|
||||
lv_obj_invalidate(btnm);
|
||||
}else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
|
||||
} 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) {
|
||||
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -655,25 +655,25 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
*/
|
||||
static void create_buttons(lv_obj_t * btnm, const char ** map)
|
||||
{
|
||||
/*Count the buttons in the map*/
|
||||
uint16_t btn_cnt = 0;
|
||||
uint16_t i = 0;
|
||||
while(strlen(map[i]) != 0) {
|
||||
if(strcmp(map[i], "\n") != 0) { /*Do not count line breaks*/
|
||||
btn_cnt ++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/*Count the buttons in the map*/
|
||||
uint16_t btn_cnt = 0;
|
||||
uint16_t i = 0;
|
||||
while(strlen(map[i]) != 0) {
|
||||
if(strcmp(map[i], "\n") != 0) { /*Do not count line breaks*/
|
||||
btn_cnt ++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
if(ext->button_areas != NULL) {
|
||||
lv_mem_free(ext->button_areas);
|
||||
ext->button_areas = NULL;
|
||||
}
|
||||
if(ext->button_areas != NULL) {
|
||||
lv_mem_free(ext->button_areas);
|
||||
ext->button_areas = NULL;
|
||||
}
|
||||
|
||||
ext->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt);
|
||||
ext->btn_cnt = btn_cnt;
|
||||
ext->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt);
|
||||
ext->btn_cnt = btn_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -683,19 +683,19 @@ static void create_buttons(lv_obj_t * btnm, const char ** map)
|
||||
*/
|
||||
static uint8_t get_button_width(const char * btn_str)
|
||||
{
|
||||
if((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE){
|
||||
return btn_str[0] & LV_BTNM_WIDTH_MASK;
|
||||
}
|
||||
if((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) {
|
||||
return btn_str[0] & LV_BTNM_WIDTH_MASK;
|
||||
}
|
||||
|
||||
return 1; /*Default width is 1*/
|
||||
return 1; /*Default width is 1*/
|
||||
}
|
||||
|
||||
static bool button_is_hidden(const char * btn_str)
|
||||
{
|
||||
/*If control byte presents and hidden bit is '1' then the button is hidden*/
|
||||
if(((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) &&
|
||||
(btn_str[0] & LV_BTNM_HIDE_MASK)) {
|
||||
return true;
|
||||
(btn_str[0] & LV_BTNM_HIDE_MASK)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -705,8 +705,8 @@ static bool button_is_repeat_disabled(const char * btn_str)
|
||||
{
|
||||
/*If control byte presents and hidden bit is '1' then the button is hidden*/
|
||||
if(((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) &&
|
||||
(btn_str[0] & LV_BTNM_REPEAT_DISABLE_MASK)) {
|
||||
return true;
|
||||
(btn_str[0] & LV_BTNM_REPEAT_DISABLE_MASK)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -716,8 +716,8 @@ static bool button_is_inactive(const char * btn_str)
|
||||
{
|
||||
/*If control byte presents and hidden bit is '1' then the button is hidden*/
|
||||
if(((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) &&
|
||||
(btn_str[0] & LV_BTNM_INACTIVE_MASK)) {
|
||||
return true;
|
||||
(btn_str[0] & LV_BTNM_INACTIVE_MASK)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -79,7 +79,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_btn_set_toggle(new_cb, true);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, th->cb.bg);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, th->cb.box.rel);
|
||||
@ -88,13 +88,13 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_PR, th->cb.box.tgl_pr);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_INA, th->cb.box.ina);
|
||||
} else {
|
||||
lv_cb_set_style(new_cb,LV_CB_STYLE_BG, &lv_style_transp);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL,&lv_style_pretty);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, &lv_style_transp);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, &lv_style_pretty);
|
||||
}
|
||||
} else {
|
||||
lv_cb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->bullet = lv_btn_create(new_cb, copy_ext->bullet);
|
||||
ext->label = lv_label_create(new_cb, copy_ext->label);
|
||||
lv_cb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->bullet = lv_btn_create(new_cb, copy_ext->bullet);
|
||||
ext->label = lv_label_create(new_cb, copy_ext->label);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_cb);
|
||||
@ -116,8 +116,8 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,11 +126,11 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
* */
|
||||
void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t *style)
|
||||
void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_CB_STYLE_BG:
|
||||
lv_btn_set_style(cb, LV_BTN_STYLE_REL, style);
|
||||
lv_btn_set_style(cb, LV_BTN_STYLE_PR, style);
|
||||
@ -169,8 +169,8 @@ void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t *style)
|
||||
*/
|
||||
const char * lv_cb_get_text(lv_obj_t * cb)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
return lv_label_get_text(ext->label);
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
return lv_label_get_text(ext->label);
|
||||
}
|
||||
|
||||
|
||||
@ -184,13 +184,19 @@ 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_BOX_REL: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
|
||||
case LV_CB_STYLE_BOX_PR: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
|
||||
case LV_CB_STYLE_BOX_TGL_REL: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
|
||||
case LV_CB_STYLE_BOX_TGL_PR: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
|
||||
case LV_CB_STYLE_BOX_INA: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_CB_STYLE_BOX_REL:
|
||||
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
|
||||
case LV_CB_STYLE_BOX_PR:
|
||||
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
|
||||
case LV_CB_STYLE_BOX_TGL_REL:
|
||||
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
|
||||
case LV_CB_STYLE_BOX_TGL_PR:
|
||||
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
|
||||
case LV_CB_STYLE_BOX_INA:
|
||||
return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid awrning*/
|
||||
@ -214,8 +220,8 @@ lv_style_t * lv_cb_get_style(lv_obj_t * cb, lv_cb_style_t type)
|
||||
static bool lv_cb_design(lv_obj_t * cb, const lv_area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_bg_design(cb, mask, mode);
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_bg_design(cb, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN || mode == LV_DESIGN_DRAW_POST) {
|
||||
lv_cb_ext_t * cb_ext = lv_obj_get_ext_attr(cb);
|
||||
lv_btn_ext_t * bullet_ext = lv_obj_get_ext_attr(cb_ext->bullet);
|
||||
@ -298,18 +304,17 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
||||
lv_obj_set_size(ext->bullet, lv_font_get_height(label_style->text.font), lv_font_get_height(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 ||
|
||||
sign == LV_SIGNAL_PRESS_LOST) {
|
||||
sign == LV_SIGNAL_RELEASED ||
|
||||
sign == LV_SIGNAL_PRESS_LOST) {
|
||||
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char*)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_LONG) {
|
||||
c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP ||
|
||||
c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
|
||||
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
|
@ -16,11 +16,11 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_CHART_YMIN_DEF 0
|
||||
#define LV_CHART_YMAX_DEF 100
|
||||
#define LV_CHART_HDIV_DEF 3
|
||||
#define LV_CHART_VDIV_DEF 5
|
||||
#define LV_CHART_PNUM_DEF 10
|
||||
#define LV_CHART_YMIN_DEF 0
|
||||
#define LV_CHART_YMAX_DEF 100
|
||||
#define LV_CHART_HDIV_DEF 3
|
||||
#define LV_CHART_VDIV_DEF 5
|
||||
#define LV_CHART_PNUM_DEF 10
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -85,10 +85,10 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Init the new chart background object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_chart, LV_HOR_RES / 3, LV_VER_RES / 3);
|
||||
lv_obj_set_size(new_chart, LV_HOR_RES / 3, LV_VER_RES / 3);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_chart_set_style(new_chart, th->chart);
|
||||
} else {
|
||||
@ -96,12 +96,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
|
||||
} else {
|
||||
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
|
||||
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
|
||||
ext->type = ext_copy->type;
|
||||
ext->ymin = ext_copy->ymin;
|
||||
ext->ymax = ext_copy->ymax;
|
||||
ext->hdiv_cnt = ext_copy->hdiv_cnt;
|
||||
ext->vdiv_cnt = ext_copy->vdiv_cnt;
|
||||
ext->ymin = ext_copy->ymin;
|
||||
ext->ymax = ext_copy->ymax;
|
||||
ext->hdiv_cnt = ext_copy->hdiv_cnt;
|
||||
ext->vdiv_cnt = ext_copy->vdiv_cnt;
|
||||
ext->point_cnt = ext_copy->point_cnt;
|
||||
ext->series.opa = ext_copy->series.opa;
|
||||
|
||||
@ -124,26 +124,26 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_series_t *ser = lv_ll_ins_head(&ext->series_ll);
|
||||
lv_coord_t def = (ext->ymin + ext->ymax) >> 1; /*half range as default value*/
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_series_t * ser = lv_ll_ins_head(&ext->series_ll);
|
||||
lv_coord_t def = (ext->ymin + ext->ymax) >> 1; /*half range as default value*/
|
||||
|
||||
if(ser == NULL) return NULL;
|
||||
if(ser == NULL) return NULL;
|
||||
|
||||
ser->color = color;
|
||||
|
||||
ser->points = lv_mem_alloc(sizeof(lv_coord_t) * ext->point_cnt);
|
||||
ser->points = lv_mem_alloc(sizeof(lv_coord_t) * ext->point_cnt);
|
||||
|
||||
uint16_t i;
|
||||
lv_coord_t * p_tmp = ser->points;
|
||||
for(i = 0; i < ext->point_cnt; i++) {
|
||||
*p_tmp = def;
|
||||
p_tmp++;
|
||||
}
|
||||
uint16_t i;
|
||||
lv_coord_t * p_tmp = ser->points;
|
||||
for(i = 0; i < ext->point_cnt; i++) {
|
||||
*p_tmp = def;
|
||||
p_tmp++;
|
||||
}
|
||||
|
||||
ext->series.num++;
|
||||
ext->series.num++;
|
||||
|
||||
return ser;
|
||||
return ser;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -158,13 +158,13 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
||||
*/
|
||||
void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->hdiv_cnt == hdiv && ext->vdiv_cnt == vdiv) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->hdiv_cnt == hdiv && ext->vdiv_cnt == vdiv) return;
|
||||
|
||||
ext->hdiv_cnt = hdiv;
|
||||
ext->vdiv_cnt = vdiv;
|
||||
ext->hdiv_cnt = hdiv;
|
||||
ext->vdiv_cnt = vdiv;
|
||||
|
||||
lv_obj_invalidate(chart);
|
||||
lv_obj_invalidate(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,13 +175,13 @@ void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
||||
*/
|
||||
void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->ymin == ymin && ext->ymax == ymax) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->ymin == ymin && ext->ymax == ymax) return;
|
||||
|
||||
ext->ymin = ymin;
|
||||
ext->ymax = ymax;
|
||||
ext->ymin = ymin;
|
||||
ext->ymax = ymax;
|
||||
|
||||
lv_chart_refresh(chart);
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,12 +191,12 @@ void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
|
||||
*/
|
||||
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->type == type) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->type == type) return;
|
||||
|
||||
ext->type = type;
|
||||
ext->type = type;
|
||||
|
||||
lv_chart_refresh(chart);
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,29 +206,29 @@ void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type)
|
||||
*/
|
||||
void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->point_cnt == point_cnt) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->point_cnt == point_cnt) return;
|
||||
|
||||
lv_chart_series_t *ser;
|
||||
uint16_t point_cnt_old = ext->point_cnt;
|
||||
uint16_t i;
|
||||
lv_chart_series_t * ser;
|
||||
uint16_t point_cnt_old = ext->point_cnt;
|
||||
uint16_t i;
|
||||
lv_coord_t def = (ext->ymin + ext->ymax) >> 1; /*half range as default value*/
|
||||
|
||||
if(point_cnt < 1) point_cnt = 1;
|
||||
if(point_cnt < 1) point_cnt = 1;
|
||||
|
||||
LL_READ_BACK(ext->series_ll, ser) {
|
||||
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
|
||||
LL_READ_BACK(ext->series_ll, ser) {
|
||||
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
|
||||
|
||||
/*Initialize the new points*/
|
||||
if(point_cnt > point_cnt_old) {
|
||||
for(i = point_cnt_old - 1; i < point_cnt; i++) {
|
||||
ser->points[i] = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*Initialize the new points*/
|
||||
if(point_cnt > point_cnt_old) {
|
||||
for(i = point_cnt_old - 1; i < point_cnt; i++) {
|
||||
ser->points[i] = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ext->point_cnt = point_cnt;
|
||||
lv_chart_refresh(chart);
|
||||
ext->point_cnt = point_cnt;
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,15 +309,15 @@ void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t *
|
||||
*/
|
||||
void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < ext->point_cnt - 1; i++) {
|
||||
ser->points[i] = ser->points[i + 1];
|
||||
}
|
||||
uint16_t i;
|
||||
for(i = 0; i < ext->point_cnt - 1; i++) {
|
||||
ser->points[i] = ser->points[i + 1];
|
||||
}
|
||||
|
||||
ser->points[ext->point_cnt - 1] = y;
|
||||
lv_chart_refresh(chart);
|
||||
ser->points[ext->point_cnt - 1] = y;
|
||||
lv_chart_refresh(chart);
|
||||
|
||||
}
|
||||
|
||||
@ -410,19 +410,19 @@ void lv_chart_refresh(lv_obj_t * chart)
|
||||
static bool lv_chart_design(lv_obj_t * chart, const lv_area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_design_f(chart, mask, mode);
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_design_f(chart, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the background*/
|
||||
/*Draw the background*/
|
||||
lv_draw_rect(&chart->coords, mask, lv_obj_get_style(chart));
|
||||
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
lv_chart_draw_div(chart, mask);
|
||||
lv_chart_draw_div(chart, mask);
|
||||
|
||||
if(ext->type & LV_CHART_TYPE_LINE) lv_chart_draw_lines(chart, mask);
|
||||
if(ext->type & LV_CHART_TYPE_COLUMN) lv_chart_draw_cols(chart, mask);
|
||||
if(ext->type & LV_CHART_TYPE_POINT) lv_chart_draw_points(chart, mask);
|
||||
if(ext->type & LV_CHART_TYPE_LINE) lv_chart_draw_lines(chart, mask);
|
||||
if(ext->type & LV_CHART_TYPE_COLUMN) lv_chart_draw_cols(chart, mask);
|
||||
if(ext->type & LV_CHART_TYPE_POINT) lv_chart_draw_points(chart, mask);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -448,8 +448,7 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
|
||||
lv_mem_free(*datal);
|
||||
}
|
||||
lv_ll_clear(&ext->series_ll);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -468,20 +467,20 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
|
||||
*/
|
||||
static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t div_i;
|
||||
uint8_t div_i;
|
||||
uint8_t div_i_end;
|
||||
uint8_t div_i_start;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
lv_coord_t x_ofs = chart->coords.x1;
|
||||
lv_coord_t y_ofs = chart->coords.y1;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
lv_coord_t x_ofs = chart->coords.x1;
|
||||
lv_coord_t y_ofs = chart->coords.y1;
|
||||
|
||||
if(ext->hdiv_cnt != 0) {
|
||||
if(ext->hdiv_cnt != 0) {
|
||||
/*Draw slide lines if no border*/
|
||||
if(style->body.border.width != 0) {
|
||||
div_i_start = 1;
|
||||
@ -502,9 +501,9 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ext->vdiv_cnt != 0) {
|
||||
if(ext->vdiv_cnt != 0) {
|
||||
/*Draw slide lines if no border*/
|
||||
if(style->body.border.width != 0) {
|
||||
div_i_start = 1;
|
||||
@ -524,7 +523,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
p2.x = p1.x;
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -533,45 +532,45 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
*/
|
||||
static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
uint16_t i;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
uint16_t i;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
lv_coord_t x_ofs = chart->coords.x1;
|
||||
lv_coord_t y_ofs = chart->coords.y1;
|
||||
int32_t y_tmp;
|
||||
lv_chart_series_t *ser;
|
||||
lv_style_t lines;
|
||||
lv_style_copy(&lines, &lv_style_plain);
|
||||
lines.line.opa = ext->series.opa;
|
||||
int32_t y_tmp;
|
||||
lv_chart_series_t * ser;
|
||||
lv_style_t lines;
|
||||
lv_style_copy(&lines, &lv_style_plain);
|
||||
lines.line.opa = ext->series.opa;
|
||||
lines.line.width = ext->series.width;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LL_READ_BACK(ext->series_ll, ser) {
|
||||
lines.line.color = ser->color;
|
||||
/*Go through all data lines*/
|
||||
LL_READ_BACK(ext->series_ll, ser) {
|
||||
lines.line.color = ser->color;
|
||||
|
||||
p1.x = 0 + x_ofs;
|
||||
p2.x = 0 + x_ofs;
|
||||
y_tmp = (int32_t)((int32_t) ser->points[0] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
p1.x = 0 + x_ofs;
|
||||
p2.x = 0 + x_ofs;
|
||||
y_tmp = (int32_t)((int32_t) ser->points[0] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
for(i = 1; i < ext->point_cnt; i ++) {
|
||||
p1.x = p2.x;
|
||||
p1.y = p2.y;
|
||||
for(i = 1; i < ext->point_cnt; i ++) {
|
||||
p1.x = p2.x;
|
||||
p1.y = p2.y;
|
||||
|
||||
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
|
||||
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
|
||||
|
||||
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
lv_draw_line(&p1, &p2, mask, &lines);
|
||||
}
|
||||
}
|
||||
lv_draw_line(&p1, &p2, mask, &lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -581,46 +580,46 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
|
||||
*/
|
||||
static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
uint16_t i;
|
||||
lv_area_t cir_a;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
uint16_t i;
|
||||
lv_area_t cir_a;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
lv_coord_t x_ofs = chart->coords.x1;
|
||||
lv_coord_t y_ofs = chart->coords.y1;
|
||||
int32_t y_tmp;
|
||||
int32_t y_tmp;
|
||||
lv_chart_series_t * ser;
|
||||
uint8_t series_cnt = 0;
|
||||
lv_style_t style_point;
|
||||
lv_style_copy(&style_point, &lv_style_plain);
|
||||
|
||||
style_point.body.border.width = 0;
|
||||
style_point.body.empty = 0;
|
||||
style_point.body.radius = LV_RADIUS_CIRCLE;
|
||||
style_point.body.border.width = 0;
|
||||
style_point.body.empty = 0;
|
||||
style_point.body.radius = LV_RADIUS_CIRCLE;
|
||||
style_point.body.opa = ext->series.opa;
|
||||
style_point.body.radius = ext->series.width;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LL_READ_BACK(ext->series_ll, ser) {
|
||||
style_point.body.main_color = ser->color;
|
||||
style_point.body.grad_color = lv_color_mix(LV_COLOR_BLACK, ser->color, ext->series.dark);
|
||||
/*Go through all data lines*/
|
||||
LL_READ_BACK(ext->series_ll, ser) {
|
||||
style_point.body.main_color = ser->color;
|
||||
style_point.body.grad_color = lv_color_mix(LV_COLOR_BLACK, ser->color, ext->series.dark);
|
||||
|
||||
for(i = 0; i < ext->point_cnt; i ++) {
|
||||
cir_a.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
|
||||
cir_a.x2 = cir_a.x1 + style_point.body.radius;
|
||||
cir_a.x1 -= style_point.body.radius;
|
||||
for(i = 0; i < ext->point_cnt; i ++) {
|
||||
cir_a.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
|
||||
cir_a.x2 = cir_a.x1 + style_point.body.radius;
|
||||
cir_a.x1 -= style_point.body.radius;
|
||||
|
||||
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
cir_a.y1 = h - y_tmp + y_ofs;
|
||||
cir_a.y2 = cir_a.y1 + style_point.body.radius;
|
||||
cir_a.y1 -= style_point.body.radius;
|
||||
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
cir_a.y1 = h - y_tmp + y_ofs;
|
||||
cir_a.y2 = cir_a.y1 + style_point.body.radius;
|
||||
cir_a.y1 -= style_point.body.radius;
|
||||
|
||||
lv_draw_rect(&cir_a, mask, &style_point);
|
||||
}
|
||||
series_cnt++;
|
||||
}
|
||||
lv_draw_rect(&cir_a, mask, &style_point);
|
||||
}
|
||||
series_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -630,31 +629,31 @@ static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask)
|
||||
*/
|
||||
static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
uint16_t i;
|
||||
lv_area_t col_a;
|
||||
lv_area_t col_mask;
|
||||
bool mask_ret;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
int32_t y_tmp;
|
||||
lv_chart_series_t *ser;
|
||||
uint16_t i;
|
||||
lv_area_t col_a;
|
||||
lv_area_t col_mask;
|
||||
bool mask_ret;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
int32_t y_tmp;
|
||||
lv_chart_series_t * ser;
|
||||
lv_style_t rects;
|
||||
lv_coord_t col_w = w / ((ext->series.num + 1) * ext->point_cnt); /* Suppose + 1 series as separator*/
|
||||
lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/
|
||||
lv_coord_t col_w = w / ((ext->series.num + 1) * ext->point_cnt); /* Suppose + 1 series as separator*/
|
||||
lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/
|
||||
|
||||
lv_style_copy(&rects, &lv_style_plain);
|
||||
rects.body.border.width = 0;
|
||||
rects.body.empty = 0;
|
||||
rects.body.radius = 0;
|
||||
rects.body.opa = ext->series.opa;
|
||||
lv_style_copy(&rects, &lv_style_plain);
|
||||
rects.body.border.width = 0;
|
||||
rects.body.empty = 0;
|
||||
rects.body.radius = 0;
|
||||
rects.body.opa = ext->series.opa;
|
||||
|
||||
col_a.y2 = chart->coords.y2;
|
||||
col_a.y2 = chart->coords.y2;
|
||||
|
||||
lv_coord_t x_act;
|
||||
lv_coord_t x_act;
|
||||
|
||||
/*Go through all points*/
|
||||
/*Go through all points*/
|
||||
for(i = 0; i < ext->point_cnt; i ++) {
|
||||
x_act = (int32_t)((int32_t) w * i) / ext->point_cnt;
|
||||
x_act += chart->coords.x1 + x_ofs;
|
||||
@ -676,6 +675,6 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
|
||||
lv_draw_rect(&chart->coords, &col_mask, &rects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -80,7 +80,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Init the new container*/
|
||||
if(copy == NULL) {
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_cont_set_style(new_cont, th->cont);
|
||||
} else {
|
||||
@ -89,10 +89,10 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_cont_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->hor_fit = copy_ext->hor_fit;
|
||||
ext->ver_fit = copy_ext->ver_fit;
|
||||
ext->layout = copy_ext->layout;
|
||||
lv_cont_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->hor_fit = copy_ext->hor_fit;
|
||||
ext->ver_fit = copy_ext->ver_fit;
|
||||
ext->layout = copy_ext->layout;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_cont);
|
||||
@ -112,13 +112,13 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
if(ext->layout == layout) return;
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
if(ext->layout == layout) return;
|
||||
|
||||
ext->layout = layout;
|
||||
ext->layout = layout;
|
||||
|
||||
/*Send a signal to refresh the layout*/
|
||||
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
/*Send a signal to refresh the layout*/
|
||||
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -131,17 +131,17 @@ void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
|
||||
*/
|
||||
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
|
||||
{
|
||||
lv_obj_invalidate(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
if(ext->hor_fit == hor_en && ext->ver_fit == ver_en) return;
|
||||
lv_obj_invalidate(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
if(ext->hor_fit == hor_en && ext->ver_fit == ver_en) return;
|
||||
|
||||
ext->hor_fit = hor_en == false ? 0 : 1;
|
||||
ext->ver_fit = ver_en == false ? 0 : 1;
|
||||
ext->hor_fit = hor_en == false ? 0 : 1;
|
||||
ext->ver_fit = ver_en == false ? 0 : 1;
|
||||
|
||||
/*Send a signal to set a new size*/
|
||||
lv_area_t area;
|
||||
lv_obj_get_coords(cont, &area);
|
||||
cont->signal_func(cont, LV_SIGNAL_CORD_CHG, &area);
|
||||
/*Send a signal to set a new size*/
|
||||
lv_area_t area;
|
||||
lv_obj_get_coords(cont, &area);
|
||||
cont->signal_func(cont, LV_SIGNAL_CORD_CHG, &area);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -155,8 +155,8 @@ void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
|
||||
*/
|
||||
lv_layout_t lv_cont_get_layout(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->layout;
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->layout;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,8 +166,8 @@ lv_layout_t lv_cont_get_layout(lv_obj_t * cont)
|
||||
*/
|
||||
bool lv_cont_get_hor_fit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->hor_fit == 0 ? false : true;
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->hor_fit == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,8 +177,8 @@ bool lv_cont_get_hor_fit(lv_obj_t * cont)
|
||||
*/
|
||||
bool lv_cont_get_ver_fit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->ver_fit == 0 ? false : true;
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->ver_fit == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**********************
|
||||
@ -208,12 +208,11 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
||||
lv_cont_refr_autofit(cont);
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
if(lv_obj_get_width(cont) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(cont) != lv_area_get_height(param)) {
|
||||
lv_obj_get_height(cont) != lv_area_get_height(param)) {
|
||||
lv_cont_refr_layout(cont);
|
||||
lv_cont_refr_autofit(cont);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -232,24 +231,24 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
||||
*/
|
||||
static void lv_cont_refr_layout(lv_obj_t * cont)
|
||||
{
|
||||
lv_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_layout_t type = lv_cont_get_layout(cont);
|
||||
|
||||
/*'cont' has to be at least 1 child*/
|
||||
if(lv_obj_get_child(cont, NULL) == NULL) return;
|
||||
/*'cont' has to be at least 1 child*/
|
||||
if(lv_obj_get_child(cont, NULL) == NULL) return;
|
||||
|
||||
if(type == LV_LAYOUT_OFF) return;
|
||||
if(type == LV_LAYOUT_OFF) return;
|
||||
|
||||
if(type == LV_LAYOUT_CENTER) {
|
||||
lv_cont_layout_center(cont);
|
||||
} else if(type == LV_LAYOUT_COL_L || type == LV_LAYOUT_COL_M || type == LV_LAYOUT_COL_R) {
|
||||
lv_cont_layout_col(cont);
|
||||
} else if(type == LV_LAYOUT_ROW_T || type == LV_LAYOUT_ROW_M || type == LV_LAYOUT_ROW_B) {
|
||||
lv_cont_layout_row(cont);
|
||||
} else if(type == LV_LAYOUT_PRETTY) {
|
||||
lv_cont_layout_pretty(cont);
|
||||
} else if(type == LV_LAYOUT_GRID) {
|
||||
lv_cont_layout_grid(cont);
|
||||
}
|
||||
if(type == LV_LAYOUT_CENTER) {
|
||||
lv_cont_layout_center(cont);
|
||||
} else if(type == LV_LAYOUT_COL_L || type == LV_LAYOUT_COL_M || type == LV_LAYOUT_COL_R) {
|
||||
lv_cont_layout_col(cont);
|
||||
} else if(type == LV_LAYOUT_ROW_T || type == LV_LAYOUT_ROW_M || type == LV_LAYOUT_ROW_B) {
|
||||
lv_cont_layout_row(cont);
|
||||
} else if(type == LV_LAYOUT_PRETTY) {
|
||||
lv_cont_layout_pretty(cont);
|
||||
} else if(type == LV_LAYOUT_GRID) {
|
||||
lv_cont_layout_grid(cont);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,45 +257,45 @@ static void lv_cont_refr_layout(lv_obj_t * cont)
|
||||
*/
|
||||
static void lv_cont_layout_col(lv_obj_t * cont)
|
||||
{
|
||||
lv_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_obj_t * child;
|
||||
lv_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_obj_t * child;
|
||||
|
||||
/*Adjust margin and get the alignment type*/
|
||||
lv_align_t align;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_coord_t hpad_corr;
|
||||
/*Adjust margin and get the alignment type*/
|
||||
lv_align_t align;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_coord_t hpad_corr;
|
||||
|
||||
switch(type) {
|
||||
case LV_LAYOUT_COL_L:
|
||||
switch(type) {
|
||||
case LV_LAYOUT_COL_L:
|
||||
hpad_corr = style->body.padding.hor;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
case LV_LAYOUT_COL_M:
|
||||
hpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_MID;
|
||||
break;
|
||||
case LV_LAYOUT_COL_R:
|
||||
hpad_corr = -style->body.padding.hor;
|
||||
align = LV_ALIGN_IN_TOP_RIGHT;
|
||||
break;
|
||||
default:
|
||||
hpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
}
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
case LV_LAYOUT_COL_M:
|
||||
hpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_MID;
|
||||
break;
|
||||
case LV_LAYOUT_COL_R:
|
||||
hpad_corr = -style->body.padding.hor;
|
||||
align = LV_ALIGN_IN_TOP_RIGHT;
|
||||
break;
|
||||
default:
|
||||
hpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = style->body.padding.ver;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = style->body.padding.ver;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, cont, align, hpad_corr , last_cord);
|
||||
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
}
|
||||
lv_obj_align(child, cont, align, hpad_corr, last_cord);
|
||||
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
}
|
||||
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
@ -307,46 +306,46 @@ static void lv_cont_layout_col(lv_obj_t * cont)
|
||||
*/
|
||||
static void lv_cont_layout_row(lv_obj_t * cont)
|
||||
{
|
||||
lv_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_obj_t * child;
|
||||
lv_layout_t type = lv_cont_get_layout(cont);
|
||||
lv_obj_t * child;
|
||||
|
||||
/*Adjust margin and get the alignment type*/
|
||||
lv_align_t align;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_coord_t vpad_corr = style->body.padding.ver;
|
||||
/*Adjust margin and get the alignment type*/
|
||||
lv_align_t align;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_coord_t vpad_corr = style->body.padding.ver;
|
||||
|
||||
switch(type) {
|
||||
case LV_LAYOUT_ROW_T:
|
||||
vpad_corr = style->body.padding.ver;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
case LV_LAYOUT_ROW_M:
|
||||
vpad_corr = 0;
|
||||
align = LV_ALIGN_IN_LEFT_MID;
|
||||
break;
|
||||
case LV_LAYOUT_ROW_B:
|
||||
vpad_corr = -style->body.padding.ver;
|
||||
align = LV_ALIGN_IN_BOTTOM_LEFT;
|
||||
break;
|
||||
default:
|
||||
vpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
}
|
||||
switch(type) {
|
||||
case LV_LAYOUT_ROW_T:
|
||||
vpad_corr = style->body.padding.ver;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
case LV_LAYOUT_ROW_M:
|
||||
vpad_corr = 0;
|
||||
align = LV_ALIGN_IN_LEFT_MID;
|
||||
break;
|
||||
case LV_LAYOUT_ROW_B:
|
||||
vpad_corr = -style->body.padding.ver;
|
||||
align = LV_ALIGN_IN_BOTTOM_LEFT;
|
||||
break;
|
||||
default:
|
||||
vpad_corr = 0;
|
||||
align = LV_ALIGN_IN_TOP_LEFT;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = style->body.padding.hor;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = style->body.padding.hor;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, cont, align, last_cord, vpad_corr);
|
||||
last_cord += lv_obj_get_width(child) + style->body.padding.inner;
|
||||
}
|
||||
lv_obj_align(child, cont, align, last_cord, vpad_corr);
|
||||
last_cord += lv_obj_get_width(child) + style->body.padding.inner;
|
||||
}
|
||||
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
@ -357,35 +356,35 @@ static void lv_cont_layout_row(lv_obj_t * cont)
|
||||
*/
|
||||
static void lv_cont_layout_center(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
uint32_t obj_num = 0;
|
||||
lv_coord_t h_tot = 0;
|
||||
lv_obj_t * child;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
uint32_t obj_num = 0;
|
||||
lv_coord_t h_tot = 0;
|
||||
|
||||
LL_READ(cont->child_ll, child) {
|
||||
LL_READ(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
h_tot += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
obj_num ++;
|
||||
}
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
h_tot += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
obj_num ++;
|
||||
}
|
||||
|
||||
if(obj_num == 0) return;
|
||||
if(obj_num == 0) return;
|
||||
|
||||
h_tot -= style->body.padding.inner;
|
||||
h_tot -= style->body.padding.inner;
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = - (h_tot / 2);
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = - (h_tot / 2);
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
|
||||
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
}
|
||||
lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
|
||||
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
}
|
||||
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
@ -397,61 +396,61 @@ static void lv_cont_layout_center(lv_obj_t * cont)
|
||||
*/
|
||||
static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child_rs; /* Row starter child */
|
||||
lv_obj_t * child_rc; /* Row closer child */
|
||||
lv_obj_t * child_tmp; /* Temporary child */
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_coord_t w_obj = lv_obj_get_width(cont);
|
||||
lv_coord_t act_y = style->body.padding.ver;
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_t * child_rs; /* Row starter child */
|
||||
lv_obj_t * child_rc; /* Row closer child */
|
||||
lv_obj_t * child_tmp; /* Temporary child */
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_coord_t w_obj = lv_obj_get_width(cont);
|
||||
lv_coord_t act_y = style->body.padding.ver;
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
|
||||
child_rs = lv_ll_get_tail(&cont->child_ll); /*Set the row starter child*/
|
||||
if(child_rs == NULL) return; /*Return if no child*/
|
||||
child_rs = lv_ll_get_tail(&cont->child_ll); /*Set the row starter child*/
|
||||
if(child_rs == NULL) return; /*Return if no child*/
|
||||
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
|
||||
while(child_rs != NULL) {
|
||||
lv_coord_t h_row = 0;
|
||||
lv_coord_t w_row = style->body.padding.hor * 2; /*The width is at least the left+right hpad*/
|
||||
uint32_t obj_num = 0;
|
||||
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
|
||||
while(child_rs != NULL) {
|
||||
lv_coord_t h_row = 0;
|
||||
lv_coord_t w_row = style->body.padding.hor * 2; /*The width is at least the left+right hpad*/
|
||||
uint32_t obj_num = 0;
|
||||
|
||||
/*Find the row closer object and collect some data*/
|
||||
do {
|
||||
if(lv_obj_get_hidden(child_rc) == false &&
|
||||
lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) {
|
||||
/*If this object is already not fit then break*/
|
||||
if(w_row + lv_obj_get_width(child_rc) > w_obj) {
|
||||
/*Step back one child because the last already not fit, so the previous is the closer*/
|
||||
if(child_rc != NULL && obj_num != 0 ) {
|
||||
child_rc = lv_ll_get_next(&cont->child_ll, child_rc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
w_row += lv_obj_get_width(child_rc) + style->body.padding.inner; /*Add the object width + opad*/
|
||||
h_row = LV_MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
|
||||
obj_num ++;
|
||||
if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW)) break; /*If can not be followed by an other object then break here*/
|
||||
/*Find the row closer object and collect some data*/
|
||||
do {
|
||||
if(lv_obj_get_hidden(child_rc) == false &&
|
||||
lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) {
|
||||
/*If this object is already not fit then break*/
|
||||
if(w_row + lv_obj_get_width(child_rc) > w_obj) {
|
||||
/*Step back one child because the last already not fit, so the previous is the closer*/
|
||||
if(child_rc != NULL && obj_num != 0) {
|
||||
child_rc = lv_ll_get_next(&cont->child_ll, child_rc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
w_row += lv_obj_get_width(child_rc) + style->body.padding.inner; /*Add the object width + opad*/
|
||||
h_row = LV_MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
|
||||
obj_num ++;
|
||||
if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW)) break; /*If can not be followed by an other object then break here*/
|
||||
|
||||
}
|
||||
child_rc = lv_ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
|
||||
if(obj_num == 0) child_rs = child_rc; /*If the first object was hidden (or too long) then set the next as first */
|
||||
}while(child_rc != NULL);
|
||||
}
|
||||
child_rc = lv_ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
|
||||
if(obj_num == 0) child_rs = child_rc; /*If the first object was hidden (or too long) then set the next as first */
|
||||
} while(child_rc != NULL);
|
||||
|
||||
/*If the object is too long then align it to the middle*/
|
||||
if(obj_num == 0) {
|
||||
if(child_rc != NULL) {
|
||||
lv_obj_align(child_rc, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
h_row = lv_obj_get_height(child_rc); /*Not set previously because of the early break*/
|
||||
}
|
||||
}
|
||||
/*If there is only one object in the row then align it to the middle*/
|
||||
else if (obj_num == 1) {
|
||||
lv_obj_align(child_rs, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
}
|
||||
/*If the object is too long then align it to the middle*/
|
||||
if(obj_num == 0) {
|
||||
if(child_rc != NULL) {
|
||||
lv_obj_align(child_rc, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
h_row = lv_obj_get_height(child_rc); /*Not set previously because of the early break*/
|
||||
}
|
||||
}
|
||||
/*If there is only one object in the row then align it to the middle*/
|
||||
else if(obj_num == 1) {
|
||||
lv_obj_align(child_rs, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
|
||||
}
|
||||
/*If there are two object in the row then align them proportionally*/
|
||||
else if (obj_num == 2) {
|
||||
else if(obj_num == 2) {
|
||||
lv_obj_t * obj1 = child_rs;
|
||||
lv_obj_t * obj2 = lv_ll_get_prev(&cont->child_ll, child_rs);
|
||||
w_row = lv_obj_get_width(obj1) + lv_obj_get_width(obj2);
|
||||
@ -459,29 +458,29 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + (h_row - lv_obj_get_height(obj1)) / 2);
|
||||
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + (h_row - lv_obj_get_height(obj2)) / 2);
|
||||
}
|
||||
/* Align the children (from child_rs to child_rc)*/
|
||||
else {
|
||||
w_row -= style->body.padding.inner * obj_num;
|
||||
lv_coord_t new_opad = (w_obj - w_row) / (obj_num - 1);
|
||||
lv_coord_t act_x = style->body.padding.hor; /*x init*/
|
||||
child_tmp = child_rs;
|
||||
while(child_tmp != NULL) {
|
||||
if(lv_obj_get_hidden(child_tmp) == false &&
|
||||
lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
|
||||
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x, act_y + (h_row - lv_obj_get_height(child_tmp)) / 2);
|
||||
act_x += lv_obj_get_width(child_tmp) + new_opad;
|
||||
}
|
||||
if(child_tmp == child_rc) break;
|
||||
child_tmp = lv_ll_get_prev(&cont->child_ll, child_tmp);
|
||||
}
|
||||
/* Align the children (from child_rs to child_rc)*/
|
||||
else {
|
||||
w_row -= style->body.padding.inner * obj_num;
|
||||
lv_coord_t new_opad = (w_obj - w_row) / (obj_num - 1);
|
||||
lv_coord_t act_x = style->body.padding.hor; /*x init*/
|
||||
child_tmp = child_rs;
|
||||
while(child_tmp != NULL) {
|
||||
if(lv_obj_get_hidden(child_tmp) == false &&
|
||||
lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
|
||||
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x, act_y + (h_row - lv_obj_get_height(child_tmp)) / 2);
|
||||
act_x += lv_obj_get_width(child_tmp) + new_opad;
|
||||
}
|
||||
if(child_tmp == child_rc) break;
|
||||
child_tmp = lv_ll_get_prev(&cont->child_ll, child_tmp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(child_rc == NULL) break;
|
||||
act_y += style->body.padding.inner + h_row; /*y increment*/
|
||||
child_rs = lv_ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
|
||||
child_rc = child_rs;
|
||||
}
|
||||
if(child_rc == NULL) break;
|
||||
act_y += style->body.padding.inner + h_row; /*y increment*/
|
||||
child_rs = lv_ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
|
||||
child_rc = child_rs;
|
||||
}
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
@ -491,46 +490,46 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
*/
|
||||
static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
{
|
||||
lv_obj_t * child;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_coord_t w_tot = lv_obj_get_width(cont);
|
||||
lv_coord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL));
|
||||
lv_coord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL));
|
||||
uint16_t obj_row = (w_tot - (2 * style->body.padding.hor)) / (w_obj + style->body.padding.inner); /*Obj. num. in a row*/
|
||||
lv_coord_t x_ofs;
|
||||
if(obj_row > 1) {
|
||||
x_ofs = w_obj + (w_tot - (2 * style->body.padding.hor) - (obj_row * w_obj)) / (obj_row - 1);
|
||||
} else {
|
||||
x_ofs = w_tot / 2 - w_obj / 2;
|
||||
}
|
||||
lv_coord_t y_ofs = h_obj + style->body.padding.inner;
|
||||
lv_obj_t * child;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_coord_t w_tot = lv_obj_get_width(cont);
|
||||
lv_coord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL));
|
||||
lv_coord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL));
|
||||
uint16_t obj_row = (w_tot - (2 * style->body.padding.hor)) / (w_obj + style->body.padding.inner); /*Obj. num. in a row*/
|
||||
lv_coord_t x_ofs;
|
||||
if(obj_row > 1) {
|
||||
x_ofs = w_obj + (w_tot - (2 * style->body.padding.hor) - (obj_row * w_obj)) / (obj_row - 1);
|
||||
} else {
|
||||
x_ofs = w_tot / 2 - w_obj / 2;
|
||||
}
|
||||
lv_coord_t y_ofs = h_obj + style->body.padding.inner;
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
|
||||
/* Align the children */
|
||||
lv_coord_t act_x = style->body.padding.hor;
|
||||
lv_coord_t act_y = style->body.padding.ver;
|
||||
uint16_t obj_cnt = 0;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
/* Align the children */
|
||||
lv_coord_t act_x = style->body.padding.hor;
|
||||
lv_coord_t act_y = style->body.padding.ver;
|
||||
uint16_t obj_cnt = 0;
|
||||
LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
|
||||
if(obj_row > 1) {
|
||||
lv_obj_set_pos(child, act_x, act_y);
|
||||
act_x += x_ofs;
|
||||
} else {
|
||||
lv_obj_set_pos(child, x_ofs, act_y);
|
||||
}
|
||||
obj_cnt ++;
|
||||
if(obj_row > 1) {
|
||||
lv_obj_set_pos(child, act_x, act_y);
|
||||
act_x += x_ofs;
|
||||
} else {
|
||||
lv_obj_set_pos(child, x_ofs, act_y);
|
||||
}
|
||||
obj_cnt ++;
|
||||
|
||||
if(obj_cnt >= obj_row) {
|
||||
obj_cnt = 0;
|
||||
act_x = style->body.padding.hor;
|
||||
act_y += y_ofs;
|
||||
}
|
||||
}
|
||||
if(obj_cnt >= obj_row) {
|
||||
obj_cnt = 0;
|
||||
act_x = style->body.padding.hor;
|
||||
act_y += y_ofs;
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
@ -541,59 +540,59 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
*/
|
||||
static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
|
||||
if(ext->hor_fit == 0 &&
|
||||
ext->ver_fit == 0) {
|
||||
return;
|
||||
}
|
||||
if(ext->hor_fit == 0 &&
|
||||
ext->ver_fit == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
lv_area_t new_cords;
|
||||
lv_area_t ori;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_obj_t * i;
|
||||
lv_coord_t hpad = style->body.padding.hor;
|
||||
lv_coord_t vpad = style->body.padding.ver;
|
||||
lv_area_t new_cords;
|
||||
lv_area_t ori;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_obj_t * i;
|
||||
lv_coord_t hpad = style->body.padding.hor;
|
||||
lv_coord_t vpad = style->body.padding.ver;
|
||||
|
||||
/*Search the side coordinates of the children*/
|
||||
lv_obj_get_coords(cont, &ori);
|
||||
lv_obj_get_coords(cont, &new_cords);
|
||||
/*Search the side coordinates of the children*/
|
||||
lv_obj_get_coords(cont, &ori);
|
||||
lv_obj_get_coords(cont, &new_cords);
|
||||
|
||||
new_cords.x1 = LV_COORD_MAX;
|
||||
new_cords.y1 = LV_COORD_MAX;
|
||||
new_cords.x2 = LV_COORD_MIN;
|
||||
new_cords.y2 = LV_COORD_MIN;
|
||||
new_cords.x1 = LV_COORD_MAX;
|
||||
new_cords.y1 = LV_COORD_MAX;
|
||||
new_cords.x2 = LV_COORD_MIN;
|
||||
new_cords.y2 = LV_COORD_MIN;
|
||||
|
||||
LL_READ(cont->child_ll, i) {
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
new_cords.x1 = LV_MATH_MIN(new_cords.x1, i->coords.x1);
|
||||
new_cords.y1 = LV_MATH_MIN(new_cords.y1, i->coords.y1);
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
new_cords.x1 = LV_MATH_MIN(new_cords.x1, i->coords.x1);
|
||||
new_cords.y1 = LV_MATH_MIN(new_cords.y1, i->coords.y1);
|
||||
new_cords.x2 = LV_MATH_MAX(new_cords.x2, i->coords.x2);
|
||||
new_cords.y2 = LV_MATH_MAX(new_cords.y2, i->coords.y2);
|
||||
}
|
||||
|
||||
/*If the value is not the init value then the page has >=1 child.*/
|
||||
if(new_cords.x1 != LV_COORD_MAX) {
|
||||
if(ext->hor_fit != 0) {
|
||||
new_cords.x1 -= hpad;
|
||||
new_cords.x2 += hpad;
|
||||
} else {
|
||||
new_cords.x1 = cont->coords.x1;
|
||||
new_cords.x2 = cont->coords.x2;
|
||||
}
|
||||
if(ext->ver_fit != 0) {
|
||||
new_cords.y1 -= vpad;
|
||||
new_cords.y2 += vpad;
|
||||
} else {
|
||||
new_cords.y1 = cont->coords.y1;
|
||||
new_cords.y2 = cont->coords.y2;
|
||||
}
|
||||
if(ext->hor_fit != 0) {
|
||||
new_cords.x1 -= hpad;
|
||||
new_cords.x2 += hpad;
|
||||
} else {
|
||||
new_cords.x1 = cont->coords.x1;
|
||||
new_cords.x2 = cont->coords.x2;
|
||||
}
|
||||
if(ext->ver_fit != 0) {
|
||||
new_cords.y1 -= vpad;
|
||||
new_cords.y2 += vpad;
|
||||
} else {
|
||||
new_cords.y1 = cont->coords.y1;
|
||||
new_cords.y2 = cont->coords.y2;
|
||||
}
|
||||
|
||||
/*Do nothing if the coordinates are not changed*/
|
||||
if(cont->coords.x1 != new_cords.x1 ||
|
||||
cont->coords.y1 != new_cords.y1 ||
|
||||
cont->coords.x2 != new_cords.x2 ||
|
||||
cont->coords.y2 != new_cords.y2) {
|
||||
/*Do nothing if the coordinates are not changed*/
|
||||
if(cont->coords.x1 != new_cords.x1 ||
|
||||
cont->coords.y1 != new_cords.y1 ||
|
||||
cont->coords.x2 != new_cords.x2 ||
|
||||
cont->coords.y2 != new_cords.y2) {
|
||||
|
||||
lv_obj_invalidate(cont);
|
||||
lv_area_copy(&cont->coords, &new_cords);
|
||||
@ -605,7 +604,7 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
/*Inform the parent about the new coordinates*/
|
||||
lv_obj_t * par = lv_obj_get_parent(cont);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,11 @@
|
||||
*********************/
|
||||
#if USE_LV_ANIMATION
|
||||
# ifndef LV_DDLIST_ANIM_TIME
|
||||
# define LV_DDLIST_ANIM_TIME 200 /*ms*/
|
||||
# define LV_DDLIST_ANIM_TIME 200 /*ms*/
|
||||
# endif
|
||||
#else
|
||||
# undef LV_DDLIST_ANIM_TIME
|
||||
# define LV_DDLIST_ANIM_TIME 0 /*No animation*/
|
||||
# define LV_DDLIST_ANIM_TIME 0 /*No animation*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -109,10 +109,10 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_ddlist_set_options(new_ddlist, "Option 1\nOption 2\nOption 3");
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, th->ddlist.bg);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL,th->ddlist.sel);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, th->ddlist.sel);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, th->ddlist.sb);
|
||||
} else {
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, &lv_style_pretty);
|
||||
@ -122,7 +122,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing drop down list*/
|
||||
else {
|
||||
lv_ddlist_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
lv_ddlist_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
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;
|
||||
@ -245,11 +245,11 @@ void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *style)
|
||||
void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_DDLIST_STYLE_BG:
|
||||
lv_page_set_style(ddlist, LV_PAGE_STYLE_BG, style);
|
||||
break;
|
||||
@ -258,7 +258,7 @@ void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *s
|
||||
break;
|
||||
case LV_DDLIST_STYLE_SEL:
|
||||
ext->sel_style = style;
|
||||
lv_obj_t *scrl = lv_page_get_scrl(ddlist);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ddlist);
|
||||
lv_obj_refresh_ext_size(scrl); /*Because of the wider selected rectangle*/
|
||||
break;
|
||||
}
|
||||
@ -356,15 +356,19 @@ uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_ddlist_get_style(lv_obj_t *ddlist, lv_ddlist_style_t type)
|
||||
lv_style_t * lv_ddlist_get_style(lv_obj_t * ddlist, lv_ddlist_style_t type)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
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_SEL: return ext->sel_style;
|
||||
default: return NULL;
|
||||
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_SEL:
|
||||
return ext->sel_style;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -424,7 +428,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return ancestor_design(ddlist, mask, mode);
|
||||
return ancestor_design(ddlist, mask, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
@ -434,7 +438,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
|
||||
/*If the list is opened draw a rectangle under the selected item*/
|
||||
if(ext->opened != 0) {
|
||||
lv_style_t *style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_coord_t font_h = lv_font_get_height(font);
|
||||
|
||||
@ -461,7 +465,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
/*Redraw only in opened state*/
|
||||
if(ext->opened == 0) return true;
|
||||
|
||||
lv_style_t *style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_coord_t font_h = lv_font_get_height(font);
|
||||
|
||||
@ -477,7 +481,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
bool area_ok;
|
||||
area_ok = lv_area_union(&mask_sel, mask, &area_sel);
|
||||
if(area_ok) {
|
||||
lv_style_t *sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_SEL);
|
||||
lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_SEL);
|
||||
lv_style_t new_style;
|
||||
lv_style_copy(&new_style, style);
|
||||
new_style.text.color = sel_style->text.color;
|
||||
@ -508,26 +512,22 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_ddlist_refr_size(ddlist, 0);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
ext->label = NULL;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
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) {
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char*)param);
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
|
||||
if(!ext->opened) {
|
||||
ext->opened = 1;
|
||||
@ -554,21 +554,18 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||
ext->opened = 0;
|
||||
if(ext->action) ext->action(ddlist);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ext->opened = 1;
|
||||
}
|
||||
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_ESC) {
|
||||
} 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) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -595,16 +592,15 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
|
||||
res = ancestor_scrl_signal(scrl, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
lv_obj_t *ddlist = lv_obj_get_parent(scrl);
|
||||
lv_obj_t * ddlist = lv_obj_get_parent(scrl);
|
||||
|
||||
if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
/* Because of the wider selected rectangle ext. size
|
||||
* In this way by dragging the scrollable part the wider rectangle area can be redrawn too*/
|
||||
lv_style_t *style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
if(scrl->ext_size < style->body.padding.hor) scrl->ext_size = style->body.padding.hor;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_ddlist_ext_t *ext = lv_obj_get_ext_attr(ddlist);
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
ext->label = NULL; /*The label is already deleted*/
|
||||
}
|
||||
|
||||
@ -628,7 +624,7 @@ static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist)
|
||||
lv_obj_set_drag(lv_page_get_scrl(ddlist), false);
|
||||
|
||||
/*Search the clicked option*/
|
||||
lv_indev_t *indev = lv_indev_get_act();
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_point_t p;
|
||||
lv_indev_get_point(indev, &p);
|
||||
p.x -= ext->label->coords.x1;
|
||||
|
@ -90,7 +90,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_gauge_set_style(new_gauge, th->gauge);
|
||||
} else {
|
||||
@ -99,7 +99,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing gauge*/
|
||||
else {
|
||||
lv_gauge_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
lv_gauge_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
lv_gauge_set_needle_count(new_gauge, copy_ext->needle_count, copy_ext->needle_colors);
|
||||
|
||||
uint8_t i;
|
||||
@ -129,20 +129,20 @@ void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_co
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
if(ext->needle_count != needle_cnt) {
|
||||
if(ext->values != NULL) {
|
||||
lv_mem_free(ext->values);
|
||||
ext->values = NULL;
|
||||
}
|
||||
if(ext->values != NULL) {
|
||||
lv_mem_free(ext->values);
|
||||
ext->values = NULL;
|
||||
}
|
||||
|
||||
ext->values = lv_mem_realloc(ext->values, needle_cnt * sizeof(int16_t));
|
||||
ext->values = lv_mem_realloc(ext->values, needle_cnt * sizeof(int16_t));
|
||||
|
||||
int16_t min = lv_gauge_get_min_value(gauge);
|
||||
uint8_t n;
|
||||
for(n = ext->needle_count; n < needle_cnt; n++) {
|
||||
ext->values[n] = min;
|
||||
}
|
||||
int16_t min = lv_gauge_get_min_value(gauge);
|
||||
uint8_t n;
|
||||
for(n = ext->needle_count; n < needle_cnt; n++) {
|
||||
ext->values[n] = min;
|
||||
}
|
||||
|
||||
ext->needle_count = needle_cnt;
|
||||
ext->needle_count = needle_cnt;
|
||||
}
|
||||
|
||||
ext->needle_colors = colors;
|
||||
@ -253,7 +253,7 @@ static bool lv_gauge_design(lv_obj_t * gauge, const lv_area_t * mask, lv_design_
|
||||
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
@ -261,9 +261,9 @@ static bool lv_gauge_design(lv_obj_t * gauge, const lv_area_t * mask, lv_design_
|
||||
/* Store the real pointer because of 'lv_group'
|
||||
* If the object is in focus 'lv_obj_get_style()' will give a pointer to tmp style
|
||||
* and to the real object style. It is important because of style change tricks below*/
|
||||
lv_style_t *style_ori_p = gauge->style_p;
|
||||
lv_style_t *style = lv_obj_get_style(gauge);
|
||||
lv_gauge_ext_t *ext = lv_obj_get_ext_attr(gauge);
|
||||
lv_style_t * style_ori_p = gauge->style_p;
|
||||
lv_style_t * style = lv_obj_get_style(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
lv_gauge_draw_scale(gauge, mask);
|
||||
|
||||
@ -314,8 +314,7 @@ static lv_res_t lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_mem_free(ext->values);
|
||||
ext->values = NULL;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -358,14 +357,14 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
lv_coord_t x = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r) / LV_TRIGO_SIN_MAX;
|
||||
x += x_ofs;
|
||||
|
||||
int16_t scale_act = (int32_t)((int32_t)(max - min) * i) / (label_num - 1);
|
||||
int16_t scale_act = (int32_t)((int32_t)(max - min) * i) / (label_num - 1);
|
||||
scale_act += min;
|
||||
lv_math_num_to_str(scale_act, scale_txt);
|
||||
|
||||
lv_area_t label_cord;
|
||||
lv_point_t label_size;
|
||||
lv_txt_get_size(&label_size, scale_txt, style->text.font,
|
||||
style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
|
||||
/*Draw the label*/
|
||||
label_cord.x1 = x - label_size.x / 2;
|
||||
|
@ -78,17 +78,17 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_design_func(new_img, lv_img_design);
|
||||
|
||||
if(copy == NULL) {
|
||||
/* Enable auto size for non screens
|
||||
* because image screens are wallpapers
|
||||
* and must be screen sized*/
|
||||
if(par != NULL) ext->auto_size = 1;
|
||||
else ext->auto_size = 0;
|
||||
if(par != NULL) lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
|
||||
else lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/
|
||||
/* Enable auto size for non screens
|
||||
* because image screens are wallpapers
|
||||
* and must be screen sized*/
|
||||
if(par != NULL) ext->auto_size = 1;
|
||||
else ext->auto_size = 0;
|
||||
if(par != NULL) lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
|
||||
else lv_obj_set_style(new_img, &lv_style_plain); /*Set a style for screens*/
|
||||
} else {
|
||||
lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->auto_size = copy_ext->auto_size;
|
||||
lv_img_set_src(new_img, copy_ext->src);
|
||||
ext->auto_size = copy_ext->auto_size;
|
||||
lv_img_set_src(new_img, copy_ext->src);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_img);
|
||||
@ -132,10 +132,10 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||
|
||||
if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||
ext->src = src_img;
|
||||
ext->w = ((lv_img_t*)src_img)->header.w;
|
||||
ext->h = ((lv_img_t*)src_img)->header.h;
|
||||
ext->chroma_keyed = ((lv_img_t*)src_img)->header.chroma_keyed;
|
||||
ext->alpha_byte = ((lv_img_t*)src_img)->header.alpha_byte;
|
||||
ext->w = ((lv_img_t *)src_img)->header.w;
|
||||
ext->h = ((lv_img_t *)src_img)->header.h;
|
||||
ext->chroma_keyed = ((lv_img_t *)src_img)->header.chroma_keyed;
|
||||
ext->alpha_byte = ((lv_img_t *)src_img)->header.alpha_byte;
|
||||
lv_obj_set_size(img, ext->w, ext->h);
|
||||
}
|
||||
#if USE_LV_FILESYSTEM
|
||||
@ -291,12 +291,12 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
if(ext->h == 0 || ext->w == 0) return true;
|
||||
lv_area_t coords;
|
||||
lv_area_t coords;
|
||||
|
||||
lv_obj_get_coords(img, &coords);
|
||||
lv_obj_get_coords(img, &coords);
|
||||
|
||||
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
lv_area_t cords_tmp;
|
||||
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
lv_area_t cords_tmp;
|
||||
cords_tmp.y1 = coords.y1;
|
||||
cords_tmp.y2 = coords.y1 + ext->h - 1;
|
||||
|
||||
@ -307,15 +307,15 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
lv_draw_img(&cords_tmp, mask, style, ext->src);
|
||||
}
|
||||
}
|
||||
} else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||
} else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_draw_label(&coords, mask, style, ext->src, LV_TXT_FLAG_NONE, NULL);
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
/*Trigger the error handler of image drawer*/
|
||||
/*Trigger the error handler of image drawer*/
|
||||
lv_draw_img(&img->coords, mask, style, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -344,15 +344,13 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
||||
ext->src = NULL;
|
||||
ext->src_type = LV_IMG_SRC_UNKNOWN;
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Refresh the file name to refresh the symbol text size*/
|
||||
if(ext->src_type == LV_IMG_SRC_SYMBOL) {
|
||||
lv_img_set_src(img, ext->src);
|
||||
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
|
@ -34,31 +34,31 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt);
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
|
||||
static const char * kb_map_lc[] = {
|
||||
"\2051#", "\204q", "\204w", "\204e", "\204r", "\204t", "\204y", "\204u", "\204i", "\204o", "\204p", "\207Del", "\n",
|
||||
"\226ABC", "\203a", "\203s", "\203d", "\203f", "\203g", "\203h", "\203j", "\203k", "\203l", "\207Enter", "\n",
|
||||
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
|
||||
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
|
||||
"\2051#", "\204q", "\204w", "\204e", "\204r", "\204t", "\204y", "\204u", "\204i", "\204o", "\204p", "\207Del", "\n",
|
||||
"\226ABC", "\203a", "\203s", "\203d", "\203f", "\203g", "\203h", "\203j", "\203k", "\203l", "\207Enter", "\n",
|
||||
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
|
||||
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
|
||||
};
|
||||
|
||||
static const char * kb_map_uc[] = {
|
||||
"\2051#", "\204Q", "\204W", "\204E", "\204R", "\204T", "\204Y", "\204U", "\204I", "\204O", "\204P", "\207Del", "\n",
|
||||
"\226abc", "\203A", "\203S", "\203D", "\203F", "\203G", "\203H", "\203J", "\203K", "\203L", "\207Enter", "\n",
|
||||
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
|
||||
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
|
||||
"\2051#", "\204Q", "\204W", "\204E", "\204R", "\204T", "\204Y", "\204U", "\204I", "\204O", "\204P", "\207Del", "\n",
|
||||
"\226abc", "\203A", "\203S", "\203D", "\203F", "\203G", "\203H", "\203J", "\203K", "\203L", "\207Enter", "\n",
|
||||
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
|
||||
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
|
||||
};
|
||||
|
||||
static const char * kb_map_spec[] = {
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\202Del", "\n",
|
||||
"\222abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
||||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
||||
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\202Del", "\n",
|
||||
"\222abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
||||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
||||
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
|
||||
};
|
||||
|
||||
static const char * kb_map_num[] = {
|
||||
"1", "2", "3", "\202"SYMBOL_CLOSE,"\n",
|
||||
"4", "5", "6", "\202"SYMBOL_OK, "\n",
|
||||
"7", "8", "9", "\202Del", "\n",
|
||||
"+/-", "0", ".", SYMBOL_LEFT, SYMBOL_RIGHT, ""
|
||||
"1", "2", "3", "\202"SYMBOL_CLOSE, "\n",
|
||||
"4", "5", "6", "\202"SYMBOL_OK, "\n",
|
||||
"7", "8", "9", "\202Del", "\n",
|
||||
"+/-", "0", ".", SYMBOL_LEFT, SYMBOL_RIGHT, ""
|
||||
};
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -104,7 +104,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_btnm_set_map(new_kb, kb_map_lc);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->kb.bg);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->kb.btn.rel);
|
||||
@ -118,7 +118,8 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing keyboard*/
|
||||
else {
|
||||
lv_kb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);ext->ta = NULL;
|
||||
lv_kb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->ta = NULL;
|
||||
ext->ta = copy_ext->ta;
|
||||
ext->mode = copy_ext->mode;
|
||||
ext->cursor_mng = copy_ext->cursor_mng;
|
||||
@ -187,15 +188,15 @@ void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
if(ext->cursor_mng == en) return;
|
||||
|
||||
ext->cursor_mng = en == false? 0 : 1;
|
||||
ext->cursor_mng = en == false ? 0 : 1;
|
||||
|
||||
if(ext->ta) {
|
||||
lv_cursor_type_t cur_type;
|
||||
cur_type = lv_ta_get_cursor_type(ext->ta);
|
||||
|
||||
if(ext->cursor_mng){
|
||||
if(ext->cursor_mng) {
|
||||
lv_ta_set_cursor_type(ext->ta, cur_type & (~LV_CURSOR_HIDDEN));
|
||||
}else{
|
||||
} else {
|
||||
lv_ta_set_cursor_type(ext->ta, cur_type | LV_CURSOR_HIDDEN);
|
||||
}
|
||||
}
|
||||
@ -229,9 +230,9 @@ void lv_kb_set_hide_action(lv_obj_t * kb, lv_action_t action)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_kb_set_style(lv_obj_t *kb, lv_kb_style_t type, lv_style_t *style)
|
||||
void lv_kb_set_style(lv_obj_t * kb, lv_kb_style_t type, lv_style_t * style)
|
||||
{
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_KB_STYLE_BG:
|
||||
lv_btnm_set_style(kb, LV_BTNM_STYLE_BG, style);
|
||||
break;
|
||||
@ -319,16 +320,23 @@ lv_action_t lv_kb_get_hide_action(lv_obj_t * kb)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_kb_get_style(lv_obj_t *kb, lv_kb_style_t type)
|
||||
lv_style_t * lv_kb_get_style(lv_obj_t * kb, lv_kb_style_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case LV_KB_STYLE_BG: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BG);
|
||||
case LV_KB_STYLE_BTN_REL: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_REL);
|
||||
case LV_KB_STYLE_BTN_PR: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_PR);
|
||||
case LV_KB_STYLE_BTN_TGL_REL: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_REL);
|
||||
case LV_KB_STYLE_BTN_TGL_PR: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_PR);
|
||||
case LV_KB_STYLE_BTN_INA: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_INA);
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_KB_STYLE_BG:
|
||||
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BG);
|
||||
case LV_KB_STYLE_BTN_REL:
|
||||
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_REL);
|
||||
case LV_KB_STYLE_BTN_PR:
|
||||
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_PR);
|
||||
case LV_KB_STYLE_BTN_TGL_REL:
|
||||
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_REL);
|
||||
case LV_KB_STYLE_BTN_TGL_PR:
|
||||
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_PR);
|
||||
case LV_KB_STYLE_BTN_INA:
|
||||
return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_INA);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -356,8 +364,7 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -383,16 +390,13 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt)
|
||||
if(strcmp(txt, "abc") == 0) {
|
||||
lv_btnm_set_map(kb, kb_map_lc);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
else if(strcmp(txt, "ABC") == 0) {
|
||||
} else if(strcmp(txt, "ABC") == 0) {
|
||||
lv_btnm_set_map(kb, kb_map_uc);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
else if(strcmp(txt, "1#") == 0) {
|
||||
} else if(strcmp(txt, "1#") == 0) {
|
||||
lv_btnm_set_map(kb, kb_map_spec);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
else if(strcmp(txt, SYMBOL_CLOSE) == 0) {
|
||||
} else if(strcmp(txt, SYMBOL_CLOSE) == 0) {
|
||||
if(ext->hide_action) ext->hide_action(kb);
|
||||
else {
|
||||
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
||||
|
@ -38,7 +38,7 @@
|
||||
static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param);
|
||||
static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_mode_t mode);
|
||||
static void lv_label_refr_text(lv_obj_t * label);
|
||||
static void lv_label_revert_dots(lv_obj_t *label);
|
||||
static void lv_label_revert_dots(lv_obj_t * label);
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
static void lv_label_set_offset_x(lv_obj_t * label, lv_coord_t x);
|
||||
@ -86,14 +86,14 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->anim_speed = LV_LABEL_SCROLL_SPEED;
|
||||
ext->offset.x = 0;
|
||||
ext->offset.y = 0;
|
||||
lv_obj_set_design_func(new_label, lv_label_design);
|
||||
lv_obj_set_signal_func(new_label, lv_label_signal);
|
||||
lv_obj_set_design_func(new_label, lv_label_design);
|
||||
lv_obj_set_signal_func(new_label, lv_label_signal);
|
||||
|
||||
/*Init the new label*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_click(new_label, false);
|
||||
lv_label_set_long_mode(new_label, LV_LABEL_LONG_EXPAND);
|
||||
lv_label_set_text(new_label, "Text");
|
||||
lv_obj_set_click(new_label, false);
|
||||
lv_label_set_long_mode(new_label, LV_LABEL_LONG_EXPAND);
|
||||
lv_label_set_text(new_label, "Text");
|
||||
lv_label_set_style(new_label, NULL); /*Inherit parent's style*/
|
||||
}
|
||||
/*Copy 'copy' if not NULL*/
|
||||
@ -250,9 +250,9 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
||||
* @param label pointer to a label object
|
||||
* @param align 'LV_LABEL_ALIGN_LEFT' or 'LV_LABEL_ALIGN_LEFT'
|
||||
*/
|
||||
void lv_label_set_align(lv_obj_t *label, lv_label_align_t align)
|
||||
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
|
||||
{
|
||||
lv_label_ext_t *ext = lv_obj_get_ext_attr(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
if(ext->align == align) return;
|
||||
|
||||
ext->align = align;
|
||||
@ -296,7 +296,7 @@ void lv_label_set_no_break(lv_obj_t * label, bool no_break_en)
|
||||
* @param label pointer to a label object
|
||||
* @param body_en true: draw body; false: don't draw body
|
||||
*/
|
||||
void lv_label_set_body_draw(lv_obj_t *label, bool body_en)
|
||||
void lv_label_set_body_draw(lv_obj_t * label, bool body_en)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
if(ext->body_draw == body_en) return;
|
||||
@ -313,9 +313,9 @@ void lv_label_set_body_draw(lv_obj_t *label, bool body_en)
|
||||
* @param label pointer to a label object
|
||||
* @param anim_speed speed of animation in px/sec unit
|
||||
*/
|
||||
void lv_label_set_anim_speed(lv_obj_t *label, uint16_t anim_speed)
|
||||
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
|
||||
{
|
||||
lv_label_ext_t *ext = lv_obj_get_ext_attr(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
if(ext->anim_speed == anim_speed) return;
|
||||
|
||||
ext->anim_speed = anim_speed;
|
||||
@ -390,7 +390,7 @@ bool lv_label_get_no_break(lv_obj_t * label)
|
||||
* @param label pointer to a label object
|
||||
* @return true: draw body; false: don't draw body
|
||||
*/
|
||||
bool lv_label_get_body_draw(lv_obj_t *label)
|
||||
bool lv_label_get_body_draw(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
return ext->body_draw == 0 ? false : true;
|
||||
@ -401,9 +401,9 @@ bool lv_label_get_body_draw(lv_obj_t *label)
|
||||
* @param label pointer to a label object
|
||||
* @return speed of animation in px/sec unit
|
||||
*/
|
||||
uint16_t lv_label_get_anim_speed(lv_obj_t *label)
|
||||
uint16_t lv_label_get_anim_speed(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t *ext = lv_obj_get_ext_attr(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
return ext->anim_speed;
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ uint16_t lv_label_get_anim_speed(lv_obj_t *label)
|
||||
*/
|
||||
void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
{
|
||||
const char * txt = lv_label_get_text(label);
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
@ -439,7 +439,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
index = txt_utf8_get_byte_id(txt, index);
|
||||
|
||||
/*Search the line of the index letter */;
|
||||
while (txt[new_line_start] != '\0') {
|
||||
while(txt[new_line_start] != '\0') {
|
||||
new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);
|
||||
if(index < new_line_start || txt[new_line_start] == '\0') break; /*The line of 'index' letter begins at 'line_start'*/
|
||||
|
||||
@ -455,13 +455,13 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
|
||||
/*Calculate the x coordinate*/
|
||||
lv_coord_t x = 0;
|
||||
uint32_t i = line_start;
|
||||
uint32_t i = line_start;
|
||||
uint32_t cnt = line_start; /*Count the letter (in UTF-8 1 letter not 1 byte)*/
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
uint32_t letter;
|
||||
while(cnt < index) {
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
uint32_t letter;
|
||||
while(cnt < index) {
|
||||
cnt += lv_txt_utf8_size(txt[i]);
|
||||
letter = lv_txt_utf8_next(txt, &i);
|
||||
letter = lv_txt_utf8_next(txt, &i);
|
||||
/*Handle the recolor command*/
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
|
||||
@ -469,13 +469,13 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
}
|
||||
}
|
||||
x += lv_font_get_width(font, letter) + style->text.letter_space;
|
||||
}
|
||||
}
|
||||
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) {
|
||||
lv_coord_t line_w;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) {
|
||||
lv_coord_t line_w;
|
||||
line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||
font, style->text.letter_space, flag);
|
||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||
}
|
||||
|
||||
pos->x = x;
|
||||
@ -492,7 +492,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
*/
|
||||
uint16_t lv_label_get_letter_on(lv_obj_t * label, lv_point_t * pos)
|
||||
{
|
||||
const char * txt = lv_label_get_text(label);
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
@ -514,45 +514,45 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, lv_point_t * pos)
|
||||
}
|
||||
|
||||
/*Search the line of the index letter */;
|
||||
while (txt[line_start] != '\0') {
|
||||
new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);
|
||||
if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/
|
||||
y += letter_height + style->text.line_space;
|
||||
while(txt[line_start] != '\0') {
|
||||
new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);
|
||||
if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/
|
||||
y += letter_height + style->text.line_space;
|
||||
line_start = new_line_start;
|
||||
}
|
||||
|
||||
/*Calculate the x coordinate*/
|
||||
lv_coord_t x = 0;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) {
|
||||
lv_coord_t line_w;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) {
|
||||
lv_coord_t line_w;
|
||||
line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||
font, style->text.letter_space, flag);
|
||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||
}
|
||||
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
uint32_t i = line_start;
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
uint32_t i = line_start;
|
||||
uint32_t i_current = i;
|
||||
uint32_t letter;
|
||||
while(i < new_line_start - 1) {
|
||||
letter = lv_txt_utf8_next(txt, &i); /*Be careful 'i' already points to the next character*/
|
||||
/*Handle the recolor command*/
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
uint32_t letter;
|
||||
while(i < new_line_start - 1) {
|
||||
letter = lv_txt_utf8_next(txt, &i); /*Be careful 'i' already points to the next character*/
|
||||
/*Handle the recolor command*/
|
||||
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
|
||||
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
|
||||
continue; /*Skip the letter is it is part of a command*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x += lv_font_get_width(font, letter);
|
||||
if(pos->x < x) {
|
||||
i = i_current;
|
||||
break;
|
||||
}
|
||||
x += style->text.letter_space;
|
||||
i_current = i;
|
||||
}
|
||||
x += lv_font_get_width(font, letter);
|
||||
if(pos->x < x) {
|
||||
i = i_current;
|
||||
break;
|
||||
}
|
||||
x += style->text.letter_space;
|
||||
i_current = i;
|
||||
}
|
||||
|
||||
return lv_txt_utf8_get_char_id(txt, i);
|
||||
return lv_txt_utf8_get_char_id(txt, i);
|
||||
}
|
||||
|
||||
|
||||
@ -664,15 +664,15 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
|
||||
}
|
||||
|
||||
/*TEST: draw a background for the label*/
|
||||
// lv_draw_rect(&label->coords, mask, &lv_style_plain_color);
|
||||
// lv_draw_rect(&label->coords, mask, &lv_style_plain_color);
|
||||
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
|
||||
if(ext->no_break != 0) flag |= LV_TXT_FLAG_NO_BREAK;
|
||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||
|
||||
lv_draw_label(&coords, mask, style, ext->text, flag, &ext->offset);
|
||||
lv_draw_label(&coords, mask, style, ext->text, flag, &ext->offset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -700,29 +700,24 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
|
||||
lv_mem_free(ext->text);
|
||||
ext->text = NULL;
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Revert dots for proper refresh*/
|
||||
lv_label_revert_dots(label);
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Revert dots for proper refresh*/
|
||||
lv_label_revert_dots(label);
|
||||
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
else if (sign == LV_SIGNAL_CORD_CHG) {
|
||||
lv_label_refr_text(label);
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
if(lv_area_get_width(&label->coords) != lv_area_get_width(param) ||
|
||||
lv_area_get_height(&label->coords) != lv_area_get_height(param))
|
||||
{
|
||||
lv_area_get_height(&label->coords) != lv_area_get_height(param)) {
|
||||
lv_label_revert_dots(label);
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
if(ext->body_draw) {
|
||||
lv_style_t * style = lv_label_get_style(label);
|
||||
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.hor);
|
||||
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.ver);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -750,7 +745,7 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
|
||||
/*If the width will be expanded set the max length to very big */
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND ||
|
||||
ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
ext->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
max_w = LV_COORD_MAX;
|
||||
}
|
||||
|
||||
@ -785,7 +780,7 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
anim.path = lv_anim_path_linear;
|
||||
|
||||
anim.playback_pause = (((lv_font_get_width(style->text.font, ' ') +
|
||||
style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;
|
||||
style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;
|
||||
anim.repeat_pause = anim.playback_pause;
|
||||
|
||||
if(lv_obj_get_width(label) > lv_obj_get_width(parent)) {
|
||||
@ -813,7 +808,7 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
anim.act_time = 0;
|
||||
anim.end_cb = NULL;
|
||||
anim.path = lv_anim_path_linear;
|
||||
anim.playback_pause = (((lv_font_get_width(style->text.font, ' ') + style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;;
|
||||
anim.playback_pause = (((lv_font_get_width(style->text.font, ' ') + style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;;
|
||||
anim.repeat_pause = anim.playback_pause;
|
||||
|
||||
bool hor_anim = false;
|
||||
@ -840,59 +835,58 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
ext->offset.y = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(ext->long_mode == LV_LABEL_LONG_DOT) {
|
||||
if(size.y <= lv_obj_get_height(label)) { /*No dots are required, the text is short enough*/
|
||||
ext->dot_end = LV_LABEL_DOT_END_INV;
|
||||
} else if(lv_txt_get_length(ext->text) <= LV_LABEL_DOT_NUM) { /*Don't turn to dots all the characters*/
|
||||
ext->dot_end = LV_LABEL_DOT_END_INV;
|
||||
} else {
|
||||
lv_point_t p;
|
||||
p.x = lv_obj_get_width(label) - (lv_font_get_width(style->text.font, '.') + style->text.letter_space) * LV_LABEL_DOT_NUM; /*Shrink with dots*/
|
||||
p.y = lv_obj_get_height(label);
|
||||
p.y -= p.y % (lv_font_get_height(style->text.font) + style->text.line_space); /*Round down to the last line*/
|
||||
p.y -= style->text.line_space; /*Trim the last line space*/
|
||||
uint32_t letter_id = lv_label_get_letter_on(label, &p);
|
||||
} else if(ext->long_mode == LV_LABEL_LONG_DOT) {
|
||||
if(size.y <= lv_obj_get_height(label)) { /*No dots are required, the text is short enough*/
|
||||
ext->dot_end = LV_LABEL_DOT_END_INV;
|
||||
} else if(lv_txt_get_length(ext->text) <= LV_LABEL_DOT_NUM) { /*Don't turn to dots all the characters*/
|
||||
ext->dot_end = LV_LABEL_DOT_END_INV;
|
||||
} else {
|
||||
lv_point_t p;
|
||||
p.x = lv_obj_get_width(label) - (lv_font_get_width(style->text.font, '.') + style->text.letter_space) * LV_LABEL_DOT_NUM; /*Shrink with dots*/
|
||||
p.y = lv_obj_get_height(label);
|
||||
p.y -= p.y % (lv_font_get_height(style->text.font) + style->text.line_space); /*Round down to the last line*/
|
||||
p.y -= style->text.line_space; /*Trim the last line space*/
|
||||
uint32_t letter_id = lv_label_get_letter_on(label, &p);
|
||||
|
||||
|
||||
#if LV_TXT_UTF8 == 0
|
||||
/*Save letters under the dots and replace them with dots*/
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
|
||||
ext->dot_tmp[i] = ext->text[letter_id + i];
|
||||
ext->text[letter_id + i] = '.';
|
||||
}
|
||||
/*Save letters under the dots and replace them with dots*/
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
|
||||
ext->dot_tmp[i] = ext->text[letter_id + i];
|
||||
ext->text[letter_id + i] = '.';
|
||||
}
|
||||
|
||||
ext->dot_tmp[LV_LABEL_DOT_NUM] = ext->text[letter_id + LV_LABEL_DOT_NUM];
|
||||
ext->text[letter_id + LV_LABEL_DOT_NUM] = '\0';
|
||||
ext->dot_tmp[LV_LABEL_DOT_NUM] = ext->text[letter_id + LV_LABEL_DOT_NUM];
|
||||
ext->text[letter_id + LV_LABEL_DOT_NUM] = '\0';
|
||||
|
||||
ext->dot_end = letter_id + LV_LABEL_DOT_NUM;
|
||||
ext->dot_end = letter_id + LV_LABEL_DOT_NUM;
|
||||
#else
|
||||
/*Save letters under the dots and replace them with dots*/
|
||||
uint32_t i;
|
||||
uint32_t byte_id = txt_utf8_get_byte_id(ext->text, letter_id);
|
||||
uint32_t byte_id_ori = byte_id;
|
||||
uint8_t len = 0;
|
||||
for(i = 0; i <= LV_LABEL_DOT_NUM; i++) {
|
||||
len += lv_txt_utf8_size(ext->text[byte_id]);
|
||||
lv_txt_utf8_next(ext->text, &byte_id);
|
||||
}
|
||||
/*Save letters under the dots and replace them with dots*/
|
||||
uint32_t i;
|
||||
uint32_t byte_id = txt_utf8_get_byte_id(ext->text, letter_id);
|
||||
uint32_t byte_id_ori = byte_id;
|
||||
uint8_t len = 0;
|
||||
for(i = 0; i <= LV_LABEL_DOT_NUM; i++) {
|
||||
len += lv_txt_utf8_size(ext->text[byte_id]);
|
||||
lv_txt_utf8_next(ext->text, &byte_id);
|
||||
}
|
||||
|
||||
memcpy(ext->dot_tmp, &ext->text[byte_id_ori], len);
|
||||
ext->dot_tmp[len] = '\0'; /*Close with a zero*/
|
||||
memcpy(ext->dot_tmp, &ext->text[byte_id_ori], len);
|
||||
ext->dot_tmp[len] = '\0'; /*Close with a zero*/
|
||||
|
||||
for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
|
||||
ext->text[byte_id_ori + i] = '.';
|
||||
}
|
||||
ext->text[byte_id_ori + LV_LABEL_DOT_NUM] = '\0';
|
||||
for(i = 0; i < LV_LABEL_DOT_NUM; i++) {
|
||||
ext->text[byte_id_ori + i] = '.';
|
||||
}
|
||||
ext->text[byte_id_ori + LV_LABEL_DOT_NUM] = '\0';
|
||||
|
||||
ext->dot_end = letter_id + LV_LABEL_DOT_NUM;
|
||||
ext->dot_end = letter_id + LV_LABEL_DOT_NUM;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*In break mode only the height can change*/
|
||||
else if (ext->long_mode == LV_LABEL_LONG_BREAK) {
|
||||
else if(ext->long_mode == LV_LABEL_LONG_BREAK) {
|
||||
lv_obj_set_height(label, size.y);
|
||||
}
|
||||
|
||||
@ -900,7 +894,7 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
lv_obj_invalidate(label);
|
||||
}
|
||||
|
||||
static void lv_label_revert_dots(lv_obj_t *label)
|
||||
static void lv_label_revert_dots(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
if(ext->long_mode != LV_LABEL_LONG_DOT) return;
|
||||
|
@ -18,8 +18,8 @@
|
||||
*********************/
|
||||
#define LV_LED_WIDTH_DEF (LV_DPI / 3)
|
||||
#define LV_LED_HEIGHT_DEF (LV_DPI / 3)
|
||||
#define LV_LED_BRIGHT_OFF 100
|
||||
#define LV_LED_BRIGHT_ON 255
|
||||
#define LV_LED_BRIGHT_OFF 100
|
||||
#define LV_LED_BRIGHT_ON 255
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -54,7 +54,7 @@ static lv_signal_func_t ancestor_signal;
|
||||
lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_led = lv_obj_create(par, copy);
|
||||
lv_obj_t * new_led = lv_obj_create(par, copy);
|
||||
lv_mem_assert(new_led);
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_led);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_led);
|
||||
@ -69,10 +69,10 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Init the new led object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
|
||||
lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_led_set_style(new_led, th->led);
|
||||
} else {
|
||||
@ -81,8 +81,8 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_led_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->bright = copy_ext->bright;
|
||||
lv_led_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->bright = copy_ext->bright;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_led);
|
||||
@ -102,14 +102,14 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
|
||||
{
|
||||
/*Set the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
if(ext->bright == bright) return;
|
||||
/*Set the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
if(ext->bright == bright) return;
|
||||
|
||||
ext->bright = bright;
|
||||
ext->bright = bright;
|
||||
|
||||
/*Invalidate the object there fore it will be redrawn*/
|
||||
lv_obj_invalidate(led);
|
||||
/*Invalidate the object there fore it will be redrawn*/
|
||||
lv_obj_invalidate(led);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,7 +118,7 @@ void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
|
||||
*/
|
||||
void lv_led_on(lv_obj_t * led)
|
||||
{
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_ON);
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +127,7 @@ void lv_led_on(lv_obj_t * led)
|
||||
*/
|
||||
void lv_led_off(lv_obj_t * led)
|
||||
{
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_OFF);
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_OFF);
|
||||
}
|
||||
|
||||
|
||||
@ -137,9 +137,9 @@ void lv_led_off(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);
|
||||
else lv_led_on(led);
|
||||
uint8_t bright = lv_led_get_bright(led);
|
||||
if(bright > (LV_LED_BRIGHT_OFF + LV_LED_BRIGHT_ON) >> 1) lv_led_off(led);
|
||||
else lv_led_on(led);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -153,8 +153,8 @@ void lv_led_toggle(lv_obj_t * led)
|
||||
*/
|
||||
uint8_t lv_led_get_bright(lv_obj_t * led)
|
||||
{
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
return ext->bright;
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
return ext->bright;
|
||||
}
|
||||
|
||||
/**********************
|
||||
@ -174,33 +174,33 @@ uint8_t lv_led_get_bright(lv_obj_t * led)
|
||||
static bool lv_led_design(lv_obj_t * led, const lv_area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return ancestor_design_f(led, mask, mode);
|
||||
/*Return false if the object is not covers the mask area*/
|
||||
return ancestor_design_f(led, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Make darker colors in a temporary style according to the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
lv_style_t * style = lv_obj_get_style(led);
|
||||
/*Make darker colors in a temporary style according to the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
lv_style_t * style = lv_obj_get_style(led);
|
||||
|
||||
/* Store the real pointer because of 'lv_group'
|
||||
* If the object is in focus 'lv_obj_get_style()' will give a pointer to tmp style
|
||||
* and to the real object style. It is important because of style change tricks below*/
|
||||
lv_style_t *style_ori_p = led->style_p;
|
||||
lv_style_t * style_ori_p = led->style_p;
|
||||
|
||||
/*Create a temporal style*/
|
||||
/*Create a temporal style*/
|
||||
lv_style_t leds_tmp;
|
||||
memcpy(&leds_tmp, style, sizeof(leds_tmp));
|
||||
memcpy(&leds_tmp, style, sizeof(leds_tmp));
|
||||
|
||||
/*Mix. the color with black proportionally with brightness*/
|
||||
leds_tmp.body.main_color = lv_color_mix(leds_tmp.body.main_color, LV_COLOR_BLACK, ext->bright);
|
||||
leds_tmp.body.grad_color = lv_color_mix(leds_tmp.body.grad_color, LV_COLOR_BLACK, ext->bright);
|
||||
/*Mix. the color with black proportionally with brightness*/
|
||||
leds_tmp.body.main_color = lv_color_mix(leds_tmp.body.main_color, LV_COLOR_BLACK, ext->bright);
|
||||
leds_tmp.body.grad_color = lv_color_mix(leds_tmp.body.grad_color, LV_COLOR_BLACK, ext->bright);
|
||||
leds_tmp.body.border.color = lv_color_mix(leds_tmp.body.border.color, LV_COLOR_BLACK, ext->bright);
|
||||
|
||||
/*Set the current swidth according to brightness proportionally between LV_LED_BRIGHT_OFF and LV_LED_BRIGHT_ON*/
|
||||
uint16_t bright_tmp = ext->bright;
|
||||
/*Set the current swidth according to brightness proportionally between LV_LED_BRIGHT_OFF and LV_LED_BRIGHT_ON*/
|
||||
uint16_t bright_tmp = ext->bright;
|
||||
leds_tmp.body.shadow.width = ((bright_tmp - LV_LED_BRIGHT_OFF) * style->body.shadow.width) / (LV_LED_BRIGHT_ON - LV_LED_BRIGHT_OFF);
|
||||
|
||||
led->style_p = &leds_tmp;
|
||||
ancestor_design_f(led, mask, mode);
|
||||
led->style_p = &leds_tmp;
|
||||
ancestor_design_f(led, mask, mode);
|
||||
led->style_p = style_ori_p; /*Restore the ORIGINAL style pointer*/
|
||||
}
|
||||
return true;
|
||||
|
@ -70,16 +70,16 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Init the new line*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_line, LV_DPI, LV_DPI); /*Auto size is enables, but set default size until no points are added*/
|
||||
lv_obj_set_style(new_line, NULL); /*Inherit parent's style*/
|
||||
lv_obj_set_click(new_line, false);
|
||||
lv_obj_set_style(new_line, NULL); /*Inherit parent's style*/
|
||||
lv_obj_set_click(new_line, false);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_line_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
lv_line_set_auto_size(new_line,lv_line_get_auto_size(copy));
|
||||
lv_line_set_y_invert(new_line,lv_line_get_y_inv(copy));
|
||||
lv_line_set_auto_size(new_line,lv_line_get_auto_size(copy));
|
||||
lv_line_set_points(new_line, copy_ext->point_array, copy_ext->point_num);
|
||||
lv_line_set_auto_size(new_line, lv_line_get_auto_size(copy));
|
||||
lv_line_set_y_invert(new_line, lv_line_get_y_inv(copy));
|
||||
lv_line_set_auto_size(new_line, lv_line_get_auto_size(copy));
|
||||
lv_line_set_points(new_line, copy_ext->point_array, copy_ext->point_num);
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_line);
|
||||
}
|
||||
@ -100,24 +100,24 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
void lv_line_set_points(lv_obj_t * line, const lv_point_t * point_a, uint16_t point_num)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
ext->point_array = point_a;
|
||||
ext->point_num = point_num;
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
ext->point_array = point_a;
|
||||
ext->point_num = point_num;
|
||||
|
||||
if(point_num > 0 && ext->auto_size != 0) {
|
||||
uint16_t i;
|
||||
lv_coord_t xmax = LV_COORD_MIN;
|
||||
lv_coord_t ymax = LV_COORD_MIN;
|
||||
for(i = 0; i < point_num; i++) {
|
||||
xmax = LV_MATH_MAX(point_a[i].x, xmax);
|
||||
ymax = LV_MATH_MAX(point_a[i].y, ymax);
|
||||
}
|
||||
if(point_num > 0 && ext->auto_size != 0) {
|
||||
uint16_t i;
|
||||
lv_coord_t xmax = LV_COORD_MIN;
|
||||
lv_coord_t ymax = LV_COORD_MIN;
|
||||
for(i = 0; i < point_num; i++) {
|
||||
xmax = LV_MATH_MAX(point_a[i].x, xmax);
|
||||
ymax = LV_MATH_MAX(point_a[i].y, ymax);
|
||||
}
|
||||
|
||||
lv_style_t * style = lv_line_get_style(line);
|
||||
lv_obj_set_size(line, xmax + style->line.width, ymax + style->line.width);
|
||||
}
|
||||
lv_style_t * style = lv_line_get_style(line);
|
||||
lv_obj_set_size(line, xmax + style->line.width, ymax + style->line.width);
|
||||
}
|
||||
|
||||
lv_obj_invalidate(line);
|
||||
lv_obj_invalidate(line);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,13 +128,13 @@ void lv_line_set_points(lv_obj_t * line, const lv_point_t * point_a, uint16_t po
|
||||
*/
|
||||
void lv_line_set_auto_size(lv_obj_t * line, bool autosize_en)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
if(ext->auto_size == autosize_en) return;
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
if(ext->auto_size == autosize_en) return;
|
||||
|
||||
ext->auto_size = autosize_en == false ? 0 : 1;
|
||||
ext->auto_size = autosize_en == false ? 0 : 1;
|
||||
|
||||
/*Refresh the object*/
|
||||
if(autosize_en) lv_line_set_points(line, ext->point_array, ext->point_num);
|
||||
/*Refresh the object*/
|
||||
if(autosize_en) lv_line_set_points(line, ext->point_array, ext->point_num);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,12 +146,12 @@ void lv_line_set_auto_size(lv_obj_t * line, bool autosize_en)
|
||||
*/
|
||||
void lv_line_set_y_invert(lv_obj_t * line, bool yinv_en)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
if(ext->y_inv == yinv_en) return;
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
if(ext->y_inv == yinv_en) return;
|
||||
|
||||
ext->y_inv = yinv_en == false ? 0 : 1;
|
||||
ext->y_inv = yinv_en == false ? 0 : 1;
|
||||
|
||||
lv_obj_invalidate(line);
|
||||
lv_obj_invalidate(line);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -165,9 +165,9 @@ void lv_line_set_y_invert(lv_obj_t * line, bool yinv_en)
|
||||
*/
|
||||
bool lv_line_get_auto_size(lv_obj_t * line)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
return ext->auto_size == 0 ? false : true;
|
||||
return ext->auto_size == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,9 +177,9 @@ bool lv_line_get_auto_size(lv_obj_t * line)
|
||||
*/
|
||||
bool lv_line_get_y_inv(lv_obj_t * line)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
return ext->y_inv == 0 ? false : true;
|
||||
return ext->y_inv == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**********************
|
||||
@ -201,35 +201,35 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
|
||||
/*A line never covers an area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) return false;
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
if(ext->point_num == 0 || ext->point_array == NULL) return false;
|
||||
if(ext->point_num == 0 || ext->point_array == NULL) return false;
|
||||
|
||||
lv_style_t * style = lv_obj_get_style(line);
|
||||
lv_area_t area;
|
||||
lv_obj_get_coords(line, &area);
|
||||
lv_coord_t x_ofs = area.x1;
|
||||
lv_coord_t y_ofs = area.y1;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_coord_t h = lv_obj_get_height(line);
|
||||
uint16_t i;
|
||||
lv_style_t * style = lv_obj_get_style(line);
|
||||
lv_area_t area;
|
||||
lv_obj_get_coords(line, &area);
|
||||
lv_coord_t x_ofs = area.x1;
|
||||
lv_coord_t y_ofs = area.y1;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_coord_t h = lv_obj_get_height(line);
|
||||
uint16_t i;
|
||||
|
||||
/*Read all pints and draw the lines*/
|
||||
for (i = 0; i < ext->point_num - 1; i++) {
|
||||
/*Read all pints and draw the lines*/
|
||||
for(i = 0; i < ext->point_num - 1; i++) {
|
||||
|
||||
p1.x = ext->point_array[i].x + x_ofs;
|
||||
p2.x = ext->point_array[i + 1].x + x_ofs;
|
||||
p1.x = ext->point_array[i].x + x_ofs;
|
||||
p2.x = ext->point_array[i + 1].x + x_ofs;
|
||||
|
||||
if(ext->y_inv == 0) {
|
||||
p1.y = ext->point_array[i].y + y_ofs;
|
||||
p2.y = ext->point_array[i + 1].y + y_ofs;
|
||||
} else {
|
||||
p1.y = h - ext->point_array[i].y + y_ofs;
|
||||
p2.y = h - ext->point_array[i + 1].y + y_ofs;
|
||||
}
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
}
|
||||
if(ext->y_inv == 0) {
|
||||
p1.y = ext->point_array[i].y + y_ofs;
|
||||
p2.y = ext->point_array[i + 1].y + y_ofs;
|
||||
} else {
|
||||
p1.y = h - ext->point_array[i].y + y_ofs;
|
||||
p2.y = h - ext->point_array[i + 1].y + y_ofs;
|
||||
}
|
||||
lv_draw_line(&p1, &p2, mask, style);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -256,8 +256,7 @@ static lv_res_t lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param)
|
||||
if(buf->type[i] == NULL) break;
|
||||
}
|
||||
buf->type[i] = "lv_line";
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
lv_style_t * style = lv_line_get_style(line);
|
||||
if(line->ext_size < style->line.width) line->ext_size = style->line.width;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_LIST_LAYOUT_DEF LV_LAYOUT_COL_M
|
||||
#define LV_LIST_LAYOUT_DEF LV_LAYOUT_COL_M
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
# ifndef LV_LIST_FOCUS_TIME
|
||||
@ -26,7 +26,7 @@
|
||||
# endif
|
||||
#else
|
||||
# undef LV_LIST_FOCUS_TIME
|
||||
# define LV_LIST_FOCUS_TIME 0 /*No animations*/
|
||||
# define LV_LIST_FOCUS_TIME 0 /*No animations*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -36,9 +36,9 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_res_t lv_list_signal(lv_obj_t *list, lv_signal_t sign, void *param);
|
||||
static lv_obj_t * get_next_btn(lv_obj_t *list, lv_obj_t *prev_btn);
|
||||
static void refr_btn_width(lv_obj_t *list);
|
||||
static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
|
||||
static lv_obj_t * get_next_btn(lv_obj_t * list, lv_obj_t * prev_btn);
|
||||
static void refr_btn_width(lv_obj_t * list);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -82,16 +82,16 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
|
||||
ext->anim_time = LV_LIST_FOCUS_TIME;
|
||||
|
||||
lv_obj_set_signal_func(new_list, lv_list_signal);
|
||||
lv_obj_set_signal_func(new_list, lv_list_signal);
|
||||
|
||||
/*Init the new list object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
|
||||
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
|
||||
lv_list_set_sb_mode(new_list, LV_SB_MODE_DRAG);
|
||||
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
|
||||
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
|
||||
lv_list_set_sb_mode(new_list, LV_SB_MODE_DRAG);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BG, th->list.bg);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, th->list.scrl);
|
||||
@ -108,12 +108,12 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
} else {
|
||||
lv_list_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
|
||||
lv_obj_t *copy_btn = lv_obj_get_child_back(lv_page_get_scrl(copy), NULL);
|
||||
lv_obj_t *new_btn;
|
||||
lv_obj_t * copy_btn = lv_obj_get_child_back(lv_page_get_scrl(copy), NULL);
|
||||
lv_obj_t * new_btn;
|
||||
while(copy_btn) {
|
||||
new_btn = lv_btn_create(new_list, copy_btn);
|
||||
#if USE_LV_IMG
|
||||
lv_obj_t *copy_img = lv_list_get_btn_img(copy_btn);
|
||||
lv_obj_t * copy_img = lv_list_get_btn_img(copy_btn);
|
||||
if(copy_img) lv_img_create(new_btn, copy_img);
|
||||
#endif
|
||||
lv_label_create(new_btn, lv_list_get_btn_label(copy_btn));
|
||||
@ -147,12 +147,12 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_action_t rel_action)
|
||||
{
|
||||
lv_style_t * style = lv_obj_get_style(list);
|
||||
lv_style_t * style = lv_obj_get_style(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
/*Create a list element with the image an the text*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_btn_create(list, NULL);
|
||||
/*Create a list element with the image an the text*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_btn_create(list, NULL);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_btn_set_style(liste, LV_BTN_STYLE_REL, ext->styles_btn[LV_BTN_STATE_REL]);
|
||||
@ -161,39 +161,39 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
|
||||
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_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);
|
||||
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);
|
||||
if(btn_signal == NULL) btn_signal = lv_obj_get_signal_func(liste);
|
||||
|
||||
/*Make the size adjustment*/
|
||||
lv_coord_t w = lv_obj_get_width(list);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(list));
|
||||
lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(list));
|
||||
lv_coord_t pad_hor_tot = style->body.padding.hor + style_scrl->body.padding.hor;
|
||||
w -= pad_hor_tot * 2;
|
||||
|
||||
lv_obj_set_width(liste, w);
|
||||
#if USE_LV_IMG != 0
|
||||
lv_obj_t * img = NULL;
|
||||
if(img_src) {
|
||||
img = lv_img_create(liste, NULL);
|
||||
lv_img_set_src(img, img_src);
|
||||
lv_obj_set_style(img, ext->style_img);
|
||||
lv_obj_set_click(img, false);
|
||||
if(img_signal == NULL) img_signal = lv_obj_get_signal_func(img);
|
||||
}
|
||||
if(img_src) {
|
||||
img = lv_img_create(liste, NULL);
|
||||
lv_img_set_src(img, img_src);
|
||||
lv_obj_set_style(img, ext->style_img);
|
||||
lv_obj_set_click(img, false);
|
||||
if(img_signal == NULL) img_signal = lv_obj_get_signal_func(img);
|
||||
}
|
||||
#endif
|
||||
if(txt != NULL) {
|
||||
lv_obj_t * label = lv_label_create(liste, NULL);
|
||||
lv_label_set_text(label, txt);
|
||||
lv_obj_set_click(label, false);
|
||||
if(txt != NULL) {
|
||||
lv_obj_t * label = lv_label_create(liste, NULL);
|
||||
lv_label_set_text(label, txt);
|
||||
lv_obj_set_click(label, false);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_ROLL);
|
||||
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1);
|
||||
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1);
|
||||
if(label_signal == NULL) label_signal = lv_obj_get_signal_func(label);
|
||||
}
|
||||
}
|
||||
|
||||
return liste;
|
||||
return liste;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -205,7 +205,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
|
||||
* @param list pointer to a list object
|
||||
* @param anim_time duration of animation [ms]
|
||||
*/
|
||||
void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time)
|
||||
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
|
||||
@ -222,13 +222,13 @@ void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_list_set_style(lv_obj_t *list, lv_list_style_t type, lv_style_t *style)
|
||||
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_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;
|
||||
lv_obj_t * btn;
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_LIST_STYLE_BG:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_BG, style);
|
||||
/*style change signal will call 'refr_btn_width' */
|
||||
@ -265,10 +265,9 @@ void lv_list_set_style(lv_obj_t *list, lv_list_style_t type, lv_style_t *style)
|
||||
|
||||
/*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)
|
||||
{
|
||||
btn= get_next_btn(list, NULL);
|
||||
type == LV_LIST_STYLE_BTN_TGL_REL || type == LV_LIST_STYLE_BTN_TGL_PR ||
|
||||
type == LV_LIST_STYLE_BTN_INA) {
|
||||
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);
|
||||
@ -337,7 +336,7 @@ lv_obj_t * lv_list_get_btn_img(lv_obj_t * btn)
|
||||
* @param list pointer to a list object
|
||||
* @return duration of animation [ms]
|
||||
*/
|
||||
uint16_t lv_list_get_anim_time(lv_obj_t *list)
|
||||
uint16_t lv_list_get_anim_time(lv_obj_t * list)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
return ext->anim_time;
|
||||
@ -349,20 +348,29 @@ uint16_t lv_list_get_anim_time(lv_obj_t *list)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
* */
|
||||
lv_style_t * lv_list_get_style(lv_obj_t *list, lv_list_style_t type)
|
||||
lv_style_t * lv_list_get_style(lv_obj_t * list, lv_list_style_t type)
|
||||
{
|
||||
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
switch (type) {
|
||||
case LV_LIST_STYLE_BG: return lv_page_get_style(list, LV_PAGE_STYLE_BG);
|
||||
case LV_LIST_STYLE_SCRL: return lv_page_get_style(list, LV_PAGE_STYLE_SB);
|
||||
case LV_LIST_STYLE_SB: return lv_page_get_style(list, LV_PAGE_STYLE_SCRL);
|
||||
case LV_LIST_STYLE_BTN_REL: return ext->styles_btn[LV_BTN_STATE_REL];
|
||||
case LV_LIST_STYLE_BTN_PR: return ext->styles_btn[LV_BTN_STATE_PR];
|
||||
case LV_LIST_STYLE_BTN_TGL_REL: return ext->styles_btn[LV_BTN_STATE_TGL_REL];
|
||||
case LV_LIST_STYLE_BTN_TGL_PR: return ext->styles_btn[LV_BTN_STATE_TGL_PR];
|
||||
case LV_LIST_STYLE_BTN_INA: return ext->styles_btn[LV_BTN_STATE_INA];
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_LIST_STYLE_BG:
|
||||
return lv_page_get_style(list, LV_PAGE_STYLE_BG);
|
||||
case LV_LIST_STYLE_SCRL:
|
||||
return lv_page_get_style(list, LV_PAGE_STYLE_SB);
|
||||
case LV_LIST_STYLE_SB:
|
||||
return lv_page_get_style(list, LV_PAGE_STYLE_SCRL);
|
||||
case LV_LIST_STYLE_BTN_REL:
|
||||
return ext->styles_btn[LV_BTN_STATE_REL];
|
||||
case LV_LIST_STYLE_BTN_PR:
|
||||
return ext->styles_btn[LV_BTN_STATE_PR];
|
||||
case LV_LIST_STYLE_BTN_TGL_REL:
|
||||
return ext->styles_btn[LV_BTN_STATE_TGL_REL];
|
||||
case LV_LIST_STYLE_BTN_TGL_PR:
|
||||
return ext->styles_btn[LV_BTN_STATE_TGL_PR];
|
||||
case LV_LIST_STYLE_BTN_INA:
|
||||
return ext->styles_btn[LV_BTN_STATE_INA];
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -388,7 +396,7 @@ void lv_list_up(lv_obj_t * list)
|
||||
if(e->coords.y2 <= list->coords.y2) {
|
||||
if(e_prev != NULL) {
|
||||
lv_coord_t new_y = lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev));
|
||||
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
if(ext->anim_time == 0) {
|
||||
lv_obj_set_y(scrl, new_y);
|
||||
} else {
|
||||
@ -431,7 +439,7 @@ void lv_list_down(lv_obj_t * list)
|
||||
while(e != NULL) {
|
||||
if(e->coords.y1 < list->coords.y1) {
|
||||
lv_coord_t new_y = -lv_obj_get_y(e);
|
||||
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
if(ext->anim_time == 0) {
|
||||
lv_obj_set_y(scrl, new_y);
|
||||
} else {
|
||||
@ -464,16 +472,16 @@ void lv_list_down(lv_obj_t * list)
|
||||
* @param btn pointer to a list button to focus
|
||||
* @param anim_en true: scroll with animation, false: without animation
|
||||
*/
|
||||
void lv_list_focus(lv_obj_t *btn, bool anim_en)
|
||||
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_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));
|
||||
lv_page_focus(list, btn, anim_en == false ? 0 : lv_list_get_anim_time(list));
|
||||
}
|
||||
|
||||
/**********************
|
||||
@ -499,14 +507,12 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
/*Be sure the width of the buttons are correct*/
|
||||
lv_coord_t w = lv_obj_get_width(list);
|
||||
if(w != lv_area_get_width(param)) { /*Width changed*/
|
||||
refr_btn_width(list);
|
||||
refr_btn_width(list);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Because of the possible change of horizontal and vertical padding refresh buttons width */
|
||||
refr_btn_width(list);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
/*Get the first button*/
|
||||
lv_obj_t * btn = NULL;
|
||||
lv_obj_t * btn_prev = NULL;
|
||||
@ -518,8 +524,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
if(btn_prev != NULL) {
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_TGL_REL);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
/*Get the 'pressed' button*/
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = get_next_btn(list, btn);
|
||||
@ -531,14 +536,13 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
if(btn != NULL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char*)param);
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
|
||||
/*Get the last pressed button*/
|
||||
lv_obj_t * btn = NULL;
|
||||
lv_obj_t * btn_prev = NULL;
|
||||
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
btn = get_next_btn(list, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TGL_REL) break;
|
||||
@ -551,11 +555,10 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_TGL_REL);
|
||||
lv_page_focus(list, btn_prev, ext->anim_time);
|
||||
}
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
|
||||
/*Get the last pressed button*/
|
||||
lv_obj_t * btn = NULL;
|
||||
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
btn = get_next_btn(list, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TGL_REL) break;
|
||||
@ -584,8 +587,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_CLICK);
|
||||
if(rel_action != NULL) rel_action(btn);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -622,25 +624,25 @@ static lv_obj_t * get_next_btn(lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
return btn;
|
||||
}
|
||||
|
||||
static void refr_btn_width(lv_obj_t *list)
|
||||
static void refr_btn_width(lv_obj_t * list)
|
||||
{
|
||||
lv_style_t *style = lv_list_get_style(list, LV_LIST_STYLE_BG);
|
||||
lv_style_t *style_scrl = lv_obj_get_style(lv_page_get_scrl(list));
|
||||
lv_coord_t w = lv_obj_get_width(list);
|
||||
lv_coord_t btn_w = w - (style->body.padding.hor + style_scrl->body.padding.hor) * 2;
|
||||
lv_style_t * style = lv_list_get_style(list, LV_LIST_STYLE_BG);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(list));
|
||||
lv_coord_t w = lv_obj_get_width(list);
|
||||
lv_coord_t btn_w = w - (style->body.padding.hor + style_scrl->body.padding.hor) * 2;
|
||||
|
||||
lv_obj_t *btn = get_next_btn(list, NULL);
|
||||
while(btn) {
|
||||
/*Make the size adjustment for each buttons*/
|
||||
if(lv_obj_get_width(btn) != btn_w) {
|
||||
lv_obj_set_width(btn, btn_w);
|
||||
/*Set the label size to roll its text*/
|
||||
lv_obj_t *label = lv_list_get_btn_label(btn);
|
||||
lv_obj_set_width(label, btn->coords.x2 - label->coords.x1);
|
||||
lv_label_set_text(label, NULL);
|
||||
}
|
||||
btn = get_next_btn(list, btn);
|
||||
}
|
||||
lv_obj_t * btn = get_next_btn(list, NULL);
|
||||
while(btn) {
|
||||
/*Make the size adjustment for each buttons*/
|
||||
if(lv_obj_get_width(btn) != btn_w) {
|
||||
lv_obj_set_width(btn, btn_w);
|
||||
/*Set the label size to roll its text*/
|
||||
lv_obj_t * label = lv_list_get_btn_label(btn);
|
||||
lv_obj_set_width(label, btn->coords.x2 - label->coords.x1);
|
||||
lv_label_set_text(label, NULL);
|
||||
}
|
||||
btn = get_next_btn(list, btn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_size(new_lmeter, LV_DPI, LV_DPI);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_lmeter_set_style(new_lmeter, th->lmeter);
|
||||
} else {
|
||||
@ -87,8 +87,8 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing line meter*/
|
||||
else {
|
||||
lv_lmeter_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->scale_angle = copy_ext->scale_angle;
|
||||
lv_lmeter_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->scale_angle = copy_ext->scale_angle;
|
||||
ext->line_cnt = copy_ext->line_cnt;
|
||||
ext->min_value = copy_ext->min_value;
|
||||
ext->max_value = copy_ext->max_value;
|
||||
@ -110,12 +110,12 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @param value new value
|
||||
*/
|
||||
void lv_lmeter_set_value(lv_obj_t *lmeter, int16_t value)
|
||||
void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
if(ext->cur_value == value) return;
|
||||
|
||||
ext->cur_value = value > ext->max_value ? ext->max_value : value;
|
||||
ext->cur_value = value > ext->max_value ? ext->max_value : value;
|
||||
ext->cur_value = ext->cur_value < ext->min_value ? ext->min_value : ext->cur_value;
|
||||
lv_obj_invalidate(lmeter);
|
||||
}
|
||||
@ -126,7 +126,7 @@ void lv_lmeter_set_value(lv_obj_t *lmeter, int16_t value)
|
||||
* @param min minimum value
|
||||
* @param max maximum value
|
||||
*/
|
||||
void lv_lmeter_set_range(lv_obj_t *lmeter, int16_t min, int16_t max)
|
||||
void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
if(ext->min_value == min && ext->max_value == max) return;
|
||||
@ -171,7 +171,7 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt)
|
||||
* @param lmeter pointer to a line meter object
|
||||
* @return the value of the line meter
|
||||
*/
|
||||
int16_t lv_lmeter_get_value(lv_obj_t *lmeter)
|
||||
int16_t lv_lmeter_get_value(lv_obj_t * lmeter)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
return ext->cur_value;
|
||||
@ -240,7 +240,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
@ -251,59 +251,59 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t *g = lv_obj_get_group(lmeter);
|
||||
lv_group_t * g = lv_obj_get_group(lmeter);
|
||||
if(lv_group_get_focused(g) == lmeter) {
|
||||
style_tmp.line.width += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_coord_t r_out = lv_obj_get_width(lmeter) / 2;
|
||||
lv_coord_t r_in = r_out - style->body.padding.hor;
|
||||
if(r_in < 1) r_in = 1;
|
||||
lv_coord_t r_out = lv_obj_get_width(lmeter) / 2;
|
||||
lv_coord_t r_in = r_out - style->body.padding.hor;
|
||||
if(r_in < 1) r_in = 1;
|
||||
|
||||
lv_coord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1;
|
||||
lv_coord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1;
|
||||
int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2;
|
||||
int16_t level = (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
|
||||
uint8_t i;
|
||||
lv_coord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1;
|
||||
lv_coord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1;
|
||||
int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2;
|
||||
int16_t level = (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
|
||||
uint8_t i;
|
||||
|
||||
style_tmp.line.color = style->body.main_color;
|
||||
style_tmp.line.color = style->body.main_color;
|
||||
|
||||
/*Calculate every coordinate in x32 size to make rounding later*/
|
||||
r_out = r_out << LV_LMETER_LINE_UPSCALE;
|
||||
r_in = r_in << LV_LMETER_LINE_UPSCALE;
|
||||
/*Calculate every coordinate in x32 size to make rounding later*/
|
||||
r_out = r_out << LV_LMETER_LINE_UPSCALE;
|
||||
r_in = r_in << LV_LMETER_LINE_UPSCALE;
|
||||
|
||||
for(i = 0; i < ext->line_cnt; i++) {
|
||||
/*Calculate the position a scale label*/
|
||||
int16_t angle = (i * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs;
|
||||
for(i = 0; i < ext->line_cnt; i++) {
|
||||
/*Calculate the position a scale label*/
|
||||
int16_t angle = (i * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs;
|
||||
|
||||
lv_coord_t y_out = (int32_t)((int32_t)lv_trigo_sin(angle) * r_out) >> LV_TRIGO_SHIFT;
|
||||
lv_coord_t x_out = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_out) >> LV_TRIGO_SHIFT;
|
||||
lv_coord_t y_in = (int32_t)((int32_t)lv_trigo_sin(angle) * r_in) >> LV_TRIGO_SHIFT;
|
||||
lv_coord_t x_in = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_in) >> LV_TRIGO_SHIFT;
|
||||
lv_coord_t y_out = (int32_t)((int32_t)lv_trigo_sin(angle) * r_out) >> LV_TRIGO_SHIFT;
|
||||
lv_coord_t x_out = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_out) >> LV_TRIGO_SHIFT;
|
||||
lv_coord_t y_in = (int32_t)((int32_t)lv_trigo_sin(angle) * r_in) >> LV_TRIGO_SHIFT;
|
||||
lv_coord_t x_in = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_in) >> LV_TRIGO_SHIFT;
|
||||
|
||||
/*Rounding*/
|
||||
x_out = lv_lmeter_coord_round(x_out);
|
||||
x_in = lv_lmeter_coord_round(x_in);
|
||||
y_out = lv_lmeter_coord_round(y_out);
|
||||
y_in = lv_lmeter_coord_round(y_in);
|
||||
/*Rounding*/
|
||||
x_out = lv_lmeter_coord_round(x_out);
|
||||
x_in = lv_lmeter_coord_round(x_in);
|
||||
y_out = lv_lmeter_coord_round(y_out);
|
||||
y_in = lv_lmeter_coord_round(y_in);
|
||||
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
|
||||
p2.x = x_in + x_ofs;
|
||||
p2.y = y_in + y_ofs;
|
||||
p2.x = x_in + x_ofs;
|
||||
p2.y = y_in + y_ofs;
|
||||
|
||||
p1.x = x_out+ x_ofs;
|
||||
p1.y = y_out + y_ofs;
|
||||
p1.x = x_out + x_ofs;
|
||||
p1.y = y_out + y_ofs;
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
lv_draw_line(&p1, &p2, mask, &style_tmp);
|
||||
}
|
||||
lv_draw_line(&p1, &p2, mask, &style_tmp);
|
||||
}
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
@ -331,8 +331,7 @@ static lv_res_t lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * par
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
|
@ -26,7 +26,7 @@
|
||||
# endif
|
||||
#else
|
||||
# undef LV_MBOX_CLOSE_ANIM_TIME
|
||||
# define LV_MBOX_CLOSE_ANIM_TIME 0 /*No animations*/
|
||||
# define LV_MBOX_CLOSE_ANIM_TIME 0 /*No animations*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -37,8 +37,8 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param);
|
||||
static void mbox_realign(lv_obj_t *mbox);
|
||||
static lv_res_t lv_mbox_close_action(lv_obj_t *btn, const char *txt);
|
||||
static void mbox_realign(lv_obj_t * mbox);
|
||||
static lv_res_t lv_mbox_close_action(lv_obj_t * btn, const char * txt);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -62,7 +62,7 @@ static lv_signal_func_t ancestor_signal;
|
||||
lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor message box*/
|
||||
lv_obj_t * new_mbox = lv_cont_create(par, copy);
|
||||
lv_obj_t * new_mbox = lv_cont_create(par, copy);
|
||||
lv_mem_assert(new_mbox);
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_mbox);
|
||||
|
||||
@ -78,10 +78,10 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Init the new message box message box*/
|
||||
if(copy == NULL) {
|
||||
ext->text = lv_label_create(new_mbox, NULL);
|
||||
lv_label_set_align(ext->text, LV_LABEL_ALIGN_CENTER);
|
||||
lv_label_set_long_mode(ext->text, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->text, "Message");
|
||||
ext->text = lv_label_create(new_mbox, NULL);
|
||||
lv_label_set_align(ext->text, LV_LABEL_ALIGN_CENTER);
|
||||
lv_label_set_long_mode(ext->text, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->text, "Message");
|
||||
|
||||
lv_cont_set_layout(new_mbox, LV_LAYOUT_COL_M);
|
||||
lv_cont_set_fit(new_mbox, false, true);
|
||||
@ -89,12 +89,12 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, th->mbox.bg);
|
||||
} else {
|
||||
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, &lv_style_pretty);
|
||||
}
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, th->mbox.bg);
|
||||
} else {
|
||||
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, &lv_style_pretty);
|
||||
}
|
||||
|
||||
}
|
||||
/*Copy an existing message box*/
|
||||
@ -124,7 +124,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
|
||||
* @param action a function which will be called when a button is released
|
||||
*/
|
||||
void lv_mbox_add_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action)
|
||||
void lv_mbox_add_btns(lv_obj_t * mbox, const char ** btn_map, lv_btnm_action_t action)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
@ -133,14 +133,14 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t ac
|
||||
ext->btnm = lv_btnm_create(mbox, NULL);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_BG, th->mbox.btn.bg);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_REL, th->mbox.btn.rel);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_PR, th->mbox.btn.pr);
|
||||
} else {
|
||||
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, &lv_style_transp_fit);
|
||||
}
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_BG, th->mbox.btn.bg);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_REL, th->mbox.btn.rel);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_PR, th->mbox.btn.pr);
|
||||
} else {
|
||||
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, &lv_style_transp_fit);
|
||||
}
|
||||
}
|
||||
|
||||
lv_btnm_set_map(ext->btnm, btn_map);
|
||||
@ -175,7 +175,7 @@ void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
||||
*/
|
||||
void lv_mbox_set_action(lv_obj_t * mbox, lv_btnm_action_t action)
|
||||
{
|
||||
lv_mbox_ext_t *ext = lv_obj_get_ext_attr(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
lv_btnm_set_action(ext->btnm, action);
|
||||
}
|
||||
|
||||
@ -207,13 +207,13 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
|
||||
|
||||
if(ext->anim_time != 0) {
|
||||
/*Add shrinking animations*/
|
||||
lv_obj_animate(mbox, LV_ANIM_GROW_H| LV_ANIM_OUT, ext->anim_time, delay, NULL);
|
||||
lv_obj_animate(mbox, LV_ANIM_GROW_V| LV_ANIM_OUT, ext->anim_time, delay, (void (*)(lv_obj_t*))lv_obj_del);
|
||||
lv_obj_animate(mbox, LV_ANIM_GROW_H | LV_ANIM_OUT, ext->anim_time, delay, NULL);
|
||||
lv_obj_animate(mbox, LV_ANIM_GROW_V | LV_ANIM_OUT, ext->anim_time, delay, (void (*)(lv_obj_t *))lv_obj_del);
|
||||
|
||||
/*Disable fit to let shrinking work*/
|
||||
lv_cont_set_fit(mbox, false, false);
|
||||
} else {
|
||||
lv_obj_animate(mbox, LV_ANIM_NONE, ext->anim_time, delay, (void (*)(lv_obj_t*))lv_obj_del);
|
||||
lv_obj_animate(mbox, LV_ANIM_NONE, ext->anim_time, delay, (void (*)(lv_obj_t *))lv_obj_del);
|
||||
}
|
||||
#else
|
||||
lv_obj_del(mbox);
|
||||
@ -237,11 +237,11 @@ void lv_mbox_stop_auto_close(lv_obj_t * mbox)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_mbox_set_style(lv_obj_t *mbox, lv_mbox_style_t type, lv_style_t *style)
|
||||
void lv_mbox_set_style(lv_obj_t * mbox, lv_mbox_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_mbox_ext_t *ext = lv_obj_get_ext_attr(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_MBOX_STYLE_BG:
|
||||
lv_obj_set_style(mbox, style);
|
||||
break;
|
||||
@ -279,9 +279,9 @@ void lv_mbox_set_style(lv_obj_t *mbox, lv_mbox_style_t type, lv_style_t *style)
|
||||
*/
|
||||
const char * lv_mbox_get_text(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
return lv_label_get_text(ext->text);
|
||||
return lv_label_get_text(ext->text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,9 +292,9 @@ const char * lv_mbox_get_text(lv_obj_t * mbox)
|
||||
*/
|
||||
lv_obj_t * lv_mbox_get_from_btn(lv_obj_t * btn)
|
||||
{
|
||||
lv_obj_t * mbox = lv_obj_get_parent(btn);
|
||||
lv_obj_t * mbox = lv_obj_get_parent(btn);
|
||||
|
||||
return mbox;
|
||||
return mbox;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,7 +302,7 @@ lv_obj_t * lv_mbox_get_from_btn(lv_obj_t * btn)
|
||||
* @param mbox pointer to a message box object
|
||||
* @return animation length in milliseconds (0: no animation)
|
||||
*/
|
||||
uint16_t lv_mbox_get_anim_time(lv_obj_t * mbox )
|
||||
uint16_t lv_mbox_get_anim_time(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
return ext->anim_time;
|
||||
@ -314,19 +314,27 @@ uint16_t lv_mbox_get_anim_time(lv_obj_t * mbox )
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_mbox_get_style(lv_obj_t *mbox, lv_mbox_style_t type)
|
||||
lv_style_t * lv_mbox_get_style(lv_obj_t * mbox, lv_mbox_style_t type)
|
||||
{
|
||||
lv_mbox_ext_t *ext = lv_obj_get_ext_attr(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
switch (type) {
|
||||
case LV_MBOX_STYLE_BG: return lv_obj_get_style(mbox);
|
||||
case LV_MBOX_STYLE_BTN_BG: return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BG);
|
||||
case LV_MBOX_STYLE_BTN_REL: return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_REL);
|
||||
case LV_MBOX_STYLE_BTN_PR: return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_PR);
|
||||
case LV_MBOX_STYLE_BTN_TGL_REL: return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_REL);
|
||||
case LV_MBOX_STYLE_BTN_TGL_PR: return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_PR);
|
||||
case LV_MBOX_STYLE_BTN_INA: return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_INA);
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_MBOX_STYLE_BG:
|
||||
return lv_obj_get_style(mbox);
|
||||
case LV_MBOX_STYLE_BTN_BG:
|
||||
return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BG);
|
||||
case LV_MBOX_STYLE_BTN_REL:
|
||||
return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_REL);
|
||||
case LV_MBOX_STYLE_BTN_PR:
|
||||
return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_PR);
|
||||
case LV_MBOX_STYLE_BTN_TGL_REL:
|
||||
return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_REL);
|
||||
case LV_MBOX_STYLE_BTN_TGL_PR:
|
||||
return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_PR);
|
||||
case LV_MBOX_STYLE_BTN_INA:
|
||||
return lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_INA);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -352,7 +360,7 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
/*Translate LV_GROUP_KEY_UP/DOWN to LV_GROUP_KEY_LEFT/RIGHT */
|
||||
char c_trans = 0;
|
||||
if(sign == LV_SIGNAL_CONTROLL) {
|
||||
c_trans = *((char*)param);
|
||||
c_trans = *((char *)param);
|
||||
if(c_trans == LV_GROUP_KEY_DOWN) c_trans = LV_GROUP_KEY_LEFT;
|
||||
if(c_trans == LV_GROUP_KEY_UP) c_trans = LV_GROUP_KEY_RIGHT;
|
||||
|
||||
@ -368,17 +376,14 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
if(lv_obj_get_width(mbox) != lv_area_get_width(param)) {
|
||||
mbox_realign(mbox);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
mbox_realign(mbox);
|
||||
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROLL) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROLL) {
|
||||
if(ext->btnm) {
|
||||
ext->btnm->signal_func(ext->btnm, sign, param);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -394,11 +399,11 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
* Resize the button holder to fit
|
||||
* @param mbox pointer to message box object
|
||||
*/
|
||||
static void mbox_realign(lv_obj_t *mbox)
|
||||
static void mbox_realign(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
lv_style_t *style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BG);
|
||||
lv_style_t * style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BG);
|
||||
lv_coord_t w = lv_obj_get_width(mbox) - 2 * style->body.padding.hor;
|
||||
|
||||
if(ext->text) {
|
||||
@ -406,16 +411,16 @@ static void mbox_realign(lv_obj_t *mbox)
|
||||
}
|
||||
|
||||
if(ext->btnm) {
|
||||
lv_style_t *btn_bg_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_BG);
|
||||
lv_style_t *btn_rel_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_REL);
|
||||
lv_style_t * btn_bg_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_BG);
|
||||
lv_style_t * btn_rel_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_REL);
|
||||
lv_coord_t font_h = lv_font_get_height(btn_rel_style->text.font);
|
||||
lv_obj_set_size(ext->btnm, w, font_h + 2 * btn_rel_style->body.padding.ver + 2 * btn_bg_style->body.padding.ver);
|
||||
}
|
||||
}
|
||||
|
||||
static lv_res_t lv_mbox_close_action(lv_obj_t *btn, const char *txt)
|
||||
static lv_res_t lv_mbox_close_action(lv_obj_t * btn, const char * txt)
|
||||
{
|
||||
lv_obj_t *mbox = lv_mbox_get_from_btn(btn);
|
||||
lv_obj_t * mbox = lv_mbox_get_from_btn(btn);
|
||||
|
||||
if(txt[0] != '\0') {
|
||||
lv_mbox_start_auto_close(mbox, 0);
|
||||
|
@ -55,7 +55,7 @@ static lv_design_func_t ancestor_design;
|
||||
lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor of template*/
|
||||
/*TODO modify it to the ancestor create function */
|
||||
/*TODO modify it to the ancestor create function */
|
||||
lv_obj_t * new_templ = lv_ANCESTOR_create(par, copy);
|
||||
dm_assert(new_templ);
|
||||
|
||||
@ -78,7 +78,7 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing template*/
|
||||
else {
|
||||
lv_templ_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_templ_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_templ);
|
||||
@ -111,11 +111,11 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
* */
|
||||
void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, lv_style_t *style)
|
||||
void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_templ_ext_t *ext = lv_obj_get_ext_attr(templ);
|
||||
lv_templ_ext_t * ext = lv_obj_get_ext_attr(templ);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_TEMPL_STYLE_X:
|
||||
break;
|
||||
case LV_TEMPL_STYLE_Y:
|
||||
@ -139,12 +139,15 @@ void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, lv_style_t *sty
|
||||
* */
|
||||
lv_style_t * lv_btn_get_style(lv_obj_t * templ, lv_templ_style_t type)
|
||||
{
|
||||
lv_templ_ext_t *ext = lv_obj_get_ext_attr(templ);
|
||||
lv_templ_ext_t * ext = lv_obj_get_ext_attr(templ);
|
||||
|
||||
switch (type) {
|
||||
case LV_TEMPL_STYLE_X: return NULL;
|
||||
case LV_TEMPL_STYLE_Y: return NULL;
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_TEMPL_STYLE_X:
|
||||
return NULL;
|
||||
case LV_TEMPL_STYLE_Y:
|
||||
return NULL;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -177,7 +180,7 @@ static bool lv_templ_design(lv_obj_t * templ, const area_t * mask, lv_design_mod
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
@ -209,8 +212,7 @@ static lv_res_t lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
|
@ -76,25 +76,25 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Init the new page object*/
|
||||
if(copy == NULL) {
|
||||
ext->scrl = lv_cont_create(new_page, NULL);
|
||||
lv_obj_set_signal_func(ext->scrl, lv_page_scrollable_signal);
|
||||
ext->scrl = lv_cont_create(new_page, NULL);
|
||||
lv_obj_set_signal_func(ext->scrl, lv_page_scrollable_signal);
|
||||
lv_obj_set_design_func(ext->scrl, lv_scrl_design);
|
||||
lv_obj_set_drag(ext->scrl, true);
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
||||
lv_cont_set_fit(ext->scrl, false, true);
|
||||
lv_obj_set_drag(ext->scrl, true);
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
||||
lv_cont_set_fit(ext->scrl, false, true);
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_func(new_page, lv_page_signal);
|
||||
lv_obj_set_design_func(new_page, lv_page_design);
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_func(new_page, lv_page_signal);
|
||||
lv_obj_set_design_func(new_page, lv_page_design);
|
||||
|
||||
lv_page_set_sb_mode(new_page, ext->sb.mode);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
if(par == NULL){ /*Different styles if it is screen*/
|
||||
if(par == NULL) { /*Different styles if it is screen*/
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->bg);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_transp);
|
||||
} else {
|
||||
@ -110,9 +110,9 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
|
||||
} else {
|
||||
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
|
||||
lv_obj_set_signal_func(ext->scrl, lv_page_scrollable_signal);
|
||||
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
|
||||
lv_obj_set_signal_func(ext->scrl, lv_page_scrollable_signal);
|
||||
|
||||
lv_page_set_pr_action(new_page, copy_ext->pr_action);
|
||||
lv_page_set_rel_action(new_page, copy_ext->rel_action);
|
||||
@ -122,10 +122,10 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL));
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, lv_page_get_style(copy, LV_PAGE_STYLE_SB));
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_func(new_page, lv_page_signal);
|
||||
lv_obj_set_design_func(new_page, lv_page_design);
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_func(new_page, lv_page_signal);
|
||||
lv_obj_set_design_func(new_page, lv_page_design);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_page);
|
||||
@ -147,8 +147,8 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
*/
|
||||
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->rel_action = rel_action;
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->rel_action = rel_action;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,8 +158,8 @@ void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action)
|
||||
*/
|
||||
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->pr_action = pr_action;
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->pr_action = pr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,11 +185,11 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
* */
|
||||
void lv_page_set_style(lv_obj_t *page, lv_page_style_t type, lv_style_t *style)
|
||||
void lv_page_set_style(lv_obj_t * page, lv_page_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_PAGE_STYLE_BG:
|
||||
lv_obj_set_style(page, style);
|
||||
break;
|
||||
@ -218,9 +218,9 @@ void lv_page_set_style(lv_obj_t *page, lv_page_style_t type, lv_style_t *style)
|
||||
*/
|
||||
lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
|
||||
return ext->scrl;
|
||||
return ext->scrl;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,15 +240,19 @@ lv_sb_mode_t lv_page_get_sb_mode(lv_obj_t * page)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
* */
|
||||
lv_style_t * lv_page_get_style(lv_obj_t *page, lv_page_style_t type)
|
||||
lv_style_t * lv_page_get_style(lv_obj_t * page, lv_page_style_t type)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
|
||||
switch (type) {
|
||||
case LV_PAGE_STYLE_BG: return lv_obj_get_style(page);
|
||||
case LV_PAGE_STYLE_SCRL: return lv_obj_get_style(ext->scrl);
|
||||
case LV_PAGE_STYLE_SB: return ext->sb.style;
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_PAGE_STYLE_BG:
|
||||
return lv_obj_get_style(page);
|
||||
case LV_PAGE_STYLE_SCRL:
|
||||
return lv_obj_get_style(ext->scrl);
|
||||
case LV_PAGE_STYLE_SB:
|
||||
return ext->sb.style;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -294,7 +298,7 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
|
||||
/*Out of the page on the top*/
|
||||
if((obj_h <= page_h && top_err > 0) ||
|
||||
(obj_h > page_h && top_err < bot_err)) {
|
||||
(obj_h > page_h && top_err < bot_err)) {
|
||||
/*Calculate a new position and let some space above*/
|
||||
scrlable_y = -(obj_y - style_scrl->body.padding.ver - style->body.padding.ver);
|
||||
scrlable_y += style_scrl->body.padding.ver;
|
||||
@ -313,8 +317,7 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
|
||||
if(anim_time == 0) {
|
||||
lv_obj_set_y(ext->scrl, scrlable_y);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
#if USE_LV_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.act_time = 0;
|
||||
@ -349,19 +352,19 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return ancestor_design(page, mask, mode);
|
||||
return ancestor_design(page, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw without border*/
|
||||
lv_style_t *style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_coord_t border_width_tmp = style->body.border.width;
|
||||
style->body.border.width = 0;
|
||||
lv_draw_rect(&page->coords, mask, style);
|
||||
style->body.border.width = border_width_tmp;
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) { /*Draw the scroll bars finally*/
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) { /*Draw the scroll bars finally*/
|
||||
|
||||
/*Draw only a border*/
|
||||
lv_style_t *style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_coord_t shadow_width_tmp = style->body.shadow.width;
|
||||
uint8_t empty_tmp = style->body.empty;
|
||||
style->body.shadow.width = 0;
|
||||
@ -371,32 +374,32 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
|
||||
style->body.empty = empty_tmp;
|
||||
|
||||
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
|
||||
/*Draw the scrollbars*/
|
||||
lv_area_t sb_area;
|
||||
if(ext->sb.hor_draw) {
|
||||
/*Convert the relative coordinates to absolute*/
|
||||
/*Draw the scrollbars*/
|
||||
lv_area_t sb_area;
|
||||
if(ext->sb.hor_draw) {
|
||||
/*Convert the relative coordinates to absolute*/
|
||||
lv_area_copy(&sb_area, &ext->sb.hor_area);
|
||||
sb_area.x1 += page->coords.x1;
|
||||
sb_area.x1 += page->coords.x1;
|
||||
sb_area.y1 += page->coords.y1;
|
||||
sb_area.x2 += page->coords.x1;
|
||||
sb_area.y2 += page->coords.y1;
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style);
|
||||
}
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style);
|
||||
}
|
||||
|
||||
if(ext->sb.ver_draw) {
|
||||
if(ext->sb.ver_draw) {
|
||||
/*Convert the relative coordinates to absolute*/
|
||||
lv_area_copy(&sb_area, &ext->sb.ver_area);
|
||||
sb_area.x1 += page->coords.x1;
|
||||
sb_area.y1 += page->coords.y1;
|
||||
sb_area.x2 += page->coords.x1;
|
||||
sb_area.y2 += page->coords.y1;
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style);
|
||||
}
|
||||
}
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -471,8 +474,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
child = lv_obj_get_child(page, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*If no hor_fit enabled set the scrollable's width to the page's width*/
|
||||
if(lv_cont_get_hor_fit(ext->scrl) == false) {
|
||||
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.hor);
|
||||
@ -485,12 +487,10 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
|
||||
/*Refresh the ext. size because the scrollbars might be positioned out of the page*/
|
||||
lv_obj_refresh_ext_size(page);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/*Refresh the scrollbar and notify the scrl if the size is changed*/
|
||||
if(ext->scrl != NULL && (lv_obj_get_width(page) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(page) != lv_area_get_height(param)))
|
||||
{
|
||||
lv_obj_get_height(page) != lv_area_get_height(param))) {
|
||||
/*If no hor_fit enabled set the scrollable's width to the page's width*/
|
||||
if(lv_cont_get_hor_fit(ext->scrl) == false) {
|
||||
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.hor);
|
||||
@ -501,25 +501,21 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
/*The scrollbars are important only if they are visible now*/
|
||||
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSED) {
|
||||
} else if(sign == LV_SIGNAL_PRESSED) {
|
||||
if(ext->pr_action != NULL) {
|
||||
ext->pr_action(page);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
||||
if(ext->rel_action != NULL) {
|
||||
ext->rel_action(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
/*Ensure ext. size for the scrollbars if they are out of the page*/
|
||||
if(page->ext_size < (-ext->sb.style->body.padding.hor)) page->ext_size = -ext->sb.style->body.padding.hor;
|
||||
if(page->ext_size < (-ext->sb.style->body.padding.ver)) page->ext_size = -ext->sb.style->body.padding.ver;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -581,10 +577,10 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
} else {
|
||||
/*The edges of the scrollable can not be in the page (minus hpad) */
|
||||
if(scrl_cords.x2 < page_cords.x2 - hpad) {
|
||||
new_x = lv_area_get_width(&page_cords) - lv_area_get_width(&scrl_cords) - hpad; /* Right align */
|
||||
refr_x = true;
|
||||
new_x = lv_area_get_width(&page_cords) - lv_area_get_width(&scrl_cords) - hpad; /* Right align */
|
||||
refr_x = true;
|
||||
}
|
||||
if (scrl_cords.x1 > page_cords.x1 + hpad) {
|
||||
if(scrl_cords.x1 > page_cords.x1 + hpad) {
|
||||
new_x = hpad; /*Left align*/
|
||||
refr_x = true;
|
||||
}
|
||||
@ -599,10 +595,10 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
} else {
|
||||
/*The edges of the scrollable can not be in the page (minus vpad) */
|
||||
if(scrl_cords.y2 < page_cords.y2 - vpad) {
|
||||
new_y = lv_area_get_height(&page_cords) - lv_area_get_height(&scrl_cords) - vpad; /* Bottom align */
|
||||
refr_y = true;
|
||||
new_y = lv_area_get_height(&page_cords) - lv_area_get_height(&scrl_cords) - vpad; /* Bottom align */
|
||||
refr_y = true;
|
||||
}
|
||||
if (scrl_cords.y1 > page_cords.y1 + vpad) {
|
||||
if(scrl_cords.y1 > page_cords.y1 + vpad) {
|
||||
new_y = vpad; /*Top align*/
|
||||
refr_y = true;
|
||||
}
|
||||
@ -612,8 +608,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
}
|
||||
|
||||
lv_page_sb_refresh(page);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DRAG_END) {
|
||||
} else if(sign == LV_SIGNAL_DRAG_END) {
|
||||
/*Hide scrollbars if required*/
|
||||
if(page_ext->sb.mode == LV_SB_MODE_DRAG) {
|
||||
lv_area_t sb_area_tmp;
|
||||
@ -636,13 +631,11 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
page_ext->sb.ver_draw = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSED) {
|
||||
} else if(sign == LV_SIGNAL_PRESSED) {
|
||||
if(page_ext->pr_action != NULL) {
|
||||
page_ext->pr_action(page);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
||||
if(page_ext->rel_action != NULL) {
|
||||
page_ext->rel_action(page);
|
||||
@ -724,9 +717,9 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
lv_area_set_width(&ext->sb.hor_area, size_tmp);
|
||||
|
||||
lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad +
|
||||
(-(lv_obj_get_x(scrl) - hpad) * (obj_w - size_tmp - 2 * sb_hor_pad)) /
|
||||
(scrl_w + 2 * hpad - obj_w ),
|
||||
obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.ver);
|
||||
(-(lv_obj_get_x(scrl) - hpad) * (obj_w - size_tmp - 2 * sb_hor_pad)) /
|
||||
(scrl_w + 2 * hpad - obj_w),
|
||||
obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.ver);
|
||||
|
||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 1;
|
||||
}
|
||||
@ -742,9 +735,9 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
lv_area_set_height(&ext->sb.ver_area, size_tmp);
|
||||
|
||||
lv_area_set_pos(&ext->sb.ver_area, obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.hor,
|
||||
sb_ver_pad +
|
||||
(-(lv_obj_get_y(scrl) - vpad) * (obj_h - size_tmp - 2 * sb_ver_pad)) /
|
||||
(scrl_h + 2 * vpad - obj_h ));
|
||||
sb_ver_pad +
|
||||
(-(lv_obj_get_y(scrl) - vpad) * (obj_h - size_tmp - 2 * sb_ver_pad)) /
|
||||
(scrl_h + 2 * vpad - obj_h));
|
||||
|
||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 1;
|
||||
}
|
||||
|
@ -36,8 +36,8 @@
|
||||
static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_design_mode_t mode);
|
||||
static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * param);
|
||||
static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param);
|
||||
static void refr_position(lv_obj_t *roller, bool anim_en);
|
||||
static void draw_bg(lv_obj_t *roller, const lv_area_t *mask);
|
||||
static void refr_position(lv_obj_t * roller, bool anim_en);
|
||||
static void draw_bg(lv_obj_t * roller, const lv_area_t * mask);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -62,7 +62,7 @@ static lv_signal_func_t ancestor_scrl_signal;
|
||||
lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
{
|
||||
/*Create the ancestor of roller*/
|
||||
lv_obj_t * new_roller = lv_ddlist_create(par, copy);
|
||||
lv_obj_t * new_roller = lv_ddlist_create(par, copy);
|
||||
lv_mem_assert(new_roller);
|
||||
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_func(lv_page_get_scrl(new_roller));
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_roller);
|
||||
@ -89,7 +89,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_signal_func(scrl, lv_roller_scrl_signal);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_BG, th->roller.bg);
|
||||
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_SEL, th->roller.sel);
|
||||
@ -120,7 +120,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
* @param sel_opt id of the selected option (0 ... number of option - 1);
|
||||
* @param anim_en true: set with animation; false set immediately
|
||||
*/
|
||||
void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en)
|
||||
void lv_roller_set_selected(lv_obj_t * roller, uint16_t sel_opt, bool anim_en)
|
||||
{
|
||||
#if USE_LV_ANIMATION == 0
|
||||
anim_en = false;
|
||||
@ -137,9 +137,9 @@ 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_visible_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_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(style_label->text.font) * row_cnt + style_label->text.line_space * (row_cnt));
|
||||
|
||||
@ -150,9 +150,9 @@ void lv_roller_set_visible_row_count(lv_obj_t *roller, uint8_t row_cnt)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_roller_set_style(lv_obj_t *roller, lv_roller_style_t type, lv_style_t *style)
|
||||
void lv_roller_set_style(lv_obj_t * roller, lv_roller_style_t type, lv_style_t * style)
|
||||
{
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_ROLLER_STYLE_BG:
|
||||
lv_obj_set_style(roller, style);
|
||||
break;
|
||||
@ -171,7 +171,7 @@ void lv_roller_set_style(lv_obj_t *roller, lv_roller_style_t type, lv_style_t *s
|
||||
* @param roller pointer to a roller object
|
||||
* @return true: auto size enabled; false: manual width settings enabled
|
||||
*/
|
||||
bool lv_roller_get_hor_fit(lv_obj_t *roller)
|
||||
bool lv_roller_get_hor_fit(lv_obj_t * roller)
|
||||
{
|
||||
return lv_page_get_scrl_hor_fit(roller);
|
||||
}
|
||||
@ -182,12 +182,15 @@ bool lv_roller_get_hor_fit(lv_obj_t *roller)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
* */
|
||||
lv_style_t * lv_roller_get_style(lv_obj_t *roller, lv_roller_style_t type)
|
||||
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_SEL: return lv_ddlist_get_style(roller, LV_DDLIST_STYLE_SEL);
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_ROLLER_STYLE_BG:
|
||||
return lv_obj_get_style(roller);
|
||||
case LV_ROLLER_STYLE_SEL:
|
||||
return lv_ddlist_get_style(roller, LV_DDLIST_STYLE_SEL);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -213,13 +216,13 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
draw_bg(roller, mask);
|
||||
|
||||
lv_style_t *style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
|
||||
lv_style_t * style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
lv_coord_t font_h = lv_font_get_height(font);
|
||||
@ -233,7 +236,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
lv_style_t *style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
|
||||
lv_style_t * style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_coord_t font_h = lv_font_get_height(font);
|
||||
@ -248,7 +251,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
bool area_ok;
|
||||
area_ok = lv_area_union(&mask_sel, mask, &rect_area);
|
||||
if(area_ok) {
|
||||
lv_style_t *sel_style = lv_roller_get_style(roller, LV_ROLLER_STYLE_SEL);
|
||||
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;
|
||||
@ -274,7 +277,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
|
||||
/*Don't let the drop down list to handle the control signals. It works differently*/
|
||||
if(sign != LV_SIGNAL_CONTROLL && sign != LV_SIGNAL_FOCUS && sign != LV_SIGNAL_DEFOCUS) {
|
||||
/* Include the ancient signal function */
|
||||
/* Include the ancient signal function */
|
||||
res = ancestor_signal(roller, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
@ -282,39 +285,36 @@ 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.label) + lv_obj_get_height(roller));
|
||||
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) {
|
||||
|
||||
if(lv_obj_get_width(roller) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(roller) != lv_area_get_height(param)) {
|
||||
lv_obj_get_height(roller) != lv_area_get_height(param)) {
|
||||
|
||||
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.label) + lv_obj_get_height(roller));
|
||||
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_FOCUS) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
} 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);
|
||||
} 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) {
|
||||
if(ext->ddlist.sel_opt_id + 1 < ext->ddlist.option_cnt) {
|
||||
lv_roller_set_selected(roller, ext->ddlist.sel_opt_id + 1, true);
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
|
||||
@ -323,10 +323,9 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ENTER_LONG) {
|
||||
if(ext->ddlist.action) ext->ddlist.action(roller);
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -374,8 +373,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
|
||||
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
|
||||
ext->ddlist.sel_opt_id = id;
|
||||
if(ext->ddlist.action) ext->ddlist.action(roller);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
/*If picked an option by clicking then set it*/
|
||||
if(!lv_indev_is_dragging(indev)) {
|
||||
lv_point_t p;
|
||||
@ -402,9 +400,9 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
|
||||
* @param roller pointer to a roller object
|
||||
* @param mask pointer to the current mask (from the design function)
|
||||
*/
|
||||
static void draw_bg(lv_obj_t *roller, const lv_area_t *mask)
|
||||
static void draw_bg(lv_obj_t * roller, const lv_area_t * mask)
|
||||
{
|
||||
lv_style_t *style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
|
||||
lv_style_t * style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
|
||||
lv_area_t half_mask;
|
||||
lv_area_t half_roller;
|
||||
lv_coord_t h = lv_obj_get_height(roller);
|
||||
@ -440,7 +438,7 @@ static void draw_bg(lv_obj_t *roller, const lv_area_t *mask)
|
||||
half_roller.y2 -= roller->ext_size;
|
||||
half_roller.y1 -= style->body.radius;
|
||||
|
||||
if(union_ok){
|
||||
if(union_ok) {
|
||||
lv_color_t main_tmp = style->body.main_color;
|
||||
lv_color_t grad_tmp = style->body.grad_color;
|
||||
|
||||
@ -458,12 +456,12 @@ static void draw_bg(lv_obj_t *roller, const lv_area_t *mask)
|
||||
* @param roller pointer to a roller object
|
||||
* @param anim_en true: refresh with animation; false: without animation
|
||||
*/
|
||||
static void refr_position(lv_obj_t *roller, bool anim_en)
|
||||
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_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);
|
||||
const lv_font_t * font = style_label->text.font;
|
||||
|
@ -81,7 +81,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_protect(new_slider, LV_PROTECT_PRESS_LOST);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_BG, th->slider.bg);
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_INDIC, th->slider.indic);
|
||||
@ -92,8 +92,8 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing slider*/
|
||||
else {
|
||||
lv_slider_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->style_knob = copy_ext->style_knob;
|
||||
lv_slider_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->style_knob = copy_ext->style_knob;
|
||||
ext->action = copy_ext->action;
|
||||
ext->knob_in = copy_ext->knob_in;
|
||||
/*Refresh the style with new signal function*/
|
||||
@ -139,11 +139,11 @@ void lv_slider_set_knob_in(lv_obj_t * slider, bool in)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_slider_set_style(lv_obj_t *slider, lv_slider_style_t type, lv_style_t *style)
|
||||
void lv_slider_set_style(lv_obj_t * slider, lv_slider_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_SLIDER_STYLE_BG:
|
||||
lv_bar_set_style(slider, LV_BAR_STYLE_BG, style);
|
||||
break;
|
||||
@ -214,15 +214,19 @@ bool lv_slider_get_knob_in(lv_obj_t * slider)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_slider_get_style(lv_obj_t *slider, lv_slider_style_t type)
|
||||
lv_style_t * lv_slider_get_style(lv_obj_t * slider, lv_slider_style_t type)
|
||||
{
|
||||
lv_slider_ext_t *ext = lv_obj_get_ext_attr(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
|
||||
switch (type) {
|
||||
case LV_SLIDER_STYLE_BG: return lv_bar_get_style(slider, LV_BAR_STYLE_BG);
|
||||
case LV_SLIDER_STYLE_INDIC: return lv_bar_get_style(slider, LV_BAR_STYLE_INDIC);
|
||||
case LV_SLIDER_STYLE_KNOB: return ext->style_knob;
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_SLIDER_STYLE_BG:
|
||||
return lv_bar_get_style(slider, LV_BAR_STYLE_BG);
|
||||
case LV_SLIDER_STYLE_INDIC:
|
||||
return lv_bar_get_style(slider, LV_BAR_STYLE_INDIC);
|
||||
case LV_SLIDER_STYLE_KNOB:
|
||||
return ext->style_knob;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -248,7 +252,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
@ -320,11 +324,11 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
if(ext->drag_value != LV_SLIDER_NOT_PRESSED) cur_value = ext->drag_value;
|
||||
|
||||
if(slider_w >= slider_h) {
|
||||
area_indic.x2 = (int32_t) ((int32_t)(lv_area_get_width(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
area_indic.x2 = (int32_t)((int32_t)(lv_area_get_width(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
area_indic.x2 += area_indic.x1 + area_indic.x2;
|
||||
|
||||
} else {
|
||||
area_indic.y1 = (int32_t) ((int32_t)(lv_area_get_height(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
area_indic.y1 = (int32_t)((int32_t)(lv_area_get_height(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
area_indic.y1 = area_indic.y2 - area_indic.y1;
|
||||
}
|
||||
|
||||
@ -339,7 +343,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
knob_area.x1 = area_indic.x2 - slider_h / 2;
|
||||
knob_area.x2 = knob_area.x1 + slider_h;
|
||||
} else {
|
||||
knob_area.x1 = (int32_t) ((int32_t)(slider_w - slider_h - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
knob_area.x1 = (int32_t)((int32_t)(slider_w - slider_h - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
knob_area.x1 += slider->coords.x1;
|
||||
knob_area.x2 = knob_area.x1 + slider_h;
|
||||
}
|
||||
@ -351,7 +355,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
knob_area.y1 = area_indic.y1 - slider_w / 2;
|
||||
knob_area.y2 = knob_area.y1 + slider_w;
|
||||
} else {
|
||||
knob_area.y2 = (int32_t) ((int32_t)(slider_h - slider_w - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
knob_area.y2 = (int32_t)((int32_t)(slider_h - slider_w - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
knob_area.y2 = slider->coords.y2 - knob_area.y2;
|
||||
knob_area.y1 = knob_area.y2 - slider_w;
|
||||
}
|
||||
@ -393,19 +397,18 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
ext->drag_value = lv_slider_get_value(slider);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
lv_indev_get_point(param, &p);
|
||||
int16_t tmp = 0;
|
||||
if(w > h) {
|
||||
lv_coord_t knob_w = h;
|
||||
p.x -= slider->coords.x1 + h / 2; /*Modify the point to shift with half knob (important on the start and end)*/
|
||||
tmp = (int32_t) ((int32_t) p.x * (ext->bar.max_value - ext->bar.min_value + 1)) / (w - knob_w);
|
||||
tmp = (int32_t)((int32_t) p.x * (ext->bar.max_value - ext->bar.min_value + 1)) / (w - knob_w);
|
||||
tmp += ext->bar.min_value;
|
||||
} else {
|
||||
lv_coord_t knob_h = w;
|
||||
p.y -= slider->coords.y1 + w / 2; /*Modify the point to shift with half knob (important on the start and end)*/
|
||||
tmp = (int32_t) ((int32_t) p.y * (ext->bar.max_value - ext->bar.min_value + 1)) / (h - knob_h);
|
||||
tmp = (int32_t)((int32_t) p.y * (ext->bar.max_value - ext->bar.min_value + 1)) / (h - knob_h);
|
||||
tmp = ext->bar.max_value - tmp; /*Invert the value: smaller value means higher y*/
|
||||
}
|
||||
|
||||
@ -417,22 +420,20 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
if(ext->action != NULL) ext->action(slider);
|
||||
lv_obj_invalidate(slider);
|
||||
}
|
||||
}
|
||||
else if (sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
lv_slider_set_value(slider, ext->drag_value);
|
||||
ext->drag_value = LV_SLIDER_NOT_PRESSED;
|
||||
if(ext->action != NULL) ext->action(slider);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/* The knob size depends on slider size.
|
||||
* During the drawing method the ext. size is used by the knob so refresh the ext. size.*/
|
||||
if(lv_obj_get_width(slider) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(slider) != lv_area_get_height(param)) {
|
||||
lv_obj_get_height(slider) != lv_area_get_height(param)) {
|
||||
slider->signal_func(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
lv_style_t *style = lv_slider_get_style(slider, LV_SLIDER_STYLE_BG);
|
||||
lv_style_t *knob_style = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB);
|
||||
lv_style_t * style = lv_slider_get_style(slider, LV_SLIDER_STYLE_BG);
|
||||
lv_style_t * knob_style = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB);
|
||||
lv_coord_t shadow_w = knob_style->body.shadow.width;
|
||||
if(ext->knob_in == 0) {
|
||||
/* The smaller size is the knob diameter*/
|
||||
@ -446,7 +447,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
if(slider->ext_size < shadow_w) slider->ext_size = shadow_w;
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char*)param);
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
lv_slider_set_value(slider, lv_slider_get_value(slider) + 1);
|
||||
if(ext->action != NULL) ext->action(slider);
|
||||
@ -454,8 +455,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
lv_slider_set_value(slider, lv_slider_get_value(slider) - 1);
|
||||
if(ext->action != NULL) ext->action(slider);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
|
@ -76,7 +76,7 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_slider_set_knob_in(new_sw, true);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_BG, th->sw.bg);
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_INDIC, th->sw.indic);
|
||||
@ -89,7 +89,7 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing switch*/
|
||||
else {
|
||||
lv_sw_ext_t *copy_ext = lv_obj_get_ext_attr(copy);
|
||||
lv_sw_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->style_knob_off = copy_ext->style_knob_off;
|
||||
ext->style_knob_on = copy_ext->style_knob_on;
|
||||
|
||||
@ -110,26 +110,26 @@ 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_on(lv_obj_t *sw)
|
||||
void lv_sw_on(lv_obj_t * sw)
|
||||
{
|
||||
if(lv_sw_get_state(sw)) return; /*Do nothing is already turned on*/
|
||||
if(lv_sw_get_state(sw)) return; /*Do nothing is already turned on*/
|
||||
|
||||
lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw);
|
||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||
lv_slider_set_value(sw, 1);
|
||||
lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB,ext->style_knob_on);
|
||||
lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_on);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn OFF the switch
|
||||
* @param sw pointer to a switch object
|
||||
*/
|
||||
void lv_sw_off(lv_obj_t *sw)
|
||||
void lv_sw_off(lv_obj_t * sw)
|
||||
{
|
||||
if(!lv_sw_get_state(sw)) return; /*Do nothing is already turned off*/
|
||||
if(!lv_sw_get_state(sw)) return; /*Do nothing is already turned off*/
|
||||
|
||||
lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw);
|
||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||
lv_slider_set_value(sw, 0);
|
||||
lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB,ext->style_knob_off);
|
||||
lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,11 +138,11 @@ void lv_sw_off(lv_obj_t *sw)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_sw_set_style(lv_obj_t *sw, lv_sw_style_t type, lv_style_t *style)
|
||||
void lv_sw_set_style(lv_obj_t * sw, lv_sw_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_SLIDER_STYLE_BG:
|
||||
lv_slider_set_style(sw, LV_SLIDER_STYLE_BG, style);
|
||||
break;
|
||||
@ -170,16 +170,21 @@ void lv_sw_set_style(lv_obj_t *sw, lv_sw_style_t type, lv_style_t *style)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_sw_get_style(lv_obj_t *sw, lv_sw_style_t type)
|
||||
lv_style_t * lv_sw_get_style(lv_obj_t * sw, lv_sw_style_t type)
|
||||
{
|
||||
lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw);
|
||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||
|
||||
switch (type) {
|
||||
case LV_SW_STYLE_BG: return lv_slider_get_style(sw, LV_SLIDER_STYLE_BG);
|
||||
case LV_SW_STYLE_INDIC: return lv_slider_get_style(sw, LV_SLIDER_STYLE_INDIC);
|
||||
case LV_SW_STYLE_KNOB_OFF: return ext->style_knob_off;
|
||||
case LV_SW_STYLE_KNOB_ON: return ext->style_knob_on;
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_SW_STYLE_BG:
|
||||
return lv_slider_get_style(sw, LV_SLIDER_STYLE_BG);
|
||||
case LV_SW_STYLE_INDIC:
|
||||
return lv_slider_get_style(sw, LV_SLIDER_STYLE_INDIC);
|
||||
case LV_SW_STYLE_KNOB_OFF:
|
||||
return ext->style_knob_off;
|
||||
case LV_SW_STYLE_KNOB_ON:
|
||||
return ext->style_knob_on;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -216,17 +221,14 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
int16_t act_val = ext->slider.drag_value;
|
||||
if(act_val != old_val) ext->changed = 1;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
} else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
ext->changed = 0;
|
||||
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);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(ext->changed == 0) {
|
||||
int16_t v = lv_slider_get_value(sw);
|
||||
if(v == 0) lv_slider_set_value(sw, 1);
|
||||
@ -239,26 +241,22 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
if(slider_action != NULL) slider_action(sw);
|
||||
|
||||
ext->changed = 0;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
|
||||
char c = *((char*)param);
|
||||
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) {
|
||||
} 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) {
|
||||
} 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) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
|
343
lv_objx/lv_ta.c
343
lv_objx/lv_ta.c
@ -103,19 +103,19 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/*Init the new text area object*/
|
||||
if(copy == NULL) {
|
||||
ext->label = lv_label_create(new_ta, NULL);
|
||||
ext->label = lv_label_create(new_ta, NULL);
|
||||
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
|
||||
|
||||
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->label, "Text area");
|
||||
lv_obj_set_click(ext->label, false);
|
||||
lv_obj_set_size(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
|
||||
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->label, "Text area");
|
||||
lv_obj_set_click(ext->label, false);
|
||||
lv_obj_set_size(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
|
||||
lv_ta_set_sb_mode(new_ta, LV_SB_MODE_DRAG);
|
||||
lv_page_set_style(new_ta, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, th->ta.area);
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_SB, th->ta.sb);
|
||||
@ -125,17 +125,17 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
|
||||
lv_ta_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->label = lv_label_create(new_ta, copy_ext->label);
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
|
||||
lv_ta_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->label = lv_label_create(new_ta, copy_ext->label);
|
||||
ext->pwd_mode = copy_ext->pwd_mode;
|
||||
ext->cursor.style = copy_ext->cursor.style;
|
||||
ext->cursor.pos = copy_ext->cursor.pos;
|
||||
ext->cursor.valid_x = copy_ext->cursor.valid_x;
|
||||
ext->cursor.type = copy_ext->cursor.type;
|
||||
if(copy_ext->one_line) lv_ta_set_one_line(new_ta, true);
|
||||
if(copy_ext->one_line) lv_ta_set_one_line(new_ta, true);
|
||||
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_CURSOR, lv_ta_get_style(copy, LV_TA_STYLE_CURSOR));
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_CURSOR, lv_ta_get_style(copy, LV_TA_STYLE_CURSOR));
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_ta);
|
||||
@ -303,15 +303,15 @@ void lv_ta_del_char(lv_obj_t * ta)
|
||||
*/
|
||||
void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
lv_ta_set_cursor_pos(ta, LV_TA_CURSOR_LAST);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
lv_ta_set_cursor_pos(ta, LV_TA_CURSOR_LAST);
|
||||
|
||||
/*Don't let 'width == 0' because cursor will not be visible*/
|
||||
if(lv_obj_get_width(ext->label) == 0) {
|
||||
lv_style_t * style = lv_obj_get_style(ext->label);
|
||||
lv_obj_set_width(ext->label, lv_font_get_width(style->text.font, ' '));
|
||||
}
|
||||
/*Don't let 'width == 0' because cursor will not be visible*/
|
||||
if(lv_obj_get_width(ext->label) == 0) {
|
||||
lv_style_t * style = lv_obj_get_style(ext->label);
|
||||
lv_obj_set_width(ext->label, lv_font_get_width(style->text.font, ' '));
|
||||
}
|
||||
|
||||
if(ext->pwd_mode != 0) {
|
||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(txt) + 1);
|
||||
@ -346,40 +346,40 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||
*/
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(ext->cursor.pos == pos) return;
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(ext->cursor.pos == pos) return;
|
||||
|
||||
uint16_t len = lv_txt_get_length(lv_label_get_text(ext->label));
|
||||
|
||||
if(pos < 0) pos = len + pos;
|
||||
if(pos < 0) pos = len + pos;
|
||||
|
||||
if(pos > len || pos == LV_TA_CURSOR_LAST) pos = len;
|
||||
if(pos > len || pos == LV_TA_CURSOR_LAST) pos = len;
|
||||
|
||||
ext->cursor.pos = pos;
|
||||
ext->cursor.pos = pos;
|
||||
|
||||
/*Position the label to make the cursor visible*/
|
||||
lv_obj_t * label_par = lv_obj_get_parent(ext->label);
|
||||
lv_point_t cur_pos;
|
||||
lv_style_t * style = lv_obj_get_style(ta);
|
||||
const lv_font_t * font_p = style->text.font;
|
||||
lv_area_t label_cords;
|
||||
/*Position the label to make the cursor visible*/
|
||||
lv_obj_t * label_par = lv_obj_get_parent(ext->label);
|
||||
lv_point_t cur_pos;
|
||||
lv_style_t * style = lv_obj_get_style(ta);
|
||||
const lv_font_t * font_p = style->text.font;
|
||||
lv_area_t label_cords;
|
||||
lv_area_t ta_cords;
|
||||
lv_label_get_letter_pos(ext->label, pos, &cur_pos);
|
||||
lv_obj_get_coords(ta, &ta_cords);
|
||||
lv_label_get_letter_pos(ext->label, pos, &cur_pos);
|
||||
lv_obj_get_coords(ta, &ta_cords);
|
||||
lv_obj_get_coords(ext->label, &label_cords);
|
||||
|
||||
/*Check the top*/
|
||||
/*Check the top*/
|
||||
lv_coord_t font_h = lv_font_get_height(font_p);
|
||||
if(lv_obj_get_y(label_par) + cur_pos.y < 0) {
|
||||
lv_obj_set_y(label_par, - cur_pos.y + style->body.padding.ver);
|
||||
}
|
||||
if(lv_obj_get_y(label_par) + cur_pos.y < 0) {
|
||||
lv_obj_set_y(label_par, - cur_pos.y + style->body.padding.ver);
|
||||
}
|
||||
|
||||
/*Check the bottom*/
|
||||
if(label_cords.y1 + cur_pos.y + font_h + style->body.padding.ver > ta_cords.y2) {
|
||||
lv_obj_set_y(label_par, -(cur_pos.y - lv_obj_get_height(ta) +
|
||||
font_h + 2 * style->body.padding.ver));
|
||||
}
|
||||
/*Check the left (use the font_h as general unit)*/
|
||||
/*Check the bottom*/
|
||||
if(label_cords.y1 + cur_pos.y + font_h + style->body.padding.ver > ta_cords.y2) {
|
||||
lv_obj_set_y(label_par, -(cur_pos.y - lv_obj_get_height(ta) +
|
||||
font_h + 2 * style->body.padding.ver));
|
||||
}
|
||||
/*Check the left (use the font_h as general unit)*/
|
||||
if(lv_obj_get_x(label_par) + cur_pos.x < font_h) {
|
||||
lv_obj_set_x(label_par, - cur_pos.x + font_h);
|
||||
}
|
||||
@ -387,7 +387,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
/*Check the right (use the font_h as general unit)*/
|
||||
if(label_cords.x1 + cur_pos.x + font_h + style->body.padding.hor > ta_cords.x2) {
|
||||
lv_obj_set_x(label_par, -(cur_pos.x - lv_obj_get_width(ta) +
|
||||
font_h + 2 * style->body.padding.hor));
|
||||
font_h + 2 * style->body.padding.hor));
|
||||
}
|
||||
|
||||
ext->cursor.valid_x = cur_pos.x;
|
||||
@ -401,7 +401,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
a.act_time = 0;
|
||||
a.end_cb = NULL;
|
||||
a.start = 1;
|
||||
a.end= 0;
|
||||
a.end = 0;
|
||||
a.repeat = 1;
|
||||
a.repeat_pause = 0;
|
||||
a.playback = 1;
|
||||
@ -410,7 +410,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
lv_anim_create(&a);
|
||||
#endif
|
||||
|
||||
lv_obj_invalidate(ta);
|
||||
lv_obj_invalidate(ta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -470,7 +470,7 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool pwd_en)
|
||||
void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(ext->one_line == en) return;
|
||||
if(ext->one_line == en) return;
|
||||
|
||||
if(en != false) {
|
||||
lv_style_t * style_ta = lv_obj_get_style(ta);
|
||||
@ -502,11 +502,11 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_ta_set_style(lv_obj_t *ta, lv_ta_style_t type, lv_style_t *style)
|
||||
void lv_ta_set_style(lv_obj_t * ta, lv_ta_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_TA_STYLE_BG:
|
||||
lv_page_set_style(ta, LV_PAGE_STYLE_BG, style);
|
||||
break;
|
||||
@ -531,16 +531,16 @@ void lv_ta_set_style(lv_obj_t *ta, lv_ta_style_t type, lv_style_t *style)
|
||||
*/
|
||||
const char * lv_ta_get_text(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
|
||||
const char * txt;
|
||||
if(ext->pwd_mode == 0) {
|
||||
txt = lv_label_get_text(ext->label);
|
||||
} else {
|
||||
txt = ext->pwd_tmp;
|
||||
}
|
||||
const char * txt;
|
||||
if(ext->pwd_mode == 0) {
|
||||
txt = lv_label_get_text(ext->label);
|
||||
} else {
|
||||
txt = ext->pwd_tmp;
|
||||
}
|
||||
|
||||
return txt;
|
||||
return txt;
|
||||
}
|
||||
|
||||
|
||||
@ -563,8 +563,8 @@ lv_obj_t * lv_ta_get_label(lv_obj_t * ta)
|
||||
*/
|
||||
uint16_t lv_ta_get_cursor_pos(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
return ext->cursor.pos;
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
return ext->cursor.pos;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -606,15 +606,19 @@ bool lv_ta_get_one_line(lv_obj_t * ta)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_ta_get_style(lv_obj_t *ta, lv_ta_style_t type)
|
||||
lv_style_t * lv_ta_get_style(lv_obj_t * ta, lv_ta_style_t type)
|
||||
{
|
||||
lv_ta_ext_t *ext = lv_obj_get_ext_attr(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
|
||||
switch (type) {
|
||||
case LV_TA_STYLE_BG: return lv_page_get_style(ta, LV_PAGE_STYLE_BG);
|
||||
case LV_TA_STYLE_SB: return lv_page_get_style(ta, LV_PAGE_STYLE_SB);
|
||||
case LV_TA_STYLE_CURSOR: return ext->cursor.style;
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_TA_STYLE_BG:
|
||||
return lv_page_get_style(ta, LV_PAGE_STYLE_BG);
|
||||
case LV_TA_STYLE_SB:
|
||||
return lv_page_get_style(ta, LV_PAGE_STYLE_SB);
|
||||
case LV_TA_STYLE_CURSOR:
|
||||
return ext->cursor.style;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -723,14 +727,14 @@ void lv_ta_cursor_up(lv_obj_t * ta)
|
||||
static bool lv_ta_design(lv_obj_t * ta, const lv_area_t * masp, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_design(ta, masp, mode);
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_design(ta, masp, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the object*/
|
||||
ancestor_design(ta, masp, mode);
|
||||
/*Draw the object*/
|
||||
ancestor_design(ta, masp, mode);
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
ancestor_design(ta, masp, mode);
|
||||
ancestor_design(ta, masp, mode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -747,53 +751,51 @@ static bool lv_ta_design(lv_obj_t * ta, const lv_area_t * masp, lv_design_mode_t
|
||||
*/
|
||||
static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return scrl_design(scrl, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the object*/
|
||||
scrl_design(scrl, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
scrl_design(scrl, mask, mode);
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return scrl_design(scrl, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the object*/
|
||||
scrl_design(scrl, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
scrl_design(scrl, mask, mode);
|
||||
|
||||
/*Draw the cursor too*/
|
||||
lv_obj_t * ta = lv_obj_get_parent(scrl);
|
||||
lv_ta_ext_t * ta_ext = lv_obj_get_ext_attr(ta);
|
||||
/*Draw the cursor too*/
|
||||
lv_obj_t * ta = lv_obj_get_parent(scrl);
|
||||
lv_ta_ext_t * ta_ext = lv_obj_get_ext_attr(ta);
|
||||
lv_style_t * label_style = lv_obj_get_style(ta_ext->label);
|
||||
if(ta_ext->cursor.type == LV_CURSOR_NONE ||
|
||||
(ta_ext->cursor.type & LV_CURSOR_HIDDEN) ||
|
||||
ta_ext->cursor.state == 0 ||
|
||||
label_style->body.opa == LV_OPA_TRANSP)
|
||||
{
|
||||
return true; /*The cursor is not visible now*/
|
||||
}
|
||||
if(ta_ext->cursor.type == LV_CURSOR_NONE ||
|
||||
(ta_ext->cursor.type & LV_CURSOR_HIDDEN) ||
|
||||
ta_ext->cursor.state == 0 ||
|
||||
label_style->body.opa == LV_OPA_TRANSP) {
|
||||
return true; /*The cursor is not visible now*/
|
||||
}
|
||||
|
||||
|
||||
lv_style_t cur_style;
|
||||
if(ta_ext->cursor.style != NULL) {
|
||||
lv_style_copy(&cur_style, ta_ext->cursor.style);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/*If cursor style is not specified then use the modified label style */
|
||||
lv_style_copy(&cur_style, label_style);
|
||||
lv_color_t clv_color_tmp = cur_style.text.color; /*Make letter color to cursor color*/
|
||||
cur_style.text.color = cur_style.body.main_color; /*In block mode the letter color will be current background color*/
|
||||
cur_style.body.main_color = clv_color_tmp;
|
||||
cur_style.body.grad_color = clv_color_tmp;
|
||||
cur_style.body.border.color = clv_color_tmp;
|
||||
cur_style.body.border.opa = LV_OPA_COVER;
|
||||
cur_style.body.border.width = 1;
|
||||
cur_style.body.shadow.width = 0;
|
||||
cur_style.body.radius = 0;
|
||||
cur_style.body.empty = 0;
|
||||
cur_style.body.padding.hor = 0;
|
||||
lv_style_copy(&cur_style, label_style);
|
||||
lv_color_t clv_color_tmp = cur_style.text.color; /*Make letter color to cursor color*/
|
||||
cur_style.text.color = cur_style.body.main_color; /*In block mode the letter color will be current background color*/
|
||||
cur_style.body.main_color = clv_color_tmp;
|
||||
cur_style.body.grad_color = clv_color_tmp;
|
||||
cur_style.body.border.color = clv_color_tmp;
|
||||
cur_style.body.border.opa = LV_OPA_COVER;
|
||||
cur_style.body.border.width = 1;
|
||||
cur_style.body.shadow.width = 0;
|
||||
cur_style.body.radius = 0;
|
||||
cur_style.body.empty = 0;
|
||||
cur_style.body.padding.hor = 0;
|
||||
cur_style.body.padding.ver = 0;
|
||||
cur_style.line.width = 1;
|
||||
cur_style.body.opa = LV_OPA_COVER;
|
||||
}
|
||||
|
||||
uint16_t cur_pos = lv_ta_get_cursor_pos(ta);
|
||||
const char * txt = lv_label_get_text(ta_ext->label);
|
||||
uint16_t cur_pos = lv_ta_get_cursor_pos(ta);
|
||||
const char * txt = lv_label_get_text(ta_ext->label);
|
||||
uint32_t byte_pos;
|
||||
#if LV_TXT_UTF8 != 0
|
||||
byte_pos = txt_utf8_get_byte_id(txt, cur_pos);
|
||||
@ -801,56 +803,56 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
byte_pos = cur_pos;
|
||||
#endif
|
||||
|
||||
uint32_t letter = lv_txt_utf8_next(&txt[byte_pos], NULL);
|
||||
lv_coord_t letter_h = lv_font_get_height(label_style->text.font);
|
||||
/*Set letter_w (set not 0 on non printable but valid chars)*/
|
||||
uint32_t letter = lv_txt_utf8_next(&txt[byte_pos], NULL);
|
||||
lv_coord_t letter_h = lv_font_get_height(label_style->text.font);
|
||||
/*Set letter_w (set not 0 on non printable but valid chars)*/
|
||||
lv_coord_t letter_w;
|
||||
if(letter == '\0' || letter == '\n' || letter == '\r') {
|
||||
letter_w = lv_font_get_width(label_style->text.font, ' ');
|
||||
} else {
|
||||
if(letter == '\0' || letter == '\n' || letter == '\r') {
|
||||
letter_w = lv_font_get_width(label_style->text.font, ' ');
|
||||
} else {
|
||||
letter_w = lv_font_get_width(label_style->text.font, letter);
|
||||
}
|
||||
}
|
||||
|
||||
lv_point_t letter_pos;
|
||||
lv_label_get_letter_pos(ta_ext->label, cur_pos, &letter_pos);
|
||||
lv_point_t letter_pos;
|
||||
lv_label_get_letter_pos(ta_ext->label, cur_pos, &letter_pos);
|
||||
|
||||
/*If the cursor is out of the text (most right) draw it to the next line*/
|
||||
if(letter_pos.x + ta_ext->label->coords.x1 + letter_w > ta_ext->label->coords.x2 && ta_ext->one_line == 0) {
|
||||
letter_pos.x = 0;
|
||||
letter_pos.y += letter_h + label_style->text.line_space;
|
||||
/*If the cursor is out of the text (most right) draw it to the next line*/
|
||||
if(letter_pos.x + ta_ext->label->coords.x1 + letter_w > ta_ext->label->coords.x2 && ta_ext->one_line == 0) {
|
||||
letter_pos.x = 0;
|
||||
letter_pos.y += letter_h + label_style->text.line_space;
|
||||
|
||||
if(letter != '\0'){
|
||||
byte_pos += lv_txt_utf8_size(txt[byte_pos]);
|
||||
letter = lv_txt_utf8_next(&txt[byte_pos], NULL);
|
||||
}
|
||||
if(letter != '\0') {
|
||||
byte_pos += lv_txt_utf8_size(txt[byte_pos]);
|
||||
letter = lv_txt_utf8_next(&txt[byte_pos], NULL);
|
||||
}
|
||||
|
||||
if(letter == '\0' || letter == '\n' || letter == '\r') {
|
||||
if(letter == '\0' || letter == '\n' || letter == '\r') {
|
||||
letter_w = lv_font_get_width(label_style->text.font, ' ');
|
||||
} else {
|
||||
letter_w = lv_font_get_width(label_style->text.font, letter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Draw he cursor according to the type*/
|
||||
lv_area_t cur_area;
|
||||
if(ta_ext->cursor.type == LV_CURSOR_LINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor - (cur_style.line.width >> 1) - (cur_style.line.width & 0x1);
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + (cur_style.line.width >> 1);
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h;
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_BLOCK) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.ver;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h;
|
||||
/*Draw he cursor according to the type*/
|
||||
lv_area_t cur_area;
|
||||
if(ta_ext->cursor.type == LV_CURSOR_LINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor - (cur_style.line.width >> 1) - (cur_style.line.width & 0x1);
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + (cur_style.line.width >> 1);
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h;
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_BLOCK) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.ver;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h;
|
||||
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
|
||||
/*Get the current letter*/
|
||||
/*Get the current letter*/
|
||||
#if LV_TXT_UTF8 == 0
|
||||
char letter_buf[2];
|
||||
letter_buf[0] = txt[byte_pos];
|
||||
char letter_buf[2];
|
||||
letter_buf[0] = txt[byte_pos];
|
||||
letter_buf[1] = '\0';
|
||||
#else
|
||||
char letter_buf[8] = {0};
|
||||
@ -858,29 +860,29 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
#endif
|
||||
cur_area.x1 += cur_style.body.padding.hor;
|
||||
cur_area.y1 += cur_style.body.padding.ver;
|
||||
lv_draw_label(&cur_area, mask, &cur_style, letter_buf, LV_TXT_FLAG_NONE, 0);
|
||||
lv_draw_label(&cur_area, mask, &cur_style, letter_buf, LV_TXT_FLAG_NONE, 0);
|
||||
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_OUTLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.ver;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver+ letter_h;
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_OUTLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.ver;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h;
|
||||
|
||||
cur_style.body.empty = 1;
|
||||
if(cur_style.body.border.width == 0) cur_style.body.border.width = 1; /*Be sure the border will be drawn*/
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_UNDERLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h - (cur_style.line.width >> 1);
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h + (cur_style.line.width >> 1) + (cur_style.line.width & 0x1);
|
||||
cur_style.body.empty = 1;
|
||||
if(cur_style.body.border.width == 0) cur_style.body.border.width = 1; /*Be sure the border will be drawn*/
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
} else if(ta_ext->cursor.type == LV_CURSOR_UNDERLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h - (cur_style.line.width >> 1);
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h + (cur_style.line.width >> 1) + (cur_style.line.width & 0x1);
|
||||
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
}
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -925,7 +927,7 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
/*Set the label width according to the text area width*/
|
||||
if(ext->label) {
|
||||
if(lv_obj_get_width(ta) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(ta) != lv_area_get_height(param)) {
|
||||
lv_obj_get_height(ta) != lv_area_get_height(param)) {
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ta);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->body.padding.hor);
|
||||
@ -933,9 +935,8 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
lv_label_set_text(ext->label, NULL); /*Refresh the label*/
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sign == LV_SIGNAL_CONTROLL) {
|
||||
uint32_t c = *((uint32_t*)param); /*uint32_t because can be UTF-8*/
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
|
||||
if(c == LV_GROUP_KEY_RIGHT) lv_ta_cursor_right(ta);
|
||||
else if(c == LV_GROUP_KEY_LEFT) lv_ta_cursor_left(ta);
|
||||
else if(c == LV_GROUP_KEY_UP) lv_ta_cursor_up(ta);
|
||||
@ -945,13 +946,12 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
/*Swap the bytes (UTF-8 is big endian, but the MCUs are little endian)*/
|
||||
if((c & 0x80) == 0) { /*ASCII*/
|
||||
lv_ta_add_char(ta, (char)c);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
uint32_t swapped[2] = {0, 0}; /*the 2. element is the closing '\0'*/
|
||||
uint8_t c8[4];
|
||||
memcpy(c8, &c, 4);
|
||||
swapped[0] = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]);
|
||||
char *p = (char*)swapped;
|
||||
char * p = (char *)swapped;
|
||||
uint8_t i;
|
||||
for(i = 0; i < 4; i++) {
|
||||
if(p[0] == 0) p++; /*Ignore leading zeros (they were in the end originally)*/
|
||||
@ -963,8 +963,7 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -1012,14 +1011,14 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
||||
*/
|
||||
static void cursor_blink_anim(lv_obj_t * ta, uint8_t show)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(show != ext->cursor.state) {
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(show != ext->cursor.state) {
|
||||
ext->cursor.state = show == 0 ? 0 : 1;
|
||||
if(ext->cursor.type != LV_CURSOR_NONE &&
|
||||
(ext->cursor.type & LV_CURSOR_HIDDEN) == 0) {
|
||||
(ext->cursor.type & LV_CURSOR_HIDDEN) == 0) {
|
||||
lv_obj_invalidate(ta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
# endif
|
||||
#else
|
||||
# undef LV_TABVIEW_ANIM_TIME
|
||||
# define LV_TABVIEW_ANIM_TIME 0 /*No animations*/
|
||||
# define LV_TABVIEW_ANIM_TIME 0 /*No animations*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -88,7 +88,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->btns = NULL;
|
||||
ext->tab_load_action = NULL;
|
||||
ext->anim_time = LV_TABVIEW_ANIM_TIME;
|
||||
ext->tab_name_ptr = lv_mem_alloc(sizeof(char*));
|
||||
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
|
||||
ext->tab_name_ptr[0] = "";
|
||||
ext->tab_cnt = 0;
|
||||
|
||||
@ -118,7 +118,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->tabview.bg);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->tabview.indic);
|
||||
@ -135,7 +135,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing tab view*/
|
||||
else {
|
||||
lv_tabview_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
lv_tabview_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->point_last.x = 0;
|
||||
ext->point_last.y = 0;
|
||||
ext->btns = lv_btnm_create(new_tabview, copy_ext->btns);
|
||||
@ -144,14 +144,14 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->anim_time = copy_ext->anim_time;
|
||||
ext->tab_load_action = copy_ext->tab_load_action;
|
||||
|
||||
ext->tab_name_ptr = lv_mem_alloc(sizeof(char*));
|
||||
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
|
||||
ext->tab_name_ptr[0] = "";
|
||||
lv_btnm_set_map(ext->btns, ext->tab_name_ptr);
|
||||
|
||||
uint16_t i;
|
||||
lv_obj_t *new_tab;
|
||||
lv_obj_t *copy_tab;
|
||||
for (i = 0; i < copy_ext->tab_cnt; i++) {
|
||||
lv_obj_t * new_tab;
|
||||
lv_obj_t * copy_tab;
|
||||
for(i = 0; i < copy_ext->tab_cnt; i++) {
|
||||
new_tab = lv_tabview_add_tab(new_tabview, copy_ext->tab_name_ptr[i]);
|
||||
copy_tab = lv_tabview_get_tab(copy, i);
|
||||
lv_page_set_style(new_tab, LV_PAGE_STYLE_BG, lv_page_get_style(copy_tab, LV_PAGE_STYLE_BG));
|
||||
@ -193,7 +193,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||
lv_obj_set_signal_func(lv_page_get_scrl(h), tabpage_scrl_signal);
|
||||
|
||||
/*Extend the button matrix map with the new name*/
|
||||
char *name_dm;
|
||||
char * name_dm;
|
||||
if((name[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) { /*If control byte presented let is*/
|
||||
name_dm = lv_mem_alloc(strlen(name) + 1); /*+1 for the the closing '\0' */
|
||||
strcpy(name_dm, name);
|
||||
@ -276,7 +276,7 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
|
||||
lv_style_t * tabs_style = lv_obj_get_style(ext->btns);
|
||||
lv_coord_t indic_x = indic_width * id + tabs_style->body.padding.inner * id + tabs_style->body.padding.hor;
|
||||
|
||||
if(ext->anim_time == 0 || anim_en == false ) {
|
||||
if(ext->anim_time == 0 || anim_en == false) {
|
||||
lv_obj_set_x(ext->indic, indic_x);
|
||||
} else {
|
||||
#if USE_LV_ANIMATION
|
||||
@ -306,7 +306,7 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
|
||||
* @param tabview pointer to a tabview object
|
||||
* @param action pointer to a function to call when a btn is loaded
|
||||
*/
|
||||
void lv_tabview_set_tab_load_action(lv_obj_t *tabview, lv_tabview_action_t action)
|
||||
void lv_tabview_set_tab_load_action(lv_obj_t * tabview, lv_tabview_action_t action)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
ext->tab_load_action = action;
|
||||
@ -343,9 +343,9 @@ void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to the new style
|
||||
*/
|
||||
void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t *style)
|
||||
void lv_tabview_set_style(lv_obj_t * tabview, lv_tabview_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
|
||||
switch(type) {
|
||||
case LV_TABVIEW_STYLE_BG:
|
||||
@ -429,7 +429,7 @@ lv_obj_t * lv_tabview_get_tab(lv_obj_t * tabview, uint16_t id)
|
||||
* @param tabview pointer to a tabview object
|
||||
* @param return the current btn load action
|
||||
*/
|
||||
lv_tabview_action_t lv_tabview_get_tab_load_action(lv_obj_t *tabview)
|
||||
lv_tabview_action_t lv_tabview_get_tab_load_action(lv_obj_t * tabview)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
return ext->tab_load_action;
|
||||
@ -442,7 +442,7 @@ lv_tabview_action_t lv_tabview_get_tab_load_action(lv_obj_t *tabview)
|
||||
*/
|
||||
bool lv_tabview_get_sliding(lv_obj_t * tabview)
|
||||
{
|
||||
lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
return ext->slide_enable ? true : false;
|
||||
}
|
||||
|
||||
@ -463,18 +463,25 @@ uint16_t lv_tabview_get_anim_time(lv_obj_t * tabview)
|
||||
* @param type which style should be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_tabview_get_style(lv_obj_t *tabview, lv_tabview_style_t type)
|
||||
lv_style_t * lv_tabview_get_style(lv_obj_t * tabview, lv_tabview_style_t type)
|
||||
{
|
||||
lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
|
||||
switch (type) {
|
||||
case LV_TABVIEW_STYLE_BG: return lv_obj_get_style(tabview);
|
||||
case LV_TABVIEW_STYLE_BTN_BG: return lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BG);
|
||||
case LV_TABVIEW_STYLE_BTN_REL: return lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_REL);
|
||||
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);
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_TABVIEW_STYLE_BG:
|
||||
return lv_obj_get_style(tabview);
|
||||
case LV_TABVIEW_STYLE_BTN_BG:
|
||||
return lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BG);
|
||||
case LV_TABVIEW_STYLE_BTN_REL:
|
||||
return lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_REL);
|
||||
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);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -508,22 +515,18 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
lv_mem_free(ext->tab_name_ptr);
|
||||
ext->tab_name_ptr = NULL;
|
||||
ext->btns = NULL; /*These objects were children so they are already invalid*/
|
||||
ext->content= NULL;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
ext->content = NULL;
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
if(ext->content != NULL &&
|
||||
(lv_obj_get_width(tabview) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(tabview) != lv_area_get_height(param)))
|
||||
{
|
||||
(lv_obj_get_width(tabview) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(tabview) != lv_area_get_height(param))) {
|
||||
tabview_realign(tabview);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROLL) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROLL) {
|
||||
if(ext->btns) {
|
||||
ext->btns->signal_func(ext->btns, sign, param);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -558,11 +561,9 @@ static lv_res_t tabpage_signal(lv_obj_t * tab_page, lv_signal_t sign, void * par
|
||||
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
tabpage_pressed_handler(tabview, tab_page);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
tabpage_pressing_handler(tabview, tab_page);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
tabpage_press_lost_handler(tabview, tab_page);
|
||||
}
|
||||
|
||||
@ -591,11 +592,9 @@ static lv_res_t tabpage_scrl_signal(lv_obj_t * tab_scrl, lv_signal_t sign, void
|
||||
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
tabpage_pressed_handler(tabview, tab_page);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
tabpage_pressing_handler(tabview, tab_page);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
tabpage_press_lost_handler(tabview, tab_page);
|
||||
}
|
||||
|
||||
@ -631,7 +630,7 @@ static void tabpage_pressing_handler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
lv_coord_t y_diff = point_act.y - ext->point_last.y;
|
||||
|
||||
if(ext->draging == 0) {
|
||||
if(x_diff >= LV_INDEV_DRAG_LIMIT || x_diff<= -LV_INDEV_DRAG_LIMIT) {
|
||||
if(x_diff >= LV_INDEV_DRAG_LIMIT || x_diff <= -LV_INDEV_DRAG_LIMIT) {
|
||||
ext->drag_hor = 1;
|
||||
ext->draging = 1;
|
||||
lv_obj_set_drag(lv_page_get_scrl(tabpage), false);
|
||||
@ -733,13 +732,13 @@ static void tabview_realign(lv_obj_t * tabview)
|
||||
|
||||
/*Set the indicator widths*/
|
||||
lv_coord_t indic_width = (lv_obj_get_width(tabview) - style_btn_bg->body.padding.inner * (ext->tab_cnt - 1) -
|
||||
2 * style_btn_bg->body.padding.hor) / ext->tab_cnt;
|
||||
2 * style_btn_bg->body.padding.hor) / ext->tab_cnt;
|
||||
lv_obj_set_width(ext->indic, indic_width);
|
||||
|
||||
/*Set the tabs height*/
|
||||
lv_coord_t btns_height = lv_font_get_height(style_btn_rel->text.font) +
|
||||
2 * style_btn_rel->body.padding.ver +
|
||||
2 * style_btn_bg->body.padding.ver;
|
||||
2 * style_btn_rel->body.padding.ver +
|
||||
2 * style_btn_bg->body.padding.ver;
|
||||
lv_obj_set_height(ext->btns, btns_height);
|
||||
}
|
||||
|
||||
|
144
lv_objx/lv_win.c
144
lv_objx/lv_win.c
@ -61,7 +61,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->style_header = &lv_style_plain_color;
|
||||
ext->style_btn_rel = &lv_style_btn_rel;
|
||||
ext->style_btn_pr = &lv_style_btn_pr;
|
||||
ext->btn_size = ( LV_DPI) / 2;
|
||||
ext->btn_size = (LV_DPI) / 2;
|
||||
|
||||
/*Init the new window object*/
|
||||
if(copy == NULL) {
|
||||
@ -73,18 +73,18 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_protect(ext->page, LV_PROTECT_PARENT);
|
||||
lv_page_set_sb_mode(ext->page, LV_SB_MODE_AUTO);
|
||||
|
||||
/*Create a holder for the header*/
|
||||
ext->header = lv_obj_create(new_win, NULL);
|
||||
/*Move back the header because it is automatically moved to the scrollable */
|
||||
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
|
||||
lv_obj_set_parent(ext->header, new_win);
|
||||
/*Create a holder for the header*/
|
||||
ext->header = lv_obj_create(new_win, NULL);
|
||||
/*Move back the header because it is automatically moved to the scrollable */
|
||||
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
|
||||
lv_obj_set_parent(ext->header, new_win);
|
||||
|
||||
/*Create a title on the header*/
|
||||
ext->title = lv_label_create(ext->header, NULL);
|
||||
lv_label_set_text(ext->title,"My title");
|
||||
/*Create a title on the header*/
|
||||
ext->title = lv_label_create(ext->header, NULL);
|
||||
lv_label_set_text(ext->title, "My title");
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t *th = lv_theme_get_current();
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_BG, th->win.bg);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_SB, th->win.sb);
|
||||
@ -108,23 +108,23 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_win_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
/*Create the objects*/
|
||||
ext->header = lv_obj_create(new_win, copy_ext->header);
|
||||
ext->title = lv_label_create(ext->header, copy_ext->title);
|
||||
lv_win_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
/*Create the objects*/
|
||||
ext->header = lv_obj_create(new_win, copy_ext->header);
|
||||
ext->title = lv_label_create(ext->header, copy_ext->title);
|
||||
ext->page = lv_page_create(new_win, copy_ext->page);
|
||||
ext->btn_size = copy_ext->btn_size;
|
||||
|
||||
/*Copy the control buttons*/
|
||||
lv_obj_t * child;
|
||||
lv_obj_t * cbtn;
|
||||
child = lv_obj_get_child_back(copy_ext->header, NULL);
|
||||
/*Copy the control buttons*/
|
||||
lv_obj_t * child;
|
||||
lv_obj_t * cbtn;
|
||||
child = lv_obj_get_child_back(copy_ext->header, NULL);
|
||||
child = lv_obj_get_child_back(copy_ext->header, child); /*Sip the title*/
|
||||
while(child != NULL) {
|
||||
cbtn = lv_btn_create(ext->header, child);
|
||||
lv_img_create(cbtn, lv_obj_get_child(child, NULL));
|
||||
child = lv_obj_get_child_back(copy_ext->header, child);
|
||||
}
|
||||
while(child != NULL) {
|
||||
cbtn = lv_btn_create(ext->header, child);
|
||||
lv_img_create(cbtn, lv_obj_get_child(child, NULL));
|
||||
child = lv_obj_get_child_back(copy_ext->header, child);
|
||||
}
|
||||
|
||||
lv_obj_set_signal_func(new_win, lv_win_signal);
|
||||
|
||||
@ -153,7 +153,7 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_action_t rel_
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
lv_obj_t *btn = lv_btn_create(ext->header, NULL);
|
||||
lv_obj_t * btn = lv_btn_create(ext->header, NULL);
|
||||
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);
|
||||
@ -179,11 +179,11 @@ lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src, lv_action_t rel_
|
||||
*/
|
||||
lv_res_t lv_win_close_action(lv_obj_t * btn)
|
||||
{
|
||||
lv_obj_t * win = lv_win_get_from_btn(btn);
|
||||
lv_obj_t * win = lv_win_get_from_btn(btn);
|
||||
|
||||
lv_obj_del(win);
|
||||
lv_obj_del(win);
|
||||
|
||||
return LV_RES_INV;
|
||||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,10 +193,10 @@ lv_res_t lv_win_close_action(lv_obj_t * btn)
|
||||
*/
|
||||
void lv_win_set_title(lv_obj_t * win, const char * title)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
lv_label_set_text(ext->title, title);
|
||||
lv_win_realign(win);
|
||||
lv_label_set_text(ext->title, title);
|
||||
lv_win_realign(win);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,7 +219,7 @@ void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size)
|
||||
* @param win pointer to a window object
|
||||
* @param layout the layout from 'lv_layout_t'
|
||||
*/
|
||||
void lv_win_set_layout(lv_obj_t *win, lv_layout_t layout)
|
||||
void lv_win_set_layout(lv_obj_t * win, lv_layout_t layout)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
lv_page_set_scrl_layout(ext->page, layout);
|
||||
@ -230,7 +230,7 @@ void lv_win_set_layout(lv_obj_t *win, lv_layout_t layout)
|
||||
* @param win pointer to a window object
|
||||
* @param sb_mode the new scroll bar mode from 'lv_sb_mode_t'
|
||||
*/
|
||||
void lv_win_set_sb_mode(lv_obj_t *win, lv_sb_mode_t sb_mode)
|
||||
void lv_win_set_sb_mode(lv_obj_t * win, lv_sb_mode_t sb_mode)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
lv_page_set_sb_mode(ext->page, sb_mode);
|
||||
@ -242,11 +242,11 @@ void lv_win_set_sb_mode(lv_obj_t *win, lv_sb_mode_t sb_mode)
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_win_set_style(lv_obj_t *win, lv_win_style_t type, lv_style_t *style)
|
||||
void lv_win_set_style(lv_obj_t * win, lv_win_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_win_ext_t *ext = lv_obj_get_ext_attr(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case LV_WIN_STYLE_BG:
|
||||
lv_obj_set_style(win, style);
|
||||
lv_win_realign(win);
|
||||
@ -274,7 +274,7 @@ void lv_win_set_style(lv_obj_t *win, lv_win_style_t type, lv_style_t *style)
|
||||
|
||||
/*Refresh the existing buttons*/
|
||||
if(type == LV_WIN_STYLE_BTN_REL || type == LV_WIN_STYLE_BTN_PR) {
|
||||
lv_obj_t *btn;
|
||||
lv_obj_t * btn;
|
||||
btn = lv_obj_get_child_back(ext->header, NULL);
|
||||
btn = lv_obj_get_child_back(ext->header, btn); /*Skip the title*/
|
||||
while(btn != NULL) {
|
||||
@ -298,8 +298,8 @@ void lv_win_set_style(lv_obj_t *win, lv_win_style_t type, lv_style_t *style)
|
||||
*/
|
||||
const char * lv_win_get_title(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return lv_label_get_text(ext->title);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return lv_label_get_text(ext->title);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -318,7 +318,7 @@ lv_coord_t lv_win_get_btn_size(lv_obj_t * win)
|
||||
* @param win pointer to a window object
|
||||
* @return the layout of the window (from 'lv_layout_t')
|
||||
*/
|
||||
lv_layout_t lv_win_get_layout(lv_obj_t *win)
|
||||
lv_layout_t lv_win_get_layout(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return lv_page_get_scrl_layout(ext->page);
|
||||
@ -329,7 +329,7 @@ lv_layout_t lv_win_get_layout(lv_obj_t *win)
|
||||
* @param win pointer to a window object
|
||||
* @return the scroll bar mode of the window (from 'lv_sb_mode_t')
|
||||
*/
|
||||
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t *win)
|
||||
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return lv_page_get_sb_mode(ext->page);
|
||||
@ -357,10 +357,10 @@ lv_coord_t lv_win_get_width(lv_obj_t * win)
|
||||
*/
|
||||
lv_obj_t * lv_win_get_from_btn(lv_obj_t * ctrl_btn)
|
||||
{
|
||||
lv_obj_t * header = lv_obj_get_parent(ctrl_btn);
|
||||
lv_obj_t * win = lv_obj_get_parent(header);
|
||||
lv_obj_t * header = lv_obj_get_parent(ctrl_btn);
|
||||
lv_obj_t * win = lv_obj_get_parent(header);
|
||||
|
||||
return win;
|
||||
return win;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,19 +369,27 @@ lv_obj_t * lv_win_get_from_btn(lv_obj_t * ctrl_btn)
|
||||
* @param type which style window be get
|
||||
* @return style pointer to a style
|
||||
*/
|
||||
lv_style_t * lv_win_get_style(lv_obj_t *win, lv_win_style_t type)
|
||||
lv_style_t * lv_win_get_style(lv_obj_t * win, lv_win_style_t type)
|
||||
{
|
||||
lv_win_ext_t *ext = lv_obj_get_ext_attr(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
switch (type) {
|
||||
case LV_WIN_STYLE_BG: return lv_obj_get_style(win);
|
||||
case LV_WIN_STYLE_CONTENT_BG: return lv_page_get_style(ext->page, LV_PAGE_STYLE_BG);
|
||||
case LV_WIN_STYLE_CONTENT_SCRL: return lv_page_get_style(ext->page, LV_PAGE_STYLE_SCRL);
|
||||
case LV_WIN_STYLE_SB: return lv_page_get_style(ext->page, LV_PAGE_STYLE_SB);
|
||||
case LV_WIN_STYLE_HEADER: return lv_obj_get_style(ext->header);
|
||||
case LV_WIN_STYLE_BTN_REL: return ext->style_btn_rel;
|
||||
case LV_WIN_STYLE_BTN_PR: return ext->style_btn_pr;
|
||||
default: return NULL;
|
||||
switch(type) {
|
||||
case LV_WIN_STYLE_BG:
|
||||
return lv_obj_get_style(win);
|
||||
case LV_WIN_STYLE_CONTENT_BG:
|
||||
return lv_page_get_style(ext->page, LV_PAGE_STYLE_BG);
|
||||
case LV_WIN_STYLE_CONTENT_SCRL:
|
||||
return lv_page_get_style(ext->page, LV_PAGE_STYLE_SCRL);
|
||||
case LV_WIN_STYLE_SB:
|
||||
return lv_page_get_style(ext->page, LV_PAGE_STYLE_SB);
|
||||
case LV_WIN_STYLE_HEADER:
|
||||
return lv_obj_get_style(ext->header);
|
||||
case LV_WIN_STYLE_BTN_REL:
|
||||
return ext->style_btn_rel;
|
||||
case LV_WIN_STYLE_BTN_PR:
|
||||
return ext->style_btn_pr;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*To avoid warning*/
|
||||
@ -400,7 +408,7 @@ lv_style_t * lv_win_get_style(lv_obj_t *win, lv_win_style_t type)
|
||||
*/
|
||||
void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, uint16_t anim_time)
|
||||
{
|
||||
lv_win_ext_t *ext = lv_obj_get_ext_attr(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
lv_page_focus(ext->page, obj, anim_time);
|
||||
}
|
||||
|
||||
@ -439,23 +447,19 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_win_realign(win);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/*If the size is changed refresh the window*/
|
||||
if(lv_area_get_width(param) != lv_obj_get_width(win) ||
|
||||
lv_area_get_height(param) != lv_obj_get_height(win)) {
|
||||
lv_area_get_height(param) != lv_obj_get_height(win)) {
|
||||
lv_win_realign(win);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
ext->header = NULL; /*These objects were children so they are already invalid*/
|
||||
ext->page = NULL;
|
||||
ext->title = NULL;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
||||
@ -478,12 +482,12 @@ static void lv_win_realign(lv_obj_t * win)
|
||||
|
||||
if(ext->page == NULL || ext->header == NULL || ext->title == NULL) return;
|
||||
|
||||
lv_style_t *header_style = lv_win_get_style(win, LV_WIN_STYLE_HEADER);
|
||||
lv_style_t * header_style = lv_win_get_style(win, LV_WIN_STYLE_HEADER);
|
||||
lv_obj_set_size(ext->header, lv_obj_get_width(win), ext->btn_size + 2 * header_style->body.padding.ver);
|
||||
|
||||
bool first_btn = true;
|
||||
lv_obj_t *btn;
|
||||
lv_obj_t *btn_prev = NULL;
|
||||
lv_obj_t * btn;
|
||||
lv_obj_t * btn_prev = NULL;
|
||||
/*Refresh the size of all control buttons*/
|
||||
btn = lv_obj_get_child_back(ext->header, NULL);
|
||||
btn = lv_obj_get_child_back(ext->header, btn); /*Skip the title*/
|
||||
@ -504,8 +508,8 @@ static void lv_win_realign(lv_obj_t * win)
|
||||
|
||||
lv_obj_set_pos(ext->header, 0, 0);
|
||||
|
||||
lv_obj_set_size( ext->page, lv_obj_get_width(win), lv_obj_get_height(win) - lv_obj_get_height(ext->header));
|
||||
lv_obj_align( ext->page, ext->header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
lv_obj_set_size(ext->page, lv_obj_get_width(win), lv_obj_get_height(win) - lv_obj_get_height(ext->header));
|
||||
lv_obj_align(ext->page, ext->header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -23,7 +23,7 @@
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_theme_t *current_theme;
|
||||
static lv_theme_t * current_theme;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -38,7 +38,7 @@ static lv_theme_t *current_theme;
|
||||
* From now, all the created objects will use styles from this theme by default
|
||||
* @param th pointer to theme (return value of: 'lv_theme_init_xxx()')
|
||||
*/
|
||||
void lv_theme_set_current(lv_theme_t *th)
|
||||
void lv_theme_set_current(lv_theme_t * th)
|
||||
{
|
||||
current_theme = th;
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ static void led_init(void)
|
||||
lv_style_copy(&led, &lv_style_pretty_color);
|
||||
led.body.shadow.width = LV_DPI / 10;
|
||||
led.body.radius = LV_RADIUS_CIRCLE;
|
||||
led.body.border.width= LV_DPI / 30;
|
||||
led.body.border.width = LV_DPI / 30;
|
||||
led.body.border.opa = LV_OPA_30;
|
||||
led.body.main_color = lv_color_hsv_to_rgb(_hue, 100, 100);
|
||||
led.body.grad_color = lv_color_hsv_to_rgb(_hue, 100, 40);
|
||||
@ -701,7 +701,7 @@ static void win_init(void)
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t *font)
|
||||
lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
@ -710,8 +710,8 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t *font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t **style_p = (lv_style_t**) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ static void basic_init(void)
|
||||
|
||||
lv_style_copy(&plain_bordered, &lv_style_plain);
|
||||
plain_bordered.body.border.width = 2;
|
||||
plain_bordered.body.border.color= LV_COLOR_HEX3(0xbbb);
|
||||
plain_bordered.body.border.color = LV_COLOR_HEX3(0xbbb);
|
||||
|
||||
theme.bg = &lv_style_plain;
|
||||
theme.panel = &lv_style_pretty;
|
||||
@ -125,7 +125,7 @@ static void led_init(void)
|
||||
lv_style_copy(&led, &lv_style_pretty_color);
|
||||
led.body.shadow.width = LV_DPI / 10;
|
||||
led.body.radius = LV_RADIUS_CIRCLE;
|
||||
led.body.border.width= LV_DPI / 30;
|
||||
led.body.border.width = LV_DPI / 30;
|
||||
led.body.border.opa = LV_OPA_30;
|
||||
led.body.shadow.color = led.body.main_color;
|
||||
|
||||
@ -367,7 +367,7 @@ static void win_init(void)
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t *font)
|
||||
lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
@ -376,8 +376,8 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t *font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t **style_p = (lv_style_t**) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ static void led_init(void)
|
||||
lv_style_copy(&led, &def);
|
||||
led.body.shadow.width = LV_DPI / 10;
|
||||
led.body.radius = LV_RADIUS_CIRCLE;
|
||||
led.body.border.width= LV_DPI / 30;
|
||||
led.body.border.width = LV_DPI / 30;
|
||||
led.body.border.opa = LV_OPA_30;
|
||||
led.body.main_color = lv_color_hsv_to_rgb(_hue, 100, 100);
|
||||
led.body.grad_color = lv_color_hsv_to_rgb(_hue, 100, 100);
|
||||
@ -326,7 +326,7 @@ static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
static lv_style_t rel, pr, tgl_rel, tgl_pr, ina;
|
||||
lv_style_copy(&rel,theme.panel);
|
||||
lv_style_copy(&rel, theme.panel);
|
||||
rel.body.shadow.type = LV_SHADOW_BOTTOM;
|
||||
rel.body.shadow.width = 3;
|
||||
|
||||
@ -363,13 +363,13 @@ static void btnm_init(void)
|
||||
#if USE_LV_BTNM
|
||||
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
|
||||
|
||||
lv_style_copy(&bg,theme.panel);
|
||||
lv_style_copy(&bg, theme.panel);
|
||||
bg.body.padding.hor = 0;
|
||||
bg.body.padding.ver = 0;
|
||||
bg.body.padding.inner = 0;
|
||||
bg.text.color = LV_COLOR_HEX3(0x555);
|
||||
|
||||
lv_style_copy(&rel,theme.panel);
|
||||
lv_style_copy(&rel, theme.panel);
|
||||
rel.body.border.part = LV_BORDER_RIGHT;
|
||||
rel.body.border.width = 1;
|
||||
rel.body.border.color = LV_COLOR_HEX3(0xbbb);
|
||||
@ -695,7 +695,7 @@ static void win_init(void)
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t *font)
|
||||
lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
@ -704,8 +704,8 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t *font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t **style_p = (lv_style_t**) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
|
@ -346,9 +346,9 @@ static void list_init(void)
|
||||
static void ddlist_init(void)
|
||||
{
|
||||
#if USE_LV_DDLIST != 0
|
||||
static lv_style_t bg;
|
||||
lv_style_copy(&bg, &light_frame);
|
||||
bg.text.line_space = LV_DPI / 12;
|
||||
static lv_style_t bg;
|
||||
lv_style_copy(&bg, &light_frame);
|
||||
bg.text.line_space = LV_DPI / 12;
|
||||
|
||||
theme.ddlist.bg = &bg;
|
||||
theme.ddlist.sel = &dark_plain;
|
||||
@ -359,9 +359,9 @@ static void ddlist_init(void)
|
||||
static void roller_init(void)
|
||||
{
|
||||
#if USE_LV_ROLLER != 0
|
||||
static lv_style_t bg;
|
||||
lv_style_copy(&bg, &light_frame);
|
||||
bg.text.line_space = LV_DPI / 12;
|
||||
static lv_style_t bg;
|
||||
lv_style_copy(&bg, &light_frame);
|
||||
bg.text.line_space = LV_DPI / 12;
|
||||
|
||||
theme.roller.bg = &bg;
|
||||
theme.roller.sel = &dark_frame;
|
||||
@ -414,7 +414,7 @@ static void win_init(void)
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t *font)
|
||||
lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
@ -423,8 +423,8 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t *font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t **style_p = (lv_style_t**) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ static void led_init(void)
|
||||
lv_style_copy(&led, &def);
|
||||
led.body.shadow.width = LV_DPI / 10;
|
||||
led.body.radius = LV_RADIUS_CIRCLE;
|
||||
led.body.border.width= LV_DPI / 30;
|
||||
led.body.border.width = LV_DPI / 30;
|
||||
led.body.border.opa = LV_OPA_30;
|
||||
led.body.main_color = lv_color_hsv_to_rgb(_hue, 100, 100);
|
||||
led.body.grad_color = lv_color_hsv_to_rgb(_hue, 100, 40);
|
||||
@ -583,7 +583,7 @@ static void win_init(void)
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t *font)
|
||||
lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
@ -592,8 +592,8 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t *font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t **style_p = (lv_style_t**) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ static void win_init(void)
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t *font)
|
||||
lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
@ -343,8 +343,8 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t *font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t **style_p = (lv_style_t**) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ static void led_init(void)
|
||||
lv_style_copy(&led, &lv_style_pretty_color);
|
||||
led.body.shadow.width = LV_DPI / 10;
|
||||
led.body.radius = LV_RADIUS_CIRCLE;
|
||||
led.body.border.width= LV_DPI / 30;
|
||||
led.body.border.width = LV_DPI / 30;
|
||||
led.body.border.opa = LV_OPA_30;
|
||||
led.body.main_color = lv_color_hsv_to_rgb(_hue, 60, 100);
|
||||
led.body.grad_color = lv_color_hsv_to_rgb(_hue, 60, 40);
|
||||
@ -305,7 +305,7 @@ static void chart_init(void)
|
||||
static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
static lv_style_t rel ,pr, tgl_rel, tgl_pr, ina;
|
||||
static lv_style_t rel, pr, tgl_rel, tgl_pr, ina;
|
||||
lv_style_copy(&rel, &def);
|
||||
rel.body.radius = LV_DPI / 20;
|
||||
rel.body.shadow.width = 0;
|
||||
@ -348,7 +348,7 @@ static void cb_init(void)
|
||||
static void btnm_init(void)
|
||||
{
|
||||
#if USE_LV_BTNM
|
||||
static lv_style_t bg, rel ,pr, tgl_rel, tgl_pr, ina;
|
||||
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
|
||||
|
||||
lv_style_copy(&bg, &lv_style_transp);
|
||||
bg.glass = 0;
|
||||
@ -397,15 +397,15 @@ static void btnm_init(void)
|
||||
static void kb_init(void)
|
||||
{
|
||||
#if USE_LV_KB
|
||||
static lv_style_t bg, rel ,pr, tgl_rel, tgl_pr, ina;
|
||||
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
|
||||
lv_style_copy(&bg, &def);
|
||||
bg.body.main_color = LV_COLOR_HEX3(0x666);
|
||||
bg.body.grad_color = bg.body.main_color;
|
||||
bg.body.padding.hor = 0;
|
||||
bg.body.padding.ver = 0;
|
||||
bg.body.padding.inner = 0;
|
||||
bg.body.radius = 0;
|
||||
bg.body.border.width = 0;
|
||||
bg.body.main_color = LV_COLOR_HEX3(0x666);
|
||||
bg.body.grad_color = bg.body.main_color;
|
||||
bg.body.padding.hor = 0;
|
||||
bg.body.padding.ver = 0;
|
||||
bg.body.padding.inner = 0;
|
||||
bg.body.radius = 0;
|
||||
bg.body.border.width = 0;
|
||||
|
||||
lv_style_copy(&rel, &def);
|
||||
rel.body.empty = 1;
|
||||
@ -676,7 +676,7 @@ static void win_init(void)
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t *font)
|
||||
lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
@ -685,8 +685,8 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t *font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t **style_p = (lv_style_t**) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user