mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
run clang format
This commit is contained in:
parent
80e2a1d5d5
commit
ba2160042a
@ -35,7 +35,8 @@
|
||||
|
||||
/**
|
||||
* Return with a pointer to the active screen
|
||||
* @param disp pointer to display which active screen should be get. (NULL to use the default screen)
|
||||
* @param disp pointer to display which active screen should be get. (NULL to use the default
|
||||
* screen)
|
||||
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp)
|
||||
@ -79,7 +80,8 @@ lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top layer)
|
||||
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top
|
||||
* layer)
|
||||
* @param disp pointer to display which sys. layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
|
@ -30,7 +30,8 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* Return with a pointer to the active screen
|
||||
* @param disp pointer to display which active screen should be get. (NULL to use the default screen)
|
||||
* @param disp pointer to display which active screen should be get. (NULL to use the default
|
||||
* screen)
|
||||
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp);
|
||||
@ -49,7 +50,8 @@ void lv_disp_set_scr_act(lv_obj_t * scr);
|
||||
lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top layer)
|
||||
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top
|
||||
* layer)
|
||||
* @param disp pointer to display which sys. layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
@ -95,7 +97,6 @@ void lv_disp_trig_activity(lv_disp_t * disp);
|
||||
static inline lv_obj_t * lv_scr_act(void)
|
||||
{
|
||||
return lv_disp_get_scr_act(lv_disp_get_default());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,7 +122,6 @@ static inline void lv_scr_load(lv_obj_t * scr)
|
||||
lv_disp_set_scr_act(scr);
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -30,12 +30,11 @@
|
||||
static void style_mod_def(lv_group_t * group, lv_style_t * style);
|
||||
static void style_mod_edit_def(lv_group_t * group, lv_style_t * style);
|
||||
static void refresh_theme(lv_group_t * g, lv_theme_t * th);
|
||||
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *), void * (*move)(const lv_ll_t *, const void *));
|
||||
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
|
||||
void * (*move)(const lv_ll_t *, const void *));
|
||||
static void lv_group_refocus(lv_group_t * g);
|
||||
static void obj_to_foreground(lv_obj_t * obj);
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@ -85,7 +84,6 @@ lv_group_t * lv_group_create(void)
|
||||
memset(&group->style_mod_edit_user_data, 0, sizeof(lv_group_user_data_t));
|
||||
#endif
|
||||
|
||||
|
||||
/*Initialize style modification callbacks from current theme*/
|
||||
refresh_theme(group, lv_theme_get_current());
|
||||
|
||||
@ -106,7 +104,8 @@ void lv_group_del(lv_group_t * group)
|
||||
|
||||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
LV_LL_READ(group->obj_ll, obj) {
|
||||
LV_LL_READ(group->obj_ll, obj)
|
||||
{
|
||||
(*obj)->group_p = NULL;
|
||||
}
|
||||
|
||||
@ -125,7 +124,8 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
||||
|
||||
/*Do not add the object twice*/
|
||||
lv_obj_t ** obj_i;
|
||||
LV_LL_READ(group->obj_ll, obj_i) {
|
||||
LV_LL_READ(group->obj_ll, obj_i)
|
||||
{
|
||||
if((*obj_i) == obj) {
|
||||
LV_LOG_INFO("lv_group_add_obj: the object is already added to this group");
|
||||
return;
|
||||
@ -162,12 +162,14 @@ 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)*/
|
||||
|
||||
/*Focus on the next object*/
|
||||
if(*g->obj_focus == obj) {
|
||||
/*If this is the only object in the group then focus to nothing.*/
|
||||
if(lv_ll_get_head(&g->obj_ll) == g->obj_focus && lv_ll_get_tail(&g->obj_ll) == g->obj_focus) {
|
||||
if(lv_ll_get_head(&g->obj_ll) == g->obj_focus &&
|
||||
lv_ll_get_tail(&g->obj_ll) == g->obj_focus) {
|
||||
(*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
}
|
||||
/*If there more objects in the group then focus to the next/prev object*/
|
||||
@ -176,15 +178,17 @@ void lv_group_remove_obj(lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 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;
|
||||
}
|
||||
|
||||
/*Search the object and remove it from its group */
|
||||
lv_obj_t ** i;
|
||||
LV_LL_READ(g->obj_ll, i) {
|
||||
LV_LL_READ(g->obj_ll, i)
|
||||
{
|
||||
if(*i == obj) {
|
||||
lv_ll_rem(&g->obj_ll, i);
|
||||
lv_mem_free(i);
|
||||
@ -210,7 +214,8 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
||||
lv_group_set_editing(g, false);
|
||||
|
||||
lv_obj_t ** i;
|
||||
LV_LL_READ(g->obj_ll, i) {
|
||||
LV_LL_READ(g->obj_ll, i)
|
||||
{
|
||||
if(*i == obj) {
|
||||
if(g->obj_focus == i) return; /*Don't focus the already focused object again*/
|
||||
if(g->obj_focus != NULL) {
|
||||
@ -262,8 +267,10 @@ void lv_group_focus_prev(lv_group_t * group)
|
||||
*/
|
||||
void lv_group_focus_freeze(lv_group_t * group, bool en)
|
||||
{
|
||||
if(en == false) group->frozen = 0;
|
||||
else group->frozen = 1;
|
||||
if(en == false)
|
||||
group->frozen = 0;
|
||||
else
|
||||
group->frozen = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,7 +334,8 @@ void lv_group_set_editing(lv_group_t * group, bool edit)
|
||||
lv_obj_t * focused = lv_group_get_focused(group);
|
||||
|
||||
if(focused) {
|
||||
focused->signal_cb(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave/open edit/navigate mode*/
|
||||
focused->signal_cb(focused, LV_SIGNAL_FOCUS,
|
||||
NULL); /*Focus again to properly leave/open edit/navigate mode*/
|
||||
lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, NULL);
|
||||
if(res != LV_RES_OK) return;
|
||||
}
|
||||
@ -345,7 +353,8 @@ void lv_group_set_click_focus(lv_group_t * group, bool en)
|
||||
group->click_focus = en ? 1 : 0;
|
||||
}
|
||||
|
||||
void lv_group_set_refocus_policy(lv_group_t * group, lv_group_refocus_policy_t policy) {
|
||||
void lv_group_set_refocus_policy(lv_group_t * group, lv_group_refocus_policy_t policy)
|
||||
{
|
||||
group->refocus_policy = policy & 0x01;
|
||||
}
|
||||
|
||||
@ -403,7 +412,6 @@ lv_group_user_data_t * lv_group_get_user_data(lv_group_t * group)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Get a the style modifier function of a group
|
||||
* @param group pointer to a group
|
||||
@ -471,7 +479,8 @@ bool lv_group_get_wrap(lv_group_t * group)
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the group that current theme changed and style modification callbacks need to be refreshed.
|
||||
* Notify the group that current theme changed and style modification callbacks need to be
|
||||
* refreshed.
|
||||
* @param group pointer to group. If NULL then all groups are notified.
|
||||
*/
|
||||
void lv_group_report_style_mod(lv_group_t * group)
|
||||
@ -484,7 +493,8 @@ void lv_group_report_style_mod(lv_group_t * group)
|
||||
}
|
||||
|
||||
lv_group_t * i;
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_group_ll), i) {
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_group_ll), i)
|
||||
{
|
||||
refresh_theme(i, th);
|
||||
}
|
||||
}
|
||||
@ -493,7 +503,8 @@ void lv_group_report_style_mod(lv_group_t * group)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_group_refocus(lv_group_t *g) {
|
||||
static void lv_group_refocus(lv_group_t * g)
|
||||
{
|
||||
/*Refocus must temporarily allow wrapping to work correctly*/
|
||||
uint8_t temp_wrap = g->wrap;
|
||||
g->wrap = 1;
|
||||
@ -521,7 +532,8 @@ static void style_mod_def(lv_group_t * group, lv_style_t * style)
|
||||
style->body.border.color = LV_COLOR_ORANGE;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0)
|
||||
style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
@ -534,7 +546,6 @@ static void style_mod_def(lv_group_t * group, lv_style_t * style)
|
||||
style->body.border.width = 2;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -552,7 +563,8 @@ static void style_mod_edit_def(lv_group_t * group, lv_style_t * style)
|
||||
style->body.border.color = LV_COLOR_GREEN;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0)
|
||||
style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
@ -565,7 +577,6 @@ static void style_mod_edit_def(lv_group_t * group, lv_style_t * style)
|
||||
style->body.border.width = 3;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void refresh_theme(lv_group_t * g, lv_theme_t * th)
|
||||
@ -573,14 +584,13 @@ static void refresh_theme(lv_group_t * g, lv_theme_t * th)
|
||||
g->style_mod = style_mod_def;
|
||||
g->style_mod_edit = style_mod_edit_def;
|
||||
if(th) {
|
||||
if(th->group.style_mod)
|
||||
g->style_mod = th->group.style_mod;
|
||||
if(th->group.style_mod_edit)
|
||||
g->style_mod_edit = th->group.style_mod_edit;
|
||||
if(th->group.style_mod) g->style_mod = th->group.style_mod;
|
||||
if(th->group.style_mod_edit) g->style_mod_edit = th->group.style_mod_edit;
|
||||
}
|
||||
}
|
||||
|
||||
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *), void * (*move)(const lv_ll_t *, const void *))
|
||||
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
|
||||
void * (*move)(const lv_ll_t *, const void *))
|
||||
{
|
||||
if(group->frozen) return;
|
||||
|
||||
@ -622,7 +632,8 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
|
||||
if(!lv_obj_get_hidden(*obj_next)) break;
|
||||
}
|
||||
|
||||
if(obj_next == group->obj_focus) return; /*There's only one visible object and it's already focused*/
|
||||
if(obj_next == group->obj_focus)
|
||||
return; /*There's only one visible object and it's already focused*/
|
||||
|
||||
if(group->obj_focus) {
|
||||
(*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
|
@ -52,8 +52,10 @@ typedef struct _lv_group_t
|
||||
{
|
||||
lv_ll_t obj_ll; /*Linked list to store the objects in the group */
|
||||
lv_obj_t ** obj_focus; /*The object in focus*/
|
||||
lv_group_style_mod_func_t style_mod; /*A function which modifies the style of the focused object*/
|
||||
lv_group_style_mod_func_t style_mod_edit;/*A function which modifies the style of the focused object*/
|
||||
lv_group_style_mod_func_t
|
||||
style_mod; /*A function which modifies the style of the focused object*/
|
||||
lv_group_style_mod_func_t
|
||||
style_mod_edit; /*A function which modifies the style of the focused object*/
|
||||
lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/
|
||||
lv_style_t style_tmp; /*Stores the modified style of the focused object */
|
||||
#if LV_USE_USER_DATA_SINGLE
|
||||
@ -68,15 +70,15 @@ typedef struct _lv_group_t
|
||||
|
||||
uint8_t frozen : 1; /*1: can't focus to new object*/
|
||||
uint8_t editing : 1; /*1: Edit mode, 0: Navigate mode*/
|
||||
uint8_t click_focus :1; /*1: If an object in a group is clicked by an indev then it will be focused */
|
||||
uint8_t refocus_policy :1; /*1: Focus prev if focused on deletion. 0: Focus next if focused on deletion.*/
|
||||
uint8_t wrap :1; /*1: Focus next/prev can wrap at end of list. 0: Focus next/prev stops at end of list.*/
|
||||
uint8_t click_focus : 1; /*1: If an object in a group is clicked by an indev then it will be
|
||||
focused */
|
||||
uint8_t refocus_policy : 1; /*1: Focus prev if focused on deletion. 0: Focus next if focused on
|
||||
deletion.*/
|
||||
uint8_t wrap : 1; /*1: Focus next/prev can wrap at end of list. 0: Focus next/prev stops at end
|
||||
of list.*/
|
||||
} lv_group_t;
|
||||
|
||||
enum {
|
||||
LV_GROUP_REFOCUS_POLICY_NEXT = 0,
|
||||
LV_GROUP_REFOCUS_POLICY_PREV = 1
|
||||
};
|
||||
enum { LV_GROUP_REFOCUS_POLICY_NEXT = 0, LV_GROUP_REFOCUS_POLICY_PREV = 1 };
|
||||
typedef uint8_t lv_group_refocus_policy_t;
|
||||
|
||||
/**********************
|
||||
@ -169,7 +171,8 @@ void lv_group_set_style_mod_edit_cb(lv_group_t * group, lv_group_style_mod_func_
|
||||
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb);
|
||||
|
||||
/**
|
||||
* Set whether the next or previous item in a group is focused if the currently focussed obj is deleted.
|
||||
* Set whether the next or previous item in a group is focused if the currently focussed obj is
|
||||
* deleted.
|
||||
* @param group pointer to a group
|
||||
* @param new refocus policy enum
|
||||
*/
|
||||
@ -264,7 +267,8 @@ bool lv_group_get_click_focus(const lv_group_t * group);
|
||||
bool lv_group_get_wrap(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Notify the group that current theme changed and style modification callbacks need to be refreshed.
|
||||
* Notify the group that current theme changed and style modification callbacks need to be
|
||||
* refreshed.
|
||||
* @param group pointer to group. If NULL then all groups are notified.
|
||||
*/
|
||||
void lv_group_report_style_mod(lv_group_t * group);
|
||||
|
@ -115,10 +115,10 @@ void lv_indev_read_task(void * param)
|
||||
LV_LOG_TRACE("indev read task finished");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the currently processed input device. Can be used in action functions too.
|
||||
* @return pointer to the currently processed input device or NULL if no input device processing right now
|
||||
* @return pointer to the currently processed input device or NULL if no input device processing
|
||||
* right now
|
||||
*/
|
||||
lv_indev_t * lv_indev_get_act(void)
|
||||
{
|
||||
@ -142,7 +142,8 @@ lv_indev_type_t lv_indev_get_type(const lv_indev_t * indev)
|
||||
*/
|
||||
void lv_indev_reset(lv_indev_t * indev)
|
||||
{
|
||||
if(indev) indev->proc.reset_query = 1;
|
||||
if(indev)
|
||||
indev->proc.reset_query = 1;
|
||||
else {
|
||||
lv_indev_t * i = lv_indev_get_next(NULL);
|
||||
while(i) {
|
||||
@ -186,7 +187,8 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
|
||||
|
||||
indev->cursor = cur_obj;
|
||||
lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp));
|
||||
lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y);
|
||||
lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x,
|
||||
indev->proc.types.pointer.act_point.y);
|
||||
}
|
||||
|
||||
#if LV_USE_GROUP
|
||||
@ -249,24 +251,29 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point)
|
||||
*/
|
||||
uint32_t lv_indev_get_key(const lv_indev_t * indev)
|
||||
{
|
||||
if(indev->driver.type != LV_INDEV_TYPE_KEYPAD) return 0;
|
||||
else return indev->proc.types.keypad.last_key;
|
||||
if(indev->driver.type != LV_INDEV_TYPE_KEYPAD)
|
||||
return 0;
|
||||
else
|
||||
return indev->proc.types.keypad.last_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
|
||||
* Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and
|
||||
* LV_INDEV_TYPE_BUTTON)
|
||||
* @param indev pointer to an input device
|
||||
* @return true: drag is in progress
|
||||
*/
|
||||
bool lv_indev_is_dragging(const lv_indev_t * indev)
|
||||
{
|
||||
if(indev == NULL) return false;
|
||||
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) return false;
|
||||
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON)
|
||||
return false;
|
||||
return indev->proc.types.pointer.drag_in_prog == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the types.pointer.vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
|
||||
* Get the types.pointer.vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and
|
||||
* LV_INDEV_TYPE_BUTTON)
|
||||
* @param indev pointer to an input device
|
||||
* @param point pointer to a point to store the types.pointer.vector
|
||||
*/
|
||||
@ -334,8 +341,7 @@ lv_task_t * lv_indev_get_read_task(lv_disp_t * indev)
|
||||
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.types.pointer.last_point.x != data->point.x ||
|
||||
if(i->cursor != NULL && (i->proc.types.pointer.last_point.x != data->point.x ||
|
||||
i->proc.types.pointer.last_point.y != data->point.y)) {
|
||||
lv_obj_set_pos(i->cursor, data->point.x, data->point.y);
|
||||
}
|
||||
@ -390,8 +396,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
i->proc.types.keypad.last_state = data->state;
|
||||
|
||||
/*Key press happened*/
|
||||
if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_REL)
|
||||
{
|
||||
if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_REL) {
|
||||
i->proc.pr_timestamp = lv_tick_get();
|
||||
|
||||
/*Simulate a press on the object if ENTER was pressed*/
|
||||
@ -406,13 +411,15 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
/*Move the focus on NEXT*/
|
||||
else if(data->key == LV_GROUP_KEY_NEXT) {
|
||||
lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
|
||||
lv_group_set_editing(g,
|
||||
false); /*Editing is not used by KEYPAD is be sure it is disabled*/
|
||||
lv_group_focus_next(g);
|
||||
if(i->proc.reset_query) return; /*The object might be deleted*/
|
||||
}
|
||||
/*Move the focus on PREV*/
|
||||
else if(data->key == LV_GROUP_KEY_PREV) {
|
||||
lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
|
||||
lv_group_set_editing(g,
|
||||
false); /*Editing is not used by KEYPAD is be sure it is disabled*/
|
||||
lv_group_focus_prev(g);
|
||||
if(i->proc.reset_query) return; /*The object might be deleted*/
|
||||
}
|
||||
@ -422,10 +429,10 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Pressing*/
|
||||
else if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_PR)
|
||||
{
|
||||
else if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_PR) {
|
||||
/*Long press time has elapsed?*/
|
||||
if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
|
||||
if(i->proc.long_pr_sent == 0 &&
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
|
||||
i->proc.long_pr_sent = 1;
|
||||
if(data->key == LV_GROUP_KEY_ENTER) {
|
||||
i->proc.longpr_rep_timestamp = lv_tick_get();
|
||||
@ -436,7 +443,8 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Long press repeated time has elapsed?*/
|
||||
else if(i->proc.long_pr_sent != 0 && lv_tick_elaps(i->proc.longpr_rep_timestamp) > i->driver.long_press_rep_time) {
|
||||
else if(i->proc.long_pr_sent != 0 &&
|
||||
lv_tick_elaps(i->proc.longpr_rep_timestamp) > i->driver.long_press_rep_time) {
|
||||
|
||||
i->proc.longpr_rep_timestamp = lv_tick_get();
|
||||
|
||||
@ -449,13 +457,15 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
/*Move the focus on NEXT again*/
|
||||
else if(data->key == LV_GROUP_KEY_NEXT) {
|
||||
lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
|
||||
lv_group_set_editing(
|
||||
g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
|
||||
lv_group_focus_next(g);
|
||||
if(i->proc.reset_query) return; /*The object might be deleted*/
|
||||
}
|
||||
/*Move the focus on PREV again*/
|
||||
else if(data->key == LV_GROUP_KEY_PREV) {
|
||||
lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
|
||||
lv_group_set_editing(
|
||||
g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/
|
||||
lv_group_focus_prev(g);
|
||||
if(i->proc.reset_query) return; /*The object might be deleted*/
|
||||
}
|
||||
@ -467,8 +477,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Release happened*/
|
||||
else if(data->state == LV_INDEV_STATE_REL && prev_state == LV_INDEV_STATE_PR)
|
||||
{
|
||||
else if(data->state == LV_INDEV_STATE_REL && prev_state == LV_INDEV_STATE_PR) {
|
||||
/*The user might clear the key when it was released. Always release the pressed key*/
|
||||
data->key = prev_key;
|
||||
if(data->key == LV_GROUP_KEY_ENTER) {
|
||||
@ -546,9 +555,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
if(focused == NULL) return;
|
||||
|
||||
/*Button press happened*/
|
||||
if(data->state == LV_INDEV_STATE_PR &&
|
||||
i->proc.types.keypad.last_state == LV_INDEV_STATE_REL)
|
||||
{
|
||||
if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_REL) {
|
||||
bool editable = false;
|
||||
focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
|
||||
@ -562,10 +569,10 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Pressing*/
|
||||
else if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
else if(data->state == LV_INDEV_STATE_PR &&
|
||||
i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
if(i->proc.long_pr_sent == 0 &&
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time)
|
||||
{
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
|
||||
bool editable = false;
|
||||
focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
|
||||
@ -573,7 +580,9 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
if(editable) {
|
||||
/*Don't leave edit mode if there is only one object (nowhere to navigate)*/
|
||||
if(lv_ll_is_empty(&g->obj_ll) == false) {
|
||||
lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/
|
||||
lv_group_set_editing(g, lv_group_get_editing(g)
|
||||
? false
|
||||
: true); /*Toggle edit mode on long press*/
|
||||
}
|
||||
}
|
||||
/*If not editable then just send a long press signal*/
|
||||
@ -587,7 +596,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Release happened*/
|
||||
else if(data->state == LV_INDEV_STATE_REL && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
else if(data->state == LV_INDEV_STATE_REL &&
|
||||
i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
|
||||
bool editable = false;
|
||||
focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
@ -625,7 +635,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
lv_group_send_data(g, LV_GROUP_KEY_ENTER);
|
||||
}
|
||||
}
|
||||
/*If the focused object is editable and now in navigate mode then on enter switch edit mode*/
|
||||
/*If the focused object is editable and now in navigate mode then on enter switch edit
|
||||
mode*/
|
||||
else if(editable && !g->editing && !i->proc.long_pr_sent) {
|
||||
lv_group_set_editing(g, true); /*Set edit mode*/
|
||||
}
|
||||
@ -656,8 +667,7 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
/*Still the same point is pressed*/
|
||||
if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x &&
|
||||
i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y &&
|
||||
data->state == LV_INDEV_STATE_PR)
|
||||
{
|
||||
data->state == LV_INDEV_STATE_PR) {
|
||||
indev_proc_press(&i->proc);
|
||||
} else {
|
||||
/*If a new point comes always make a release*/
|
||||
@ -689,14 +699,14 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
}
|
||||
/*If there is last object but it is not dragged and not protected also search*/
|
||||
else if(proc->types.pointer.drag_in_prog == 0 &&
|
||||
lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now types.pointer.act_obj != NULL*/
|
||||
lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_PRESS_LOST) ==
|
||||
false) { /*Now types.pointer.act_obj != NULL*/
|
||||
pr_obj = indev_search_obj(proc, lv_disp_get_layer_sys(disp));
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_layer_top(disp));
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_scr_act(disp));
|
||||
}
|
||||
/*If a dragable or a protected object was the last then keep it*/
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
/*If a new object was found reset some variables and send a pressed signal*/
|
||||
@ -707,14 +717,16 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
|
||||
/*If a new object found the previous was lost, so send a signal*/
|
||||
if(proc->types.pointer.act_obj != NULL) {
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj,
|
||||
LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
lv_event_send(proc->types.pointer.act_obj, LV_EVENT_PRESS_LOST, NULL);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
}
|
||||
|
||||
proc->types.pointer.act_obj = pr_obj; /*Save the pressed object*/
|
||||
proc->types.pointer.last_obj = proc->types.pointer.act_obj; /*Refresh the types.pointer.last_obj*/
|
||||
proc->types.pointer.last_obj =
|
||||
proc->types.pointer.act_obj; /*Refresh the types.pointer.last_obj*/
|
||||
|
||||
if(proc->types.pointer.act_obj != NULL) {
|
||||
/* Save the time when the obj pressed.
|
||||
@ -745,7 +757,8 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
}
|
||||
|
||||
/*Send a signal about the press*/
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESSED, indev_act);
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESSED,
|
||||
indev_act);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
lv_event_send(proc->types.pointer.act_obj, LV_EVENT_PRESSED, NULL);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
@ -759,18 +772,23 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
proc->types.pointer.drag_throw_vect.x = (proc->types.pointer.drag_throw_vect.x * 5) >> 3;
|
||||
proc->types.pointer.drag_throw_vect.y = (proc->types.pointer.drag_throw_vect.y * 5) >> 3;
|
||||
|
||||
if(proc->types.pointer.drag_throw_vect.x < 0) proc->types.pointer.drag_throw_vect.x++;
|
||||
else if(proc->types.pointer.drag_throw_vect.x > 0) proc->types.pointer.drag_throw_vect.x--;
|
||||
if(proc->types.pointer.drag_throw_vect.x < 0)
|
||||
proc->types.pointer.drag_throw_vect.x++;
|
||||
else if(proc->types.pointer.drag_throw_vect.x > 0)
|
||||
proc->types.pointer.drag_throw_vect.x--;
|
||||
|
||||
if(proc->types.pointer.drag_throw_vect.y < 0) proc->types.pointer.drag_throw_vect.y++;
|
||||
else if(proc->types.pointer.drag_throw_vect.y > 0) proc->types.pointer.drag_throw_vect.y--;
|
||||
if(proc->types.pointer.drag_throw_vect.y < 0)
|
||||
proc->types.pointer.drag_throw_vect.y++;
|
||||
else if(proc->types.pointer.drag_throw_vect.y > 0)
|
||||
proc->types.pointer.drag_throw_vect.y--;
|
||||
|
||||
proc->types.pointer.drag_throw_vect.x += (proc->types.pointer.vect.x * 4) >> 3;
|
||||
proc->types.pointer.drag_throw_vect.y += (proc->types.pointer.vect.y * 4) >> 3;
|
||||
|
||||
/*If there is active object and it can be dragged run the drag*/
|
||||
if(proc->types.pointer.act_obj != NULL) {
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESSING, indev_act);
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESSING,
|
||||
indev_act);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
lv_event_send(proc->types.pointer.act_obj, LV_EVENT_PRESSING, NULL);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
@ -803,7 +821,6 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
lv_event_send(pr_obj, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
proc->longpr_rep_timestamp = lv_tick_get();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -827,9 +844,11 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
if(proc->types.pointer.act_obj) {
|
||||
/* If the object was protected against press lost then it possible that
|
||||
* the object is already not pressed but still it is the `act_obj`.
|
||||
* In this case send the `LV_SIGNAL_RELEASED/CLICKED` instead of `LV_SIGNAL_PRESS_LOST` if the indev is ON the `types.pointer.act_obj` */
|
||||
* In this case send the `LV_SIGNAL_RELEASED/CLICKED` instead of `LV_SIGNAL_PRESS_LOST` if
|
||||
* the indev is ON the `types.pointer.act_obj` */
|
||||
if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_PRESS_LOST)) {
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED,
|
||||
indev_act);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
|
||||
if(proc->long_pr_sent == 0 && proc->types.pointer.drag_in_prog == 0) {
|
||||
@ -846,7 +865,8 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
/* The simple case: `act_obj` was not protected against press lost.
|
||||
* If it is already not pressed then was `indev_proc_press` would set `act_obj = NULL`*/
|
||||
else {
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED,
|
||||
indev_act);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
|
||||
if(proc->long_pr_sent == 0 && proc->types.pointer.drag_in_prog == 0) {
|
||||
@ -870,13 +890,16 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
if(lv_group_get_editing(g)) lv_group_set_editing(g, false);
|
||||
|
||||
/*Check, if the parent is in a group focus on it.*/
|
||||
if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_CLICK_FOCUS) == false) { /*Respect the click focus protection*/
|
||||
if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_CLICK_FOCUS) ==
|
||||
false) { /*Respect the click focus protection*/
|
||||
lv_obj_t * parent = proc->types.pointer.act_obj;
|
||||
|
||||
while(g == NULL) {
|
||||
parent = lv_obj_get_parent(parent);
|
||||
if(parent == NULL) break;
|
||||
if(lv_obj_is_protected(parent, LV_PROTECT_CLICK_FOCUS)) { /*Ignore is the protected against click focus*/
|
||||
if(lv_obj_is_protected(
|
||||
parent,
|
||||
LV_PROTECT_CLICK_FOCUS)) { /*Ignore is the protected against click focus*/
|
||||
parent = NULL;
|
||||
break;
|
||||
}
|
||||
@ -898,7 +921,8 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
* a focus/defucus signal because of `click focus`*/
|
||||
if(proc->types.pointer.last_pressed != proc->types.pointer.act_obj) {
|
||||
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, NULL);
|
||||
if(proc->reset_query) return; /*Not so strict as it's only the previous object and indev not uses it.*/
|
||||
if(proc->reset_query)
|
||||
return; /*Not so strict as it's only the previous object and indev not uses it.*/
|
||||
|
||||
lv_event_send(proc->types.pointer.act_obj, LV_EVENT_FOCUSED, NULL);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
@ -960,7 +984,8 @@ static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj)
|
||||
if(lv_area_is_point_on(&obj->coords, &proc->types.pointer.act_point)) {
|
||||
lv_obj_t * i;
|
||||
|
||||
LV_LL_READ(obj->child_ll, i) {
|
||||
LV_LL_READ(obj->child_ll, i)
|
||||
{
|
||||
found_p = indev_search_obj(proc, i);
|
||||
|
||||
/*If a child was found then break*/
|
||||
@ -980,7 +1005,6 @@ static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj)
|
||||
/*No parent found with hidden == true*/
|
||||
if(hidden_i == NULL) found_p = obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return found_p;
|
||||
@ -995,8 +1019,7 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
lv_obj_t * drag_obj = state->types.pointer.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) {
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false && drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
|
||||
@ -1020,25 +1043,26 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
/*If the drag limit is exceeded handle the dragging*/
|
||||
if(state->types.pointer.drag_limit_out != 0) {
|
||||
/*Set new position if the vector is not zero*/
|
||||
if(state->types.pointer.vect.x != 0 ||
|
||||
state->types.pointer.vect.y != 0)
|
||||
{
|
||||
if(state->types.pointer.vect.x != 0 || state->types.pointer.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);
|
||||
uint16_t inv_buf_size = lv_disp_get_inv_buf_size(indev_act->driver.disp); /*Get the number of currently invalidated areas*/
|
||||
uint16_t inv_buf_size = lv_disp_get_inv_buf_size(
|
||||
indev_act->driver.disp); /*Get the number of currently invalidated areas*/
|
||||
|
||||
lv_coord_t prev_x = drag_obj->coords.x1;
|
||||
lv_coord_t prev_y = drag_obj->coords.y1;
|
||||
lv_coord_t prev_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj));
|
||||
lv_coord_t prev_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj));
|
||||
|
||||
lv_obj_set_pos(drag_obj, act_x + state->types.pointer.vect.x, act_y + state->types.pointer.vect.y);
|
||||
lv_obj_set_pos(drag_obj, act_x + state->types.pointer.vect.x,
|
||||
act_y + state->types.pointer.vect.y);
|
||||
|
||||
/*Set the drag in progress flag if the object is really moved*/
|
||||
if(drag_obj->coords.x1 != prev_x || drag_obj->coords.y1 != prev_y) {
|
||||
if(state->types.pointer.drag_in_prog != 0) { /*Send the drag begin signal on first move*/
|
||||
if(state->types.pointer.drag_in_prog !=
|
||||
0) { /*Send the drag begin signal on first move*/
|
||||
drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act);
|
||||
if(state->reset_query != 0) return;
|
||||
}
|
||||
@ -1053,7 +1077,8 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
lv_coord_t act_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj));
|
||||
if(act_par_w == prev_par_w && act_par_h == prev_par_h) {
|
||||
uint16_t new_inv_buf_size = lv_disp_get_inv_buf_size(indev_act->driver.disp);
|
||||
lv_disp_pop_from_inv_buf(indev_act->driver.disp, new_inv_buf_size - inv_buf_size);
|
||||
lv_disp_pop_from_inv_buf(indev_act->driver.disp,
|
||||
new_inv_buf_size - inv_buf_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1072,8 +1097,7 @@ static void indev_drag_throw(lv_indev_proc_t * proc)
|
||||
lv_obj_t * drag_obj = proc->types.pointer.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) {
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false && drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
|
||||
@ -1089,11 +1113,12 @@ static void indev_drag_throw(lv_indev_proc_t * proc)
|
||||
}
|
||||
|
||||
/*Reduce the vectors*/
|
||||
proc->types.pointer.drag_throw_vect.x = proc->types.pointer.drag_throw_vect.x * (100 - indev_act->driver.drag_throw) / 100;
|
||||
proc->types.pointer.drag_throw_vect.y = proc->types.pointer.drag_throw_vect.y * (100 - indev_act->driver.drag_throw) / 100;
|
||||
proc->types.pointer.drag_throw_vect.x =
|
||||
proc->types.pointer.drag_throw_vect.x * (100 - indev_act->driver.drag_throw) / 100;
|
||||
proc->types.pointer.drag_throw_vect.y =
|
||||
proc->types.pointer.drag_throw_vect.y * (100 - indev_act->driver.drag_throw) / 100;
|
||||
|
||||
if(proc->types.pointer.drag_throw_vect.x != 0 ||
|
||||
proc->types.pointer.drag_throw_vect.y != 0) {
|
||||
if(proc->types.pointer.drag_throw_vect.x != 0 || proc->types.pointer.drag_throw_vect.y != 0) {
|
||||
/*Get the coordinates and modify them*/
|
||||
lv_area_t coords_ori;
|
||||
lv_obj_get_coords(drag_obj, &coords_ori);
|
||||
@ -1114,14 +1139,13 @@ static void indev_drag_throw(lv_indev_proc_t * proc)
|
||||
proc->types.pointer.drag_throw_vect.y = 0;
|
||||
drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
|
||||
}
|
||||
}
|
||||
/*If the types.pointer.vectors become 0 -> types.pointer.drag_in_prog = 0 and send a drag end signal*/
|
||||
/*If the types.pointer.vectors become 0 -> types.pointer.drag_in_prog = 0 and send a drag end
|
||||
signal*/
|
||||
else {
|
||||
proc->types.pointer.drag_in_prog = 0;
|
||||
drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
if(proc->reset_query) return; /*The object might be deleted*/
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,11 +42,11 @@ void lv_indev_read_task(void * param);
|
||||
|
||||
/**
|
||||
* Get the currently processed input device. Can be used in action functions too.
|
||||
* @return pointer to the currently processed input device or NULL if no input device processing right now
|
||||
* @return pointer to the currently processed input device or NULL if no input device processing
|
||||
* right now
|
||||
*/
|
||||
lv_indev_t * lv_indev_get_act(void);
|
||||
|
||||
|
||||
/**
|
||||
* Get the type of an input device
|
||||
* @param indev pointer to an input device
|
||||
@ -119,14 +119,16 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point);
|
||||
uint32_t lv_indev_get_key(const lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
|
||||
* Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and
|
||||
* LV_INDEV_TYPE_BUTTON)
|
||||
* @param indev pointer to an input device
|
||||
* @return true: drag is in progress
|
||||
*/
|
||||
bool lv_indev_is_dragging(const lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
|
||||
* Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and
|
||||
* LV_INDEV_TYPE_BUTTON)
|
||||
* @param indev pointer to an input device
|
||||
* @param point pointer to a point to store the vector
|
||||
*/
|
||||
@ -157,7 +159,6 @@ lv_task_t * lv_indev_get_read_task(lv_disp_t * indev);
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -99,7 +99,6 @@ void lv_init(void)
|
||||
lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t));
|
||||
lv_ll_init(&LV_GC_ROOT(_lv_indev_ll), sizeof(lv_indev_t));
|
||||
|
||||
|
||||
#if LV_INDEV_READ_PERIOD != 0
|
||||
/*Init the input device handling*/
|
||||
lv_indev_init();
|
||||
@ -129,7 +128,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
LV_LOG_TRACE("Screen create started");
|
||||
lv_disp_t * disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("lv_obj_create: not display created to so far. No place to assign the new screen");
|
||||
LV_LOG_WARN(
|
||||
"lv_obj_create: not display created to so far. No place to assign the new screen");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -205,17 +205,14 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
lv_mem_assert(new_obj);
|
||||
if(new_obj == NULL) return NULL;
|
||||
|
||||
|
||||
new_obj->par = parent; /*Set the parent*/
|
||||
lv_ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
||||
|
||||
/*Set coordinates left top corner of parent*/
|
||||
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;
|
||||
new_obj->coords.y2 = parent->coords.y1 +
|
||||
LV_OBJ_DEF_HEIGHT;
|
||||
new_obj->coords.x2 = parent->coords.x1 + LV_OBJ_DEF_WIDTH;
|
||||
new_obj->coords.y2 = parent->coords.y1 + LV_OBJ_DEF_HEIGHT;
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Init realign*/
|
||||
@ -292,7 +289,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
new_obj->realign.auto_realign = copy->realign.auto_realign;
|
||||
#endif
|
||||
|
||||
/*Only copy the `event_cb`. `signal_cb` and `design_cb` will be copied the the derived object type (e.g. `lv_btn`)*/
|
||||
/*Only copy the `event_cb`. `signal_cb` and `design_cb` will be copied the the derived
|
||||
* object type (e.g. `lv_btn`)*/
|
||||
new_obj->event_cb = copy->event_cb;
|
||||
|
||||
/*Copy attributes*/
|
||||
@ -322,7 +320,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
LV_LOG_INFO("Object create ready");
|
||||
}
|
||||
|
||||
|
||||
/*Send a signal to the parent to notify it about the new child*/
|
||||
if(parent != NULL) {
|
||||
parent->signal_cb(parent, LV_SIGNAL_CHILD_CHG, new_obj);
|
||||
@ -444,8 +441,7 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
/*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/
|
||||
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
|
||||
lv_disp_t * disp = lv_obj_get_disp(obj_scr);
|
||||
if(obj_scr == lv_disp_get_scr_act(disp) ||
|
||||
obj_scr == lv_disp_get_layer_top(disp)||
|
||||
if(obj_scr == lv_disp_get_scr_act(disp) || obj_scr == lv_disp_get_layer_top(disp) ||
|
||||
obj_scr == lv_disp_get_layer_sys(disp)) {
|
||||
/*Truncate recursively to the parents*/
|
||||
lv_area_t area_trunc;
|
||||
@ -463,7 +459,8 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
while(par != NULL) {
|
||||
union_ok = lv_area_intersect(&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(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);
|
||||
}
|
||||
@ -472,7 +469,6 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
@ -498,7 +494,6 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
lv_point_t old_pos;
|
||||
@ -571,7 +566,6 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object
|
||||
* @param obj pointer to an object
|
||||
@ -582,7 +576,6 @@ void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x)
|
||||
lv_obj_set_pos(obj, x, lv_obj_get_y(obj));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object
|
||||
* @param obj pointer to an object
|
||||
@ -620,7 +613,6 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
|
||||
obj->coords.x2 = obj->coords.x1 + w - 1;
|
||||
obj->coords.y2 = obj->coords.y1 + h - 1;
|
||||
|
||||
|
||||
/*Send a signal to the object with its new coordinates*/
|
||||
obj->signal_cb(obj, LV_SIGNAL_CORD_CHG, &ori);
|
||||
|
||||
@ -630,7 +622,8 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
|
||||
|
||||
/*Tell the children the parent's size has changed*/
|
||||
lv_obj_t * i;
|
||||
LV_LL_READ(obj->child_ll, i) {
|
||||
LV_LL_READ(obj->child_ll, i)
|
||||
{
|
||||
i->signal_cb(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
|
||||
}
|
||||
|
||||
@ -671,7 +664,8 @@ 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, const 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, const 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);
|
||||
@ -816,7 +810,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
||||
* @param x_mod x coordinate shift after alignment
|
||||
* @param y_mod y coordinate shift after alignment
|
||||
*/
|
||||
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
|
||||
void lv_obj_align_origo(lv_obj_t * obj, const 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);
|
||||
@ -963,8 +958,12 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
void lv_obj_realign(lv_obj_t * obj)
|
||||
{
|
||||
#if LV_OBJ_REALIGN
|
||||
if(obj->realign.origo_align) lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
|
||||
else lv_obj_align(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
|
||||
if(obj->realign.origo_align)
|
||||
lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs,
|
||||
obj->realign.yofs);
|
||||
else
|
||||
lv_obj_align(obj, obj->realign.base, obj->realign.align, obj->realign.xofs,
|
||||
obj->realign.yofs);
|
||||
#else
|
||||
(void)obj;
|
||||
LV_LOG_WARN("lv_obj_realaign: no effect because LV_OBJ_REALIGN = 0");
|
||||
@ -972,7 +971,8 @@ void lv_obj_realign(lv_obj_t * obj)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the automatic realign of the object when its size has changed based on the last `lv_obj_align` parameters.
|
||||
* Enable the automatic realign of the object when its size has changed based on the last
|
||||
* `lv_obj_align` parameters.
|
||||
* @param obj pointer to an object
|
||||
* @param en true: enable auto realign; false: disable auto realign
|
||||
*/
|
||||
@ -1016,7 +1016,6 @@ void lv_obj_refresh_style(lv_obj_t * obj)
|
||||
lv_obj_invalidate(obj);
|
||||
obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1030,7 +1029,8 @@ void lv_obj_report_style_mod(lv_style_t * style)
|
||||
|
||||
while(d) {
|
||||
lv_obj_t * i;
|
||||
LV_LL_READ(d->scr_ll, i) {
|
||||
LV_LL_READ(d->scr_ll, i)
|
||||
{
|
||||
if(i->style_p == style || style == NULL) {
|
||||
lv_obj_refresh_style(i);
|
||||
}
|
||||
@ -1052,15 +1052,16 @@ 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_cb(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1298,7 +1299,8 @@ void lv_obj_refresh_ext_size(lv_obj_t * obj)
|
||||
* @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);
|
||||
|
||||
@ -1354,8 +1356,7 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1
|
||||
a.start = 0;
|
||||
a.end = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
/*Swap start and end in case of ANIM OUT*/
|
||||
@ -1401,13 +1402,17 @@ lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
|
||||
{
|
||||
const lv_obj_t * scr;
|
||||
|
||||
if(obj->par == NULL) scr = obj; /*`obj` is a screen*/
|
||||
else scr = lv_obj_get_screen(obj); /*get the screen of `obj`*/
|
||||
if(obj->par == NULL)
|
||||
scr = obj; /*`obj` is a screen*/
|
||||
else
|
||||
scr = lv_obj_get_screen(obj); /*get the screen of `obj`*/
|
||||
|
||||
lv_disp_t * d;
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_disp_ll), d) {
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_disp_ll), d)
|
||||
{
|
||||
lv_obj_t * s;
|
||||
LV_LL_READ(d->scr_ll, s) {
|
||||
LV_LL_READ(d->scr_ll, s)
|
||||
{
|
||||
if(s == scr) return d;
|
||||
}
|
||||
}
|
||||
@ -1499,7 +1504,6 @@ void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p)
|
||||
lv_area_copy(cords_p, &obj->coords);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the x coordinate of object
|
||||
* @param obj pointer to an object
|
||||
@ -1821,7 +1825,6 @@ void lv_obj_get_type(lv_obj_t * obj, lv_obj_type_t * buf)
|
||||
if(tmp.type[cnt] == NULL) break;
|
||||
}
|
||||
|
||||
|
||||
/*Swap the order. The real type comes first*/
|
||||
uint8_t i;
|
||||
for(i = 0; i < cnt; i++) {
|
||||
@ -1937,8 +1940,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
lv_indev_t * indev_act = lv_indev_get_act();
|
||||
|
||||
if(sign > _LV_SIGNAL_FEEDBACK_SECTION_START && sign < _LV_SIGNAL_FEEDBACK_SECTION_END) {
|
||||
if(indev_act != NULL && indev_act->feedback != NULL)
|
||||
indev_act->feedback(indev_act, sign);
|
||||
if(indev_act != NULL && indev_act->feedback != NULL) indev_act->feedback(indev_act, sign);
|
||||
}
|
||||
|
||||
if(sign == LV_SIGNAL_CHILD_CHG) {
|
||||
@ -1965,7 +1967,8 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LV_LL_READ(obj->child_ll, i) {
|
||||
LV_LL_READ(obj->child_ll, i)
|
||||
{
|
||||
i->coords.x1 += x_diff;
|
||||
i->coords.y1 += y_diff;
|
||||
i->coords.x2 += x_diff;
|
||||
@ -1983,7 +1986,8 @@ static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coor
|
||||
static void report_style_mod_core(void * style_p, lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LV_LL_READ(obj->child_ll, i) {
|
||||
LV_LL_READ(obj->child_ll, i)
|
||||
{
|
||||
if(i->style_p == style_p || style_p == NULL) {
|
||||
refresh_children_style(i);
|
||||
lv_obj_refresh_style(i);
|
||||
@ -2079,5 +2083,4 @@ static void delete_children(lv_obj_t * obj)
|
||||
/*Delete the base objects*/
|
||||
if(obj->ext_attr != NULL) lv_mem_free(obj->ext_attr);
|
||||
lv_mem_free(obj); /*Free the object itself*/
|
||||
|
||||
}
|
||||
|
@ -54,31 +54,31 @@ extern "C" {
|
||||
|
||||
struct _lv_obj_t;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_DESIGN_DRAW_MAIN,
|
||||
LV_DESIGN_DRAW_POST,
|
||||
LV_DESIGN_COVER_CHK,
|
||||
};
|
||||
typedef uint8_t lv_design_mode_t;
|
||||
|
||||
typedef bool (* lv_design_cb_t) (struct _lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
|
||||
typedef bool (*lv_design_cb_t)(struct _lv_obj_t * obj, const lv_area_t * mask_p,
|
||||
lv_design_mode_t mode);
|
||||
|
||||
enum
|
||||
{
|
||||
LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action function or an operation was failed*/
|
||||
enum {
|
||||
LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action
|
||||
function or an operation was failed*/
|
||||
LV_RES_OK, /*The object is valid (no deleted) after the action*/
|
||||
};
|
||||
typedef uint8_t lv_res_t;
|
||||
|
||||
|
||||
enum {
|
||||
LV_EVENT_PRESSED, /*The object has been pressed*/
|
||||
LV_EVENT_PRESSING, /*The object is being pressed (called continuously while pressing)*/
|
||||
LV_EVENT_PRESS_LOST, /*Still pressing but slid from the objects*/
|
||||
LV_EVENT_SHORT_CLICKED, /*Released before long press time. Not called if dragged.*/
|
||||
LV_EVENT_LONG_PRESSED, /*Pressing for `LV_INDEV_LONG_PRESS_TIME` time. Not called if dragged.*/
|
||||
LV_EVENT_LONG_PRESSED_REPEAT, /*Called after `LV_INDEV_LONG_PRESS_TIME` in every `LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/
|
||||
LV_EVENT_LONG_PRESSED_REPEAT, /*Called after `LV_INDEV_LONG_PRESS_TIME` in every
|
||||
`LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/
|
||||
LV_EVENT_CLICKED, /*Called on release if not dragged (regardless to long press)*/
|
||||
LV_EVENT_RELEASED, /*Called in every cases when the object has been released*/
|
||||
LV_EVENT_LONG_HOVER_IN, /*TODO*/
|
||||
@ -99,8 +99,7 @@ typedef uint8_t lv_event_t;
|
||||
|
||||
typedef void (*lv_event_cb_t)(struct _lv_obj_t * obj, lv_event_t event);
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
/*General signals*/
|
||||
LV_SIGNAL_CLEANUP,
|
||||
LV_SIGNAL_CHILD_CHG,
|
||||
@ -132,8 +131,7 @@ typedef uint8_t lv_signal_t;
|
||||
|
||||
typedef lv_res_t (*lv_signal_cb_t)(struct _lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_ALIGN_CENTER = 0,
|
||||
LV_ALIGN_IN_TOP_LEFT,
|
||||
LV_ALIGN_IN_TOP_MID,
|
||||
@ -159,17 +157,18 @@ enum
|
||||
typedef uint8_t lv_align_t;
|
||||
|
||||
#if LV_OBJ_REALIGN
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
const struct _lv_obj_t * base;
|
||||
lv_coord_t xofs;
|
||||
lv_coord_t yofs;
|
||||
lv_align_t align;
|
||||
uint8_t auto_realign : 1;
|
||||
uint8_t origo_align :1; /*1: the oigo (center of the object) was aligned with `lv_obj_align_origo`*/
|
||||
uint8_t origo_align : 1; /*1: the oigo (center of the object) was aligned with
|
||||
`lv_obj_align_origo`*/
|
||||
} lv_reailgn_t;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _lv_obj_t
|
||||
{
|
||||
struct _lv_obj_t * par; /*Pointer to the parent object*/
|
||||
@ -196,10 +195,12 @@ typedef struct _lv_obj_t
|
||||
uint8_t top : 1; /*1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t opa_scale_en : 1; /*1: opa_scale is set*/
|
||||
uint8_t parent_event : 1; /*1: Send the object's events to the parent too. */
|
||||
uint8_t protect; /*Automatically happening actions can be prevented. 'OR'ed values from `lv_protect_t`*/
|
||||
uint8_t protect; /*Automatically happening actions can be prevented. 'OR'ed values from
|
||||
`lv_protect_t`*/
|
||||
lv_opa_t opa_scale; /*Scale down the opacity by this factor. Effects all children as well*/
|
||||
|
||||
lv_coord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
lv_coord_t
|
||||
ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
#if LV_OBJ_REALIGN
|
||||
lv_reailgn_t realign;
|
||||
#endif
|
||||
@ -217,26 +218,27 @@ typedef struct _lv_obj_t
|
||||
} lv_obj_t;
|
||||
|
||||
/*Protect some attributes (max. 8 bit)*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_PROTECT_NONE = 0x00,
|
||||
LV_PROTECT_CHILD_CHG = 0x01, /*Disable the child change signal. Used by the library*/
|
||||
LV_PROTECT_PARENT = 0x02, /*Prevent automatic parent change (e.g. in lv_page)*/
|
||||
LV_PROTECT_POS = 0x04, /*Prevent automatic positioning (e.g. in lv_cont layout)*/
|
||||
LV_PROTECT_FOLLOW = 0x08, /*Prevent the object be followed in automatic ordering (e.g. in lv_cont PRETTY layout)*/
|
||||
LV_PROTECT_PRESS_LOST= 0x10, /*If the `indev` was pressing this object but swiped out while pressing do not search other object.*/
|
||||
LV_PROTECT_FOLLOW = 0x08, /*Prevent the object be followed in automatic ordering (e.g. in
|
||||
lv_cont PRETTY layout)*/
|
||||
LV_PROTECT_PRESS_LOST = 0x10, /*If the `indev` was pressing this object but swiped out while
|
||||
pressing do not search other object.*/
|
||||
LV_PROTECT_CLICK_FOCUS = 0x20, /*Prevent focusing the object by clicking on it*/
|
||||
};
|
||||
typedef uint8_t lv_protect_t;
|
||||
|
||||
|
||||
/*Used by `lv_obj_get_type()`. The object's and its ancestor types are stored here*/
|
||||
typedef struct {
|
||||
const char * type[LV_MAX_ANCESTOR_NUM]; /*[0]: the actual type, [1]: ancestor, [2] #1's ancestor ... [x]: "lv_obj" */
|
||||
typedef struct
|
||||
{
|
||||
const char * type[LV_MAX_ANCESTOR_NUM]; /*[0]: the actual type, [1]: ancestor, [2] #1's ancestor
|
||||
... [x]: "lv_obj" */
|
||||
} lv_obj_type_t;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_ANIM_NONE = 0,
|
||||
LV_ANIM_FLOAT_TOP, /*Float from/to the top*/
|
||||
LV_ANIM_FLOAT_LEFT, /*Float from/to the left*/
|
||||
@ -359,7 +361,8 @@ 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,const 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, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod,
|
||||
lv_coord_t y_mod);
|
||||
|
||||
/**
|
||||
* Align an object to an other object.
|
||||
@ -369,7 +372,8 @@ void lv_obj_align(lv_obj_t * obj,const lv_obj_t * base, lv_align_t align, lv_coo
|
||||
* @param x_mod x coordinate shift after alignment
|
||||
* @param y_mod y coordinate shift after alignment
|
||||
*/
|
||||
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
|
||||
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod,
|
||||
lv_coord_t y_mod);
|
||||
|
||||
/**
|
||||
* Realign the object based on the last `lv_obj_align` parameters.
|
||||
@ -378,7 +382,8 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
void lv_obj_realign(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Enable the automatic realign of the object when its size has changed based on the last `lv_obj_align` parameters.
|
||||
* Enable the automatic realign of the object when its size has changed based on the last
|
||||
* `lv_obj_align` parameters.
|
||||
* @param obj pointer to an object
|
||||
* @param en true: enable auto realign; false: disable auto realign
|
||||
*/
|
||||
@ -563,7 +568,8 @@ void lv_obj_refresh_ext_size(lv_obj_t * obj);
|
||||
* @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 *));
|
||||
#endif
|
||||
|
||||
/*=======================
|
||||
@ -814,7 +820,6 @@ void * lv_obj_get_ext_attr(const lv_obj_t * obj);
|
||||
*/
|
||||
void lv_obj_get_type(lv_obj_t * obj, lv_obj_type_t * buf);
|
||||
|
||||
|
||||
#if LV_USE_USER_DATA_SINGLE
|
||||
/**
|
||||
* Get a pointer to the object's user data
|
||||
@ -832,7 +837,6 @@ lv_obj_user_data_t * lv_obj_get_user_data(lv_obj_t * obj);
|
||||
*/
|
||||
void * lv_obj_get_group(const lv_obj_t * obj);
|
||||
|
||||
|
||||
/**
|
||||
* Tell whether the object is the focused object of a group or not.
|
||||
* @param obj pointer to an object
|
||||
@ -842,12 +846,10 @@ bool lv_obj_is_focused(const lv_obj_t * obj);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -63,20 +63,20 @@ void lv_refr_init(void)
|
||||
|
||||
/**
|
||||
* Redraw the invalidated areas now.
|
||||
* Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process can
|
||||
* prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process (e.g. progress bar)
|
||||
* this function can be called when the screen should be updated.
|
||||
* Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process
|
||||
* can prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process
|
||||
* (e.g. progress bar) this function can be called when the screen should be updated.
|
||||
*/
|
||||
void lv_refr_now(void)
|
||||
{
|
||||
lv_disp_refr_task(NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Invalidate an area on display to redraw it
|
||||
* @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas)
|
||||
* @param disp pointer to display where the area should be invalidated (NULL can be used if there is only one display)
|
||||
* @param disp pointer to display where the area should be invalidated (NULL can be used if there is
|
||||
* only one display)
|
||||
*/
|
||||
void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)
|
||||
{
|
||||
@ -148,17 +148,19 @@ void lv_disp_refr_task(void * param)
|
||||
|
||||
/*If refresh happened ...*/
|
||||
if(disp_refr->inv_p != 0) {
|
||||
/*In true double buffered mode copy the refreshed areas to the new VDB to keep it up to date*/
|
||||
/*In true double buffered mode copy the refreshed areas to the new VDB to keep it up to
|
||||
* date*/
|
||||
if(lv_disp_is_true_double_buf(disp_refr)) {
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
|
||||
|
||||
/*Flush the content of the VDB*/
|
||||
lv_refr_vdb_flush();
|
||||
|
||||
/* With true double buffering the flushing should be only the address change of the current frame buffer.
|
||||
* Wait until the address change is ready and copy the changed content to the other frame buffer (new active VDB)
|
||||
* to keep the buffers synchronized*/
|
||||
while(vdb->flushing);
|
||||
/* With true double buffering the flushing should be only the address change of the
|
||||
* current frame buffer. Wait until the address change is ready and copy the changed
|
||||
* content to the other frame buffer (new active VDB) to keep the buffers synchronized*/
|
||||
while(vdb->flushing)
|
||||
;
|
||||
|
||||
uint8_t * buf_act = (uint8_t *)vdb->buf_act;
|
||||
uint8_t * buf_ina = (uint8_t *)vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1;
|
||||
@ -168,8 +170,11 @@ void lv_disp_refr_task(void * param)
|
||||
for(a = 0; a < disp_refr->inv_p; a++) {
|
||||
if(disp_refr->inv_area_joined[a] == 0) {
|
||||
lv_coord_t y;
|
||||
uint32_t start_offs = (hres * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * sizeof(lv_color_t);
|
||||
uint32_t line_length = lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t);
|
||||
uint32_t start_offs =
|
||||
(hres * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) *
|
||||
sizeof(lv_color_t);
|
||||
uint32_t line_length =
|
||||
lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t);
|
||||
|
||||
for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) {
|
||||
memcpy(buf_act + start_offs, buf_ina + start_offs, line_length);
|
||||
@ -216,8 +221,8 @@ static void lv_refr_join_area(void)
|
||||
}
|
||||
|
||||
/*Check if the areas are on each other*/
|
||||
if(lv_area_is_on(&disp_refr->inv_areas[join_in],
|
||||
&disp_refr->inv_areas[join_from]) == false) {
|
||||
if(lv_area_is_on(&disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]) ==
|
||||
false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -226,7 +231,8 @@ static void lv_refr_join_area(void)
|
||||
|
||||
/*Join two area only if the joined area size is smaller*/
|
||||
if(lv_area_get_size(&joined_area) <
|
||||
(lv_area_get_size(&disp_refr->inv_areas[join_in]) + lv_area_get_size(&disp_refr->inv_areas[join_from]))) {
|
||||
(lv_area_get_size(&disp_refr->inv_areas[join_in]) +
|
||||
lv_area_get_size(&disp_refr->inv_areas[join_from]))) {
|
||||
lv_area_copy(&disp_refr->inv_areas[join_in], &joined_area);
|
||||
|
||||
/*Mark 'join_form' is joined into 'join_in'*/
|
||||
@ -261,7 +267,8 @@ static void lv_refr_areas(void)
|
||||
*/
|
||||
static void lv_refr_area(const lv_area_t * area_p)
|
||||
{
|
||||
/*True double buffering: there are two screen sized buffers. Just redraw directly into a buffer*/
|
||||
/*True double buffering: there are two screen sized buffers. Just redraw directly into a
|
||||
* buffer*/
|
||||
if(lv_disp_is_true_double_buf(disp_refr)) {
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
|
||||
vdb->area.x1 = 0;
|
||||
@ -276,7 +283,9 @@ static void lv_refr_area(const lv_area_t * area_p)
|
||||
/*Calculate the max row num*/
|
||||
lv_coord_t w = lv_area_get_width(area_p);
|
||||
lv_coord_t h = lv_area_get_height(area_p);
|
||||
lv_coord_t y2 = area_p->y2 >= lv_disp_get_ver_res(disp_refr) ? y2 = lv_disp_get_ver_res(disp_refr) - 1 : area_p->y2;
|
||||
lv_coord_t y2 = area_p->y2 >= lv_disp_get_ver_res(disp_refr)
|
||||
? y2 = lv_disp_get_ver_res(disp_refr) - 1
|
||||
: area_p->y2;
|
||||
|
||||
int32_t max_row = (uint32_t)vdb->size / w;
|
||||
|
||||
@ -302,7 +311,8 @@ static void lv_refr_area(const lv_area_t * area_p)
|
||||
} while(y_tmp != 0);
|
||||
|
||||
if(y_tmp == 0) {
|
||||
LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to small VDB)");
|
||||
LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to "
|
||||
"small VDB)");
|
||||
return;
|
||||
} else {
|
||||
max_row = tmp.y2 + 1;
|
||||
@ -346,9 +356,11 @@ static void lv_refr_area_part(const lv_area_t * area_p)
|
||||
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
|
||||
|
||||
/*In non double buffered mode, before rendering the next part wait until the previous image is flushed*/
|
||||
/*In non double buffered mode, before rendering the next part wait until the previous image is
|
||||
* flushed*/
|
||||
if(lv_disp_is_double_buf(disp_refr) == false) {
|
||||
while(vdb->flushing);
|
||||
while(vdb->flushing)
|
||||
;
|
||||
}
|
||||
|
||||
lv_obj_t * top_p;
|
||||
@ -388,7 +400,8 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
|
||||
|
||||
/*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) {
|
||||
LV_LL_READ(obj->child_ll, i) {
|
||||
LV_LL_READ(obj->child_ll, i)
|
||||
{
|
||||
found_p = lv_refr_get_top_obj(area_p, i);
|
||||
|
||||
/*If a children is ok then break*/
|
||||
@ -490,7 +503,6 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
obj->design_cb(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||
// usleep(5 * 1000); /*DEBUG: Wait after every object draw to see the order of drawing*/
|
||||
|
||||
|
||||
/*Create a new 'obj_mask' without 'ext_size' because the children can't be visible there*/
|
||||
lv_obj_get_coords(obj, &obj_area);
|
||||
union_ok = lv_area_intersect(&obj_mask, mask_ori_p, &obj_area);
|
||||
@ -498,7 +510,8 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
lv_area_t mask_child; /*Mask from obj and its child*/
|
||||
lv_obj_t * child_p;
|
||||
lv_area_t child_area;
|
||||
LV_LL_READ_BACK(obj->child_ll, child_p) {
|
||||
LV_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;
|
||||
@ -519,7 +532,6 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
|
||||
/* If all the children are redrawn make 'post draw' design */
|
||||
obj->design_cb(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,9 +542,11 @@ static void lv_refr_vdb_flush(void)
|
||||
{
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
|
||||
|
||||
/*In double buffered mode wait until the other buffer is flushed before flushing the current one*/
|
||||
/*In double buffered mode wait until the other buffer is flushed before flushing the current
|
||||
* one*/
|
||||
if(lv_disp_is_double_buf(disp_refr)) {
|
||||
while(vdb->flushing);
|
||||
while(vdb->flushing)
|
||||
;
|
||||
}
|
||||
|
||||
vdb->flushing = 1;
|
||||
@ -541,10 +555,11 @@ static void lv_refr_vdb_flush(void)
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
if(disp->driver.flush_cb) disp->driver.flush_cb(&disp->driver, &vdb->area, vdb->buf_act);
|
||||
|
||||
|
||||
if(vdb->buf1 && vdb->buf2) {
|
||||
if(vdb->buf_act == vdb->buf1) vdb->buf_act = vdb->buf2;
|
||||
else vdb->buf_act = vdb->buf1;
|
||||
if(vdb->buf_act == vdb->buf1)
|
||||
vdb->buf_act = vdb->buf2;
|
||||
else
|
||||
vdb->buf_act = vdb->buf1;
|
||||
|
||||
/*If the screen is transparent initialize it when the new VDB is selected*/
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
|
@ -47,16 +47,17 @@ void lv_refr_init(void);
|
||||
|
||||
/**
|
||||
* Redraw the invalidated areas now.
|
||||
* Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process can
|
||||
* prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process (e.g. progress bar)
|
||||
* this function can be called when the screen should be updated.
|
||||
* Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process
|
||||
* can prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process
|
||||
* (e.g. progress bar) this function can be called when the screen should be updated.
|
||||
*/
|
||||
void lv_refr_now(void);
|
||||
|
||||
/**
|
||||
* Invalidate an area on display to redraw it
|
||||
* @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas)
|
||||
* @param disp pointer to display where the area should be invalidated (NULL can be used if there is only one display)
|
||||
* @param disp pointer to display where the area should be invalidated (NULL can be used if there is
|
||||
* only one display)
|
||||
*/
|
||||
void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p);
|
||||
|
||||
@ -76,7 +77,6 @@ void lv_disp_refr_task(void * param);
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -16,15 +16,21 @@
|
||||
#define STYLE_MIX_SHIFT 8 /*log2(STYLE_MIX_MAX)*/
|
||||
|
||||
#define VAL_PROP(v1, v2, r) v1 + (((v2 - v1) * r) >> STYLE_MIX_SHIFT)
|
||||
#define STYLE_ATTR_MIX(attr, r) if(start->attr != end->attr) {res->attr = VAL_PROP(start->attr, end->attr, r);} else {res->attr = start->attr;}
|
||||
|
||||
#define STYLE_ATTR_MIX(attr, r) \
|
||||
if(start->attr != end->attr) { \
|
||||
res->attr = VAL_PROP(start->attr, end->attr, r); \
|
||||
} else { \
|
||||
res->attr = start->attr; \
|
||||
}
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
#if LV_USE_ANIMATION
|
||||
typedef struct {
|
||||
lv_style_t style_start; /*Save not only pointers because can be same as 'style_anim' then it will be modified too*/
|
||||
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;
|
||||
void (*end_cb)(void *);
|
||||
@ -215,7 +221,6 @@ void lv_style_init(void)
|
||||
lv_style_btn_ina.line.color = lv_color_make(0x70, 0x70, 0x70);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy a style to an other
|
||||
* @param dest pointer to the destination style
|
||||
@ -226,7 +231,6 @@ void lv_style_copy(lv_style_t * dest, const lv_style_t * src)
|
||||
memcpy(dest, src, sizeof(lv_style_t));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mix two styles according to a given ratio
|
||||
* @param start start style
|
||||
@ -234,7 +238,8 @@ void lv_style_copy(lv_style_t * dest, const lv_style_t * src)
|
||||
* @param res store the result style here
|
||||
* @param ratio the ratio of mix [0..256]; 0: `start` style; 256: `end` style
|
||||
*/
|
||||
void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * res, uint16_t ratio)
|
||||
void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * res,
|
||||
uint16_t ratio)
|
||||
{
|
||||
STYLE_ATTR_MIX(body.opa, ratio);
|
||||
STYLE_ATTR_MIX(body.radius, ratio);
|
||||
@ -284,7 +289,8 @@ void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t *
|
||||
/**
|
||||
* Create an animation from a pre-configured 'lv_style_anim_t' variable
|
||||
* @param anim pointer to a pre-configured 'lv_style_anim_t' variable (will be copied)
|
||||
* @return pointer to a descriptor. Really this variable will be animated. (Can be used in `lv_anim_del(dsc, NULL)`)
|
||||
* @return pointer to a descriptor. Really this variable will be animated. (Can be used in
|
||||
* `lv_anim_del(dsc, NULL)`)
|
||||
*/
|
||||
void * lv_style_anim_create(lv_style_anim_t * anim)
|
||||
{
|
||||
@ -299,7 +305,6 @@ void * lv_style_anim_create(lv_style_anim_t * anim)
|
||||
memcpy(dsc->style_anim, anim->style_start, sizeof(lv_style_t));
|
||||
dsc->end_cb = anim->end_cb;
|
||||
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = (void *)dsc;
|
||||
a.start = 0;
|
||||
|
@ -29,8 +29,7 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
/*Border types (Use 'OR'ed values)*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_BORDER_NONE = 0x00,
|
||||
LV_BORDER_BOTTOM = 0x01,
|
||||
LV_BORDER_TOP = 0x02,
|
||||
@ -42,8 +41,7 @@ enum
|
||||
typedef uint8_t lv_border_part_t;
|
||||
|
||||
/*Shadow types*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_SHADOW_BOTTOM = 0,
|
||||
LV_SHADOW_FULL,
|
||||
};
|
||||
@ -53,26 +51,30 @@ typedef struct
|
||||
{
|
||||
uint8_t glass : 1; /*1: Do not inherit this style*/
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
lv_color_t main_color;
|
||||
lv_color_t grad_color; /*`grad_color` will be removed in v6.0, use `aux_color` instead*/
|
||||
lv_coord_t radius;
|
||||
lv_opa_t opa;
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
lv_color_t color;
|
||||
lv_coord_t width;
|
||||
lv_border_part_t part;
|
||||
lv_opa_t opa;
|
||||
} border;
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
lv_color_t color;
|
||||
lv_coord_t width;
|
||||
lv_shadow_type_t type;
|
||||
} shadow;
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
lv_coord_t top;
|
||||
lv_coord_t bottom;
|
||||
lv_coord_t left;
|
||||
@ -81,8 +83,8 @@ typedef struct
|
||||
} padding;
|
||||
} body;
|
||||
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
lv_color_t color;
|
||||
lv_color_t sel_color;
|
||||
const lv_font_t * font;
|
||||
@ -91,13 +93,15 @@ typedef struct
|
||||
lv_opa_t opa;
|
||||
} text;
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
lv_color_t color;
|
||||
lv_opa_t intense;
|
||||
lv_opa_t opa;
|
||||
} image;
|
||||
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
lv_color_t color;
|
||||
lv_coord_t width;
|
||||
lv_opa_t opa;
|
||||
@ -106,7 +110,8 @@ typedef struct
|
||||
} lv_style_t;
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
const lv_style_t * style_start; /*Pointer to the starting style*/
|
||||
const lv_style_t * style_end; /*Pointer to the destination style*/
|
||||
lv_style_t * style_anim; /*Pointer to a style to animate*/
|
||||
@ -151,7 +156,6 @@ void lv_style_init (void);
|
||||
*/
|
||||
void lv_style_copy(lv_style_t * dest, const lv_style_t * src);
|
||||
|
||||
|
||||
/**
|
||||
* Mix two styles according to a given ratio
|
||||
* @param start start style
|
||||
@ -159,14 +163,16 @@ void lv_style_copy(lv_style_t * dest, const lv_style_t * src);
|
||||
* @param res store the result style here
|
||||
* @param ratio the ratio of mix [0..256]; 0: `start` style; 256: `end` style
|
||||
*/
|
||||
void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * res, uint16_t ratio);
|
||||
void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * res,
|
||||
uint16_t ratio);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
|
||||
/**
|
||||
* Create an animation from a pre-configured 'lv_style_anim_t' variable
|
||||
* @param anim pointer to a pre-configured 'lv_style_anim_t' variable (will be copied)
|
||||
* @return pointer to a descriptor. Really this variable will be animated. (Can be used in `lv_anim_del(dsc, NULL)`)
|
||||
* @return pointer to a descriptor. Really this variable will be animated. (Can be used in
|
||||
* `lv_anim_del(dsc, NULL)`)
|
||||
*/
|
||||
void * lv_style_anim_create(lv_style_anim_t * anim);
|
||||
#endif
|
||||
@ -192,7 +198,6 @@ extern lv_style_t lv_style_btn_ina;
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -58,14 +58,15 @@ lv_opa_t lv_draw_aa_get_opa(lv_coord_t seg, lv_coord_t px_id, lv_opa_t base_opa)
|
||||
* * * |
|
||||
*
|
||||
* Anti-aliased pixels come to the '*' characters
|
||||
* Calculate what percentage of the pixels should be covered if real line (not rasterized) would be drawn:
|
||||
* Calculate what percentage of the pixels should be covered if real line (not rasterized) would
|
||||
* be drawn:
|
||||
* 1. A real line should start on (0;0) and end on (2;1)
|
||||
* 2. So the line intersection coordinates on the first pixel: (0;0) (1;0.5) -> 25% covered pixel in average
|
||||
* 2. So the line intersection coordinates on the first pixel: (0;0) (1;0.5) -> 25% covered
|
||||
* pixel in average
|
||||
* 3. For the second pixel: (1;0.5) (2;1) -> 75% covered pixel in average
|
||||
* 4. The equation: (px_id * 2 + 1) / (segment_width * 2)
|
||||
* segment_width: the line segment which is being anti-aliased (was 2 in the example)
|
||||
* px_id: pixel ID from 0 to (segment_width - 1)
|
||||
* result: [0..1] coverage of the pixel
|
||||
* segment_width: the line segment which is being anti-aliased (was 2 in the
|
||||
* example) px_id: pixel ID from 0 to (segment_width - 1) result: [0..1] coverage of the pixel
|
||||
*/
|
||||
|
||||
/*Accelerate the common segment sizes to avoid division*/
|
||||
@ -78,16 +79,15 @@ lv_opa_t lv_draw_aa_get_opa(lv_coord_t seg, lv_coord_t px_id, lv_opa_t base_opa)
|
||||
static const lv_opa_t seg7[7] = {18, 55, 91, 128, 164, 200, 237};
|
||||
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
|
||||
};
|
||||
static const lv_opa_t * seg_map[] = {seg1, seg2, seg3, seg4, 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] * base_opa) >> 8;
|
||||
if(seg == 0)
|
||||
return LV_OPA_TRANSP;
|
||||
else if(seg < 8)
|
||||
return (uint32_t)((uint32_t)seg_map[seg - 1][px_id] * base_opa) >> 8;
|
||||
else {
|
||||
return ((px_id * 2 + 1) * base_opa) / (2 * seg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,7 +99,8 @@ lv_opa_t lv_draw_aa_get_opa(lv_coord_t seg, lv_coord_t px_id, lv_opa_t base_opa)
|
||||
* @param color color of pixels
|
||||
* @param opa maximum opacity
|
||||
*/
|
||||
void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, lv_opa_t opa)
|
||||
void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
bool aa_inv = false;
|
||||
if(length < 0) {
|
||||
@ -124,7 +125,8 @@ void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_
|
||||
* @param color color of pixels
|
||||
* @param opa maximum opacity
|
||||
*/
|
||||
void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, lv_opa_t opa)
|
||||
void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
bool aa_inv = false;
|
||||
if(length < 0) {
|
||||
|
@ -46,7 +46,6 @@ enum {
|
||||
};
|
||||
typedef uint8_t lv_img_src_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -71,7 +70,8 @@ lv_opa_t lv_draw_aa_get_opa(lv_coord_t seg, lv_coord_t px_id, lv_opa_t base_opa)
|
||||
* @param color color of pixels
|
||||
* @param opa maximum opacity
|
||||
*/
|
||||
void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, lv_opa_t opa);
|
||||
void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Add a horizontal anti-aliasing segment (pixels with decreasing opacity)
|
||||
@ -82,7 +82,8 @@ void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_
|
||||
* @param color color of pixels
|
||||
* @param opa maximum opacity
|
||||
*/
|
||||
void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, lv_opa_t opa);
|
||||
void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
|
@ -21,8 +21,10 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static uint16_t fast_atan2(int x, int y);
|
||||
static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, lv_opa_t opa);
|
||||
static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, lv_opa_t opa);
|
||||
static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
static bool deg_test_norm(uint16_t deg, uint16_t start, uint16_t end);
|
||||
static bool deg_test_inv(uint16_t deg, uint16_t start, uint16_t end);
|
||||
|
||||
@ -50,7 +52,8 @@ static bool deg_test_inv(uint16_t deg, uint16_t start, uint16_t end);
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask,
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style,
|
||||
lv_opa_t opa_scale)
|
||||
{
|
||||
lv_coord_t thickness = style->line.width;
|
||||
if(thickness > radius) thickness = radius;
|
||||
@ -63,17 +66,24 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons
|
||||
lv_coord_t x_end[4];
|
||||
|
||||
lv_color_t color = style->line.color;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->body.opa
|
||||
: (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8;
|
||||
|
||||
bool (*deg_test)(uint16_t, uint16_t, uint16_t);
|
||||
if(start_angle <= end_angle) deg_test = deg_test_norm;
|
||||
else deg_test = deg_test_inv;
|
||||
if(start_angle <= end_angle)
|
||||
deg_test = deg_test_norm;
|
||||
else
|
||||
deg_test = deg_test_inv;
|
||||
|
||||
if(deg_test(270, start_angle, end_angle)) hor_line(center_x - r_out + 1, center_y, mask, thickness - 1, color, opa); // Left Middle
|
||||
if(deg_test(90, start_angle, end_angle)) hor_line(center_x + r_in, center_y, mask, thickness - 1, color, opa); // Right Middle
|
||||
if(deg_test(180, start_angle, end_angle)) ver_line(center_x, center_y - r_out + 1, mask, thickness - 1, color, opa); // Top Middle
|
||||
if(deg_test(0, start_angle, end_angle)) ver_line(center_x, center_y + r_in, mask, thickness - 1, color, opa); // Bottom middle
|
||||
if(deg_test(270, start_angle, end_angle))
|
||||
hor_line(center_x - r_out + 1, center_y, mask, thickness - 1, color, opa); // Left Middle
|
||||
if(deg_test(90, start_angle, end_angle))
|
||||
hor_line(center_x + r_in, center_y, mask, thickness - 1, color, opa); // Right Middle
|
||||
if(deg_test(180, start_angle, end_angle))
|
||||
ver_line(center_x, center_y - r_out + 1, mask, thickness - 1, color, opa); // Top Middle
|
||||
if(deg_test(0, start_angle, end_angle))
|
||||
ver_line(center_x, center_y + r_in, mask, thickness - 1, color, opa); // Bottom middle
|
||||
|
||||
uint32_t r_out_sqr = r_out * r_out;
|
||||
uint32_t r_in_sqr = r_in * r_in;
|
||||
@ -123,10 +133,11 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons
|
||||
x_end[3] = xi - 1;
|
||||
}
|
||||
|
||||
if(r_act_sqr < r_in_sqr) break; /*No need to continue the iteration in x once we found the inner edge of the arc*/
|
||||
if(r_act_sqr < r_in_sqr)
|
||||
break; /*No need to continue the iteration in x once we found the inner edge of the
|
||||
arc*/
|
||||
}
|
||||
|
||||
|
||||
if(x_start[0] != LV_COORD_MIN) {
|
||||
if(x_end[0] == LV_COORD_MIN) x_end[0] = xi - 1;
|
||||
hor_line(center_x + x_start[0], center_y + yi, mask, x_end[0] - x_start[0], color, opa);
|
||||
@ -139,20 +150,20 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons
|
||||
|
||||
if(x_start[2] != LV_COORD_MIN) {
|
||||
if(x_end[2] == LV_COORD_MIN) x_end[2] = xi - 1;
|
||||
hor_line(center_x - x_end[2], center_y + yi, mask, LV_MATH_ABS(x_end[2] - x_start[2]), color, opa);
|
||||
hor_line(center_x - x_end[2], center_y + yi, mask, LV_MATH_ABS(x_end[2] - x_start[2]),
|
||||
color, opa);
|
||||
}
|
||||
|
||||
if(x_start[3] != LV_COORD_MIN) {
|
||||
if(x_end[3] == LV_COORD_MIN) x_end[3] = xi - 1;
|
||||
hor_line(center_x - x_end[3], center_y - yi, mask, LV_MATH_ABS(x_end[3] - x_start[3]), color, opa);
|
||||
hor_line(center_x - x_end[3], center_y - yi, mask, LV_MATH_ABS(x_end[3] - x_start[3]),
|
||||
color, opa);
|
||||
}
|
||||
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
/*TODO*/
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,7 +245,8 @@ static uint16_t fast_atan2(int x, int y)
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, lv_opa_t opa)
|
||||
static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
lv_area_t area;
|
||||
lv_area_set(&area, x, y, x, y + len);
|
||||
@ -242,7 +254,8 @@ static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coor
|
||||
lv_draw_fill(&area, mask, color, opa);
|
||||
}
|
||||
|
||||
static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, lv_opa_t opa)
|
||||
static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
lv_area_t area;
|
||||
lv_area_set(&area, x, y, x + len, y);
|
||||
@ -252,13 +265,16 @@ static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coor
|
||||
|
||||
static bool deg_test_norm(uint16_t deg, uint16_t start, uint16_t end)
|
||||
{
|
||||
if(deg >= start && deg <= end) return true;
|
||||
else return false;
|
||||
if(deg >= start && deg <= end)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool deg_test_inv(uint16_t deg, uint16_t start, uint16_t end)
|
||||
{
|
||||
if(deg >= start || deg <= end) {
|
||||
return true;
|
||||
} else return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
@ -39,13 +39,13 @@ extern "C" {
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask,
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style,
|
||||
lv_opa_t opa_scale);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -26,7 +26,8 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define VFILL_HW_ACC_SIZE_LIMIT 50 /*Always fill < 50 px with 'sw_color_fill' because of the hw. init overhead*/
|
||||
#define VFILL_HW_ACC_SIZE_LIMIT \
|
||||
50 /*Always fill < 50 px with 'sw_color_fill' because of the hw. init overhead*/
|
||||
|
||||
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||
@ -40,10 +41,12 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color, lv_opa_t opa);
|
||||
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, lv_color_t fg_color, lv_opa_t fg_opa);
|
||||
static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
|
||||
lv_color_t fg_color, lv_opa_t fg_opa);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -66,15 +69,14 @@ static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
|
||||
* @param color pixel color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
|
||||
void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color,
|
||||
lv_opa_t opa)
|
||||
{
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
|
||||
|
||||
/*Pixel out of the mask*/
|
||||
if(x < mask_p->x1 || x > mask_p->x2 ||
|
||||
y < mask_p->y1 || y > mask_p->y2) {
|
||||
if(x < mask_p->x1 || x > mask_p->x2 || y < mask_p->y1 || y > mask_p->y2) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -103,7 +105,6 @@ void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill an area in the Virtual Display Buffer
|
||||
* @param cords_p coordinates of the area to fill
|
||||
@ -111,8 +112,8 @@ void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color,
|
||||
lv_opa_t opa)
|
||||
{
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
@ -142,9 +143,9 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
/*Move the vdb_tmp to the first row*/
|
||||
vdb_buf_tmp += vdb_width * vdb_rel_a.y1;
|
||||
|
||||
|
||||
#if LV_USE_GPU
|
||||
static LV_ATTRIBUTE_MEM_ALIGN lv_color_t color_array_tmp[LV_HOR_RES_MAX]; /*Used by 'lv_disp_mem_blend'*/
|
||||
static LV_ATTRIBUTE_MEM_ALIGN lv_color_t
|
||||
color_array_tmp[LV_HOR_RES_MAX]; /*Used by 'lv_disp_mem_blend'*/
|
||||
static lv_coord_t last_width = -1;
|
||||
|
||||
lv_coord_t w = lv_area_get_width(&vdb_rel_a);
|
||||
@ -211,7 +212,6 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
else {
|
||||
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
|
||||
@ -227,17 +227,14 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_draw_letter(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)
|
||||
void lv_draw_letter(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 uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
|
||||
const uint8_t bpp1_opa_table[2] = {
|
||||
0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
|
||||
const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
|
||||
const 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(opa < LV_OPA_MIN) return;
|
||||
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
|
||||
@ -259,7 +256,6 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
pos_x += (lv_font_get_width(font_p, letter) - letter_w) / 2;
|
||||
}
|
||||
|
||||
|
||||
switch(bpp) {
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
@ -277,8 +273,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
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*/
|
||||
default: return; /*Invalid bpp. Can't render the letter*/
|
||||
}
|
||||
|
||||
const uint8_t * map_p = lv_font_get_bitmap(font_p, letter);
|
||||
@ -286,8 +281,9 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
if(map_p == NULL) return;
|
||||
|
||||
/*If the letter is completely out of mask don't draw it */
|
||||
if(pos_x + letter_w < mask_p->x1 || pos_x > mask_p->x2 ||
|
||||
pos_y + letter_h < mask_p->y1 || pos_y > mask_p->y2) return;
|
||||
if(pos_x + letter_w < mask_p->x1 || pos_x > mask_p->x2 || pos_y + letter_h < mask_p->y1 ||
|
||||
pos_y > mask_p->y2)
|
||||
return;
|
||||
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
@ -297,7 +293,8 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
lv_coord_t col, row;
|
||||
uint8_t col_bit;
|
||||
uint8_t col_byte_cnt;
|
||||
uint8_t width_byte_scr = letter_w >> 3; /*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
|
||||
uint8_t width_byte_scr =
|
||||
letter_w >> 3; /*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
|
||||
if(letter_w & 0x7) width_byte_scr++;
|
||||
uint8_t width_byte_bpp = (letter_w * bpp) >> 3; /*Letter width in byte. Real width in the font*/
|
||||
if((letter_w * bpp) & 0x7) width_byte_bpp++;
|
||||
@ -309,8 +306,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
lv_coord_t row_end = pos_y + letter_h <= mask_p->y2 ? letter_h : mask_p->y2 - pos_y + 1;
|
||||
|
||||
/*Set a pointer on VDB to the first pixel of the letter*/
|
||||
vdb_buf_tmp += ((pos_y - vdb->area.y1) * vdb_width)
|
||||
+ pos_x - vdb->area.x1;
|
||||
vdb_buf_tmp += ((pos_y - vdb->area.y1) * vdb_width) + pos_x - vdb->area.x1;
|
||||
|
||||
/*If the letter is partially out of mask the move there on VDB*/
|
||||
vdb_buf_tmp += (row_start * vdb_width) + col_start;
|
||||
@ -330,20 +326,20 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
if(opa == LV_OPA_COVER) {
|
||||
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
|
||||
} else {
|
||||
px_opa = bpp == 8 ?
|
||||
(uint16_t)((uint16_t)letter_px * opa) >> 8 :
|
||||
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
px_opa = bpp == 8 ? (uint16_t)((uint16_t)letter_px * opa) >> 8
|
||||
: (uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
}
|
||||
|
||||
if(disp->driver.set_px_cb) {
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width,
|
||||
(col + pos_x) - vdb->area.x1, (row + pos_y) - vdb->area.y1,
|
||||
color, px_opa);
|
||||
(col + pos_x) - vdb->area.x1,
|
||||
(row + pos_y) - vdb->area.y1, color, px_opa);
|
||||
} else {
|
||||
#if LV_COLOR_SCREEN_TRANSP == 0
|
||||
*vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, px_opa);
|
||||
#else
|
||||
*vdb_buf_tmp = color_mix_2_alpha(*vdb_buf_tmp, (*vdb_buf_tmp).alpha, color, px_opa);
|
||||
*vdb_buf_tmp =
|
||||
color_mix_2_alpha(*vdb_buf_tmp, (*vdb_buf_tmp).alpha, color, px_opa);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -377,9 +373,9 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_draw_map(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)
|
||||
void lv_draw_map(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)
|
||||
{
|
||||
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
@ -426,7 +422,8 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_coord_t map_useful_w = lv_area_get_width(&masked_a);
|
||||
|
||||
/*The simplest case just copy the pixels into the VDB*/
|
||||
if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) {
|
||||
if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER &&
|
||||
recolor_opa == LV_OPA_TRANSP) {
|
||||
|
||||
/*Use the custom VDB write function is exists*/
|
||||
if(disp->driver.set_px_cb) {
|
||||
@ -434,7 +431,8 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = 0; col < map_useful_w; col++) {
|
||||
lv_color_t px_color = *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa);
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width,
|
||||
col + masked_a.x1, row, px_color, opa);
|
||||
}
|
||||
map_p += map_width * px_size_byte; /*Next row on the map*/
|
||||
}
|
||||
@ -474,14 +472,17 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
#if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1
|
||||
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*/
|
||||
/*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 == 32
|
||||
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;
|
||||
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);
|
||||
}
|
||||
@ -491,32 +492,40 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
|
||||
/*Re-color the pixel if required*/
|
||||
if(recolor_opa != LV_OPA_TRANSP) {
|
||||
if(last_img_px.full != px_color.full) { /*Minor acceleration: calculate only for new colors (save the last)*/
|
||||
if(last_img_px.full != px_color.full) { /*Minor acceleration: calculate only for
|
||||
new colors (save the last)*/
|
||||
last_img_px = px_color;
|
||||
recolored_px = lv_color_mix(recolor, last_img_px, recolor_opa);
|
||||
}
|
||||
/*Handle custom VDB write is present*/
|
||||
if(disp->driver.set_px_cb) {
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width,
|
||||
col + masked_a.x1, row, recolored_px, opa_result);
|
||||
}
|
||||
/*Normal native VDB write*/
|
||||
else {
|
||||
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full;
|
||||
else vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result);
|
||||
if(opa_result == LV_OPA_COVER)
|
||||
vdb_buf_tmp[col].full = recolored_px.full;
|
||||
else
|
||||
vdb_buf_tmp[col] =
|
||||
lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result);
|
||||
}
|
||||
} else {
|
||||
/*Handle custom VDB write is present*/
|
||||
if(disp->driver.set_px_cb) {
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result);
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width,
|
||||
col + masked_a.x1, row, px_color, opa_result);
|
||||
}
|
||||
/*Normal native VDB write*/
|
||||
else {
|
||||
if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col] = px_color;
|
||||
if(opa_result == LV_OPA_COVER)
|
||||
vdb_buf_tmp[col] = px_color;
|
||||
else {
|
||||
#if LV_COLOR_SCREEN_TRANSP == 0
|
||||
vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
|
||||
#else
|
||||
vdb_buf_tmp[col] = color_mix_2_alpha(vdb_buf_tmp[col], vdb_buf_tmp[col].alpha, px_color, opa_result);
|
||||
vdb_buf_tmp[col] = color_mix_2_alpha(
|
||||
vdb_buf_tmp[col], vdb_buf_tmp[col].alpha, px_color, opa_result);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -560,7 +569,8 @@ static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t len
|
||||
* @param color fill color
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color, lv_opa_t opa)
|
||||
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
/*Set all row in vdb to the given color*/
|
||||
lv_coord_t row;
|
||||
@ -571,7 +581,8 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
|
||||
if(disp->driver.set_px_cb) {
|
||||
for(col = fill_area->x1; col <= fill_area->x2; col++) {
|
||||
for(row = fill_area->y1; row <= fill_area->y2; row++) {
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)mem, mem_width, col, row, color, opa);
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)mem, mem_width, col, row, color,
|
||||
opa);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -633,7 +644,8 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
|
||||
* @param fg_opa alpha of the foreground color
|
||||
* @return the mixed color. the alpha channel (color.alpha) contains the result alpha
|
||||
*/
|
||||
static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, lv_color_t fg_color, lv_opa_t fg_opa)
|
||||
static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
|
||||
lv_color_t fg_color, lv_opa_t fg_opa)
|
||||
{
|
||||
/* Pick the foreground if it's fully opaque or the Background is fully transparent*/
|
||||
if(fg_opa == LV_OPA_COVER || bg_opa <= LV_OPA_MIN) {
|
||||
@ -657,26 +669,25 @@ static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
|
||||
static lv_color_t bg_color_save = {{0}};
|
||||
static lv_color_t c = {{0}};
|
||||
|
||||
if(fg_opa != fg_opa_save || bg_opa != bg_opa_save ||
|
||||
fg_color.full != fg_color_save.full || bg_color.full != bg_color_save.full)
|
||||
{
|
||||
if(fg_opa != fg_opa_save || bg_opa != bg_opa_save || fg_color.full != fg_color_save.full ||
|
||||
bg_color.full != bg_color_save.full) {
|
||||
fg_opa_save = fg_opa;
|
||||
bg_opa_save = bg_opa;
|
||||
fg_color.full = fg_color_save.full;
|
||||
bg_color.full = bg_color_save.full;
|
||||
/*Info: https://en.wikipedia.org/wiki/Alpha_compositing#Analytical_derivation_of_the_over_operator*/
|
||||
/*Info:
|
||||
* https://en.wikipedia.org/wiki/Alpha_compositing#Analytical_derivation_of_the_over_operator*/
|
||||
lv_opa_t alpha_res = 255 - ((uint16_t)((uint16_t)(255 - fg_opa) * (255 - bg_opa)) >> 8);
|
||||
if(alpha_res == 0) {
|
||||
while(1);
|
||||
while(1)
|
||||
;
|
||||
}
|
||||
lv_opa_t ratio = (uint16_t)((uint16_t)fg_opa * 255) / alpha_res;
|
||||
c = lv_color_mix(fg_color, bg_color, ratio);
|
||||
c.ch.alpha = alpha_res;
|
||||
}
|
||||
return c;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_COLOR_SCREEN_TRANSP*/
|
||||
|
||||
|
@ -35,7 +35,8 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa);
|
||||
void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color,
|
||||
lv_opa_t opa);
|
||||
/**
|
||||
* Fill an area in the Virtual Display Buffer
|
||||
* @param cords_p coordinates of the area to fill
|
||||
@ -43,8 +44,8 @@ void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color,
|
||||
lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a letter in the Virtual Display Buffer
|
||||
@ -55,9 +56,8 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_draw_letter(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);
|
||||
void lv_draw_letter(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);
|
||||
|
||||
/**
|
||||
* Draw a color map to the display (image)
|
||||
@ -70,9 +70,9 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_draw_map(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);
|
||||
void lv_draw_map(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);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -20,14 +20,16 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const void * src, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t * style);
|
||||
static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf);
|
||||
static void lv_img_decoder_close(void);
|
||||
static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf);
|
||||
static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf);
|
||||
static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, lv_coord_t len,
|
||||
uint8_t * buf);
|
||||
static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y, lv_coord_t len,
|
||||
uint8_t * buf);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -65,13 +67,14 @@ static lv_img_decoder_close_f_t lv_img_decoder_close_custom;
|
||||
* @param style style of the image
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const void * src, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
if(src == NULL) {
|
||||
LV_LOG_WARN("Image draw: src is NULL");
|
||||
lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE,
|
||||
NULL, -1, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -81,12 +84,12 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
if(res == LV_RES_INV) {
|
||||
LV_LOG_WARN("Image draw error");
|
||||
lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1);
|
||||
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE,
|
||||
NULL, -1, -1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize and `lv_img_dsc_t` variable with the image's info
|
||||
* @param src variable, filename or symbol
|
||||
@ -130,11 +133,12 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
|
||||
}
|
||||
#endif
|
||||
else if(src_type == LV_IMG_SRC_SYMBOL) {
|
||||
/*The size depend on the font but it is unknown here. It should be handled outside of the function*/
|
||||
/*The size depend on the font but it is unknown here. It should be handled outside of the
|
||||
* function*/
|
||||
header->w = 1;
|
||||
header->h = 1;
|
||||
/* Symbols always have transparent parts. Important because of cover check in the design function.
|
||||
* The actual value doesn't matter because lv_draw_label will draw it*/
|
||||
/* Symbols always have transparent parts. Important because of cover check in the design
|
||||
* function. The actual value doesn't matter because lv_draw_label will draw it*/
|
||||
header->cf = LV_IMG_CF_ALPHA_1BIT;
|
||||
} else {
|
||||
LV_LOG_WARN("Image get info found unknown src type");
|
||||
@ -148,18 +152,19 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header)
|
||||
* @param dsc an image descriptor
|
||||
* @param x x coordinate of the point to get
|
||||
* @param y x coordinate of the point to get
|
||||
* @param style style of the image. In case of `LV_IMG_CF_ALPHA_1/2/4/8` `style->image.color` shows the color.
|
||||
* Can be `NULL` but for `ALPHA` images black will be returned. In other cases it is not used.
|
||||
* @param style style of the image. In case of `LV_IMG_CF_ALPHA_1/2/4/8` `style->image.color` shows
|
||||
* the color. Can be `NULL` but for `ALPHA` images black will be returned. In other cases it is not
|
||||
* used.
|
||||
* @return color of the point
|
||||
*/
|
||||
lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_style_t * style)
|
||||
lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y,
|
||||
lv_style_t * style)
|
||||
{
|
||||
lv_color_t p_color = LV_COLOR_BLACK;
|
||||
if(x >= dsc->header.w) {
|
||||
x = dsc->header.w - 1;
|
||||
LV_LOG_WARN("lv_canvas_get_px: x is too large (out of canvas)");
|
||||
}
|
||||
else if(x < 0) {
|
||||
} else if(x < 0) {
|
||||
x = 0;
|
||||
LV_LOG_WARN("lv_canvas_get_px: x is < 0 (out of canvas)");
|
||||
}
|
||||
@ -167,8 +172,7 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y
|
||||
if(y >= dsc->header.h) {
|
||||
y = dsc->header.h - 1;
|
||||
LV_LOG_WARN("lv_canvas_get_px: y is too large (out of canvas)");
|
||||
}
|
||||
else if(y < 0) {
|
||||
} else if(y < 0) {
|
||||
y = 0;
|
||||
LV_LOG_WARN("lv_canvas_get_px: y is < 0 (out of canvas)");
|
||||
}
|
||||
@ -177,51 +181,44 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y
|
||||
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR ||
|
||||
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED ||
|
||||
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA)
|
||||
{
|
||||
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
uint8_t px_size = lv_img_color_format_get_px_size(dsc->header.cf) >> 3;
|
||||
uint32_t px = dsc->header.w * y * px_size + x * px_size;
|
||||
memcpy(&p_color, &buf_u8[px], sizeof(lv_color_t));
|
||||
#if LV_COLOR_SIZE == 32
|
||||
p_color.ch.alpha = 0xFF; /*Only the color should be get so use a deafult alpha value*/
|
||||
#endif
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
|
||||
buf_u8 += 4 * 2;
|
||||
uint8_t bit = x & 0x7;
|
||||
x = x >> 3;
|
||||
|
||||
uint32_t px = (dsc->header.w >> 3) * y + x;
|
||||
p_color.full = (buf_u8[px] & (1 << (7 - bit))) >> (7 - bit);
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
|
||||
buf_u8 += 4 * 4;
|
||||
uint8_t bit = (x & 0x3) * 2;
|
||||
x = x >> 2;
|
||||
|
||||
uint32_t px = (dsc->header.w >> 2) * y + x;
|
||||
p_color.full = (buf_u8[px] & (3 << (6 - bit))) >> (6 - bit);
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
|
||||
buf_u8 += 4 * 16;
|
||||
uint8_t bit = (x & 0x1) * 4;
|
||||
x = x >> 1;
|
||||
|
||||
uint32_t px = (dsc->header.w >> 1) * y + x;
|
||||
p_color.full = (buf_u8[px] & (0xF << (4 - bit))) >> (4 - bit);
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
buf_u8 += 4 * 256;
|
||||
uint32_t px = dsc->header.w * y + x;
|
||||
p_color.full = buf_u8[px];
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_ALPHA_8BIT)
|
||||
{
|
||||
if(style) p_color = style->image.color;
|
||||
else p_color = LV_COLOR_BLACK;
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
|
||||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
if(style)
|
||||
p_color = style->image.color;
|
||||
else
|
||||
p_color = LV_COLOR_BLACK;
|
||||
}
|
||||
return p_color;
|
||||
}
|
||||
@ -238,8 +235,7 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y)
|
||||
if(x >= dsc->header.w) {
|
||||
x = dsc->header.w - 1;
|
||||
LV_LOG_WARN("lv_canvas_get_px: x is too large (out of canvas)");
|
||||
}
|
||||
else if(x < 0) {
|
||||
} else if(x < 0) {
|
||||
x = 0;
|
||||
LV_LOG_WARN("lv_canvas_get_px: x is < 0 (out of canvas)");
|
||||
}
|
||||
@ -247,28 +243,24 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y)
|
||||
if(y >= dsc->header.h) {
|
||||
y = dsc->header.h - 1;
|
||||
LV_LOG_WARN("lv_canvas_get_px: y is too large (out of canvas)");
|
||||
}
|
||||
else if(y < 0) {
|
||||
} else if(y < 0) {
|
||||
y = 0;
|
||||
LV_LOG_WARN("lv_canvas_get_px: y is < 0 (out of canvas)");
|
||||
}
|
||||
|
||||
uint8_t * buf_u8 = (uint8_t *)dsc->data;
|
||||
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA)
|
||||
{
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
uint32_t px = dsc->header.w * y * LV_IMG_PX_SIZE_ALPHA_BYTE + x * LV_IMG_PX_SIZE_ALPHA_BYTE;
|
||||
return buf_u8[px + LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
|
||||
uint8_t bit = x & 0x7;
|
||||
x = x >> 3;
|
||||
|
||||
uint32_t px = (dsc->header.w >> 3) * y + x;
|
||||
uint8_t px_opa = (buf_u8[px] & (1 << (7 - bit))) >> (7 - bit);
|
||||
return px_opa ? LV_OPA_TRANSP : LV_OPA_COVER;
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
|
||||
const uint8_t opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
|
||||
|
||||
uint8_t bit = (x & 0x3) * 2;
|
||||
@ -277,12 +269,9 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y)
|
||||
uint32_t px = (dsc->header.w >> 2) * y + x;
|
||||
uint8_t px_opa = (buf_u8[px] & (3 << (6 - bit))) >> (6 - bit);
|
||||
return opa_table[px_opa];
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||
const uint8_t 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};
|
||||
|
||||
uint8_t bit = (x & 0x1) * 4;
|
||||
x = x >> 1;
|
||||
@ -290,8 +279,7 @@ lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y)
|
||||
uint32_t px = (dsc->header.w >> 1) * y + x;
|
||||
uint8_t px_opa = (buf_u8[px] & (0xF << (4 - bit))) >> (4 - bit);
|
||||
return opa_table[px_opa];
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
uint32_t px = dsc->header.w * y + x;
|
||||
return buf_u8[px];
|
||||
}
|
||||
@ -311,18 +299,15 @@ void lv_img_buf_set_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_c
|
||||
uint8_t * buf_u8 = (uint8_t *)dsc->data;
|
||||
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR ||
|
||||
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED)
|
||||
{
|
||||
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
|
||||
uint8_t px_size = lv_img_color_format_get_px_size(dsc->header.cf) >> 3;
|
||||
uint32_t px = dsc->header.w * y * px_size + x * px_size;
|
||||
memcpy(&buf_u8[px], &c, px_size);
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
uint8_t px_size = lv_img_color_format_get_px_size(dsc->header.cf) >> 3;
|
||||
uint32_t px = dsc->header.w * y * px_size + x * px_size;
|
||||
memcpy(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
|
||||
buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/
|
||||
|
||||
uint8_t bit = x & 0x7;
|
||||
@ -330,8 +315,7 @@ void lv_img_buf_set_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_c
|
||||
uint32_t px = (dsc->header.w >> 3) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(1 << (7 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((c.full & 0x1) << (7 - bit));
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
|
||||
buf_u8 += sizeof(lv_color32_t) * 4; /*Skip the palette*/
|
||||
uint8_t bit = (x & 0x3) * 2;
|
||||
x = x >> 2;
|
||||
@ -340,8 +324,7 @@ void lv_img_buf_set_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_c
|
||||
|
||||
buf_u8[px] = buf_u8[px] & ~(3 << (6 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((c.full & 0x3) << (6 - bit));
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
|
||||
buf_u8 += sizeof(lv_color32_t) * 16; /*Skip the palette*/
|
||||
uint8_t bit = (x & 0x1) * 4;
|
||||
x = x >> 1;
|
||||
@ -349,8 +332,7 @@ void lv_img_buf_set_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_c
|
||||
uint32_t px = (dsc->header.w >> 1) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(0xF << (4 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((c.full & 0xF) << (4 - bit));
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
buf_u8 += sizeof(lv_color32_t) * 256; /*Skip the palette*/
|
||||
uint32_t px = dsc->header.w * y + x;
|
||||
buf_u8[px] = c.full;
|
||||
@ -368,29 +350,25 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_o
|
||||
{
|
||||
uint8_t * buf_u8 = (uint8_t *)dsc->data;
|
||||
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA)
|
||||
{
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
|
||||
uint8_t px_size = lv_img_color_format_get_px_size(dsc->header.cf) >> 3;
|
||||
uint32_t px = dsc->header.w * y * px_size + x * px_size;
|
||||
buf_u8[px + px_size - 1] = opa;
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
|
||||
opa = opa >> 7; /*opa -> [0,1]*/
|
||||
uint8_t bit = x & 0x7;
|
||||
x = x >> 3;
|
||||
uint32_t px = (dsc->header.w >> 3) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(1 << (7 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((opa & 0x1) << (7 - bit));
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
|
||||
opa = opa >> 6; /*opa -> [0,3]*/
|
||||
uint8_t bit = (x & 0x3) * 2;
|
||||
x = x >> 2;
|
||||
uint32_t px = (dsc->header.w >> 2) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(3 << (6 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((opa & 0x3) << (6 - bit));
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
|
||||
opa = opa >> 4; /*opa -> [0,15]*/
|
||||
uint8_t bit = (x & 0x1) * 4;
|
||||
x = x >> 1;
|
||||
@ -398,8 +376,7 @@ void lv_img_buf_set_px_alpha(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_o
|
||||
uint32_t px = (dsc->header.w >> 1) * y + x;
|
||||
buf_u8[px] = buf_u8[px] & ~(0xF << (4 - bit));
|
||||
buf_u8[px] = buf_u8[px] | ((opa & 0xF) << (4 - bit));
|
||||
}
|
||||
else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
} else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
uint32_t px = dsc->header.w * y + x;
|
||||
buf_u8[px] = opa;
|
||||
}
|
||||
@ -420,8 +397,7 @@ void lv_img_buf_set_palette(lv_img_dsc_t *dsc, int color_id, lv_color_t color)
|
||||
if((dsc->header.cf == LV_IMG_CF_ALPHA_1BIT && color_id > 1) ||
|
||||
(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT && color_id > 3) ||
|
||||
(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT && color_id > 15) ||
|
||||
(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT && color_id > 255))
|
||||
{
|
||||
(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT && color_id > 255)) {
|
||||
LV_LOG_WARN("lv_img_buf_set_px_alpha: invalid 'color_id'");
|
||||
return;
|
||||
}
|
||||
@ -432,7 +408,6 @@ void lv_img_buf_set_palette(lv_img_dsc_t *dsc, int color_id, lv_color_t color)
|
||||
buf[color_id] = c32.full;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the pixel size of a color format in bits
|
||||
* @param cf a color format (`LV_IMG_CF_...`)
|
||||
@ -444,35 +419,19 @@ uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf)
|
||||
|
||||
switch(cf) {
|
||||
case LV_IMG_CF_UNKNOWN:
|
||||
case LV_IMG_CF_RAW:
|
||||
px_size = 0;
|
||||
break;
|
||||
case LV_IMG_CF_RAW: px_size = 0; break;
|
||||
case LV_IMG_CF_TRUE_COLOR:
|
||||
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED:
|
||||
px_size = LV_COLOR_SIZE;
|
||||
break;
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA:
|
||||
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE << 3;
|
||||
break;
|
||||
case LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED: px_size = LV_COLOR_SIZE; break;
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA: px_size = LV_IMG_PX_SIZE_ALPHA_BYTE << 3; break;
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
case LV_IMG_CF_ALPHA_1BIT:
|
||||
px_size = 1;
|
||||
break;
|
||||
case LV_IMG_CF_ALPHA_1BIT: px_size = 1; break;
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
case LV_IMG_CF_ALPHA_2BIT:
|
||||
px_size = 2;
|
||||
break;
|
||||
case LV_IMG_CF_ALPHA_2BIT: px_size = 2; break;
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
case LV_IMG_CF_ALPHA_4BIT:
|
||||
px_size = 4;
|
||||
break;
|
||||
case LV_IMG_CF_ALPHA_4BIT: px_size = 4; break;
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
case LV_IMG_CF_ALPHA_8BIT:
|
||||
px_size = 8;
|
||||
break;
|
||||
default:
|
||||
px_size = 0;
|
||||
break;
|
||||
case LV_IMG_CF_ALPHA_8BIT: px_size = 8; break;
|
||||
default: px_size = 0; break;
|
||||
}
|
||||
|
||||
return px_size;
|
||||
@ -493,18 +452,13 @@ bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf)
|
||||
case LV_IMG_CF_INDEXED_1BIT:
|
||||
case LV_IMG_CF_INDEXED_2BIT:
|
||||
case LV_IMG_CF_INDEXED_4BIT:
|
||||
case LV_IMG_CF_INDEXED_8BIT:
|
||||
is_chroma_keyed = true;
|
||||
break;
|
||||
default:
|
||||
is_chroma_keyed = false;
|
||||
break;
|
||||
case LV_IMG_CF_INDEXED_8BIT: is_chroma_keyed = true; break;
|
||||
default: is_chroma_keyed = false; break;
|
||||
}
|
||||
|
||||
return is_chroma_keyed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a color format has alpha channel or not
|
||||
* @param cf a color format (`LV_IMG_CF_...`)
|
||||
@ -520,12 +474,8 @@ bool lv_img_color_format_has_alpha(lv_img_cf_t cf)
|
||||
case LV_IMG_CF_ALPHA_1BIT:
|
||||
case LV_IMG_CF_ALPHA_2BIT:
|
||||
case LV_IMG_CF_ALPHA_4BIT:
|
||||
case LV_IMG_CF_ALPHA_8BIT:
|
||||
has_alpha = true;
|
||||
break;
|
||||
default:
|
||||
has_alpha = false;
|
||||
break;
|
||||
case LV_IMG_CF_ALPHA_8BIT: has_alpha = true; break;
|
||||
default: has_alpha = false; break;
|
||||
}
|
||||
|
||||
return has_alpha;
|
||||
@ -563,14 +513,16 @@ lv_img_src_t lv_img_src_get_type(const void * src)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom decoder functions. See the typdefs of the function typed above for more info about them
|
||||
* Set custom decoder functions. See the typdefs of the function typed above for more info about
|
||||
* them
|
||||
* @param info_fp info get function
|
||||
* @param open_fp open function
|
||||
* @param read_fp read line function
|
||||
* @param close_fp clode function
|
||||
*/
|
||||
void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_open_f_t open_fp,
|
||||
lv_img_decoder_read_line_f_t read_fp, lv_img_decoder_close_f_t close_fp)
|
||||
lv_img_decoder_read_line_f_t read_fp,
|
||||
lv_img_decoder_close_f_t close_fp)
|
||||
{
|
||||
lv_img_decoder_info_custom = info_fp;
|
||||
lv_img_decoder_open_custom = open_fp;
|
||||
@ -578,24 +530,25 @@ void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_
|
||||
lv_img_decoder_close_custom = close_fp;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const void * src, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
|
||||
lv_area_t mask_com; /*Common area of mask and coords*/
|
||||
bool union_ok;
|
||||
union_ok = lv_area_intersect(&mask_com, mask, coords);
|
||||
if(union_ok == false) {
|
||||
return LV_RES_OK; /*Out of mask. There is nothing to draw so the image is drawn successfully.*/
|
||||
return LV_RES_OK; /*Out of mask. There is nothing to draw so the image is drawn
|
||||
successfully.*/
|
||||
}
|
||||
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->image.opa : (uint16_t)((uint16_t) style->image.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->image.opa
|
||||
: (uint16_t)((uint16_t)style->image.opa * opa_scale) >> 8;
|
||||
|
||||
lv_img_header_t header;
|
||||
lv_res_t header_res;
|
||||
@ -619,7 +572,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
/* The decoder open could open the image and gave the entire uncompressed image.
|
||||
* Just draw it!*/
|
||||
if(img_data) {
|
||||
lv_draw_map(coords, mask, img_data, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense);
|
||||
lv_draw_map(coords, mask, img_data, opa, chroma_keyed, alpha_byte, style->image.color,
|
||||
style->image.intense);
|
||||
}
|
||||
/* The whole uncompressed image is not available. Try to read it line-by-line*/
|
||||
else {
|
||||
@ -628,7 +582,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
#if LV_COMPILER_VLA_SUPPORTED
|
||||
uint8_t buf[(lv_area_get_width(&mask_com) * ((LV_COLOR_DEPTH >> 3) + 1))];
|
||||
#else
|
||||
uint8_t buf[LV_HOR_RES_MAX * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/
|
||||
uint8_t buf[LV_HOR_RES_MAX *
|
||||
((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/
|
||||
#endif
|
||||
lv_area_t line;
|
||||
lv_area_copy(&line, &mask_com);
|
||||
@ -644,7 +599,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
LV_LOG_WARN("Image draw can't read the line");
|
||||
return LV_RES_INV;
|
||||
}
|
||||
lv_draw_map(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense);
|
||||
lv_draw_map(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color,
|
||||
style->image.intense);
|
||||
line.y1++;
|
||||
line.y2++;
|
||||
y++;
|
||||
@ -656,7 +612,6 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t * style)
|
||||
{
|
||||
decoder_custom = false;
|
||||
@ -666,7 +621,8 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
|
||||
const uint8_t * custom_res;
|
||||
custom_res = lv_img_decoder_open_custom(src, style);
|
||||
if(custom_res != LV_IMG_DECODER_OPEN_FAIL) {
|
||||
decoder_custom = true; /*Mark that custom decoder function should be used for this img source.*/
|
||||
decoder_custom =
|
||||
true; /*Mark that custom decoder function should be used for this img source.*/
|
||||
return custom_res; /*Custom open supported this source*/
|
||||
}
|
||||
}
|
||||
@ -698,23 +654,20 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*Process the different color formats*/
|
||||
lv_img_cf_t cf = decoder_header.cf;
|
||||
if(cf == LV_IMG_CF_TRUE_COLOR ||
|
||||
cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
|
||||
if(cf == LV_IMG_CF_TRUE_COLOR || cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
|
||||
cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
|
||||
if(decoder_src_type == LV_IMG_SRC_VARIABLE) {
|
||||
/*In case of uncompressed formats if the image stored in the ROM/RAM simply give it's pointer*/
|
||||
/*In case of uncompressed formats if the image stored in the ROM/RAM simply give it's
|
||||
* pointer*/
|
||||
return ((lv_img_dsc_t *)decoder_src)->data;
|
||||
} else {
|
||||
/*If it's file it need to be read line by line later*/
|
||||
return NULL;
|
||||
}
|
||||
} else if(cf == LV_IMG_CF_INDEXED_1BIT ||
|
||||
cf == LV_IMG_CF_INDEXED_2BIT ||
|
||||
cf == LV_IMG_CF_INDEXED_4BIT ||
|
||||
cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
} else if(cf == LV_IMG_CF_INDEXED_1BIT || cf == LV_IMG_CF_INDEXED_2BIT ||
|
||||
cf == LV_IMG_CF_INDEXED_4BIT || cf == LV_IMG_CF_INDEXED_8BIT) {
|
||||
|
||||
#if LV_IMG_CF_INDEXED
|
||||
#if LV_USE_FILESYSTEM
|
||||
@ -732,7 +685,8 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
|
||||
lv_fs_read(&decoder_file, palette_file, palette_size * sizeof(lv_color32_t), NULL);
|
||||
palette_p = palette_file;
|
||||
#else
|
||||
LV_LOG_WARN("Image built-in decoder can read the palette because LV_USE_FILESYSTEM = 0");
|
||||
LV_LOG_WARN(
|
||||
"Image built-in decoder can read the palette because LV_USE_FILESYSTEM = 0");
|
||||
return LV_IMG_DECODER_OPEN_FAIL;
|
||||
#endif
|
||||
} else {
|
||||
@ -742,17 +696,16 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < palette_size; i++) {
|
||||
decoder_index_map[i] = lv_color_make(palette_p[i].ch.red, palette_p[i].ch.green, palette_p[i].ch.blue);
|
||||
decoder_index_map[i] =
|
||||
lv_color_make(palette_p[i].ch.red, palette_p[i].ch.green, palette_p[i].ch.blue);
|
||||
}
|
||||
return NULL;
|
||||
#else
|
||||
LV_LOG_WARN("Indexed (palette) images are not enabled in lv_conf.h. See LV_IMG_CF_INDEXED");
|
||||
return LV_IMG_DECODER_OPEN_FAIL;
|
||||
#endif
|
||||
} else if(cf == LV_IMG_CF_ALPHA_1BIT ||
|
||||
cf == LV_IMG_CF_ALPHA_2BIT ||
|
||||
cf == LV_IMG_CF_ALPHA_4BIT ||
|
||||
cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
} else if(cf == LV_IMG_CF_ALPHA_1BIT || cf == LV_IMG_CF_ALPHA_2BIT ||
|
||||
cf == LV_IMG_CF_ALPHA_4BIT || cf == LV_IMG_CF_ALPHA_8BIT) {
|
||||
#if LV_IMG_CF_ALPHA
|
||||
return NULL; /*Nothing to process*/
|
||||
#else
|
||||
@ -765,7 +718,6 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t *
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static lv_res_t lv_img_decoder_read_line(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf)
|
||||
{
|
||||
/*Try to read the line with the custom functions*/
|
||||
@ -864,17 +816,17 @@ static void lv_img_decoder_close(void)
|
||||
}
|
||||
}
|
||||
|
||||
static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf)
|
||||
static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, lv_coord_t len,
|
||||
uint8_t * buf)
|
||||
{
|
||||
|
||||
#if LV_IMG_CF_ALPHA
|
||||
const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
|
||||
const lv_opa_t alpha1_opa_table[2] = {
|
||||
0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
|
||||
const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
|
||||
const lv_opa_t alpha4_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};
|
||||
|
||||
/*Simply fill the buffer with the color. Later only the alpha value will be modified.*/
|
||||
lv_color_t bg_color = decoder_style->image.color;
|
||||
@ -946,13 +898,13 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
|
||||
lv_fs_read(&decoder_file, fs_buf, w, NULL);
|
||||
data_tmp = fs_buf;
|
||||
#else
|
||||
LV_LOG_WARN("Image built-in alpha line reader can't read file because LV_USE_FILESYSTEM = 0");
|
||||
LV_LOG_WARN(
|
||||
"Image built-in alpha line reader can't read file because LV_USE_FILESYSTEM = 0");
|
||||
data_tmp = NULL; /*To avoid warnings*/
|
||||
return LV_RES_INV;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
uint8_t byte_act = 0;
|
||||
uint8_t val_act;
|
||||
for(i = 0; i < len; i++) {
|
||||
@ -971,12 +923,14 @@ static lv_res_t lv_img_built_in_decoder_line_alpha(lv_coord_t x, lv_coord_t y, l
|
||||
return LV_RES_OK;
|
||||
|
||||
#else
|
||||
LV_LOG_WARN("Image built-in alpha line reader failed because LV_IMG_CF_ALPHA is 0 in lv_conf.h");
|
||||
LV_LOG_WARN(
|
||||
"Image built-in alpha line reader failed because LV_IMG_CF_ALPHA is 0 in lv_conf.h");
|
||||
return LV_RES_INV;
|
||||
#endif
|
||||
}
|
||||
|
||||
static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf)
|
||||
static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y, lv_coord_t len,
|
||||
uint8_t * buf)
|
||||
{
|
||||
|
||||
#if LV_IMG_CF_INDEXED
|
||||
@ -1033,7 +987,8 @@ static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y,
|
||||
lv_fs_read(&decoder_file, fs_buf, w, NULL);
|
||||
data_tmp = fs_buf;
|
||||
#else
|
||||
LV_LOG_WARN("Image built-in indexed line reader can't read file because LV_USE_FILESYSTEM = 0");
|
||||
LV_LOG_WARN(
|
||||
"Image built-in indexed line reader can't read file because LV_USE_FILESYSTEM = 0");
|
||||
data_tmp = NULL; /*To avoid warnings*/
|
||||
return LV_RES_INV;
|
||||
#endif
|
||||
@ -1056,7 +1011,8 @@ static lv_res_t lv_img_built_in_decoder_line_indexed(lv_coord_t x, lv_coord_t y,
|
||||
|
||||
return LV_RES_OK;
|
||||
#else
|
||||
LV_LOG_WARN("Image built-in indexed line reader failed because LV_IMG_CF_INDEXED is 0 in lv_conf.h");
|
||||
LV_LOG_WARN(
|
||||
"Image built-in indexed line reader failed because LV_IMG_CF_INDEXED is 0 in lv_conf.h");
|
||||
return LV_RES_INV;
|
||||
#endif
|
||||
}
|
||||
|
@ -26,12 +26,14 @@ extern "C" {
|
||||
**********************/
|
||||
struct _lv_img_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
|
||||
/* The first 8 bit is very important to distinguish the different source types.
|
||||
* For more info see `lv_img_get_src_type()` in lv_img.c */
|
||||
uint32_t cf : 5; /* Color format: See `lv_img_color_format_t`*/
|
||||
uint32_t always_zero :3; /*It the upper bits of the first byte. Always zero to look like a non-printable character*/
|
||||
uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a
|
||||
non-printable character*/
|
||||
|
||||
uint32_t reserved : 2; /*Reserved to be used later*/
|
||||
|
||||
@ -44,12 +46,15 @@ enum {
|
||||
LV_IMG_CF_UNKNOWN = 0,
|
||||
|
||||
LV_IMG_CF_RAW, /*Contains the file as it is. Needs custom decoder function*/
|
||||
LV_IMG_CF_RAW_ALPHA, /*Contains the file as it is. The image has alpha. Needs custom decoder function*/
|
||||
LV_IMG_CF_RAW_CHROMA_KEYED, /*Contains the file as it is. The image is chroma keyed. Needs custom decoder function*/
|
||||
LV_IMG_CF_RAW_ALPHA, /*Contains the file as it is. The image has alpha. Needs custom decoder
|
||||
function*/
|
||||
LV_IMG_CF_RAW_CHROMA_KEYED, /*Contains the file as it is. The image is chroma keyed. Needs
|
||||
custom decoder function*/
|
||||
|
||||
LV_IMG_CF_TRUE_COLOR, /*Color format and depth should match with LV_COLOR settings*/
|
||||
LV_IMG_CF_TRUE_COLOR_ALPHA, /*Same as `LV_IMG_CF_TRUE_COLOR` but every pixel has an alpha byte*/
|
||||
LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, /*Same as `LV_IMG_CF_TRUE_COLOR` but LV_COLOR_TRANSP pixels will be transparent*/
|
||||
LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, /*Same as `LV_IMG_CF_TRUE_COLOR` but LV_COLOR_TRANSP pixels
|
||||
will be transparent*/
|
||||
|
||||
LV_IMG_CF_INDEXED_1BIT, /*Can have 2 different colors in a palette (always chroma keyed)*/
|
||||
LV_IMG_CF_INDEXED_2BIT, /*Can have 4 different colors in a palette (always chroma keyed)*/
|
||||
@ -74,10 +79,10 @@ typedef struct
|
||||
|
||||
/* Decoder function definitions */
|
||||
|
||||
|
||||
/**
|
||||
* Get info from an image and store in the `header`
|
||||
* @param src the image source. Can be a pointer to a C array or a file name (Use `lv_img_src_get_type` to determine the type)
|
||||
* @param src the image source. Can be a pointer to a C array or a file name (Use
|
||||
* `lv_img_src_get_type` to determine the type)
|
||||
* @param header store the info here
|
||||
* @return LV_RES_OK: info written correctly; LV_RES_INV: failed
|
||||
*/
|
||||
@ -85,12 +90,14 @@ typedef lv_res_t (*lv_img_decoder_info_f_t)(const void * src, lv_img_header_t *
|
||||
|
||||
/**
|
||||
* Open an image for decoding. Prepare it as it is required to read it later
|
||||
* @param src the image source. Can be a pointer to a C array or a file name (Use `lv_img_src_get_type` to determine the type)
|
||||
* @param src the image source. Can be a pointer to a C array or a file name (Use
|
||||
* `lv_img_src_get_type` to determine the type)
|
||||
* @param style the style of image (maybe it will be required to determine a color or something)
|
||||
* @return there are 3 possible return values:
|
||||
* 1) buffer with the decoded image
|
||||
* 2) if can decode the whole image NULL. decoder_read_line will be called to read the image line-by-line
|
||||
* 3) LV_IMG_DECODER_OPEN_FAIL if the image format is unknown to the decoder or an error occurred
|
||||
* 2) if can decode the whole image NULL. decoder_read_line will be called to read the image
|
||||
* line-by-line 3) LV_IMG_DECODER_OPEN_FAIL if the image format is unknown to the decoder or an
|
||||
* error occurred
|
||||
*/
|
||||
typedef const uint8_t * (*lv_img_decoder_open_f_t)(const void * src, const lv_style_t * style);
|
||||
|
||||
@ -103,7 +110,8 @@ typedef const uint8_t * (*lv_img_decoder_open_f_t)(const void * src, const lv_st
|
||||
* @param buf a buffer to store the decoded pixels
|
||||
* @return LV_RES_OK: ok; LV_RES_INV: failed
|
||||
*/
|
||||
typedef lv_res_t (*lv_img_decoder_read_line_f_t)(lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf);
|
||||
typedef lv_res_t (*lv_img_decoder_read_line_f_t)(lv_coord_t x, lv_coord_t y, lv_coord_t len,
|
||||
uint8_t * buf);
|
||||
|
||||
/**
|
||||
* Close the pending decoding. Free resources etc.
|
||||
@ -122,9 +130,8 @@ typedef void (*lv_img_decoder_close_f_t)(void);
|
||||
* @param style style of the image
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const void * src, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
/**
|
||||
* Initialize and `lv_img_dsc_t` variable with the image's info
|
||||
@ -145,25 +152,29 @@ lv_res_t lv_img_dsc_get_info(const char * src, lv_img_header_t * header);
|
||||
lv_img_src_t lv_img_src_get_type(const void * src);
|
||||
|
||||
/**
|
||||
* Set custom decoder functions. See the typdefs of the function typed above for more info about them
|
||||
* Set custom decoder functions. See the typdefs of the function typed above for more info about
|
||||
* them
|
||||
* @param info_fp info get function
|
||||
* @param open_fp open function
|
||||
* @param read_fp read line function
|
||||
* @param close_fp clode function
|
||||
*/
|
||||
void lv_img_decoder_set_custom(lv_img_decoder_info_f_t info_fp, lv_img_decoder_open_f_t open_fp,
|
||||
lv_img_decoder_read_line_f_t read_fp, lv_img_decoder_close_f_t close_fp);
|
||||
lv_img_decoder_read_line_f_t read_fp,
|
||||
lv_img_decoder_close_f_t close_fp);
|
||||
|
||||
/**
|
||||
* Get the color of an image's pixel
|
||||
* @param dsc an image descriptor
|
||||
* @param x x coordinate of the point to get
|
||||
* @param y x coordinate of the point to get
|
||||
* @param style style of the image. In case of `LV_IMG_CF_ALPHA_1/2/4/8` `style->image.color` shows the color.
|
||||
* Can be `NULL` but for `ALPHA` images black will be returned. In other cases it is not used.
|
||||
* @param style style of the image. In case of `LV_IMG_CF_ALPHA_1/2/4/8` `style->image.color` shows
|
||||
* the color. Can be `NULL` but for `ALPHA` images black will be returned. In other cases it is not
|
||||
* used.
|
||||
* @return color of the point
|
||||
*/
|
||||
lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t *dsc, lv_coord_t x, lv_coord_t y, lv_style_t * style);
|
||||
lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y,
|
||||
lv_style_t * style);
|
||||
/**
|
||||
* Get the alpha value of an image's pixel
|
||||
* @param dsc pointer to an image descriptor
|
||||
@ -228,7 +239,6 @@ bool lv_img_color_format_has_alpha(lv_img_cf_t cf);
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -33,7 +33,6 @@ static uint8_t hex_char_to_num(char hex);
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -54,8 +53,9 @@ static uint8_t hex_char_to_num(char hex);
|
||||
* @param sel_start start index of selected area (-1 if none)
|
||||
* @param sel_end end index of selected area (-1 if none)
|
||||
*/
|
||||
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale,
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset, int sel_start, int sel_end)
|
||||
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale, const char * txt, lv_txt_flag_t flag, lv_point_t * offset,
|
||||
int sel_start, int sel_end)
|
||||
{
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_coord_t w;
|
||||
@ -65,13 +65,13 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
} else {
|
||||
/*If EXAPND is enabled then not limit the text's width to the object's width*/
|
||||
lv_point_t p;
|
||||
lv_txt_get_size(&p, txt, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, flag);
|
||||
lv_txt_get_size(&p, txt, style->text.font, style->text.letter_space, style->text.line_space,
|
||||
LV_COORD_MAX, flag);
|
||||
w = p.x;
|
||||
}
|
||||
|
||||
lv_coord_t line_height = lv_font_get_height(font) + style->text.line_space;
|
||||
|
||||
|
||||
/*Init variables for the first line*/
|
||||
lv_coord_t line_width = 0;
|
||||
lv_point_t pos;
|
||||
@ -101,21 +101,22 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
|
||||
/*Align to middle*/
|
||||
if(flag & LV_TXT_FLAG_CENTER) {
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font,
|
||||
style->text.letter_space, flag);
|
||||
|
||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||
|
||||
}
|
||||
/*Align to the right*/
|
||||
else if(flag & LV_TXT_FLAG_RIGHT) {
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font,
|
||||
style->text.letter_space, flag);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
}
|
||||
|
||||
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->text.opa : (uint16_t)((uint16_t) style->text.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->text.opa
|
||||
: (uint16_t)((uint16_t)style->text.opa * opa_scale) >> 8;
|
||||
|
||||
cmd_state_t cmd_state = CMD_STATE_WAIT;
|
||||
uint32_t i;
|
||||
@ -145,7 +146,8 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
par_start = i;
|
||||
cmd_state = CMD_STATE_PAR;
|
||||
continue;
|
||||
} else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */
|
||||
} 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 */
|
||||
cmd_state = CMD_STATE_WAIT;
|
||||
@ -195,7 +197,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
}
|
||||
lv_draw_letter(&pos, mask, font, letter, color, opa);
|
||||
|
||||
|
||||
if(letter_w > 0) {
|
||||
pos.x += letter_w + style->text.letter_space;
|
||||
}
|
||||
@ -207,16 +208,16 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
pos.x = coords->x1;
|
||||
/*Align to middle*/
|
||||
if(flag & LV_TXT_FLAG_CENTER) {
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font,
|
||||
style->text.letter_space, flag);
|
||||
|
||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||
|
||||
}
|
||||
/*Align to the right*/
|
||||
else if(flag & LV_TXT_FLAG_RIGHT) {
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font,
|
||||
style->text.letter_space, flag);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
}
|
||||
|
||||
@ -242,32 +243,17 @@ static uint8_t hex_char_to_num(char hex)
|
||||
|
||||
if(hex >= '0' && hex <= '9') {
|
||||
result = hex - '0';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(hex >= 'a') hex -= 'a' - 'A'; /*Convert to upper case*/
|
||||
|
||||
switch(hex) {
|
||||
case 'A':
|
||||
result = 10;
|
||||
break;
|
||||
case 'B':
|
||||
result = 11;
|
||||
break;
|
||||
case 'C':
|
||||
result = 12;
|
||||
break;
|
||||
case 'D':
|
||||
result = 13;
|
||||
break;
|
||||
case 'E':
|
||||
result = 14;
|
||||
break;
|
||||
case 'F':
|
||||
result = 15;
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
break;
|
||||
case 'A': result = 10; break;
|
||||
case 'B': result = 11; break;
|
||||
case 'C': result = 12; break;
|
||||
case 'D': result = 13; break;
|
||||
case 'E': result = 14; break;
|
||||
case 'F': result = 15; break;
|
||||
default: result = 0; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,14 +39,14 @@ extern "C" {
|
||||
* @param sel_start start index of selected area (-1 if none)
|
||||
* @param sel_end end index of selected area (-1 if none)
|
||||
*/
|
||||
void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale,
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset, int sel_start, int sel_end);
|
||||
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale, const char * txt, lv_txt_flag_t flag, lv_point_t * offset,
|
||||
int sel_start, int sel_end);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -23,7 +23,8 @@
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_point_t p_act;
|
||||
@ -36,7 +37,8 @@ typedef struct {
|
||||
bool hor; /*Rather horizontal or vertical*/
|
||||
} line_draw_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
lv_coord_t width;
|
||||
lv_coord_t width_1;
|
||||
lv_coord_t width_half;
|
||||
@ -45,9 +47,12 @@ typedef struct {
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale);
|
||||
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale);
|
||||
static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void line_init(line_draw_t * line, const lv_point_t * p1, const lv_point_t * p2);
|
||||
static bool line_next(line_draw_t * line);
|
||||
static bool line_next_y(line_draw_t * line);
|
||||
@ -117,7 +122,6 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
|
||||
line_init(&main_line, &p1, &p2);
|
||||
|
||||
|
||||
/*Special case draw a horizontal line*/
|
||||
if(main_line.p1.y == main_line.p2.y) {
|
||||
line_draw_hor(&main_line, mask, style, opa_scale);
|
||||
@ -140,30 +144,31 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
p_tmp.x = main_line.p2.x;
|
||||
p_tmp.y = main_line.p2.y - 1;
|
||||
line_init(&main_line, &p1, &p_tmp);
|
||||
main_line.sy = LV_MATH_ABS(main_line.sy); /*The sign can change if the line becomes horizontal*/
|
||||
}
|
||||
else if(main_line.p1.y > main_line.p2.y) {
|
||||
main_line.sy = LV_MATH_ABS(
|
||||
main_line.sy); /*The sign can change if the line becomes horizontal*/
|
||||
} else if(main_line.p1.y > main_line.p2.y) {
|
||||
dir_ori = false;
|
||||
p_tmp.x = main_line.p2.x;
|
||||
p_tmp.y = main_line.p2.y + 1;
|
||||
line_init(&main_line, &p1, &p_tmp);
|
||||
main_line.sy = -LV_MATH_ABS(main_line.sy); /*The sign can change if the line becomes horizontal*/
|
||||
main_line.sy = -LV_MATH_ABS(
|
||||
main_line.sy); /*The sign can change if the line becomes horizontal*/
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(main_line.p1.x < main_line.p2.x) {
|
||||
dir_ori = true;
|
||||
p_tmp.x = main_line.p2.x - 1;
|
||||
p_tmp.y = main_line.p2.y;
|
||||
line_init(&main_line, &p1, &p_tmp);
|
||||
main_line.sx = LV_MATH_ABS(main_line.sx); /*The sign can change if the line becomes vertical*/
|
||||
}
|
||||
else if(main_line.p1.x > main_line.p2.x) {
|
||||
main_line.sx = LV_MATH_ABS(
|
||||
main_line.sx); /*The sign can change if the line becomes vertical*/
|
||||
} else if(main_line.p1.x > main_line.p2.x) {
|
||||
dir_ori = false;
|
||||
p_tmp.x = main_line.p2.x + 1;
|
||||
p_tmp.y = main_line.p2.y;
|
||||
line_init(&main_line, &p1, &p_tmp);
|
||||
main_line.sx = -LV_MATH_ABS(main_line.sx); /*The sign can change if the line becomes vertical*/
|
||||
main_line.sx = -LV_MATH_ABS(
|
||||
main_line.sx); /*The sign can change if the line becomes vertical*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -172,18 +177,19 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale)
|
||||
{
|
||||
lv_coord_t width = style->line.width - 1;
|
||||
lv_coord_t width_half = width >> 1;
|
||||
lv_coord_t width_1 = width & 0x1;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->line.opa
|
||||
: (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8;
|
||||
|
||||
lv_area_t act_area;
|
||||
act_area.x1 = main_line->p1.x;
|
||||
@ -199,12 +205,15 @@ static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale)
|
||||
{
|
||||
lv_coord_t width = style->line.width - 1;
|
||||
lv_coord_t width_half = width >> 1;
|
||||
lv_coord_t width_1 = width & 0x1;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->line.opa
|
||||
: (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8;
|
||||
|
||||
lv_area_t act_area;
|
||||
act_area.x1 = main_line->p1.x - width_half;
|
||||
@ -220,10 +229,13 @@ static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t) style->line.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->line.opa
|
||||
: (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8;
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
lv_point_t vect_main, vect_norm;
|
||||
vect_main.x = main_line->p2.x - main_line->p1.x;
|
||||
@ -276,8 +288,10 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
pattern[i].x = pattern_line.p_act.x;
|
||||
pattern[i].y = pattern_line.p_act.y;
|
||||
|
||||
/*Finish the pattern line if it's length equal to the desired width (Use Pythagoras theorem)*/
|
||||
uint32_t sqr = pattern_line.p_act.x * pattern_line.p_act.x + pattern_line.p_act.y * pattern_line.p_act.y;
|
||||
/*Finish the pattern line if it's length equal to the desired width (Use Pythagoras
|
||||
* theorem)*/
|
||||
uint32_t sqr = pattern_line.p_act.x * pattern_line.p_act.x +
|
||||
pattern_line.p_act.y * pattern_line.p_act.y;
|
||||
if(sqr >= width_sqr) {
|
||||
width = i;
|
||||
#if LV_ANTIALIAS
|
||||
@ -306,8 +320,7 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
if(width != 0) {
|
||||
x_center_ofs = pattern[width - 1].x / 2;
|
||||
y_center_ofs = pattern[width - 1].y / 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(main_line->hor && main_line->p1.y >= main_line->p2.y + dir_ori) pattern[0].y--;
|
||||
if(!main_line->hor && main_line->p1.x >= main_line->p2.x + dir_ori) pattern[0].x--;
|
||||
}
|
||||
@ -323,17 +336,23 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
if(pattern[i - 1].x != pattern[i].x) {
|
||||
lv_coord_t seg_w = pattern[i].y - pattern[aa_last_corner].y;
|
||||
if(main_line->sy < 0) {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w + 1,
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1,
|
||||
main_line->p1.y + pattern[aa_last_corner].y + seg_w +
|
||||
1,
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w + 1,
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1,
|
||||
main_line->p2.y + pattern[aa_last_corner].y + seg_w +
|
||||
1,
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
} else {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
|
||||
seg_w, mask, style->line.color, opa);
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1,
|
||||
main_line->p1.y + pattern[aa_last_corner].y, seg_w,
|
||||
mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1,
|
||||
main_line->p2.y + pattern[aa_last_corner].y, -seg_w,
|
||||
mask, style->line.color, opa);
|
||||
}
|
||||
aa_last_corner = i;
|
||||
}
|
||||
@ -341,22 +360,27 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
if(pattern[i - 1].y != pattern[i].y) {
|
||||
lv_coord_t seg_w = pattern[i].x - pattern[aa_last_corner].x;
|
||||
if(main_line->sx < 0) {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w + 1, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w +
|
||||
1,
|
||||
main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w + 1, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w +
|
||||
1,
|
||||
main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
} else {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x,
|
||||
main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x,
|
||||
main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
}
|
||||
aa_last_corner = i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -368,36 +392,43 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
if(main_line->hor) {
|
||||
lv_coord_t seg_w = pattern[width_safe - 1].y - pattern[aa_last_corner].y;
|
||||
if(main_line->sy < 0) {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w,
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1,
|
||||
main_line->p1.y + pattern[aa_last_corner].y + seg_w,
|
||||
seg_w + main_line->sy, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w,
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1,
|
||||
main_line->p2.y + pattern[aa_last_corner].y + seg_w,
|
||||
-(seg_w + main_line->sy), mask, style->line.color, opa);
|
||||
|
||||
} else {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1,
|
||||
main_line->p1.y + pattern[aa_last_corner].y,
|
||||
seg_w + main_line->sy, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1,
|
||||
main_line->p2.y + pattern[aa_last_corner].y,
|
||||
-(seg_w + main_line->sy), mask, style->line.color, opa);
|
||||
}
|
||||
} else {
|
||||
lv_coord_t seg_w = pattern[width_safe - 1].x - pattern[aa_last_corner].x;
|
||||
if(main_line->sx < 0) {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w,
|
||||
main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w + main_line->sx, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w,
|
||||
main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-(seg_w + main_line->sx), mask, style->line.color, opa);
|
||||
|
||||
} else {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x,
|
||||
main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w + main_line->sx, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x,
|
||||
main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-(seg_w + main_line->sx), mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -444,9 +475,11 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in y one pixel remains empty on every corner (don't do this on the first segment ) */
|
||||
* When stepping in y one pixel remains empty on every corner (don't do this on the
|
||||
* first segment ) */
|
||||
if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) {
|
||||
lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa);
|
||||
lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color,
|
||||
opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +487,8 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
if(aa) {
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1,
|
||||
-(main_line->p_act.x - prev_p.x), mask, style->line.color, opa);
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2,
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x,
|
||||
prev_p.y + pattern[width_safe - 1].y + aa_shift2,
|
||||
main_line->p_act.x - prev_p.x, mask, style->line.color, opa);
|
||||
}
|
||||
#endif
|
||||
@ -475,7 +509,8 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
/* Fill the gaps
|
||||
* When stepping in y one pixel remains empty on every corner */
|
||||
if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) {
|
||||
lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa);
|
||||
lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color,
|
||||
opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -483,7 +518,8 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
if(aa) {
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1,
|
||||
-(main_line->p_act.x - prev_p.x + 1), mask, style->line.color, opa);
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2,
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x,
|
||||
prev_p.y + pattern[width_safe - 1].y + aa_shift2,
|
||||
main_line->p_act.x - prev_p.x + 1, mask, style->line.color, opa);
|
||||
}
|
||||
#endif
|
||||
@ -501,18 +537,20 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in x one pixel remains empty on every corner (don't do this on the first segment ) */
|
||||
* When stepping in x one pixel remains empty on every corner (don't do this on the
|
||||
* first segment ) */
|
||||
if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) {
|
||||
lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa);
|
||||
lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color,
|
||||
opa);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
if(aa) {
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y,
|
||||
-(main_line->p_act.y - prev_p.y), mask, style->line.color, opa);
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y,
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2,
|
||||
prev_p.y + pattern[width_safe - 1].y,
|
||||
main_line->p_act.y - prev_p.y, mask, style->line.color, opa);
|
||||
}
|
||||
#endif
|
||||
@ -535,7 +573,8 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
/* Fill the gaps
|
||||
* When stepping in x one pixel remains empty on every corner */
|
||||
if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) {
|
||||
lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa);
|
||||
lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color,
|
||||
opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -543,14 +582,14 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
if(aa) {
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y,
|
||||
-(main_line->p_act.y - prev_p.y + 1), mask, style->line.color, opa);
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y,
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2,
|
||||
prev_p.y + pattern[width_safe - 1].y,
|
||||
main_line->p_act.y - prev_p.y + 1, mask, style->line.color, opa);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void line_init(line_draw_t * line, const lv_point_t * p1, const lv_point_t * p2)
|
||||
{
|
||||
line->p1.x = p1->x;
|
||||
@ -599,7 +638,6 @@ static bool line_next_y(line_draw_t * line)
|
||||
} while(last_y == line->p_act.y);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -616,6 +654,4 @@ static bool line_next_x(line_draw_t * line)
|
||||
} while(last_x == line->p_act.x);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,6 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -14,10 +14,14 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD 1 /*Circle segment greater then this value will be anti-aliased by a non-linear (cos) opacity mapping*/
|
||||
#define CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD \
|
||||
1 /*Circle segment greater then this value will be anti-aliased by a non-linear (cos) opacity \
|
||||
mapping*/
|
||||
|
||||
#define SHADOW_OPA_EXTRA_PRECISION 8 /*Calculate with 2^x bigger shadow opacity values to avoid rounding errors*/
|
||||
#define SHADOW_BOTTOM_AA_EXTRA_RADIUS 3 /*Add extra radius with LV_SHADOW_BOTTOM to cover anti-aliased corners*/
|
||||
#define SHADOW_OPA_EXTRA_PRECISION \
|
||||
8 /*Calculate with 2^x bigger shadow opacity values to avoid rounding errors*/
|
||||
#define SHADOW_BOTTOM_AA_EXTRA_RADIUS \
|
||||
3 /*Add extra radius with LV_SHADOW_BOTTOM to cover anti-aliased corners*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -26,16 +30,24 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
#if LV_USE_SHADOW
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, const lv_opa_t * map);
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, const lv_opa_t * map);
|
||||
#endif
|
||||
|
||||
static uint16_t lv_draw_cont_radius_corr(uint16_t r, lv_coord_t w, lv_coord_t h);
|
||||
@ -63,7 +75,8 @@ static lv_opa_t antialias_get_opa_circ(lv_coord_t seg, lv_coord_t px_id, lv_opa_
|
||||
* @param style pointer to a style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale)
|
||||
{
|
||||
if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
|
||||
|
||||
@ -80,7 +93,8 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty
|
||||
}
|
||||
}
|
||||
|
||||
if(style->body.border.width != 0 && style->body.border.part != LV_BORDER_NONE && style->body.border.opa >= LV_OPA_MIN) {
|
||||
if(style->body.border.width != 0 && style->body.border.part != LV_BORDER_NONE &&
|
||||
style->body.border.opa >= LV_OPA_MIN) {
|
||||
lv_draw_rect_border_straight(coords, mask, style, opa_scale);
|
||||
|
||||
if(style->body.radius != 0) {
|
||||
@ -100,7 +114,8 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
uint16_t radius = style->body.radius;
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
@ -110,7 +125,9 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma
|
||||
uint8_t mix;
|
||||
lv_coord_t height = lv_area_get_height(coords);
|
||||
lv_coord_t width = lv_area_get_width(coords);
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->body.opa
|
||||
: (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8;
|
||||
|
||||
radius = lv_draw_cont_radius_corr(radius, width, height);
|
||||
|
||||
@ -171,7 +188,8 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma
|
||||
* @param rects_p pointer to a rectangle style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
uint16_t radius = style->body.radius;
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
@ -179,7 +197,9 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
lv_color_t mcolor = style->body.main_color;
|
||||
lv_color_t gcolor = style->body.grad_color;
|
||||
lv_color_t act_color;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->body.opa
|
||||
: (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8;
|
||||
uint8_t mix;
|
||||
lv_coord_t height = lv_area_get_height(coords);
|
||||
lv_coord_t width = lv_area_get_width(coords);
|
||||
@ -213,25 +233,17 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
lv_circ_init(&cir, &cir_tmp, radius);
|
||||
|
||||
/*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));
|
||||
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));
|
||||
|
||||
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));
|
||||
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));
|
||||
|
||||
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));
|
||||
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));
|
||||
|
||||
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));
|
||||
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));
|
||||
#if LV_ANTIALIAS
|
||||
/*Store some internal states for anti-aliasing*/
|
||||
lv_coord_t out_y_seg_start = 0;
|
||||
@ -262,25 +274,38 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
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*/
|
||||
if(seg_size > CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD) { /*Use non-linear opa mapping
|
||||
on the first segment*/
|
||||
aa_opa = antialias_get_opa_circ(seg_size, i, opa);
|
||||
} else {
|
||||
aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
}
|
||||
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i,
|
||||
rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_bottom,
|
||||
aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i,
|
||||
lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_bottom,
|
||||
aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i,
|
||||
lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_top,
|
||||
aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i,
|
||||
rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_top,
|
||||
aa_opa);
|
||||
|
||||
mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height;
|
||||
aa_color_ver = lv_color_mix(mcolor, gcolor, mix);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1,
|
||||
rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1,
|
||||
lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
|
||||
aa_color_ver = lv_color_mix(gcolor, mcolor, mix);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1,
|
||||
lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1,
|
||||
rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
}
|
||||
|
||||
out_x_last = cir.x;
|
||||
@ -305,7 +330,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
|
||||
/*Draw the areas which are not disabled*/
|
||||
if(edge_top_refr != 0) {
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
if(mcolor.full == gcolor.full)
|
||||
act_color = mcolor;
|
||||
else {
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
@ -314,7 +340,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
}
|
||||
|
||||
if(mid_top_refr != 0) {
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
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);
|
||||
@ -323,7 +350,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
}
|
||||
|
||||
if(mid_bot_refr != 0) {
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
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);
|
||||
@ -333,7 +361,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
|
||||
if(edge_bot_refr != 0) {
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
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);
|
||||
@ -343,29 +372,26 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
|
||||
/*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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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);
|
||||
}
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
if(mcolor.full == gcolor.full)
|
||||
act_color = mcolor;
|
||||
else {
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
@ -374,7 +400,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
|
||||
if(edge_top_area.y1 != mid_top_area.y1) {
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
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);
|
||||
@ -382,7 +409,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
lv_draw_fill(&mid_top_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
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);
|
||||
@ -391,7 +419,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
|
||||
if(edge_bot_area.y1 != mid_bot_area.y1) {
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
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);
|
||||
@ -399,7 +428,6 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
lv_draw_fill(&edge_bot_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
if(aa) {
|
||||
/*The first and the last line is not drawn*/
|
||||
@ -428,19 +456,27 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
lv_coord_t i;
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1,
|
||||
mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1,
|
||||
mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1,
|
||||
mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1,
|
||||
mask, aa_color_hor_bottom, aa_opa);
|
||||
|
||||
mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height;
|
||||
aa_color_ver = lv_color_mix(mcolor, gcolor, mix);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i,
|
||||
mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i,
|
||||
mask, aa_color_ver, aa_opa);
|
||||
|
||||
aa_color_ver = lv_color_mix(gcolor, mcolor, mix);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i,
|
||||
mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i,
|
||||
mask, aa_color_ver, aa_opa);
|
||||
}
|
||||
|
||||
/*In some cases the last pixel is not drawn*/
|
||||
@ -453,10 +489,14 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
aa_color_hor_bottom = lv_color_mix(mcolor, gcolor, mix);
|
||||
|
||||
lv_opa_t aa_opa = opa >> 1;
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask,
|
||||
aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask,
|
||||
aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask,
|
||||
aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask,
|
||||
aa_color_hor_top, aa_opa);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -469,7 +509,8 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
* @param rstyle pointer to a rectangle style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
uint16_t radius = style->body.radius;
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
@ -477,7 +518,9 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
lv_coord_t width = lv_area_get_width(coords);
|
||||
lv_coord_t height = lv_area_get_height(coords);
|
||||
uint16_t bwidth = style->body.border.width;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.border.opa : (uint16_t)((uint16_t) style->body.border.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->body.border.opa
|
||||
: (uint16_t)((uint16_t)style->body.border.opa * opa_scale) >> 8;
|
||||
lv_border_part_t part = style->body.border.part;
|
||||
lv_color_t color = style->body.border.color;
|
||||
lv_area_t work_area;
|
||||
@ -540,11 +583,15 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
corner_size++;
|
||||
|
||||
/*Depending one which part's are drawn modify the area lengths */
|
||||
if(part & LV_BORDER_TOP) work_area.y1 = coords->y1 + corner_size;
|
||||
else work_area.y1 = coords->y1 + radius;
|
||||
if(part & LV_BORDER_TOP)
|
||||
work_area.y1 = coords->y1 + corner_size;
|
||||
else
|
||||
work_area.y1 = coords->y1 + radius;
|
||||
|
||||
if(part & LV_BORDER_BOTTOM) work_area.y2 = coords->y2 - corner_size;
|
||||
else work_area.y2 = coords->y2 - radius;
|
||||
if(part & LV_BORDER_BOTTOM)
|
||||
work_area.y2 = coords->y2 - corner_size;
|
||||
else
|
||||
work_area.y2 = coords->y2 - radius;
|
||||
|
||||
/*Left border*/
|
||||
if(part & LV_BORDER_LEFT) {
|
||||
@ -656,7 +703,6 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw the corners of a rectangle border
|
||||
* @param coords the coordinates of the original rectangle
|
||||
@ -664,14 +710,17 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
* @param style pointer to a style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
uint16_t radius = style->body.radius;
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
uint16_t bwidth = style->body.border.width;
|
||||
lv_color_t color = style->body.border.color;
|
||||
lv_border_part_t part = style->body.border.part;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.border.opa : (uint16_t)((uint16_t) style->body.border.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->body.border.opa
|
||||
: (uint16_t)((uint16_t)style->body.border.opa * opa_scale) >> 8;
|
||||
/*0 px border width drawn as 1 px, so decrement the bwidth*/
|
||||
bwidth--;
|
||||
|
||||
@ -725,7 +774,6 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
lv_coord_t out_y_seg_end = 0;
|
||||
lv_coord_t out_x_last = radius;
|
||||
|
||||
|
||||
lv_coord_t in_y_seg_start = 0;
|
||||
lv_coord_t in_y_seg_end = 0;
|
||||
lv_coord_t in_x_last = radius - bwidth;
|
||||
@ -757,31 +805,47 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
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*/
|
||||
if(seg_size > CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD) { /*Use non-linear opa mapping
|
||||
on the first segment*/
|
||||
aa_opa = antialias_get_opa_circ(seg_size, i, opa);
|
||||
} else {
|
||||
aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -802,57 +866,71 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
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*/
|
||||
if(seg_size > CIRCLE_AA_NON_LINEAR_OPA_THRESHOLD) { /*Use non-linear opa mapping
|
||||
on the first segment*/
|
||||
aa_opa = opa - antialias_get_opa_circ(seg_size, i, opa);
|
||||
} else {
|
||||
aa_opa = lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*Draw the octets to the right bottom corner*/
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
circ_area.x1 = rb_origo.x + LV_CIRC_OCT1_X(cir_out) - act_w2;
|
||||
@ -927,7 +1005,6 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
if(aa) {
|
||||
/*Last parts of the outer anti-alias*/
|
||||
@ -942,23 +1019,39 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -970,19 +1063,23 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
lv_opa_t aa_opa = opa >> 1;
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p),
|
||||
mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p),
|
||||
mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p),
|
||||
mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p),
|
||||
mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -995,42 +1092,57 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa = lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) {
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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)) {
|
||||
lv_draw_px(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);
|
||||
lv_draw_px(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if LV_USE_SHADOW
|
||||
@ -1041,7 +1153,8 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
* @param mask pointer to a mask area (from the design functions)
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
/* If mask is in the middle of cords do not draw shadow*/
|
||||
lv_coord_t radius = style->body.radius;
|
||||
@ -1069,17 +1182,19 @@ static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, con
|
||||
}
|
||||
}
|
||||
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
|
||||
/* KNOWN ISSUE
|
||||
* The algorithm calculates the shadow only above the middle point of the radius (speaking about the left top corner).
|
||||
* It causes an error because it doesn't consider how long the straight edge is which effects the value of bottom of the corner shadow.
|
||||
* In addition the straight shadow is drawn from the middles point of the radius however
|
||||
* the ends of the straight parts still should be effected by the corner shadow.
|
||||
* It also causes an issue in opacity. A smaller radius means smaller average shadow opacity.
|
||||
* The solution should be to start `line` from `- swidth` and handle if the straight part is short (or zero) and the value is taken from
|
||||
* the other corner. `col` also should start from `- swidth`
|
||||
* The algorithm calculates the shadow only above the middle point of the radius (speaking about
|
||||
* the left top corner). It causes an error because it doesn't consider how long the straight
|
||||
* edge is which effects the value of bottom of the corner shadow. In addition the straight
|
||||
* shadow is drawn from the middles point of the radius however the ends of the straight parts
|
||||
* still should be effected by the corner shadow. It also causes an issue in opacity. A smaller
|
||||
* radius means smaller average shadow opacity. The solution should be to start `line` from `-
|
||||
* swidth` and handle if the straight part is short (or zero) and the value is taken from the
|
||||
* other corner. `col` also should start from `- swidth`
|
||||
*/
|
||||
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
@ -1125,9 +1240,13 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
#endif
|
||||
#endif
|
||||
/*1D Blur horizontally*/
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->body.opa
|
||||
: (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8;
|
||||
for(line = 0; line < filter_width; line++) {
|
||||
line_1d_blur[line] = (uint32_t)((uint32_t)(filter_width - line) * (opa * 2) << SHADOW_OPA_EXTRA_PRECISION) / (filter_width * filter_width);
|
||||
line_1d_blur[line] =
|
||||
(uint32_t)((uint32_t)(filter_width - line) * (opa * 2) << SHADOW_OPA_EXTRA_PRECISION) /
|
||||
(filter_width * filter_width);
|
||||
}
|
||||
|
||||
uint16_t col;
|
||||
@ -1163,7 +1282,9 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
bool line_ready;
|
||||
for(line = 0; line <= radius + swidth; line++) { /*Check all rows and make the 1D blur to 2D*/
|
||||
line_ready = false;
|
||||
for(col = 0; col <= radius + swidth; col++) { /*Check all pixels in a 1D blur line (from the origo to last shadow pixel (radius + swidth))*/
|
||||
for(col = 0; col <= radius + swidth;
|
||||
col++) { /*Check all pixels in a 1D blur line (from the origo to last shadow pixel
|
||||
(radius + swidth))*/
|
||||
|
||||
/*Sum the opacities from the lines above and below this 'row'*/
|
||||
int16_t line_rel;
|
||||
@ -1173,7 +1294,8 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
int16_t col_rel;
|
||||
if(line + line_rel < 0) { /*Below the radius, here is the blur of the edge */
|
||||
col_rel = radius - curve_x[line] - col;
|
||||
} else if(line + line_rel > radius) { /*Above the radius, here won't be more 1D blur*/
|
||||
} else if(line + line_rel >
|
||||
radius) { /*Above the radius, here won't be more 1D blur*/
|
||||
break;
|
||||
} else { /*Blur from the curve*/
|
||||
col_rel = curve_x[line + line_rel] - curve_x[line] - col;
|
||||
@ -1181,10 +1303,16 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
|
||||
/*Add the value of the 1D blur on 'col_rel' position*/
|
||||
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*/
|
||||
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 px_opa_sum += line_1d_blur[swidth - col_rel]; /*On the 1D blur (+ swidth to align to the center)*/
|
||||
} 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)*/
|
||||
}
|
||||
|
||||
line_2d_blur[col] = px_opa_sum >> SHADOW_OPA_EXTRA_PRECISION;
|
||||
@ -1192,7 +1320,6 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
col++; /*To make this line to the last one ( drawing will go to '< col')*/
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*Flush the line*/
|
||||
@ -1241,8 +1368,8 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
lv_coord_t radius = style->body.radius;
|
||||
@ -1282,7 +1409,9 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
#endif
|
||||
#endif
|
||||
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->body.opa
|
||||
: (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8;
|
||||
for(col = 0; col < swidth; col++) {
|
||||
line_1d_blur[col] = (uint32_t)((uint32_t)(swidth - col) * opa / 2) / (swidth);
|
||||
}
|
||||
@ -1310,7 +1439,8 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
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 */
|
||||
/*When stepping a pixel in y calculate the average with the pixel from the prev. column
|
||||
* to make a blur */
|
||||
if(diff == 0) {
|
||||
px_opa = line_1d_blur[d];
|
||||
} else {
|
||||
@ -1325,7 +1455,6 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
}
|
||||
point_r.y++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
area_mid.x1 = ofs_l.x + 1;
|
||||
@ -1341,7 +1470,8 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
}
|
||||
}
|
||||
|
||||
static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, const lv_opa_t * map)
|
||||
static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask,
|
||||
const lv_style_t * style, const lv_opa_t * map)
|
||||
{
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
lv_coord_t radius = style->body.radius;
|
||||
@ -1401,7 +1531,6 @@ static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static uint16_t lv_draw_cont_radius_corr(uint16_t r, lv_coord_t w, lv_coord_t h)
|
||||
{
|
||||
bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing());
|
||||
@ -1456,7 +1585,6 @@ static lv_opa_t antialias_get_opa_circ(lv_coord_t seg, lv_coord_t px_id, lv_opa_
|
||||
|
||||
uint8_t id = (uint32_t)((uint32_t)px_id * (sizeof(opa_map8) - 1)) / (seg - 1);
|
||||
return (uint32_t)((uint32_t)opa_map8[id] * opa) >> 8;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -34,13 +34,13 @@ extern "C" {
|
||||
* @param style pointer to a style
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -41,7 +41,8 @@ static void point_swap(lv_point_t * p1, lv_point_t * p2);
|
||||
* @param style style for of the triangle
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale)
|
||||
{
|
||||
lv_point_t tri[3];
|
||||
|
||||
@ -87,8 +88,9 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l
|
||||
lv_area_t act_area;
|
||||
lv_area_t draw_area;
|
||||
|
||||
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t) style->body.opa * opa_scale) >> 8;
|
||||
lv_opa_t opa = opa_scale == LV_OPA_COVER
|
||||
? style->body.opa
|
||||
: (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8;
|
||||
|
||||
while(1) {
|
||||
act_area.x1 = edge1.x;
|
||||
@ -96,12 +98,12 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l
|
||||
act_area.y1 = edge1.y;
|
||||
act_area.y2 = edge2.y;
|
||||
|
||||
|
||||
draw_area.x1 = LV_MATH_MIN(act_area.x1, act_area.x2);
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
draw_area.x2--; /*Do not draw most right pixel because it will be drawn by the adjacent triangle*/
|
||||
draw_area.x2--; /*Do not draw most right pixel because it will be drawn by the adjacent
|
||||
triangle*/
|
||||
lv_draw_fill(&draw_area, mask, style->body.main_color, opa);
|
||||
|
||||
/*Calc. the next point of edge1*/
|
||||
@ -114,7 +116,8 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l
|
||||
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) {
|
||||
err1 -= dy1;
|
||||
@ -147,7 +150,6 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Swap two points
|
||||
* p1 pointer to the first point
|
||||
@ -164,5 +166,4 @@ static void point_swap(lv_point_t * p1, lv_point_t * p2)
|
||||
|
||||
p2->x = tmp.x;
|
||||
p2->y = tmp.y;
|
||||
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ extern "C" {
|
||||
* @param style style for of the triangle
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style,
|
||||
lv_opa_t opa_scale);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -74,7 +74,6 @@ void lv_disp_drv_init(lv_disp_drv_t * driver)
|
||||
driver->set_px_cb = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a display buffer
|
||||
* @param disp_buf pointer `lv_disp_buf_t` variable to initialize
|
||||
@ -86,8 +85,8 @@ void lv_disp_drv_init(lv_disp_drv_t * driver)
|
||||
* (sending to the display) parallel.
|
||||
* In the `disp_drv->flush` you should use DMA or similar hardware to send
|
||||
* the image to the display in the background.
|
||||
* It lets LittlevGL to render next frame into the other buffer while previous is being sent.
|
||||
* Set to `NULL` if unused.
|
||||
* It lets LittlevGL to render next frame into the other buffer while previous is being
|
||||
* sent. Set to `NULL` if unused.
|
||||
* @param size size of the `buf1` and `buf2` in pixel count.
|
||||
*/
|
||||
void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size)
|
||||
@ -100,7 +99,6 @@ void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32
|
||||
disp_buf->size = size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register an initialized display driver.
|
||||
* Automatically set the first display as active.
|
||||
@ -123,7 +121,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
if(disp_def == NULL) disp_def = disp;
|
||||
|
||||
lv_disp_t * disp_def_tmp = disp_def;
|
||||
disp_def = disp; /*Temporarily change the default screen to create the default screens on the new display*/
|
||||
disp_def = disp; /*Temporarily change the default screen to create the default screens on the
|
||||
new display*/
|
||||
|
||||
disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
|
||||
disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
|
||||
@ -138,7 +137,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
disp_def = disp_def_tmp; /*Revert the default display*/
|
||||
|
||||
/*Create a refresh task*/
|
||||
disp->refr_task = lv_task_create(lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, disp);
|
||||
disp->refr_task =
|
||||
lv_task_create(lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, disp);
|
||||
lv_mem_assert(disp->refr_task);
|
||||
if(disp->refr_task == NULL) return NULL;
|
||||
|
||||
@ -157,7 +157,8 @@ void lv_disp_drv_update(lv_disp_t * disp, lv_disp_drv_t * new_drv)
|
||||
memcpy(&disp->driver, new_drv, sizeof(lv_disp_drv_t));
|
||||
|
||||
lv_obj_t * scr;
|
||||
LV_LL_READ(disp->scr_ll, scr) {
|
||||
LV_LL_READ(disp->scr_ll, scr)
|
||||
{
|
||||
lv_obj_set_size(scr, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
|
||||
}
|
||||
}
|
||||
@ -187,7 +188,6 @@ void lv_disp_remove(lv_disp_t * disp)
|
||||
if(was_default) lv_disp_set_default(lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a default screen. The new screens will be created on it by default.
|
||||
* @param disp pointer to a display
|
||||
@ -215,8 +215,10 @@ lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) disp = lv_disp_get_default();
|
||||
|
||||
if(disp == NULL) return disp->driver.rotated == 0 ? LV_HOR_RES_MAX : LV_VER_RES_MAX;
|
||||
else return disp->driver.rotated == 0 ? disp->driver.hor_res : disp->driver.ver_res;
|
||||
if(disp == NULL)
|
||||
return disp->driver.rotated == 0 ? LV_HOR_RES_MAX : LV_VER_RES_MAX;
|
||||
else
|
||||
return disp->driver.rotated == 0 ? disp->driver.hor_res : disp->driver.ver_res;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,8 +230,10 @@ lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) disp = lv_disp_get_default();
|
||||
|
||||
if(disp == NULL) return disp->driver.rotated == 0 ? LV_VER_RES_MAX : LV_HOR_RES_MAX;
|
||||
else return disp->driver.rotated == 0 ? disp->driver.ver_res : disp->driver.hor_res;
|
||||
if(disp == NULL)
|
||||
return disp->driver.rotated == 0 ? LV_VER_RES_MAX : LV_HOR_RES_MAX;
|
||||
else
|
||||
return disp->driver.rotated == 0 ? disp->driver.ver_res : disp->driver.hor_res;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,7 +253,6 @@ bool lv_disp_get_antialiasing(lv_disp_t * disp)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call in the display driver's `flush_cb` function when the flushing is finished
|
||||
* @param disp_drv pointer to display driver in `flush_cb` where this function is called
|
||||
@ -264,7 +267,6 @@ LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next display.
|
||||
* @param disp pointer to the current display. NULL to initialize.
|
||||
@ -272,8 +274,10 @@ LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv)
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_next(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll));
|
||||
else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp);
|
||||
if(disp == NULL)
|
||||
return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll));
|
||||
else
|
||||
return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,8 +306,10 @@ uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp)
|
||||
void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num)
|
||||
{
|
||||
|
||||
if(disp->inv_p < num) disp->inv_p = 0;
|
||||
else disp->inv_p -= num;
|
||||
if(disp->inv_p < num)
|
||||
disp->inv_p = 0;
|
||||
else
|
||||
disp->inv_p -= num;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -313,12 +319,15 @@ void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num)
|
||||
*/
|
||||
bool lv_disp_is_double_buf(lv_disp_t * disp)
|
||||
{
|
||||
if(disp->driver.buffer->buf1 && disp->driver.buffer->buf2) return true;
|
||||
else return false;
|
||||
if(disp->driver.buffer->buf1 && disp->driver.buffer->buf2)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the driver configuration if it's TRUE double buffered (both `buf1` and `buf2` are set and `size` is screen sized)
|
||||
* Check the driver configuration if it's TRUE double buffered (both `buf1` and `buf2` are set and
|
||||
* `size` is screen sized)
|
||||
* @param disp pointer to to display to check
|
||||
* @return true: double buffered; false: not double buffered
|
||||
*/
|
||||
@ -326,16 +335,13 @@ bool lv_disp_is_true_double_buf(lv_disp_t * disp)
|
||||
{
|
||||
uint32_t scr_size = disp->driver.hor_res * disp->driver.ver_res;
|
||||
|
||||
if(lv_disp_is_double_buf(disp) &&
|
||||
disp->driver.buffer->size == scr_size) {
|
||||
if(lv_disp_is_double_buf(disp) && disp->driver.buffer->size == scr_size) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -41,7 +41,6 @@ extern "C" {
|
||||
struct _disp_t;
|
||||
struct _disp_drv_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * buf1;
|
||||
@ -54,11 +53,11 @@ typedef struct
|
||||
volatile uint32_t flushing : 1;
|
||||
} lv_disp_buf_t;
|
||||
|
||||
|
||||
/**
|
||||
* Display Driver structure to be registered by HAL
|
||||
*/
|
||||
typedef struct _disp_drv_t {
|
||||
typedef struct _disp_drv_t
|
||||
{
|
||||
|
||||
/*Horizontal and vertical resolution*/
|
||||
lv_coord_t hor_res;
|
||||
@ -73,7 +72,8 @@ typedef struct _disp_drv_t {
|
||||
#endif
|
||||
uint32_t rotated : 1; /*1: turn the display by 90 degree.*/
|
||||
|
||||
/* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_disp_flush_ready()' has to be called when finished */
|
||||
/* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_disp_flush_ready()' has to be
|
||||
* called when finished */
|
||||
void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
|
||||
|
||||
/* OPTIONAL: Extend the invalidated areas to match with the display drivers requirements
|
||||
@ -83,12 +83,13 @@ typedef struct _disp_drv_t {
|
||||
/* OPTIONAL: Set a pixel in a buffer according to the special requirements of the display
|
||||
* Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales
|
||||
* Note: Much slower then drawing with supported color formats. */
|
||||
void (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa);
|
||||
void (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */
|
||||
/* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the
|
||||
* number of flushed pixels */
|
||||
void (*monitor_cb)(struct _disp_drv_t * disp_drv, uint32_t time, uint32_t px);
|
||||
|
||||
|
||||
#if LV_USE_USER_DATA_SINGLE
|
||||
lv_disp_drv_user_data_t user_data;
|
||||
#endif
|
||||
@ -112,7 +113,8 @@ typedef struct _disp_drv_t {
|
||||
|
||||
struct _lv_obj_t;
|
||||
|
||||
typedef struct _disp_t {
|
||||
typedef struct _disp_t
|
||||
{
|
||||
/*Driver to the display*/
|
||||
lv_disp_drv_t driver;
|
||||
|
||||
@ -146,7 +148,6 @@ typedef struct _disp_t {
|
||||
*/
|
||||
void lv_disp_drv_init(lv_disp_drv_t * driver);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a display buffer
|
||||
* @param disp_buf pointer `lv_disp_buf_t` variable to initialize
|
||||
@ -158,8 +159,8 @@ void lv_disp_drv_init(lv_disp_drv_t * driver);
|
||||
* (sending to the display) parallel.
|
||||
* In the `disp_drv->flush` you should use DMA or similar hardware to send
|
||||
* the image to the display in the background.
|
||||
* It lets LittlevGL to render next frame into the other buffer while previous is being sent.
|
||||
* Set to `NULL` if unused.
|
||||
* It lets LittlevGL to render next frame into the other buffer while previous is being
|
||||
* sent. Set to `NULL` if unused.
|
||||
* @param size size of the `buf1` and `buf2` in pixel count.
|
||||
*/
|
||||
void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size);
|
||||
@ -224,7 +225,6 @@ bool lv_disp_get_antialiasing(lv_disp_t * disp);
|
||||
*/
|
||||
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv);
|
||||
|
||||
|
||||
/**
|
||||
* Get the next display.
|
||||
* @param disp pointer to the current display. NULL to initialize.
|
||||
@ -259,7 +259,8 @@ void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num);
|
||||
bool lv_disp_is_double_buf(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Check the driver configuration if it's TRUE double buffered (both `buf1` and `buf2` are set and `size` is screen sized)
|
||||
* Check the driver configuration if it's TRUE double buffered (both `buf1` and `buf2` are set and
|
||||
* `size` is screen sized)
|
||||
* @param disp pointer to to display to check
|
||||
* @return true: double buffered; false: not double buffered
|
||||
*/
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include LV_GC_INCLUDE
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -71,7 +70,8 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
|
||||
if(driver->disp == NULL) driver->disp = lv_disp_get_default();
|
||||
|
||||
if(driver->disp == NULL) {
|
||||
LV_LOG_WARN("lv_indev_drv_register: no display registered hence can't attache the indev to a display");
|
||||
LV_LOG_WARN("lv_indev_drv_register: no display registered hence can't attache the indev to "
|
||||
"a display");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -89,7 +89,8 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
|
||||
indev->group = NULL;
|
||||
indev->btn_points = NULL;
|
||||
|
||||
indev->driver.read_task = lv_task_create(lv_indev_read_task, LV_INDEV_DEF_READ_PERIOD, LV_TASK_PRIO_MID, indev);
|
||||
indev->driver.read_task =
|
||||
lv_task_create(lv_indev_read_task, LV_INDEV_DEF_READ_PERIOD, LV_TASK_PRIO_MID, indev);
|
||||
|
||||
return indev;
|
||||
}
|
||||
@ -107,12 +108,15 @@ void lv_indev_drv_update(lv_indev_t * indev, lv_indev_drv_t * new_drv)
|
||||
/**
|
||||
* Get the next input device.
|
||||
* @param indev pointer to the current input device. NULL to initialize.
|
||||
* @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL
|
||||
* @return the next input devise or NULL if no more. Give the first input device when the parameter
|
||||
* is NULL
|
||||
*/
|
||||
lv_indev_t * lv_indev_get_next(lv_indev_t * indev)
|
||||
{
|
||||
if(indev == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_indev_ll));
|
||||
else return lv_ll_get_next(&LV_GC_ROOT(_lv_indev_ll), indev);
|
||||
if(indev == NULL)
|
||||
return lv_ll_get_head(&LV_GC_ROOT(_lv_indev_ll));
|
||||
else
|
||||
return lv_ll_get_next(&LV_GC_ROOT(_lv_indev_ll), indev);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,20 +44,19 @@ enum {
|
||||
LV_INDEV_TYPE_NONE, /*Show uninitialized state*/
|
||||
LV_INDEV_TYPE_POINTER, /*Touch pad, mouse, external button*/
|
||||
LV_INDEV_TYPE_KEYPAD, /*Keypad or keyboard*/
|
||||
LV_INDEV_TYPE_BUTTON, /*External (hardware button) which is assinged to a specific point of the screen*/
|
||||
LV_INDEV_TYPE_BUTTON, /*External (hardware button) which is assinged to a specific point of the
|
||||
screen*/
|
||||
LV_INDEV_TYPE_ENCODER, /*Encoder with only Left, Right turn and a Button*/
|
||||
};
|
||||
typedef uint8_t lv_indev_type_t;
|
||||
|
||||
/*States for input devices*/
|
||||
enum {
|
||||
LV_INDEV_STATE_REL = 0,
|
||||
LV_INDEV_STATE_PR
|
||||
};
|
||||
enum { LV_INDEV_STATE_REL = 0, LV_INDEV_STATE_PR };
|
||||
typedef uint8_t lv_indev_state_t;
|
||||
|
||||
/*Data type when an input device is read */
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
lv_point_t point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/
|
||||
uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/
|
||||
uint32_t btn_id; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/
|
||||
@ -68,12 +67,14 @@ typedef struct {
|
||||
} lv_indev_data_t;
|
||||
|
||||
/*Initialized by the user and registered by 'lv_indev_add()'*/
|
||||
typedef struct _lv_indev_drv_t {
|
||||
typedef struct _lv_indev_drv_t
|
||||
{
|
||||
|
||||
/*Input device type*/
|
||||
lv_indev_type_t type;
|
||||
|
||||
/*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/
|
||||
/*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb
|
||||
* (buffered)*/
|
||||
bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
|
||||
|
||||
#if LV_USE_USER_DATA_MULTI
|
||||
@ -103,26 +104,30 @@ typedef struct _lv_indev_drv_t {
|
||||
uint16_t long_press_rep_time;
|
||||
} lv_indev_drv_t;
|
||||
|
||||
|
||||
/*Run time data of input devices*/
|
||||
typedef struct _lv_indev_proc_t {
|
||||
typedef struct _lv_indev_proc_t
|
||||
{
|
||||
lv_indev_state_t state;
|
||||
union {
|
||||
struct { /*Pointer and button data*/
|
||||
union
|
||||
{
|
||||
struct
|
||||
{ /*Pointer and button data*/
|
||||
lv_point_t act_point;
|
||||
lv_point_t last_point;
|
||||
lv_point_t vect;
|
||||
lv_point_t drag_sum; /*Count the dragged pixels to check LV_INDEV_DEF_DRAG_LIMIT*/
|
||||
lv_point_t drag_throw_vect;
|
||||
struct _lv_obj_t * act_obj; /*The object being pressed*/
|
||||
struct _lv_obj_t * last_obj; /*The last obejct which was pressed (used by dragthrow and other post-release event)*/
|
||||
struct _lv_obj_t * last_obj; /*The last obejct which was pressed (used by dragthrow and
|
||||
other post-release event)*/
|
||||
struct _lv_obj_t * last_pressed; /*The lastly pressed object*/
|
||||
|
||||
/*Flags*/
|
||||
uint8_t drag_limit_out : 1;
|
||||
uint8_t drag_in_prog : 1;
|
||||
} pointer;
|
||||
struct { /*Keypad data*/
|
||||
struct
|
||||
{ /*Keypad data*/
|
||||
lv_indev_state_t last_state;
|
||||
uint32_t last_key;
|
||||
} keypad;
|
||||
@ -143,14 +148,17 @@ typedef void (*lv_indev_feedback_t)(struct _lv_indev_t *, uint8_t);
|
||||
struct _lv_obj_t;
|
||||
struct _lv_group_t;
|
||||
|
||||
/*The main input device descriptor with driver, runtime data ('proc') and some additional information*/
|
||||
typedef struct _lv_indev_t {
|
||||
/*The main input device descriptor with driver, runtime data ('proc') and some additional
|
||||
* information*/
|
||||
typedef struct _lv_indev_t
|
||||
{
|
||||
lv_indev_drv_t driver;
|
||||
lv_indev_proc_t proc;
|
||||
lv_indev_feedback_t feedback;
|
||||
struct _lv_obj_t * cursor; /*Cursor for LV_INPUT_TYPE_POINTER*/
|
||||
struct _lv_group_t * group; /*Keypad destination group*/
|
||||
const lv_point_t * btn_points; /*Array points assigned to the button ()screen will be pressed here by the buttons*/
|
||||
const lv_point_t * btn_points; /*Array points assigned to the button ()screen will be pressed
|
||||
here by the buttons*/
|
||||
} lv_indev_t;
|
||||
|
||||
/**********************
|
||||
@ -182,7 +190,8 @@ void lv_indev_drv_update(lv_indev_t * indev, lv_indev_drv_t * new_drv);
|
||||
/**
|
||||
* Get the next input device.
|
||||
* @param indev pointer to the current input device. NULL to initialize.
|
||||
* @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL
|
||||
* @return the next input devise or NULL if no more. Give the first input device when the parameter
|
||||
* is NULL
|
||||
*/
|
||||
lv_indev_t * lv_indev_get_next(lv_indev_t * indev);
|
||||
|
||||
|
@ -66,7 +66,8 @@ uint32_t lv_tick_get(void)
|
||||
do {
|
||||
tick_irq_flag = 1;
|
||||
result = sys_time;
|
||||
} while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt. Continue until make a non interrupted cycle */
|
||||
} while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt.
|
||||
Continue until make a non interrupted cycle */
|
||||
|
||||
return result;
|
||||
#else
|
||||
@ -97,4 +98,3 @@ uint32_t lv_tick_elaps(uint32_t prev_tick)
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include LV_GC_INCLUDE
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -69,7 +68,8 @@ void lv_anim_create(lv_anim_t * anim_p)
|
||||
{
|
||||
LV_LOG_TRACE("animation create started")
|
||||
/* Do not let two animations for the same 'var' with the same 'fp'*/
|
||||
if(anim_p->fp != NULL) lv_anim_del(anim_p->var, anim_p->fp); /*fp == NULL would delete all animations of var*/
|
||||
if(anim_p->fp != NULL)
|
||||
lv_anim_del(anim_p->var, anim_p->fp); /*fp == NULL would delete all animations of var*/
|
||||
|
||||
/*Add the new animation to the animation linked list*/
|
||||
lv_anim_t * new_anim = lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll));
|
||||
@ -110,7 +110,8 @@ bool lv_anim_del(void * var, lv_anim_fp_t fp)
|
||||
if(a->var == var && (a->fp == fp || fp == NULL)) {
|
||||
lv_ll_rem(&LV_GC_ROOT(_lv_anim_ll), a);
|
||||
lv_mem_free(a);
|
||||
anim_list_changed = true; /*Read by `anim_task`. It need to know if a delete occurred in the linked list*/
|
||||
anim_list_changed = true; /*Read by `anim_task`. It need to know if a delete occurred in
|
||||
the linked list*/
|
||||
del = true;
|
||||
}
|
||||
|
||||
@ -163,8 +164,10 @@ int32_t lv_anim_path_linear(const lv_anim_t * a)
|
||||
{
|
||||
/*Calculate the current step*/
|
||||
uint16_t step;
|
||||
if(a->time == a->act_time) step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/
|
||||
else step = (a->act_time * LV_ANIM_RESOLUTION) / a->time;
|
||||
if(a->time == a->act_time)
|
||||
step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/
|
||||
else
|
||||
step = (a->act_time * LV_ANIM_RESOLUTION) / a->time;
|
||||
|
||||
/* Get the new value which will be proportional to `step`
|
||||
* and the `start` and `end` values*/
|
||||
@ -185,8 +188,10 @@ int32_t lv_anim_path_ease_in(const lv_anim_t * a)
|
||||
{
|
||||
/*Calculate the current step*/
|
||||
uint32_t t;
|
||||
if(a->time == a->act_time) t = 1024;
|
||||
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
if(a->time == a->act_time)
|
||||
t = 1024;
|
||||
else
|
||||
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
|
||||
int32_t step = lv_bezier3(t, 0, 1, 1, 1024);
|
||||
|
||||
@ -195,7 +200,6 @@ int32_t lv_anim_path_ease_in(const lv_anim_t * a)
|
||||
new_value = new_value >> 10;
|
||||
new_value += a->start;
|
||||
|
||||
|
||||
return new_value;
|
||||
}
|
||||
|
||||
@ -209,8 +213,10 @@ int32_t lv_anim_path_ease_out(const lv_anim_t * a)
|
||||
/*Calculate the current step*/
|
||||
|
||||
uint32_t t;
|
||||
if(a->time == a->act_time) t = 1024;
|
||||
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
if(a->time == a->act_time)
|
||||
t = 1024;
|
||||
else
|
||||
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
|
||||
int32_t step = lv_bezier3(t, 0, 1023, 1023, 1024);
|
||||
|
||||
@ -219,7 +225,6 @@ int32_t lv_anim_path_ease_out(const lv_anim_t * a)
|
||||
new_value = new_value >> 10;
|
||||
new_value += a->start;
|
||||
|
||||
|
||||
return new_value;
|
||||
}
|
||||
|
||||
@ -233,8 +238,10 @@ int32_t lv_anim_path_ease_in_out(const lv_anim_t * a)
|
||||
/*Calculate the current step*/
|
||||
|
||||
uint32_t t;
|
||||
if(a->time == a->act_time) t = 1024;
|
||||
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
if(a->time == a->act_time)
|
||||
t = 1024;
|
||||
else
|
||||
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
|
||||
int32_t step = lv_bezier3(t, 0, 100, 924, 1024);
|
||||
|
||||
@ -243,7 +250,6 @@ int32_t lv_anim_path_ease_in_out(const lv_anim_t * a)
|
||||
new_value = new_value >> 10;
|
||||
new_value += a->start;
|
||||
|
||||
|
||||
return new_value;
|
||||
}
|
||||
|
||||
@ -257,8 +263,10 @@ int32_t lv_anim_path_overshoot(const lv_anim_t * a)
|
||||
/*Calculate the current step*/
|
||||
|
||||
uint32_t t;
|
||||
if(a->time == a->act_time) t = 1024;
|
||||
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
if(a->time == a->act_time)
|
||||
t = 1024;
|
||||
else
|
||||
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
|
||||
int32_t step = lv_bezier3(t, 0, 600, 1300, 1024);
|
||||
|
||||
@ -267,7 +275,6 @@ int32_t lv_anim_path_overshoot(const lv_anim_t * a)
|
||||
new_value = new_value >> 10;
|
||||
new_value += a->start;
|
||||
|
||||
|
||||
return new_value;
|
||||
}
|
||||
|
||||
@ -280,8 +287,10 @@ int32_t lv_anim_path_bounce(const lv_anim_t * a)
|
||||
{
|
||||
/*Calculate the current step*/
|
||||
uint32_t t;
|
||||
if(a->time == a->act_time) t = 1024;
|
||||
else t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
if(a->time == a->act_time)
|
||||
t = 1024;
|
||||
else
|
||||
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
|
||||
|
||||
int32_t diff = (a->end - a->start);
|
||||
|
||||
@ -290,28 +299,24 @@ int32_t lv_anim_path_bounce(const lv_anim_t * a)
|
||||
if(t < 408) {
|
||||
/*Go down*/
|
||||
t = (t * 2500) >> 10; /*[0..1024] range*/
|
||||
}
|
||||
else if(t >= 408 && t < 614) {
|
||||
} else if(t >= 408 && t < 614) {
|
||||
/*First bounce back*/
|
||||
t -= 408;
|
||||
t = t * 5; /*to [0..1024] range*/
|
||||
t = 1024 - t;
|
||||
diff = diff / 6;
|
||||
}
|
||||
else if(t >= 614 && t < 819) {
|
||||
} else if(t >= 614 && t < 819) {
|
||||
/*Fall back*/
|
||||
t -= 614;
|
||||
t = t * 5; /*to [0..1024] range*/
|
||||
diff = diff / 6;
|
||||
}
|
||||
else if(t >= 819 && t < 921) {
|
||||
} else if(t >= 819 && t < 921) {
|
||||
/*Second bounce back*/
|
||||
t -= 819;
|
||||
t = t * 10; /*to [0..1024] range*/
|
||||
t = 1024 - t;
|
||||
diff = diff / 16;
|
||||
}
|
||||
else if(t >= 921 && t <= 1024) {
|
||||
} else if(t >= 921 && t <= 1024) {
|
||||
/*Fall back*/
|
||||
t -= 921;
|
||||
t = t * 10; /*to [0..1024] range*/
|
||||
@ -328,7 +333,6 @@ int32_t lv_anim_path_bounce(const lv_anim_t * a)
|
||||
new_value = new_value >> 10;
|
||||
new_value = a->end - new_value;
|
||||
|
||||
|
||||
return new_value;
|
||||
}
|
||||
|
||||
@ -340,8 +344,10 @@ int32_t lv_anim_path_bounce(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;
|
||||
if(a->act_time >= a->time)
|
||||
return a->end;
|
||||
else
|
||||
return a->start;
|
||||
}
|
||||
|
||||
/**********************
|
||||
@ -357,7 +363,8 @@ static void anim_task(void * param)
|
||||
(void)param;
|
||||
|
||||
lv_anim_t * a;
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_anim_ll), a) {
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_anim_ll), a)
|
||||
{
|
||||
a->has_run = 0;
|
||||
}
|
||||
|
||||
@ -365,13 +372,15 @@ static void anim_task(void * param)
|
||||
a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
|
||||
|
||||
while(a != NULL) {
|
||||
/*It can be set by `lv_anim_del()` typically in `end_cb`. If set then an animation delete happened in `anim_ready_handler`
|
||||
* which could make this linked list reading corrupt because the list is changed meanwhile
|
||||
/*It can be set by `lv_anim_del()` typically in `end_cb`. If set then an animation delete
|
||||
* happened in `anim_ready_handler` which could make this linked list reading corrupt
|
||||
* because the list is changed meanwhile
|
||||
*/
|
||||
anim_list_changed = false;
|
||||
|
||||
if(!a->has_run) {
|
||||
a->has_run = 1; /*The list readying might be reseted so need to know which anim has run already*/
|
||||
a->has_run =
|
||||
1; /*The list readying might be reseted so need to know which anim has run already*/
|
||||
a->act_time += elaps;
|
||||
if(a->act_time >= 0) {
|
||||
if(a->act_time > a->time) a->act_time = a->time;
|
||||
@ -390,8 +399,10 @@ static void anim_task(void * param)
|
||||
|
||||
/* If the linked list changed due to anim. delete then it's not safe to continue
|
||||
* the reading of the list from here -> start from the head*/
|
||||
if(anim_list_changed) a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
|
||||
else a = lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a);
|
||||
if(anim_list_changed)
|
||||
a = lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
|
||||
else
|
||||
a = lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a);
|
||||
}
|
||||
|
||||
last_task_run = lv_tick_get();
|
||||
|
@ -10,7 +10,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -174,4 +173,3 @@ int32_t lv_anim_path_step(const lv_anim_t *a);
|
||||
#endif
|
||||
|
||||
#endif /*LV_ANIM_H*/
|
||||
|
||||
|
@ -94,8 +94,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);
|
||||
size = (uint32_t)(area_p->x2 - area_p->x1 + 1) * (area_p->y2 - area_p->y1 + 1);
|
||||
|
||||
return size;
|
||||
}
|
||||
@ -117,8 +116,7 @@ bool lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_
|
||||
|
||||
/*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)) {
|
||||
if((res_p->x1 > res_p->x2) || (res_p->y1 > res_p->y2)) {
|
||||
union_ok = false;
|
||||
}
|
||||
|
||||
@ -148,8 +146,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))) {
|
||||
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))) {
|
||||
is_on = true;
|
||||
}
|
||||
|
||||
@ -164,15 +161,12 @@ 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) &&
|
||||
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)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,9 +179,7 @@ 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 &&
|
||||
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) {
|
||||
is_in = true;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -165,5 +164,4 @@ bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p);
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -10,7 +10,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -75,5 +74,4 @@ void lv_circ_next(lv_point_t * c, lv_coord_t * tmp);
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -32,7 +32,6 @@ extern "C" {
|
||||
#error "LV_COLOR_16_SWAP requires LV_COLOR_DEPTH == 16. Set it in lv_conf.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
@ -189,32 +188,24 @@ static inline uint8_t lv_color_to1(lv_color_t color)
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
return color.full;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
if((color.ch.red & 0x4) ||
|
||||
(color.ch.green & 0x4) ||
|
||||
(color.ch.blue & 0x2)) {
|
||||
if((color.ch.red & 0x4) || (color.ch.green & 0x4) || (color.ch.blue & 0x2)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
#if LV_COLOR_16_SWAP == 0
|
||||
if((color.ch.red & 0x10) ||
|
||||
(color.ch.green & 0x20) ||
|
||||
(color.ch.blue & 0x10)) {
|
||||
if((color.ch.red & 0x10) || (color.ch.green & 0x20) || (color.ch.blue & 0x10)) {
|
||||
return 1;
|
||||
#else
|
||||
if((color.ch.red & 0x10) ||
|
||||
(color.ch.green_h & 0x20) ||
|
||||
(color.ch.blue & 0x10)) {
|
||||
if((color.ch.red & 0x10) || (color.ch.green_h & 0x20) || (color.ch.blue & 0x10)) {
|
||||
return 1;
|
||||
#endif
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#elif LV_COLOR_DEPTH == 32
|
||||
if((color.ch.red & 0x80) ||
|
||||
(color.ch.green & 0x80) ||
|
||||
(color.ch.blue & 0x80)) {
|
||||
if((color.ch.red & 0x80) || (color.ch.green & 0x80) || (color.ch.blue & 0x80)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -225,8 +216,10 @@ static inline uint8_t lv_color_to1(lv_color_t color)
|
||||
static inline uint8_t lv_color_to8(lv_color_t color)
|
||||
{
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFF;
|
||||
if(color.full == 0)
|
||||
return 0;
|
||||
else
|
||||
return 0xFF;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
return color.full;
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
@ -256,8 +249,10 @@ static inline uint8_t lv_color_to8(lv_color_t color)
|
||||
static inline uint16_t lv_color_to16(lv_color_t color)
|
||||
{
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFFFF;
|
||||
if(color.full == 0)
|
||||
return 0;
|
||||
else
|
||||
return 0xFFFF;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
lv_color16_t ret;
|
||||
#if LV_COLOR_16_SWAP == 0
|
||||
@ -293,8 +288,10 @@ static inline uint16_t lv_color_to16(lv_color_t color)
|
||||
static inline uint32_t lv_color_to32(lv_color_t color)
|
||||
{
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFFFFFFFF;
|
||||
if(color.full == 0)
|
||||
return 0;
|
||||
else
|
||||
return 0xFFFFFFFF;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
lv_color32_t ret;
|
||||
ret.ch.red = color.ch.red * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
||||
@ -313,7 +310,8 @@ static inline uint32_t lv_color_to32(lv_color_t color)
|
||||
#else
|
||||
lv_color32_t ret;
|
||||
ret.ch.red = color.ch.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
|
||||
ret.ch.green = ((color.ch.green_h << 3) + color.ch.green_l) * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/
|
||||
ret.ch.green =
|
||||
((color.ch.green_h << 3) + color.ch.green_l) * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/
|
||||
ret.ch.blue = color.ch.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
|
||||
ret.ch.alpha = 0xFF;
|
||||
return ret.full;
|
||||
@ -367,14 +365,16 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
|
||||
/* The most simple macro to create a color from R,G and B values */
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){(b8 >> 7 | g8 >> 7 | r8 >> 7)})
|
||||
static inline lv_color_t lv_color_make(int r8, int g8, int b8){
|
||||
static inline lv_color_t lv_color_make(int r8, int g8, int b8)
|
||||
{
|
||||
lv_color_t color;
|
||||
color.full = (b8 >> 7 | g8 >> 7 | r8 >> 7);
|
||||
return color;
|
||||
}
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 6, g8 >> 5, r8 >> 5}})
|
||||
static inline lv_color_t lv_color_make(uint8_t r8, int g8, int b8){
|
||||
static inline lv_color_t lv_color_make(uint8_t r8, int g8, int b8)
|
||||
{
|
||||
lv_color_t color;
|
||||
color.ch.blue = b8 >> 6;
|
||||
color.ch.green = g8 >> 5;
|
||||
@ -384,7 +384,8 @@ static inline lv_color_t lv_color_make(uint8_t r8, int g8, int b8){
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
#if LV_COLOR_16_SWAP == 0
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 3, g8 >> 2, r8 >> 3}})
|
||||
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8)
|
||||
{
|
||||
lv_color_t color;
|
||||
color.ch.blue = (uint16_t)(b8 >> 3);
|
||||
color.ch.green = (uint16_t)(g8 >> 2);
|
||||
@ -393,7 +394,8 @@ static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||
}
|
||||
#else
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{g8 >> 5, r8 >> 3, b8 >> 3, (g8 >> 2) & 0x7}})
|
||||
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8)
|
||||
{
|
||||
lv_color_t color;
|
||||
color.ch.green_h = (uint16_t)(g8 >> 5);
|
||||
color.ch.red = (uint16_t)(r8 >> 3);
|
||||
@ -404,7 +406,8 @@ static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||
#endif
|
||||
#elif LV_COLOR_DEPTH == 32
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
|
||||
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||
static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8)
|
||||
{
|
||||
lv_color_t color;
|
||||
color.ch.blue = b8;
|
||||
color.ch.green = g8;
|
||||
@ -414,13 +417,14 @@ static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8){
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline lv_color_t lv_color_hex(uint32_t c) {
|
||||
return lv_color_make((uint8_t) ((c >> 16) & 0xFF),
|
||||
(uint8_t) ((c >> 8) & 0xFF),
|
||||
static inline lv_color_t lv_color_hex(uint32_t c)
|
||||
{
|
||||
return lv_color_make((uint8_t)((c >> 16) & 0xFF), (uint8_t)((c >> 8) & 0xFF),
|
||||
(uint8_t)(c & 0xFF));
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_color_hex3(uint32_t c) {
|
||||
static inline lv_color_t lv_color_hex3(uint32_t c)
|
||||
{
|
||||
return lv_color_make((uint8_t)(((c >> 4) & 0xF0) | ((c >> 8) & 0xF)),
|
||||
(uint8_t)((c & 0xF0) | ((c & 0xF0) >> 4)),
|
||||
(uint8_t)((c & 0xF) | ((c & 0xF) << 4)));
|
||||
@ -444,7 +448,6 @@ lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v);
|
||||
*/
|
||||
lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -63,7 +63,6 @@ void lv_font_add(lv_font_t * child, lv_font_t * parent)
|
||||
}
|
||||
|
||||
parent->next_page = child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +82,6 @@ void lv_font_remove(lv_font_t * child, lv_font_t * parent)
|
||||
parent->next_page = child->next_page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tells if font which contains `letter` is monospace or not
|
||||
* @param font_p point to font
|
||||
@ -150,7 +148,6 @@ uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter)
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -190,11 +187,11 @@ uint8_t lv_font_get_bpp(const lv_font_t * font, uint32_t letter)
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic bitmap get function used in 'font->get_bitmap' when the font contains all characters in the range
|
||||
* Generic bitmap get function used in 'font->get_bitmap' when the font contains all characters in
|
||||
* the range
|
||||
* @param font pointer to font
|
||||
* @param unicode_letter an unicode letter which bitmap should be get
|
||||
* @return pointer to the bitmap or NULL if not found
|
||||
@ -209,7 +206,8 @@ const uint8_t * lv_font_get_bitmap_continuous(const lv_font_t * font, uint32_t u
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic bitmap get function used in 'font->get_bitmap' when the font NOT contains all characters in the range (sparse)
|
||||
* Generic bitmap get function used in 'font->get_bitmap' when the font NOT contains all characters
|
||||
* in the range (sparse)
|
||||
* @param font pointer to font
|
||||
* @param unicode_letter an unicode letter which bitmap should be get
|
||||
* @return pointer to the bitmap or NULL if not found
|
||||
@ -221,11 +219,8 @@ const uint8_t * lv_font_get_bitmap_sparse(const lv_font_t * font, uint32_t unico
|
||||
|
||||
uint32_t * pUnicode;
|
||||
|
||||
pUnicode = lv_utils_bsearch(&unicode_letter,
|
||||
(uint32_t*) font->unicode_list,
|
||||
font->glyph_cnt,
|
||||
sizeof(uint32_t),
|
||||
lv_font_codeCompare);
|
||||
pUnicode = lv_utils_bsearch(&unicode_letter, (uint32_t *)font->unicode_list, font->glyph_cnt,
|
||||
sizeof(uint32_t), lv_font_codeCompare);
|
||||
|
||||
if(pUnicode != NULL) {
|
||||
uint32_t idx = (uint32_t)(pUnicode - font->unicode_list);
|
||||
@ -236,7 +231,8 @@ const uint8_t * lv_font_get_bitmap_sparse(const lv_font_t * font, uint32_t unico
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic glyph width get function used in 'font->get_width' when the font contains all characters in the range
|
||||
* Generic glyph width get function used in 'font->get_width' when the font contains all characters
|
||||
* in the range
|
||||
* @param font pointer to font
|
||||
* @param unicode_letter an unicode letter which width should be get
|
||||
* @return width of the gylph or -1 if not found
|
||||
@ -253,7 +249,8 @@ int16_t lv_font_get_width_continuous(const lv_font_t * font, uint32_t unicode_le
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic glyph width get function used in 'font->get_bitmap' when the font NOT contains all characters in the range (sparse)
|
||||
* Generic glyph width get function used in 'font->get_bitmap' when the font NOT contains all
|
||||
* characters in the range (sparse)
|
||||
* @param font pointer to font
|
||||
* @param unicode_letter an unicode letter which width should be get
|
||||
* @return width of the glyph or -1 if not found
|
||||
@ -265,11 +262,8 @@ int16_t lv_font_get_width_sparse(const lv_font_t * font, uint32_t unicode_letter
|
||||
|
||||
uint32_t * pUnicode;
|
||||
|
||||
pUnicode = lv_utils_bsearch(&unicode_letter,
|
||||
(uint32_t*) font->unicode_list,
|
||||
font->glyph_cnt,
|
||||
sizeof(uint32_t),
|
||||
lv_font_codeCompare);
|
||||
pUnicode = lv_utils_bsearch(&unicode_letter, (uint32_t *)font->unicode_list, font->glyph_cnt,
|
||||
sizeof(uint32_t), lv_font_codeCompare);
|
||||
|
||||
if(pUnicode != NULL) {
|
||||
uint32_t idx = (uint32_t)(pUnicode - font->unicode_list);
|
||||
@ -296,8 +290,7 @@ int16_t lv_font_get_width_sparse(const lv_font_t * font, uint32_t unicode_letter
|
||||
* @retval > 0 Reference is less than element.
|
||||
*
|
||||
*/
|
||||
static int32_t lv_font_codeCompare (const void* pRef,
|
||||
const void* pElement)
|
||||
static int32_t lv_font_codeCompare(const void * pRef, const void * pElement)
|
||||
{
|
||||
return (*(uint32_t *)pRef) - (*(uint32_t *)pElement);
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -53,8 +52,10 @@ typedef struct _lv_font_struct
|
||||
const uint8_t * glyph_bitmap;
|
||||
const lv_font_glyph_dsc_t * glyph_dsc;
|
||||
const uint32_t * unicode_list;
|
||||
const uint8_t * (*get_bitmap)(const struct _lv_font_struct *,uint32_t); /*Get a glyph's bitmap from a font*/
|
||||
int16_t (*get_width)(const struct _lv_font_struct *,uint32_t); /*Get a glyph's with with a given font*/
|
||||
const uint8_t * (*get_bitmap)(const struct _lv_font_struct *,
|
||||
uint32_t); /*Get a glyph's bitmap from a font*/
|
||||
int16_t (*get_width)(const struct _lv_font_struct *,
|
||||
uint32_t); /*Get a glyph's with with a given font*/
|
||||
struct _lv_font_struct * next_page; /*Pointer to a font extension*/
|
||||
uint32_t h_px : 8;
|
||||
uint32_t bpp : 4; /*Bit per pixel: 1, 2 or 4*/
|
||||
@ -109,7 +110,6 @@ const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter);
|
||||
*/
|
||||
uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter);
|
||||
|
||||
|
||||
/**
|
||||
* Get the width of the letter without overwriting it with the `monospace` attribute
|
||||
* @param font_p pointer to a font
|
||||
@ -137,7 +137,8 @@ static inline uint8_t lv_font_get_height(const lv_font_t * font_p)
|
||||
uint8_t lv_font_get_bpp(const lv_font_t * font, uint32_t letter);
|
||||
|
||||
/**
|
||||
* Generic bitmap get function used in 'font->get_bitmap' when the font contains all characters in the range
|
||||
* Generic bitmap get function used in 'font->get_bitmap' when the font contains all characters in
|
||||
* the range
|
||||
* @param font pointer to font
|
||||
* @param unicode_letter an unicode letter which bitmap should be get
|
||||
* @return pointer to the bitmap or NULL if not found
|
||||
@ -145,14 +146,16 @@ uint8_t lv_font_get_bpp(const lv_font_t * font, uint32_t letter);
|
||||
const uint8_t * lv_font_get_bitmap_continuous(const lv_font_t * font, uint32_t unicode_letter);
|
||||
|
||||
/**
|
||||
* Generic bitmap get function used in 'font->get_bitmap' when the font NOT contains all characters in the range (sparse)
|
||||
* Generic bitmap get function used in 'font->get_bitmap' when the font NOT contains all characters
|
||||
* in the range (sparse)
|
||||
* @param font pointer to font
|
||||
* @param unicode_letter an unicode letter which bitmap should be get
|
||||
* @return pointer to the bitmap or NULL if not found
|
||||
*/
|
||||
const uint8_t * lv_font_get_bitmap_sparse(const lv_font_t * font, uint32_t unicode_letter);
|
||||
/**
|
||||
* Generic glyph width get function used in 'font->get_width' when the font contains all characters in the range
|
||||
* Generic glyph width get function used in 'font->get_width' when the font contains all characters
|
||||
* in the range
|
||||
* @param font pointer to font
|
||||
* @param unicode_letter an unicode letter which width should be get
|
||||
* @return width of the gylph or -1 if not found
|
||||
@ -160,7 +163,8 @@ const uint8_t * lv_font_get_bitmap_sparse(const lv_font_t * font, uint32_t unico
|
||||
int16_t lv_font_get_width_continuous(const lv_font_t * font, uint32_t unicode_letter);
|
||||
|
||||
/**
|
||||
* Generic glyph width get function used in 'font->get_bitmap' when the font NOT contains all characters in the range (sparse)
|
||||
* Generic glyph width get function used in 'font->get_bitmap' when the font NOT contains all
|
||||
* characters in the range (sparse)
|
||||
* @param font pointer to font
|
||||
* @param unicode_letter an unicode letter which width should be get
|
||||
* @return width of the glyph or -1 if not found
|
||||
@ -173,7 +177,6 @@ int16_t lv_font_get_width_sparse(const lv_font_t * font, uint32_t unicode_letter
|
||||
|
||||
#define LV_FONT_DECLARE(font_name) extern lv_font_t font_name;
|
||||
|
||||
|
||||
/**********************
|
||||
* ADD BUILT IN FONTS
|
||||
**********************/
|
||||
@ -189,4 +192,3 @@ LV_FONT_CUSTOM_DECLARE
|
||||
#endif
|
||||
|
||||
#endif /*USE_FONT*/
|
||||
|
||||
|
@ -39,7 +39,6 @@
|
||||
static const char * lv_fs_get_real_path(const char * path);
|
||||
static lv_fs_drv_t * lv_fs_get_drv(char letter);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@ -61,7 +60,8 @@ void lv_fs_init(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a drive is rady or not. If the `ready` function was not initialized `true` will be returned.
|
||||
* Test if a drive is rady or not. If the `ready` function was not initialized `true` will be
|
||||
* returned.
|
||||
* @param letter letter of the drive
|
||||
* @return true: drive is ready; false: drive is not ready
|
||||
*/
|
||||
@ -307,7 +307,6 @@ lv_fs_res_t lv_fs_size(lv_fs_file_t * file_p, uint32_t * size)
|
||||
|
||||
if(file_p->drv->size == NULL) return LV_FS_RES_NOT_IMP;
|
||||
|
||||
|
||||
if(size == NULL) return LV_FS_RES_INV_PARAM;
|
||||
|
||||
lv_fs_res_t res = file_p->drv->size(file_p->file_d, size);
|
||||
@ -348,7 +347,6 @@ lv_fs_res_t lv_fs_rename(const char * oldname, const char * newname)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a 'fs_read_dir_t' variable for directory reading
|
||||
* @param rddir_p pointer to a 'fs_read_dir_t' variable
|
||||
@ -492,7 +490,8 @@ char * lv_fs_get_letters(char * buf)
|
||||
lv_fs_drv_t * drv;
|
||||
uint8_t i = 0;
|
||||
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_drv_ll), drv) {
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_drv_ll), drv)
|
||||
{
|
||||
buf[i] = drv->letter;
|
||||
i++;
|
||||
}
|
||||
@ -502,7 +501,6 @@ char * lv_fs_get_letters(char * buf)
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return with the extension of the filename
|
||||
* @param fn string with a filename
|
||||
@ -537,8 +535,10 @@ char * lv_fs_up(char * path)
|
||||
/*Ignore trailing '/' or '\'*/
|
||||
while(path[len] == '/' || path[len] == '\\') {
|
||||
path[len] = '\0';
|
||||
if(len > 0) len --;
|
||||
else return path;
|
||||
if(len > 0)
|
||||
len--;
|
||||
else
|
||||
return path;
|
||||
}
|
||||
|
||||
uint16_t i;
|
||||
@ -565,8 +565,10 @@ const char * lv_fs_get_last(const char * path)
|
||||
|
||||
/*Ignore trailing '/' or '\'*/
|
||||
while(path[len] == '/' || path[len] == '\\') {
|
||||
if(len > 0) len --;
|
||||
else return path;
|
||||
if(len > 0)
|
||||
len--;
|
||||
else
|
||||
return path;
|
||||
}
|
||||
|
||||
uint16_t i;
|
||||
@ -615,7 +617,8 @@ static lv_fs_drv_t * lv_fs_get_drv(char letter)
|
||||
{
|
||||
lv_fs_drv_t * drv;
|
||||
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_drv_ll), drv) {
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_drv_ll), drv)
|
||||
{
|
||||
if(drv->letter == letter) {
|
||||
return drv;
|
||||
}
|
||||
|
@ -33,8 +33,7 @@ extern "C" {
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_FS_RES_OK = 0,
|
||||
LV_FS_RES_HW_ERR, /*Low level hardware error*/
|
||||
LV_FS_RES_FS_ERR, /*Error in the file system structure */
|
||||
@ -59,15 +58,13 @@ typedef struct
|
||||
struct __lv_fs_drv_t * drv;
|
||||
} lv_fs_file_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * dir_d;
|
||||
struct __lv_fs_drv_t * drv;
|
||||
} lv_fs_dir_t;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_FS_MODE_WR = 0x01,
|
||||
LV_FS_MODE_RD = 0x02,
|
||||
};
|
||||
@ -114,7 +111,8 @@ void lv_fs_init(void);
|
||||
void lv_fs_add_drv(lv_fs_drv_t * drv_p);
|
||||
|
||||
/**
|
||||
* Test if a drive is rady or not. If the `ready` function was not initialized `true` will be returned.
|
||||
* Test if a drive is rady or not. If the `ready` function was not initialized `true` will be
|
||||
* returned.
|
||||
* @param letter letter of the drive
|
||||
* @return true: drive is ready; false: drive is not ready
|
||||
*/
|
||||
|
@ -37,8 +37,7 @@ extern "C" {
|
||||
prefix lv_ll_t _lv_file_ll; \
|
||||
prefix lv_ll_t _lv_anim_ll; \
|
||||
prefix lv_ll_t _lv_group_ll; \
|
||||
prefix void * _lv_task_act;\
|
||||
|
||||
prefix void * _lv_task_act;
|
||||
|
||||
#define LV_NO_PREFIX
|
||||
#define LV_ROOTS LV_GC_ROOTS(LV_NO_PREFIX)
|
||||
@ -52,7 +51,6 @@ extern "C" {
|
||||
LV_GC_ROOTS(extern)
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -65,7 +63,6 @@ extern "C" {
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -154,7 +154,6 @@ void * lv_ll_ins_tail(lv_ll_t * ll_p)
|
||||
return n_new;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the node 'node_p' from 'll_p' linked list.
|
||||
* It does not free the the memory of node.
|
||||
@ -320,10 +319,11 @@ void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after)
|
||||
{
|
||||
if(n_act == n_after) return; /*Can't move before itself*/
|
||||
|
||||
|
||||
void * n_before;
|
||||
if(n_after != NULL) n_before = lv_ll_get_prev(ll_p, n_after);
|
||||
else n_before = lv_ll_get_tail(ll_p); /*if `n_after` is NULL `n_act` should be the new tail*/
|
||||
if(n_after != NULL)
|
||||
n_before = lv_ll_get_prev(ll_p, n_after);
|
||||
else
|
||||
n_before = lv_ll_get_tail(ll_p); /*if `n_after` is NULL `n_act` should be the new tail*/
|
||||
|
||||
if(n_act == n_before) return; /*Already before `n_after`*/
|
||||
|
||||
@ -354,7 +354,6 @@ bool lv_ll_is_empty(lv_ll_t * ll_p)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -370,8 +369,10 @@ static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * pre
|
||||
if(act == NULL) return; /*Can't set the prev node of `NULL`*/
|
||||
|
||||
uint32_t node_p_size = sizeof(lv_ll_node_t *);
|
||||
if(prev) memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, node_p_size);
|
||||
else memset(act + LL_PREV_P_OFFSET(ll_p), 0, node_p_size);
|
||||
if(prev)
|
||||
memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, node_p_size);
|
||||
else
|
||||
memset(act + LL_PREV_P_OFFSET(ll_p), 0, node_p_size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -385,7 +386,8 @@ static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * nex
|
||||
if(act == NULL) return; /*Can't set the next node of `NULL`*/
|
||||
|
||||
uint32_t node_p_size = sizeof(lv_ll_node_t *);
|
||||
if(next) memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, node_p_size);
|
||||
else memset(act + LL_NEXT_P_OFFSET(ll_p), 0, node_p_size);
|
||||
if(next)
|
||||
memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, node_p_size);
|
||||
else
|
||||
memset(act + LL_NEXT_P_OFFSET(ll_p), 0, node_p_size);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -143,7 +142,8 @@ bool lv_ll_is_empty(lv_ll_t * ll_p);
|
||||
|
||||
#define LV_LL_READ(list, i) for(i = lv_ll_get_head(&list); i != NULL; i = lv_ll_get_next(&list, i))
|
||||
|
||||
#define LV_LL_READ_BACK(list, i) for(i = lv_ll_get_tail(&list); i != NULL; i = lv_ll_get_prev(&list, i))
|
||||
#define LV_LL_READ_BACK(list, i) \
|
||||
for(i = lv_ll_get_tail(&list); i != NULL; i = lv_ll_get_prev(&list, i))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -40,7 +40,8 @@ static void (*print_cb)(lv_log_level_t, const char *, uint32_t, const char *);
|
||||
/**
|
||||
* Register custom print (or anything else) function to call when log is added
|
||||
* @param f a function pointer:
|
||||
* `void my_print (lv_log_level_t level, const char * file, uint32_t line, const char * dsc)`
|
||||
* `void my_print (lv_log_level_t level, const char * file, uint32_t line, const char *
|
||||
* dsc)`
|
||||
*/
|
||||
void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const char *))
|
||||
{
|
||||
|
@ -39,7 +39,6 @@ typedef int8_t lv_log_level_t;
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -47,7 +46,8 @@ typedef int8_t lv_log_level_t;
|
||||
/**
|
||||
* Register custom print (or anything else) function to call when log is added
|
||||
* @param f a function pointer:
|
||||
* `void my_print (lv_log_level_t level, const char * file, uint32_t line, const char * dsc)`
|
||||
* `void my_print (lv_log_level_t level, const char * file, uint32_t line, const char *
|
||||
* dsc)`
|
||||
*/
|
||||
void lv_log_register_print(void f(lv_log_level_t, const char *, uint32_t, const char *));
|
||||
|
||||
@ -72,11 +72,26 @@ void lv_log_add(lv_log_level_t level, const char * file, int line, const char *
|
||||
#else /*LV_USE_LOG*/
|
||||
|
||||
/*Do nothing if `LV_USE_LOG 0`*/
|
||||
#define lv_log_add(level, file, line, dsc) {;}
|
||||
#define LV_LOG_TRACE(dsc) {;}
|
||||
#define LV_LOG_INFO(dsc) {;}
|
||||
#define LV_LOG_WARN(dsc) {;}
|
||||
#define LV_LOG_ERROR(dsc) {;}
|
||||
#define lv_log_add(level, file, line, dsc) \
|
||||
{ \
|
||||
; \
|
||||
}
|
||||
#define LV_LOG_TRACE(dsc) \
|
||||
{ \
|
||||
; \
|
||||
}
|
||||
#define LV_LOG_INFO(dsc) \
|
||||
{ \
|
||||
; \
|
||||
}
|
||||
#define LV_LOG_WARN(dsc) \
|
||||
{ \
|
||||
; \
|
||||
}
|
||||
#define LV_LOG_ERROR(dsc) \
|
||||
{ \
|
||||
; \
|
||||
}
|
||||
#endif /*LV_USE_LOG*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -26,18 +26,13 @@
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
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,
|
||||
16383, 16876, 17364, 17846, 18323, 18794, 19260, 19720, 20173, 20621,
|
||||
21062, 21497, 21925, 22347, 22762, 23170, 23571, 23964, 24351, 24730,
|
||||
25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087,
|
||||
28377, 28659, 28932, 29196, 29451, 29697, 29934, 30162, 30381, 30591,
|
||||
30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165,
|
||||
32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762,
|
||||
32767
|
||||
};
|
||||
|
||||
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, 16383, 16876, 17364, 17846, 18323, 18794, 19260, 19720, 20173,
|
||||
20621, 21062, 21497, 21925, 22347, 22762, 23170, 23571, 23964, 24351, 24730, 25101, 25465,
|
||||
25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087, 28377, 28659, 28932, 29196, 29451,
|
||||
29697, 29934, 30162, 30381, 30591, 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927,
|
||||
32051, 32165, 32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, 32767};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -92,18 +87,14 @@ int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3)
|
||||
uint32_t t2 = (t * t) >> 10;
|
||||
uint32_t t3 = (t2 * t) >> 10;
|
||||
|
||||
|
||||
uint32_t v1 = ((uint32_t)t_rem3 * u0) >> 10;
|
||||
uint32_t v2 = ((uint32_t)3 * t_rem2 * t * u1) >> 20;
|
||||
uint32_t v3 = ((uint32_t)3 * t_rem * t2 * u2) >> 20;
|
||||
uint32_t v4 = ((uint32_t)t3 * u3) >> 10;
|
||||
|
||||
return v1 + v2 + v3 + v4;
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
@ -18,8 +18,8 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_MEM_ADD_JUNK 0 /*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/
|
||||
|
||||
#define LV_MEM_ADD_JUNK \
|
||||
0 /*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/
|
||||
|
||||
#ifdef LV_MEM_ENV64
|
||||
#define MEM_UNIT uint64_t
|
||||
@ -27,7 +27,6 @@
|
||||
#define MEM_UNIT uint32_t
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -35,15 +34,18 @@
|
||||
#if LV_ENABLE_GC == 0 /*gc custom allocations must not include header*/
|
||||
|
||||
/*The size of this union must be 4 bytes (uint32_t)*/
|
||||
typedef union {
|
||||
struct {
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
MEM_UNIT used : 1; // 1: if the entry is used
|
||||
MEM_UNIT d_size : 31; // Size off the data (1 means 4 bytes)
|
||||
} s;
|
||||
MEM_UNIT 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;
|
||||
@ -139,7 +141,6 @@ void * lv_mem_alloc(uint32_t size)
|
||||
// End if there is not next entry OR the alloc. is successful
|
||||
} while(e != NULL && alloc == NULL);
|
||||
|
||||
|
||||
#else /*Use custom, user defined malloc function*/
|
||||
#if LV_ENABLE_GC == 1 /*gc must not include header*/
|
||||
alloc = LV_MEM_CUSTOM_ALLOC(size);
|
||||
@ -172,7 +173,6 @@ void lv_mem_free(const void * data)
|
||||
if(data == &zero_mem) return;
|
||||
if(data == NULL) return;
|
||||
|
||||
|
||||
#if LV_MEM_ADD_JUNK
|
||||
memset((void *)data, 0xbb, lv_mem_get_size(data));
|
||||
#endif
|
||||
@ -232,7 +232,8 @@ void * lv_mem_realloc(void * data_p, uint32_t new_size)
|
||||
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
/* Only truncate the memory is possible
|
||||
* If the 'old_size' was extended by a header size in 'ent_trunc' it avoids reallocating this same memory */
|
||||
* If the 'old_size' was extended by a header size in 'ent_trunc' it avoids reallocating this
|
||||
* same memory */
|
||||
if(new_size < old_size) {
|
||||
lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data_p - sizeof(lv_mem_header_t));
|
||||
ent_trunc(e, new_size);
|
||||
@ -251,7 +252,6 @@ void * lv_mem_realloc(void * data_p, uint32_t new_size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(new_p == NULL) LV_LOG_WARN("Couldn't allocate memory");
|
||||
|
||||
return new_p;
|
||||
@ -398,7 +398,6 @@ static lv_mem_ent_t * ent_get_next(lv_mem_ent_t * act_e)
|
||||
return next_e;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to do the real allocation with a given size
|
||||
* @param e try to allocate to this entry
|
||||
|
@ -10,7 +10,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -58,7 +57,6 @@ typedef struct
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Initiaize the dyn_mem module (work memory and other variables)
|
||||
*/
|
||||
@ -105,7 +103,6 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p);
|
||||
*/
|
||||
uint32_t lv_mem_get_size(const void * data);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -115,13 +112,24 @@ uint32_t lv_mem_get_size(const void * data);
|
||||
* p pointer to a memory
|
||||
*/
|
||||
#if LV_USE_LOG == 0
|
||||
# define lv_mem_assert(p) {if(p == NULL) while(1); }
|
||||
#define lv_mem_assert(p) \
|
||||
{ \
|
||||
if(p == NULL) \
|
||||
while(1) \
|
||||
; \
|
||||
}
|
||||
#else
|
||||
# define lv_mem_assert(p) {if(p == NULL) {LV_LOG_ERROR("Out of memory!"); while(1); }}
|
||||
#define lv_mem_assert(p) \
|
||||
{ \
|
||||
if(p == NULL) { \
|
||||
LV_LOG_ERROR("Out of memory!"); \
|
||||
while(1) \
|
||||
; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_MEM_H*/
|
||||
|
||||
|
@ -72,13 +72,14 @@ extern "C" {
|
||||
#define LV_SYMBOL_BATTERY_EMPTY _LV_SYMBOL_VALUE3(EF, A0, B0)
|
||||
#define LV_SYMBOL_BLUETOOTH _LV_SYMBOL_VALUE3(EF, A0, B1)
|
||||
#define LV_SYMBOL_GLYPH_LAST 0xF831
|
||||
#define LV_SYMBOL_DUMMY _LV_SYMBOL_VALUE3(EF,A3,BF) /*Invalid symbol at (U+F831). If written before a string then `lv_img` will show it as a label*/
|
||||
#define LV_SYMBOL_DUMMY \
|
||||
_LV_SYMBOL_VALUE3(EF, A3, BF) /*Invalid symbol at (U+F831). If written before a string then \
|
||||
`lv_img` will show it as a label*/
|
||||
|
||||
#define _LV_SYMBOL_VALUE3(x, y, z) (0x##z##y##x)
|
||||
#define _LV_SYMBOL_NUMSTR(sym) LV_##sym##_NUMSTR = sym
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
_LV_SYMBOL_NUMSTR(LV_SYMBOL_AUDIO),
|
||||
_LV_SYMBOL_NUMSTR(LV_SYMBOL_VIDEO),
|
||||
_LV_SYMBOL_NUMSTR(LV_SYMBOL_LIST),
|
||||
@ -138,11 +139,11 @@ enum
|
||||
#define _LV_SYMBOL_STR(x) _LV_SYMBOL_STR_(x)
|
||||
#define _LV_SYMBOL_CHAR(c) \x##c
|
||||
#define _LV_SYMBOL_VALUE1(x) _LV_SYMBOL_STR(_LV_SYMBOL_CHAR(x))
|
||||
#define _LV_SYMBOL_VALUE3(x, y, z) _LV_SYMBOL_STR(_LV_SYMBOL_CHAR(x)_LV_SYMBOL_CHAR(y)_LV_SYMBOL_CHAR(z))
|
||||
#define _LV_SYMBOL_VALUE3(x, y, z) \
|
||||
_LV_SYMBOL_STR(_LV_SYMBOL_CHAR(x) _LV_SYMBOL_CHAR(y) _LV_SYMBOL_CHAR(z))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*LV_LV_SYMBOL_DEF_H*/
|
||||
|
@ -100,7 +100,8 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
|
||||
|
||||
/*Here is the interrupter task. Don't execute it again.*/
|
||||
if(LV_GC_ROOT(_lv_task_act) == task_interrupter) {
|
||||
task_interrupter = NULL; /*From this point only task after the interrupter comes, so the interrupter is not interesting anymore*/
|
||||
task_interrupter = NULL; /*From this point only task after the interrupter comes, so
|
||||
the interrupter is not interesting anymore*/
|
||||
LV_GC_ROOT(_lv_task_act) = next;
|
||||
continue; /*Load the next task*/
|
||||
}
|
||||
@ -113,7 +114,8 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
|
||||
else if(task_interrupter) {
|
||||
if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio > task_interrupter->prio) {
|
||||
if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) {
|
||||
task_interrupter = LV_GC_ROOT(_lv_task_act); /*Check all tasks again from the highest priority */
|
||||
task_interrupter = LV_GC_ROOT(
|
||||
_lv_task_act); /*Check all tasks again from the highest priority */
|
||||
end_flag = false;
|
||||
break;
|
||||
}
|
||||
@ -123,14 +125,17 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
|
||||
* Just run the remaining tasks*/
|
||||
else {
|
||||
if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) {
|
||||
task_interrupter = LV_GC_ROOT(_lv_task_act); /*Check all tasks again from the highest priority */
|
||||
task_interrupter = LV_GC_ROOT(
|
||||
_lv_task_act); /*Check all tasks again from the highest priority */
|
||||
end_flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(task_deleted) break; /*If a task was deleted then this or the next item might be corrupted*/
|
||||
if(task_created) break; /*If a task was deleted then this or the next item might be corrupted*/
|
||||
if(task_deleted)
|
||||
break; /*If a task was deleted then this or the next item might be corrupted*/
|
||||
if(task_created)
|
||||
break; /*If a task was deleted then this or the next item might be corrupted*/
|
||||
|
||||
LV_GC_ROOT(_lv_task_act) = next; /*Load the next task*/
|
||||
}
|
||||
@ -140,12 +145,11 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void)
|
||||
uint32_t idle_period_time = lv_tick_elaps(idle_period_start);
|
||||
if(idle_period_time >= IDLE_MEAS_PERIOD) {
|
||||
|
||||
idle_last = (uint32_t)((uint32_t)busy_time * 100) / IDLE_MEAS_PERIOD; /*Calculate the busy percentage*/
|
||||
idle_last = (uint32_t)((uint32_t)busy_time * 100) /
|
||||
IDLE_MEAS_PERIOD; /*Calculate the busy percentage*/
|
||||
idle_last = idle_last > 100 ? 0 : 100 - idle_last; /*But we need idle time*/
|
||||
busy_time = 0;
|
||||
idle_period_start = lv_tick_get();
|
||||
|
||||
|
||||
}
|
||||
|
||||
task_handler_mutex = false; /*Release the mutex*/
|
||||
@ -224,7 +228,8 @@ 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;
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_task_ll), i) {
|
||||
LV_LL_READ(LV_GC_ROOT(_lv_task_ll), i)
|
||||
{
|
||||
if(i->prio <= prio) {
|
||||
if(i != lv_task_p) lv_ll_move_before(&LV_GC_ROOT(_lv_task_ll), lv_task_p, i);
|
||||
break;
|
||||
@ -236,7 +241,6 @@ void lv_task_set_prio(lv_task_t * lv_task_p, lv_task_prio_t prio)
|
||||
lv_ll_move_before(&LV_GC_ROOT(_lv_task_ll), lv_task_p, NULL);
|
||||
}
|
||||
|
||||
|
||||
lv_task_p->prio = prio;
|
||||
}
|
||||
|
||||
@ -296,7 +300,6 @@ uint8_t lv_task_get_idle(void)
|
||||
return idle_last;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -329,4 +332,3 @@ static bool lv_task_exec(lv_task_t * lv_task_p)
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,7 @@ extern "C" {
|
||||
/**
|
||||
* Possible priorities for lv_tasks
|
||||
*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_TASK_PRIO_OFF = 0,
|
||||
LV_TASK_PRIO_LOWEST,
|
||||
LV_TASK_PRIO_LOW,
|
||||
@ -84,7 +83,8 @@ 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);
|
||||
|
||||
/**
|
||||
* Delete a lv_task
|
||||
@ -112,7 +112,6 @@ void lv_task_set_period(lv_task_t* lv_task_p, uint32_t period);
|
||||
*/
|
||||
void lv_task_ready(lv_task_t * lv_task_p);
|
||||
|
||||
|
||||
/**
|
||||
* Delete the lv_task after one call
|
||||
* @param lv_task_p pointer to a lv_task.
|
||||
|
@ -30,7 +30,6 @@ extern "C" {
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -15,15 +15,18 @@
|
||||
#define NO_BREAK_FOUND UINT32_MAX
|
||||
|
||||
#ifndef LV_TXT_LINE_BREAK_LONG_LEN
|
||||
#define LV_TXT_LINE_BREAK_LONG_LEN 12 /* If a character is at least this long, will break wherever "prettiest" */
|
||||
#define LV_TXT_LINE_BREAK_LONG_LEN \
|
||||
12 /* If a character is at least this long, will break wherever "prettiest" */
|
||||
#endif
|
||||
|
||||
#ifndef LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN
|
||||
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 /* Minimum number of characters of a word to put on a line before a break */
|
||||
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN \
|
||||
3 /* Minimum number of characters of a word to put on a line before a break */
|
||||
#endif
|
||||
|
||||
#ifndef LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN
|
||||
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 1 /* Minimum number of characters of a word to put on a line after a break */
|
||||
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN \
|
||||
1 /* Minimum number of characters of a word to put on a line after a break */
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -48,7 +51,6 @@ static uint32_t lv_txt_utf8_get_length(const char * txt);
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
@ -77,10 +79,12 @@ uint32_t (*lv_txt_get_encoded_length)(const char *) = lv_txt_utf8_get_l
|
||||
* @param letter_space letter space of the text
|
||||
* @param txt.line_space line space of the text
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks
|
||||
* @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;
|
||||
size_res->y = 0;
|
||||
@ -97,13 +101,14 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
|
||||
|
||||
/*Calc. the height and longest line*/
|
||||
while(text[line_start] != '\0') {
|
||||
new_line_start += lv_txt_get_next_line(&text[line_start], font, letter_space, max_width, flag);
|
||||
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);
|
||||
act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start, font,
|
||||
letter_space, flag);
|
||||
|
||||
size_res->x = LV_MATH_MAX(act_line_length, size_res->x);
|
||||
line_start = new_line_start;
|
||||
@ -115,9 +120,10 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
|
||||
}
|
||||
|
||||
/*Correction with the last line space or set the height manually if the text is empty*/
|
||||
if(size_res->y == 0) size_res->y = letter_height;
|
||||
else size_res->y -= line_space;
|
||||
|
||||
if(size_res->y == 0)
|
||||
size_res->y = letter_height;
|
||||
else
|
||||
size_res->y -= line_space;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,12 +131,14 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
|
||||
* @param txt a '\0' terminated string
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid
|
||||
* line breaks
|
||||
* @param flags settings for the text from 'txt_flag_type' enum
|
||||
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
|
||||
* @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)
|
||||
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)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
@ -156,7 +164,6 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Check for new line chars*/
|
||||
if(letter == '\n' || letter == '\r') {
|
||||
uint32_t i_tmp = i;
|
||||
@ -174,14 +181,16 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
* to break the line. */
|
||||
if(cur_w > max_width) {
|
||||
if(last_break != NO_BREAK_FOUND) {
|
||||
/* Continue searching for next breakable character to see if the next word will fit */
|
||||
/* Continue searching for next breakable character to see if the next word will
|
||||
* fit */
|
||||
uint32_t n_char_fit = n_char_since_last_break - 1;
|
||||
if(n_char_since_last_break <= LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN) {
|
||||
i = last_break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
uint32_t i_tmp = i;
|
||||
cur_w -= w_at_last_break + letter_space; /*ignore the first letter_space after the break char */
|
||||
cur_w -=
|
||||
w_at_last_break +
|
||||
letter_space; /*ignore the first letter_space after the break char */
|
||||
bool other = true;
|
||||
while(txt[i_tmp] != '\0') {
|
||||
letter = lv_txt_encoded_next(txt, &i_tmp);
|
||||
@ -204,8 +213,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
char_remain++) {
|
||||
lv_txt_encoded_prev(txt, &i);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
i = last_break;
|
||||
}
|
||||
other = false;
|
||||
@ -234,15 +242,16 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
char_remain++) {
|
||||
lv_txt_encoded_prev(txt, &i);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
i = last_break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Now this character is out of the area so it will be first character of the next line*/
|
||||
/* But 'i' already points to the next character (because of lv_txt_utf8_next) step beck one*/
|
||||
/* Now this character is out of the area so it will be first character of the
|
||||
* next line*/
|
||||
/* But 'i' already points to the next character (because of lv_txt_utf8_next)
|
||||
* step beck one*/
|
||||
lv_txt_encoded_prev(txt, &i);
|
||||
}
|
||||
|
||||
@ -275,14 +284,15 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
/**
|
||||
* Give the length of a text with a given font
|
||||
* @param txt a '\0' terminate string
|
||||
* @param length length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in UTF-8)
|
||||
* @param length length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in
|
||||
* UTF-8)
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
|
||||
const lv_font_t * font, lv_coord_t letter_space, lv_txt_flag_t flag)
|
||||
lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_txt_flag_t flag)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
if(font == NULL) return 0;
|
||||
@ -309,7 +319,8 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
|
||||
}
|
||||
|
||||
if(width > 0) {
|
||||
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 */
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,8 +329,8 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
|
||||
|
||||
/**
|
||||
* Check next character in a string and decide if the character is part of the command or not
|
||||
* @param state pointer to a txt_cmd_state_t variable which stores the current state of command processing
|
||||
* (Initied. to TXT_CMD_STATE_WAIT )
|
||||
* @param state pointer to a txt_cmd_state_t variable which stores the current state of command
|
||||
* processing (Initied. to TXT_CMD_STATE_WAIT )
|
||||
* @param c the current character
|
||||
* @return true: the character is part of a command and should not be written,
|
||||
* false: the character should be written
|
||||
@ -332,7 +343,8 @@ bool lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c)
|
||||
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 */
|
||||
} 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;
|
||||
@ -354,8 +366,8 @@ bool lv_txt_is_cmd(lv_txt_cmd_state_t * state, uint32_t c)
|
||||
/**
|
||||
* Insert a string into an other
|
||||
* @param txt_buf the original text (must be big enough for the result text)
|
||||
* @param pos position to insert. Expressed in character index and not byte index (Different in UTF-8)
|
||||
* 0: before the original text, 1: after the first char etc.
|
||||
* @param pos position to insert. Expressed in character index and not byte index (Different in
|
||||
* UTF-8) 0: before the original text, 1: after the first char etc.
|
||||
* @param ins_txt text to insert
|
||||
*/
|
||||
void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
|
||||
@ -363,7 +375,8 @@ void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
|
||||
uint32_t old_len = strlen(txt_buf);
|
||||
uint32_t ins_len = strlen(ins_txt);
|
||||
uint32_t new_len = ins_len + old_len;
|
||||
pos = lv_txt_encoded_get_byte_id(txt_buf, pos); /*Convert to byte index instead of letter index*/
|
||||
pos =
|
||||
lv_txt_encoded_get_byte_id(txt_buf, pos); /*Convert to byte index instead of letter index*/
|
||||
|
||||
/*Copy the second part into the end to make place to text to insert*/
|
||||
uint32_t i;
|
||||
@ -378,7 +391,8 @@ void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
|
||||
/**
|
||||
* Delete a part of a string
|
||||
* @param txt string to modify
|
||||
* @param pos position where to start the deleting (0: before the first char, 1: after the first char etc.)
|
||||
* @param pos position where to start the deleting (0: before the first char, 1: after the first
|
||||
* char etc.)
|
||||
* @param len number of characters to delete
|
||||
*/
|
||||
void lv_txt_cut(char * txt, uint32_t pos, uint32_t len)
|
||||
@ -396,7 +410,6 @@ void lv_txt_cut(char * txt, uint32_t pos, uint32_t len)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************
|
||||
* UTF-8 ENCODER/DECOER
|
||||
******************************/
|
||||
@ -408,14 +421,17 @@ void lv_txt_cut(char * txt, uint32_t pos, uint32_t len)
|
||||
*/
|
||||
static uint8_t lv_txt_utf8_size(const char * str)
|
||||
{
|
||||
if((str[0] & 0x80) == 0) return 1;
|
||||
else if((str[0] & 0xE0) == 0xC0) return 2;
|
||||
else if((str[0] & 0xF0) == 0xE0) return 3;
|
||||
else if((str[0] & 0xF8) == 0xF0) return 4;
|
||||
if((str[0] & 0x80) == 0)
|
||||
return 1;
|
||||
else if((str[0] & 0xE0) == 0xC0)
|
||||
return 2;
|
||||
else if((str[0] & 0xF0) == 0xE0)
|
||||
return 3;
|
||||
else if((str[0] & 0xF8) == 0xF0)
|
||||
return 4;
|
||||
return 1; /*If the char was invalid step tell it's 1 byte long*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an Unicode letter to UTF-8.
|
||||
* @param letter_uni an Unicode letter
|
||||
@ -462,7 +478,8 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
|
||||
swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]);
|
||||
uint8_t i;
|
||||
for(i = 0; i < 4; i++) {
|
||||
if((swapped & 0xFF) == 0) swapped = (swapped >> 8); /*Ignore leading zeros (they were in the end originally)*/
|
||||
if((swapped & 0xFF) == 0)
|
||||
swapped = (swapped >> 8); /*Ignore leading zeros (they were in the end originally)*/
|
||||
}
|
||||
c = swapped;
|
||||
}
|
||||
@ -547,7 +564,8 @@ static uint32_t lv_txt_utf8_next(const char * txt, uint32_t * i)
|
||||
/**
|
||||
* Get previous UTF-8 character form a string.
|
||||
* @param txt pointer to '\0' terminated string
|
||||
* @param i start byte index in 'txt' where to start. After the call it will point to the previous UTF-8 char in 'txt'.
|
||||
* @param i start byte index in 'txt' where to start. After the call it will point to the previous
|
||||
* UTF-8 char in 'txt'.
|
||||
* @return the decoded Unicode character or 0 on invalid UTF-8 code
|
||||
*/
|
||||
static uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i)
|
||||
@ -562,8 +580,10 @@ static uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i)
|
||||
|
||||
c_size = lv_txt_encoded_size(&txt[*i]);
|
||||
if(c_size == 0) {
|
||||
if(*i != 0)(*i)--;
|
||||
else return 0;
|
||||
if(*i != 0)
|
||||
(*i)--;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
cnt++;
|
||||
} while(c_size == 0);
|
||||
@ -572,7 +592,6 @@ static uint32_t lv_txt_utf8_prev(const char * txt, uint32_t * i)
|
||||
uint32_t letter = lv_txt_encoded_next(txt, &i_tmp); /*Character found, get it*/
|
||||
|
||||
return letter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -593,7 +612,6 @@ static uint32_t lv_txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id)
|
||||
return byte_cnt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a byte index (in an UTF-8 text) to character index.
|
||||
* E.g. in "AÁRT" index of 'R' is 2th char but start at byte 3 because 'Á' is 2 bytes long
|
||||
@ -657,4 +675,3 @@ static bool is_break_char(uint32_t letter)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,7 @@ extern "C" {
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_TXT_FLAG_NONE = 0x00,
|
||||
LV_TXT_FLAG_RECOLOR = 0x01, /*Enable parsing of recolor command*/
|
||||
LV_TXT_FLAG_EXPAND = 0x02, /*Ignore width to avoid automatic word wrapping*/
|
||||
@ -42,8 +41,7 @@ enum
|
||||
};
|
||||
typedef uint8_t lv_txt_flag_t;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_TXT_CMD_STATE_WAIT, /*Waiting for command*/
|
||||
LV_TXT_CMD_STATE_PAR, /*Processing the parameter*/
|
||||
LV_TXT_CMD_STATE_IN, /*Processing the command*/
|
||||
@ -62,39 +60,44 @@ typedef uint8_t lv_txt_cmd_state_t;
|
||||
* @param letter_space letter space of the text
|
||||
* @param line_space line space of the text
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Get the next line of text. Check line length and break chars too.
|
||||
* @param txt a '\0' terminated string
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid line breaks
|
||||
* @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid
|
||||
* line breaks
|
||||
* @param flags settings for the text from 'txt_flag_type' enum
|
||||
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
|
||||
* @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);
|
||||
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);
|
||||
|
||||
/**
|
||||
* Give the length of a text with a given font
|
||||
* @param txt a '\0' terminate string
|
||||
* @param length length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in UTF-8)
|
||||
* @param length length of 'txt' in byte count and not characters (Á is 1 character but 2 bytes in
|
||||
* UTF-8)
|
||||
* @param font pointer to a font
|
||||
* @param letter_space letter space
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
|
||||
const lv_font_t * font, lv_coord_t letter_space, lv_txt_flag_t flag);
|
||||
|
||||
lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_txt_flag_t flag);
|
||||
|
||||
/**
|
||||
* Check next character in a string and decide if te character is part of the command or not
|
||||
* @param state pointer to a txt_cmd_state_t variable which stores the current state of command processing
|
||||
* @param state pointer to a txt_cmd_state_t variable which stores the current state of command
|
||||
* processing
|
||||
* @param c the current character
|
||||
* @return true: the character is part of a command and should not be written,
|
||||
* false: the character should be written
|
||||
@ -112,7 +115,8 @@ void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt);
|
||||
/**
|
||||
* Delete a part of a string
|
||||
* @param txt string to modify
|
||||
* @param pos position where to start the deleting (0: before the first char, 1: after the first char etc.)
|
||||
* @param pos position where to start the deleting (0: before the first char, 1: after the first
|
||||
* char etc.)
|
||||
* @param len number of characters to delete
|
||||
*/
|
||||
void lv_txt_cut(char * txt, uint32_t pos, uint32_t len);
|
||||
@ -128,7 +132,6 @@ void lv_txt_cut(char * txt, uint32_t pos, uint32_t len);
|
||||
*/
|
||||
extern uint8_t (*lv_txt_encoded_size)(const char *);
|
||||
|
||||
|
||||
/**
|
||||
* Convert an Unicode letter to encoded
|
||||
* @param letter_uni an Unicode letter
|
||||
@ -156,7 +159,8 @@ extern uint32_t (*lv_txt_encoded_next)(const char *, uint32_t * );
|
||||
/**
|
||||
* Get the previous encoded character form a string.
|
||||
* @param txt pointer to '\0' terminated string
|
||||
* @param i_start index in 'txt' where to start. After the call it will point to the previous encoded char in 'txt'.
|
||||
* @param i_start index in 'txt' where to start. After the call it will point to the previous
|
||||
* encoded char in 'txt'.
|
||||
* @return the decoded Unicode character or 0 on invalid data
|
||||
*/
|
||||
extern uint32_t (*lv_txt_encoded_prev)(const char *, uint32_t *);
|
||||
|
@ -72,7 +72,6 @@ char * lv_utils_num_to_str(int32_t num, char * buf)
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/** Searches base[0] to base[n - 1] for an item that matches *key.
|
||||
*
|
||||
* @note The function cmp must return negative if its first
|
||||
@ -85,11 +84,13 @@ char * lv_utils_num_to_str(int32_t num, char * buf)
|
||||
* @param base Pointer to first element to search
|
||||
* @param n Number of elements
|
||||
* @param size Size of each element
|
||||
* @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function example)
|
||||
* @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function
|
||||
* example)
|
||||
*
|
||||
* @return a pointer to a matching item, or NULL if none exists.
|
||||
*/
|
||||
void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, int32_t (* cmp)(const void * pRef, const void * pElement))
|
||||
void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size,
|
||||
int32_t (*cmp)(const void * pRef, const void * pElement))
|
||||
{
|
||||
const char * middle;
|
||||
int32_t c;
|
||||
@ -112,5 +113,3 @@ void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -48,11 +47,13 @@ char * lv_utils_num_to_str(int32_t num, char * buf);
|
||||
* @param base Pointer to first element to search
|
||||
* @param n Number of elements
|
||||
* @param size Size of each element
|
||||
* @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function example)
|
||||
* @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function
|
||||
* example)
|
||||
*
|
||||
* @return a pointer to a matching item, or NULL if none exists.
|
||||
*/
|
||||
void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, int32_t (* cmp)(const void * pRef, const void * pElement));
|
||||
void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size,
|
||||
int32_t (*cmp)(const void * pRef, const void * pElement));
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -3,7 +3,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -14,7 +13,6 @@
|
||||
#include "../lv_draw/lv_draw_arc.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -109,7 +107,6 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
* New object specific "add" or "remove" functions come here
|
||||
*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
@ -142,9 +139,7 @@ void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
|
||||
void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, lv_style_t * style)
|
||||
{
|
||||
switch(type) {
|
||||
case LV_ARC_STYLE_MAIN:
|
||||
lv_obj_set_style(arc, style);
|
||||
break;
|
||||
case LV_ARC_STYLE_MAIN: lv_obj_set_style(arc, style); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,12 +182,8 @@ lv_style_t * lv_arc_get_style(const lv_obj_t * arc, lv_arc_style_t type)
|
||||
lv_style_t * style = NULL;
|
||||
|
||||
switch(type) {
|
||||
case LV_ARC_STYLE_MAIN:
|
||||
style = lv_obj_get_style(arc);
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_ARC_STYLE_MAIN: style = lv_obj_get_style(arc); break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -237,12 +228,13 @@ static bool lv_arc_design(lv_obj_t * arc, const lv_area_t * mask, lv_design_mode
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(arc);
|
||||
lv_draw_arc(x, y, r, mask, ext->angle_start, ext->angle_end, style, opa_scale);
|
||||
|
||||
|
||||
/*Draw circle on the ends if enabled */
|
||||
if(style->line.rounded) {
|
||||
lv_coord_t thick_half = style->line.width / 2;
|
||||
lv_coord_t cir_x = ((r - thick_half) * lv_trigo_sin(ext->angle_start) >> LV_TRIGO_SHIFT);
|
||||
lv_coord_t cir_y = ((r - thick_half) * lv_trigo_sin(ext->angle_start + 90) >> LV_TRIGO_SHIFT);
|
||||
lv_coord_t cir_x =
|
||||
((r - thick_half) * lv_trigo_sin(ext->angle_start) >> LV_TRIGO_SHIFT);
|
||||
lv_coord_t cir_y =
|
||||
((r - thick_half) * lv_trigo_sin(ext->angle_start + 90) >> LV_TRIGO_SHIFT);
|
||||
|
||||
lv_style_t cir_style;
|
||||
lv_style_copy(&cir_style, &lv_style_plain);
|
||||
@ -271,7 +263,6 @@ static bool lv_arc_design(lv_obj_t * arc, const lv_area_t * mask, lv_design_mode
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -292,7 +283,6 @@ static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param)
|
||||
res = ancestor_signal(arc, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LV_ARC_H
|
||||
#define LV_ARC_H
|
||||
|
||||
@ -32,21 +31,19 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of arc*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
/*New data for this type */
|
||||
lv_coord_t angle_start;
|
||||
lv_coord_t angle_end;
|
||||
} lv_arc_ext_t;
|
||||
|
||||
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_ARC_STYLE_MAIN,
|
||||
};
|
||||
typedef uint8_t lv_arc_style_t;
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -63,7 +60,6 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
@ -173,7 +173,6 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value, bool anim)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set minimum and the maximum values of a bar
|
||||
* @param bar pointer to the bar object
|
||||
@ -199,7 +198,8 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the bar symmetric to zero. The indicator will grow from zero instead of the minimum position.
|
||||
* Make the bar symmetric to zero. The indicator will grow from zero instead of the minimum
|
||||
* position.
|
||||
* @param bar pointer to a bar object
|
||||
* @param en true: enable disable symmetric behavior; false: disable
|
||||
*/
|
||||
@ -220,9 +220,7 @@ 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) {
|
||||
case LV_BAR_STYLE_BG:
|
||||
lv_obj_set_style(bar, style);
|
||||
break;
|
||||
case LV_BAR_STYLE_BG: lv_obj_set_style(bar, style); break;
|
||||
case LV_BAR_STYLE_INDIC:
|
||||
ext->style_indic = style;
|
||||
lv_obj_refresh_ext_size(bar);
|
||||
@ -245,7 +243,8 @@ int16_t lv_bar_get_value(const lv_obj_t * bar)
|
||||
/*If animated tell that it's already at the end value*/
|
||||
if(ext->anim_state != LV_BAR_ANIM_STATE_INV) return ext->anim_end;
|
||||
/*No animation, simple return the current value*/
|
||||
else return ext->cur_value;
|
||||
else
|
||||
return ext->cur_value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -293,15 +292,9 @@ lv_style_t * lv_bar_get_style(const lv_obj_t * bar, lv_bar_style_t type)
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
switch(type) {
|
||||
case LV_BAR_STYLE_BG:
|
||||
style = lv_obj_get_style(bar);
|
||||
break;
|
||||
case LV_BAR_STYLE_INDIC:
|
||||
style = ext->style_indic;
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_BAR_STYLE_BG: style = lv_obj_get_style(bar); break;
|
||||
case LV_BAR_STYLE_INDIC: style = ext->style_indic; break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -333,7 +326,8 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
ancestor_design_f(bar, mask, mode);
|
||||
#else
|
||||
/* Draw the borders later if the bar is focused.
|
||||
* At value = 100% the indicator can cover to whole background and the focused style won't be visible*/
|
||||
* At value = 100% the indicator can cover to whole background and the focused style won't
|
||||
* be visible*/
|
||||
if(lv_obj_is_focused(bar)) {
|
||||
lv_style_t * style_bg = lv_bar_get_style(bar, LV_BAR_STYLE_BG);
|
||||
lv_style_t style_tmp;
|
||||
@ -346,7 +340,8 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
#endif
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
if(ext->cur_value != ext->min_value || ext->sym || ext->anim_start != LV_BAR_ANIM_STATE_INV) {
|
||||
if(ext->cur_value != ext->min_value || ext->sym ||
|
||||
ext->anim_start != LV_BAR_ANIM_STATE_INV) {
|
||||
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);
|
||||
@ -362,21 +357,31 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
/*Horizontal*/
|
||||
if(ext->anim_state != LV_BAR_ANIM_STATE_INV) {
|
||||
/*Calculate the coordinates of anim. start and end*/
|
||||
lv_coord_t anim_start_x = (int32_t)((int32_t)w * (ext->anim_start - ext->min_value)) / (ext->max_value - ext->min_value);
|
||||
lv_coord_t anim_end_x = (int32_t)((int32_t)w * (ext->anim_end - ext->min_value)) / (ext->max_value - ext->min_value);
|
||||
lv_coord_t anim_start_x =
|
||||
(int32_t)((int32_t)w * (ext->anim_start - ext->min_value)) /
|
||||
(ext->max_value - ext->min_value);
|
||||
lv_coord_t anim_end_x =
|
||||
(int32_t)((int32_t)w * (ext->anim_end - ext->min_value)) /
|
||||
(ext->max_value - ext->min_value);
|
||||
|
||||
/*Calculate the real position based on `anim_state` (between `anim_start` and `anim_end`)*/
|
||||
indic_area.x2 = anim_start_x + (((anim_end_x - anim_start_x) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM);
|
||||
/*Calculate the real position based on `anim_state` (between `anim_start` and
|
||||
* `anim_end`)*/
|
||||
indic_area.x2 =
|
||||
anim_start_x +
|
||||
(((anim_end_x - anim_start_x) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM);
|
||||
} else {
|
||||
indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
|
||||
indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) /
|
||||
(ext->max_value - ext->min_value);
|
||||
}
|
||||
|
||||
indic_area.x2 = indic_area.x1 + indic_area.x2 - 1;
|
||||
if(ext->sym && ext->min_value < 0 && ext->max_value > 0) {
|
||||
/*Calculate the coordinate of the zero point*/
|
||||
lv_coord_t zero;
|
||||
zero = indic_area.x1 + (-ext->min_value * w) / (ext->max_value - ext->min_value);
|
||||
if(indic_area.x2 > zero) indic_area.x1 = zero;
|
||||
zero =
|
||||
indic_area.x1 + (-ext->min_value * w) / (ext->max_value - ext->min_value);
|
||||
if(indic_area.x2 > zero)
|
||||
indic_area.x1 = zero;
|
||||
else {
|
||||
indic_area.x1 = indic_area.x2;
|
||||
indic_area.x2 = zero;
|
||||
@ -385,13 +390,21 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
} else {
|
||||
if(ext->anim_state != LV_BAR_ANIM_STATE_INV) {
|
||||
/*Calculate the coordinates of anim. start and end*/
|
||||
lv_coord_t anim_start_y = (int32_t)((int32_t)h * (ext->anim_start - ext->min_value)) / (ext->max_value - ext->min_value);
|
||||
lv_coord_t anim_end_y = (int32_t)((int32_t)h * (ext->anim_end - ext->min_value)) / (ext->max_value - ext->min_value);
|
||||
lv_coord_t anim_start_y =
|
||||
(int32_t)((int32_t)h * (ext->anim_start - ext->min_value)) /
|
||||
(ext->max_value - ext->min_value);
|
||||
lv_coord_t anim_end_y =
|
||||
(int32_t)((int32_t)h * (ext->anim_end - ext->min_value)) /
|
||||
(ext->max_value - ext->min_value);
|
||||
|
||||
/*Calculate the real position based on `anim_state` (between `anim_start` and `anim_end`)*/
|
||||
indic_area.y1 = anim_start_y + (((anim_end_y - anim_start_y) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM);
|
||||
/*Calculate the real position based on `anim_state` (between `anim_start` and
|
||||
* `anim_end`)*/
|
||||
indic_area.y1 =
|
||||
anim_start_y +
|
||||
(((anim_end_y - anim_start_y) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM);
|
||||
} else {
|
||||
indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
|
||||
indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) /
|
||||
(ext->max_value - ext->min_value);
|
||||
}
|
||||
|
||||
indic_area.y1 = indic_area.y2 - indic_area.y1 + 1;
|
||||
@ -399,8 +412,10 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
if(ext->sym && ext->min_value < 0 && ext->max_value > 0) {
|
||||
/*Calculate the coordinate of the zero point*/
|
||||
lv_coord_t zero;
|
||||
zero = indic_area.y2 - (-ext->min_value * h) / (ext->max_value - ext->min_value);
|
||||
if(indic_area.y1 < zero) indic_area.y2 = zero;
|
||||
zero =
|
||||
indic_area.y2 - (-ext->min_value * h) / (ext->max_value - ext->min_value);
|
||||
if(indic_area.y1 < zero)
|
||||
indic_area.y2 = zero;
|
||||
else {
|
||||
indic_area.y2 = indic_area.y1;
|
||||
indic_area.y1 = zero;
|
||||
@ -408,7 +423,6 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Draw the indicator*/
|
||||
lv_draw_rect(&indic_area, mask, style_indic, opa_scale);
|
||||
}
|
||||
@ -425,7 +439,6 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
lv_draw_rect(&bar->coords, mask, &style_tmp, opa_scale);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -447,7 +460,8 @@ 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;
|
||||
if(style_indic->body.shadow.width > bar->ext_size)
|
||||
bar->ext_size = style_indic->body.shadow.width;
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
@ -460,7 +474,6 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static void lv_bar_animate(void * bar, int32_t value)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
@ -473,7 +486,6 @@ static void lv_bar_anim_ready(void * bar)
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
ext->anim_state = LV_BAR_ANIM_STATE_INV;
|
||||
lv_bar_set_value(bar, ext->anim_end, false);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -93,7 +93,8 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value, bool anim);
|
||||
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max);
|
||||
|
||||
/**
|
||||
* Make the bar symmetric to zero. The indicator will grow from zero instead of the minimum position.
|
||||
* Make the bar symmetric to zero. The indicator will grow from zero instead of the minimum
|
||||
* position.
|
||||
* @param bar pointer to a bar object
|
||||
* @param en true: enable disable symmetric behavior; false: disable
|
||||
*/
|
||||
|
@ -185,20 +185,11 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,7 +206,8 @@ void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
|
||||
#else
|
||||
(void)btn; /*Unused*/
|
||||
(void)time; /*Unused*/
|
||||
LV_LOG_WARN("`lv_btn_set_ink_ink_time` has no effect if LV_BTN_INK_EFEFCT or LV_USE_ANIMATION is disabled")
|
||||
LV_LOG_WARN("`lv_btn_set_ink_ink_time` has no effect if LV_BTN_INK_EFEFCT or LV_USE_ANIMATION "
|
||||
"is disabled")
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -233,7 +225,8 @@ void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
|
||||
#else
|
||||
(void)btn; /*Unused*/
|
||||
(void)time; /*Unused*/
|
||||
LV_LOG_WARN("`lv_btn_set_ink_wait_time` has no effect if LV_BTN_INK_EFEFCT or LV_USE_ANIMATION is disabled")
|
||||
LV_LOG_WARN("`lv_btn_set_ink_wait_time` has no effect if LV_BTN_INK_EFEFCT or LV_USE_ANIMATION "
|
||||
"is disabled")
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -250,7 +243,8 @@ void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
|
||||
#else
|
||||
(void)btn; /*Unused*/
|
||||
(void)time; /*Unused*/
|
||||
LV_LOG_WARN("`lv_btn_set_ink_out_time` has no effect if LV_BTN_INK_EFEFCT or LV_USE_ANIMATION is disabled")
|
||||
LV_LOG_WARN("`lv_btn_set_ink_out_time` has no effect if LV_BTN_INK_EFEFCT or LV_USE_ANIMATION "
|
||||
"is disabled")
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -265,28 +259,17 @@ 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);
|
||||
|
||||
switch(type) {
|
||||
case LV_BTN_STYLE_REL:
|
||||
ext->styles[LV_BTN_STATE_REL] = style;
|
||||
break;
|
||||
case LV_BTN_STYLE_PR:
|
||||
ext->styles[LV_BTN_STATE_PR] = style;
|
||||
break;
|
||||
case LV_BTN_STYLE_TGL_REL:
|
||||
ext->styles[LV_BTN_STATE_TGL_REL] = style;
|
||||
break;
|
||||
case LV_BTN_STYLE_TGL_PR:
|
||||
ext->styles[LV_BTN_STATE_TGL_PR] = style;
|
||||
break;
|
||||
case LV_BTN_STYLE_INA:
|
||||
ext->styles[LV_BTN_STATE_INA] = style;
|
||||
break;
|
||||
case LV_BTN_STYLE_REL: ext->styles[LV_BTN_STATE_REL] = style; break;
|
||||
case LV_BTN_STYLE_PR: ext->styles[LV_BTN_STATE_PR] = style; break;
|
||||
case LV_BTN_STYLE_TGL_REL: ext->styles[LV_BTN_STATE_TGL_REL] = style; break;
|
||||
case LV_BTN_STYLE_TGL_PR: ext->styles[LV_BTN_STATE_TGL_PR] = style; break;
|
||||
case LV_BTN_STYLE_INA: ext->styles[LV_BTN_STATE_INA] = style; break;
|
||||
}
|
||||
|
||||
/*Refresh the object with the new style*/
|
||||
lv_obj_set_style(btn, ext->styles[ext->state]);
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -330,7 +313,6 @@ uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the wait time before the ink disappears
|
||||
* @param btn pointer to a button object
|
||||
@ -374,24 +356,12 @@ lv_style_t * lv_btn_get_style(const lv_obj_t * btn, lv_btn_style_t type)
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
|
||||
switch(type) {
|
||||
case LV_BTN_STYLE_REL:
|
||||
style = ext->styles[LV_BTN_STATE_REL];
|
||||
break;
|
||||
case LV_BTN_STYLE_PR:
|
||||
style = ext->styles[LV_BTN_STATE_PR];
|
||||
break;
|
||||
case LV_BTN_STYLE_TGL_REL:
|
||||
style = ext->styles[LV_BTN_STATE_TGL_REL];
|
||||
break;
|
||||
case LV_BTN_STYLE_TGL_PR:
|
||||
style = ext->styles[LV_BTN_STATE_TGL_PR];
|
||||
break;
|
||||
case LV_BTN_STYLE_INA:
|
||||
style = ext->styles[LV_BTN_STATE_INA];
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_BTN_STYLE_REL: style = ext->styles[LV_BTN_STATE_REL]; break;
|
||||
case LV_BTN_STYLE_PR: style = ext->styles[LV_BTN_STATE_PR]; break;
|
||||
case LV_BTN_STYLE_TGL_REL: style = ext->styles[LV_BTN_STATE_TGL_REL]; break;
|
||||
case LV_BTN_STYLE_TGL_PR: style = ext->styles[LV_BTN_STATE_TGL_PR]; break;
|
||||
case LV_BTN_STYLE_INA: style = ext->styles[LV_BTN_STATE_INA]; break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -401,7 +371,6 @@ lv_style_t * lv_btn_get_style(const lv_obj_t * btn, lv_btn_style_t type)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the drop down lists
|
||||
* @param btn pointer to an object
|
||||
@ -439,7 +408,9 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode
|
||||
/*In the first part of the animation increase the size of the circle (ink effect) */
|
||||
lv_area_t cir_area;
|
||||
|
||||
lv_coord_t coord_state = ink_act_value < LV_BTN_INK_VALUE_MAX / 2 ? ink_act_value : LV_BTN_INK_VALUE_MAX / 2;
|
||||
lv_coord_t coord_state = ink_act_value < LV_BTN_INK_VALUE_MAX / 2
|
||||
? ink_act_value
|
||||
: LV_BTN_INK_VALUE_MAX / 2;
|
||||
lv_point_t p_act;
|
||||
p_act.x = ink_point.x;
|
||||
p_act.y = ink_point.y;
|
||||
@ -450,18 +421,28 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode
|
||||
p_act.y += (y_err * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1);
|
||||
|
||||
lv_coord_t half_side = LV_MATH_MAX(w, h) / 2;
|
||||
cir_area.x1 = p_act.x - ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
cir_area.y1 = p_act.y - ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
cir_area.x2 = p_act.x + ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
cir_area.y2 = p_act.y + ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
cir_area.x1 =
|
||||
p_act.x - ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
cir_area.y1 =
|
||||
p_act.y - ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
cir_area.x2 =
|
||||
p_act.x + ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
cir_area.y2 =
|
||||
p_act.y + ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
|
||||
lv_area_intersect(&cir_area, &btn->coords, &cir_area); /*Limit the area. (It might be too big on the smaller side)*/
|
||||
lv_area_intersect(
|
||||
&cir_area, &btn->coords,
|
||||
&cir_area); /*Limit the area. (It might be too big on the smaller side)*/
|
||||
|
||||
/*In the second part animate the radius. Circle -> body.radius*/
|
||||
lv_coord_t r_state = ink_act_value > LV_BTN_INK_VALUE_MAX / 2 ? ink_act_value - LV_BTN_INK_VALUE_MAX / 2 : 0;
|
||||
lv_coord_t r_state = ink_act_value > LV_BTN_INK_VALUE_MAX / 2
|
||||
? ink_act_value - LV_BTN_INK_VALUE_MAX / 2
|
||||
: 0;
|
||||
|
||||
lv_style_copy(&style_tmp, ext->styles[ink_top_state]);
|
||||
style_tmp.body.radius = r_max + (((ext->styles[ink_bg_state]->body.radius - r_max) * r_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
style_tmp.body.radius =
|
||||
r_max + (((ext->styles[ink_bg_state]->body.radius - r_max) * r_state) >>
|
||||
(LV_BTN_INK_VALUE_MAX_SHIFT - 1));
|
||||
style_tmp.body.border.width = 0;
|
||||
|
||||
/*Draw the circle*/
|
||||
@ -469,9 +450,9 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode
|
||||
} else {
|
||||
lv_style_t res;
|
||||
lv_style_copy(&res, ext->styles[ink_bg_state]);
|
||||
lv_style_mix(ext->styles[ink_bg_state], ext->styles[ink_top_state], &res, ink_act_value);
|
||||
lv_style_mix(ext->styles[ink_bg_state], ext->styles[ink_top_state], &res,
|
||||
ink_act_value);
|
||||
lv_draw_rect(&btn->coords, mask, &res, opa_scale);
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -550,13 +531,17 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
#endif
|
||||
} 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);
|
||||
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) {
|
||||
/*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);
|
||||
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) {
|
||||
/*If not dragged and it was not long press action then
|
||||
@ -593,7 +578,8 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
/*If not a toggle button and the "IN" inking is ready then start an "OUT" inking*/
|
||||
else if(ink_ready && ext->ink_out_time > 0) {
|
||||
ink_obj = btn;
|
||||
ink_playback = true; /*It is the playback. If not set `lv_btn_ink_effect_anim_ready` will start its own playback*/
|
||||
ink_playback = true; /*It is the playback. If not set `lv_btn_ink_effect_anim_ready`
|
||||
will start its own playback*/
|
||||
lv_indev_get_point(lv_indev_get_act(), &ink_point);
|
||||
|
||||
lv_anim_t a;
|
||||
@ -622,11 +608,15 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
}
|
||||
// else if(c == LV_GROUP_KEY_ENTER) {
|
||||
// if(lv_btn_get_toggle(btn)) {
|
||||
// if(state == LV_BTN_STATE_REL || state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
// else if(state == LV_BTN_STATE_TGL_REL || state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
// if(state == LV_BTN_STATE_REL || state == LV_BTN_STATE_PR)
|
||||
// lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL); else if(state ==
|
||||
// LV_BTN_STATE_TGL_REL || state == LV_BTN_STATE_TGL_PR)
|
||||
// lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
// } else {
|
||||
// if(state == LV_BTN_STATE_REL || state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
// else if(state == LV_BTN_STATE_TGL_REL || state == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
// if(state == LV_BTN_STATE_REL || state == LV_BTN_STATE_PR)
|
||||
// lv_btn_set_state(btn, LV_BTN_STATE_REL); else if(state ==
|
||||
// LV_BTN_STATE_TGL_REL || state == LV_BTN_STATE_TGL_PR)
|
||||
// lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
// }
|
||||
// res = lv_obj_send_event(btn, LV_EVENT_VALUE_CHANGED);
|
||||
// if(res != LV_RES_OK) return res;
|
||||
@ -679,7 +669,8 @@ static void lv_btn_ink_effect_anim_ready(void * p)
|
||||
lv_obj_invalidate(ink_obj);
|
||||
ink_ready = true;
|
||||
|
||||
if((state == LV_BTN_STATE_REL || state == LV_BTN_STATE_TGL_REL) && ext->toggle == 0 && ink_playback == false) {
|
||||
if((state == LV_BTN_STATE_REL || state == LV_BTN_STATE_TGL_REL) && ext->toggle == 0 &&
|
||||
ink_playback == false) {
|
||||
lv_anim_t a;
|
||||
a.var = ink_obj;
|
||||
a.start = LV_BTN_INK_VALUE_MAX;
|
||||
|
@ -39,8 +39,7 @@ extern "C" {
|
||||
|
||||
/* Button states
|
||||
* It can be used not only by buttons but other button-like objects too*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_BTN_STATE_REL,
|
||||
LV_BTN_STATE_PR,
|
||||
LV_BTN_STATE_TGL_REL,
|
||||
@ -130,7 +129,8 @@ static inline void lv_btn_set_layout(lv_obj_t * btn, lv_layout_t layout)
|
||||
* @param top bottom fit policy from `lv_fit_t`
|
||||
* @param bottom bottom fit policy from `lv_fit_t`
|
||||
*/
|
||||
static inline void lv_btn_set_fit4(lv_obj_t * btn, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
|
||||
static inline void lv_btn_set_fit4(lv_obj_t * btn, lv_fit_t left, lv_fit_t right, lv_fit_t top,
|
||||
lv_fit_t bottom)
|
||||
{
|
||||
lv_cont_set_fit4(btn, left, right, top, bottom);
|
||||
}
|
||||
@ -255,7 +255,6 @@ static inline lv_fit_t lv_btn_get_fit_bottom(const lv_obj_t * btn)
|
||||
return lv_cont_get_fit_bottom(btn);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get time of the ink in effect (draw a circle on click to animate in the new state)
|
||||
* @param btn pointer to a button object
|
||||
|
@ -44,9 +44,7 @@ static void make_one_button_toggled(lv_obj_t *btnm, uint16_t btn_idx);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static const char * lv_btnm_def_map[] = {"Btn1", "Btn2", "Btn3", "\n",
|
||||
"Btn4", "Btn5", ""
|
||||
};
|
||||
static const char * lv_btnm_def_map[] = {"Btn1", "Btn2", "Btn3", "\n", "Btn4", "Btn5", ""};
|
||||
|
||||
static lv_design_cb_t ancestor_design_f;
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
@ -62,7 +60,8 @@ static lv_signal_cb_t ancestor_signal;
|
||||
/**
|
||||
* Create a button matrix objects
|
||||
* @param par pointer to an object, it will be the parent of the new button matrix
|
||||
* @param copy pointer to a button matrix object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a button matrix object, if not NULL then the new object will be copied
|
||||
* from it
|
||||
* @return pointer to the created button matrix
|
||||
*/
|
||||
lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
@ -166,8 +165,10 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * 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) - style_bg->body.padding.left - style_bg->body.padding.right;
|
||||
lv_coord_t max_h = lv_obj_get_height(btnm) - style_bg->body.padding.top - style_bg->body.padding.bottom;
|
||||
lv_coord_t max_w =
|
||||
lv_obj_get_width(btnm) - style_bg->body.padding.left - style_bg->body.padding.right;
|
||||
lv_coord_t max_h =
|
||||
lv_obj_get_height(btnm) - style_bg->body.padding.top - style_bg->body.padding.bottom;
|
||||
lv_coord_t act_y = style_bg->body.padding.top;
|
||||
|
||||
/*Count the lines to calculate button height*/
|
||||
@ -224,16 +225,18 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
|
||||
act_unit_w--; /*-1 because e.g. width = 100 means 101 pixels (0..100)*/
|
||||
|
||||
/*Always recalculate act_x because of rounding errors */
|
||||
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * style_bg->body.padding.inner + style_bg->body.padding.left;
|
||||
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * style_bg->body.padding.inner +
|
||||
style_bg->body.padding.left;
|
||||
|
||||
/* Set the button's area.
|
||||
* If inner padding is zero then use the prev. button x2 as x1 to avoid rounding errors*/
|
||||
* 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.left) {
|
||||
lv_area_set(&ext->button_areas[btn_i], ext->button_areas[btn_i - 1].x2, act_y,
|
||||
act_x + act_unit_w, act_y + btn_h);
|
||||
} else {
|
||||
lv_area_set(&ext->button_areas[btn_i], act_x, act_y,
|
||||
act_x + act_unit_w, act_y + btn_h);
|
||||
lv_area_set(&ext->button_areas[btn_i], act_x, act_y, act_x + act_unit_w,
|
||||
act_y + btn_h);
|
||||
}
|
||||
|
||||
unit_act_cnt += get_button_width(ext->ctrl_bits[btn_i]);
|
||||
@ -244,7 +247,6 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[])
|
||||
}
|
||||
act_y += btn_h + style_bg->body.padding.inner;
|
||||
|
||||
|
||||
if(strlen(map_p_tmp[btn_cnt]) == 0) break; /*Break on end of map*/
|
||||
map_p_tmp = &map_p_tmp[btn_cnt + 1]; /*Set the map to the next line*/
|
||||
i_tot++; /*Skip the '\n'*/
|
||||
@ -287,17 +289,14 @@ void lv_btnm_set_pressed(const lv_obj_t * btnm, uint16_t id)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
if (id >= ext->btn_cnt && id != LV_BTNM_BTN_NONE)
|
||||
return;
|
||||
if(id >= ext->btn_cnt && id != LV_BTNM_BTN_NONE) return;
|
||||
|
||||
if (id == ext->btn_id_pr)
|
||||
return;
|
||||
if(id == ext->btn_id_pr) return;
|
||||
|
||||
ext->btn_id_pr = id;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a style of a button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
@ -309,9 +308,7 @@ 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);
|
||||
|
||||
switch(type) {
|
||||
case LV_BTNM_STYLE_BG:
|
||||
lv_obj_set_style(btnm, style);
|
||||
break;
|
||||
case LV_BTNM_STYLE_BG: lv_obj_set_style(btnm, style); break;
|
||||
case LV_BTNM_STYLE_BTN_REL:
|
||||
ext->styles_btn[LV_BTN_STATE_REL] = style;
|
||||
lv_obj_invalidate(btnm);
|
||||
@ -366,7 +363,6 @@ void lv_btnm_set_btn_ctrl(const lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t
|
||||
}
|
||||
|
||||
invalidate_button_area(btnm, btn_id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -408,7 +404,8 @@ void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width
|
||||
* @param btnm Button matrix object
|
||||
* @param one_toggle Whether "one toggle" mode is enabled
|
||||
*/
|
||||
void lv_btnm_set_one_toggle(lv_obj_t *btnm, bool one_toggle) {
|
||||
void lv_btnm_set_one_toggle(lv_obj_t * btnm, bool one_toggle)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
ext->one_toggle = one_toggle;
|
||||
|
||||
@ -471,7 +468,6 @@ const char * lv_btnm_get_active_btn_text(const lv_obj_t * btnm)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the pressed button's index.
|
||||
* The button be really pressed by the user or manually set to pressed with `lv_btnm_set_pressed`
|
||||
@ -487,7 +483,8 @@ uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm)
|
||||
/**
|
||||
* Get the button's text
|
||||
* @param btnm pointer to button matrix object
|
||||
* @param btn_id the index a button not counting new line characters. (The return value of lv_btnm_get_pressed/released)
|
||||
* @param btn_id the index a button not counting new line characters. (The return value of
|
||||
* lv_btnm_get_pressed/released)
|
||||
* @return text of btn_index` button
|
||||
*/
|
||||
const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id)
|
||||
@ -514,7 +511,8 @@ const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id)
|
||||
/**
|
||||
* Get the whether a control value is enabled or disabled for button of a button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param btn_id the index a button not counting new line characters. (E.g. the return value of lv_btnm_get_pressed/released)
|
||||
* @param btn_id the index a button not counting new line characters. (E.g. the return value of
|
||||
* lv_btnm_get_pressed/released)
|
||||
* @param ctrl control values to check (ORed value can be used)
|
||||
* @return true: long press repeat is disabled; false: long press repeat enabled
|
||||
*/
|
||||
@ -538,27 +536,13 @@ lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type)
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
switch(type) {
|
||||
case LV_BTNM_STYLE_BG:
|
||||
style = lv_obj_get_style(btnm);
|
||||
break;
|
||||
case LV_BTNM_STYLE_BTN_REL:
|
||||
style = ext->styles_btn[LV_BTN_STATE_REL];
|
||||
break;
|
||||
case LV_BTNM_STYLE_BTN_PR:
|
||||
style = ext->styles_btn[LV_BTN_STATE_PR];
|
||||
break;
|
||||
case LV_BTNM_STYLE_BTN_TGL_REL:
|
||||
style = ext->styles_btn[LV_BTN_STATE_TGL_REL];
|
||||
break;
|
||||
case LV_BTNM_STYLE_BTN_TGL_PR:
|
||||
style = ext->styles_btn[LV_BTN_STATE_TGL_PR];
|
||||
break;
|
||||
case LV_BTNM_STYLE_BTN_INA:
|
||||
style = ext->styles_btn[LV_BTN_STATE_INA];
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_BTNM_STYLE_BG: style = lv_obj_get_style(btnm); break;
|
||||
case LV_BTNM_STYLE_BTN_REL: style = ext->styles_btn[LV_BTN_STATE_REL]; break;
|
||||
case LV_BTNM_STYLE_BTN_PR: style = ext->styles_btn[LV_BTN_STATE_PR]; break;
|
||||
case LV_BTNM_STYLE_BTN_TGL_REL: style = ext->styles_btn[LV_BTN_STATE_TGL_REL]; break;
|
||||
case LV_BTNM_STYLE_BTN_TGL_PR: style = ext->styles_btn[LV_BTN_STATE_TGL_PR]; break;
|
||||
case LV_BTNM_STYLE_BTN_INA: style = ext->styles_btn[LV_BTN_STATE_INA]; break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -569,7 +553,8 @@ lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type)
|
||||
* @param btnm Button matrix object
|
||||
* @return whether "one toggle" mode is enabled
|
||||
*/
|
||||
bool lv_btnm_get_one_toggle(const lv_obj_t *btnm) {
|
||||
bool lv_btnm_get_one_toggle(const lv_obj_t * btnm)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
return ext->one_toggle;
|
||||
@ -639,12 +624,19 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
|
||||
/*Load the style*/
|
||||
bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]);
|
||||
if(button_is_inactive(ext->ctrl_bits[btn_i])) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_INA);
|
||||
else if(btn_i != ext->btn_id_pr && tgl_state == false) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL);
|
||||
else if(btn_i == ext->btn_id_pr && tgl_state == false) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR);
|
||||
else if(btn_i != ext->btn_id_pr && tgl_state == true) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL);
|
||||
else if(btn_i == ext->btn_id_pr && tgl_state == true) 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*/
|
||||
if(button_is_inactive(ext->ctrl_bits[btn_i]))
|
||||
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_INA);
|
||||
else if(btn_i != ext->btn_id_pr && tgl_state == false)
|
||||
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL);
|
||||
else if(btn_i == ext->btn_id_pr && tgl_state == false)
|
||||
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR);
|
||||
else if(btn_i != ext->btn_id_pr && tgl_state == true)
|
||||
btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL);
|
||||
else if(btn_i == ext->btn_id_pr && tgl_state == true)
|
||||
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*/
|
||||
|
||||
lv_style_copy(&style_tmp, btn_style);
|
||||
|
||||
@ -659,8 +651,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
|
||||
if(txt_i == 0) {
|
||||
style_tmp.body.border.part &= ~LV_BORDER_LEFT;
|
||||
}
|
||||
else if(strcmp(ext->map_p[txt_i - 1],"\n") == 0) {
|
||||
} else if(strcmp(ext->map_p[txt_i - 1], "\n") == 0) {
|
||||
style_tmp.body.border.part &= ~LV_BORDER_LEFT;
|
||||
}
|
||||
|
||||
@ -674,16 +665,16 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo
|
||||
if(btn_style->glass) btn_style = bg_style;
|
||||
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), txt_flag);
|
||||
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), txt_flag);
|
||||
|
||||
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;
|
||||
|
||||
lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL, -1, -1);
|
||||
lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL,
|
||||
-1, -1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -711,10 +702,10 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
lv_mem_free(ext->ctrl_bits);
|
||||
} 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_PRESSED) {
|
||||
} else if(sign == LV_SIGNAL_PRESSED) {
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER ||
|
||||
lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
|
||||
uint16_t btn_pr;
|
||||
/*Search the pressed area*/
|
||||
lv_indev_get_point(param, &p);
|
||||
@ -728,14 +719,12 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
if(ext->btn_id_act != LV_BTNM_BTN_NONE) {
|
||||
if(button_is_click_trig(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false)
|
||||
{
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) {
|
||||
uint32_t b = ext->btn_id_act;
|
||||
lv_event_send(btnm, LV_EVENT_SELECTED, &b);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
@ -755,8 +744,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
ext->btn_id_pr = btn_pr;
|
||||
ext->btn_id_act = btn_pr;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(ext->btn_id_pr != LV_BTNM_BTN_NONE) {
|
||||
/*Toggle the button if enabled*/
|
||||
if(button_is_tgl_enabled(ext->ctrl_bits[ext->btn_id_pr])) {
|
||||
@ -765,8 +753,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
} else {
|
||||
ext->ctrl_bits[ext->btn_id_pr] |= LV_BTNM_CTRL_TGL_STATE;
|
||||
}
|
||||
if(ext->one_toggle)
|
||||
make_one_button_toggled(btnm, ext->btn_id_pr);
|
||||
if(ext->one_toggle) make_one_button_toggled(btnm, ext->btn_id_pr);
|
||||
}
|
||||
|
||||
/*Invalidate to old pressed area*/;
|
||||
@ -784,31 +771,25 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
if(button_is_click_trig(ext->ctrl_bits[ext->btn_id_act]) == true &&
|
||||
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false)
|
||||
{
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) {
|
||||
uint32_t b = ext->btn_id_act;
|
||||
lv_event_send(btnm, LV_EVENT_SELECTED, &b);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
} else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
if(ext->btn_id_act != LV_BTNM_BTN_NONE) {
|
||||
if(button_is_repeat_disabled(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false &&
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false)
|
||||
{
|
||||
button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) {
|
||||
uint32_t b = ext->btn_id_act;
|
||||
lv_event_send(btnm, LV_EVENT_SELECTED, &b);
|
||||
}
|
||||
}
|
||||
}
|
||||
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_BTN_NONE;
|
||||
ext->btn_id_act = LV_BTNM_BTN_NONE;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if LV_USE_GROUP
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
@ -821,8 +802,10 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
} else if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
/*In navigation mode don't select any button but in edit mode select the fist*/
|
||||
if(lv_group_get_editing(lv_obj_get_group(btnm))) ext->btn_id_pr = 0;
|
||||
else ext->btn_id_pr = LV_BTNM_BTN_NONE;
|
||||
if(lv_group_get_editing(lv_obj_get_group(btnm)))
|
||||
ext->btn_id_pr = 0;
|
||||
else
|
||||
ext->btn_id_pr = LV_BTNM_BTN_NONE;
|
||||
} else {
|
||||
ext->btn_id_pr = 0;
|
||||
}
|
||||
@ -832,30 +815,30 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
|
||||
ext->btn_id_act = ext->btn_id_pr;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROL) {
|
||||
} else if(sign == LV_SIGNAL_CONTROL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT) {
|
||||
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) ext->btn_id_pr = 0;
|
||||
else ext->btn_id_pr++;
|
||||
if(ext->btn_id_pr == LV_BTNM_BTN_NONE)
|
||||
ext->btn_id_pr = 0;
|
||||
else
|
||||
ext->btn_id_pr++;
|
||||
if(ext->btn_id_pr >= ext->btn_cnt - 1) ext->btn_id_pr = ext->btn_cnt - 1;
|
||||
ext->btn_id_act = ext->btn_id_pr;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_LEFT) {
|
||||
} else if(c == LV_GROUP_KEY_LEFT) {
|
||||
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) ext->btn_id_pr = 0;
|
||||
if(ext->btn_id_pr > 0) ext->btn_id_pr--;
|
||||
ext->btn_id_act = ext->btn_id_pr;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_DOWN) {
|
||||
} else if(c == LV_GROUP_KEY_DOWN) {
|
||||
lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
|
||||
/*Find the area below the the current*/
|
||||
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) {
|
||||
ext->btn_id_pr = 0;
|
||||
} else {
|
||||
uint16_t area_below;
|
||||
lv_coord_t pr_center = ext->button_areas[ext->btn_id_pr].x1 + (lv_area_get_width(&ext->button_areas[ext->btn_id_pr]) >> 1);
|
||||
lv_coord_t pr_center = ext->button_areas[ext->btn_id_pr].x1 +
|
||||
(lv_area_get_width(&ext->button_areas[ext->btn_id_pr]) >> 1);
|
||||
|
||||
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 &&
|
||||
@ -869,15 +852,15 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
}
|
||||
ext->btn_id_act = ext->btn_id_pr;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_UP) {
|
||||
} else if(c == LV_GROUP_KEY_UP) {
|
||||
lv_style_t * style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG);
|
||||
/*Find the area below the the current*/
|
||||
if(ext->btn_id_pr == LV_BTNM_BTN_NONE) {
|
||||
ext->btn_id_pr = 0;
|
||||
} else {
|
||||
int16_t area_above;
|
||||
lv_coord_t pr_center = ext->button_areas[ext->btn_id_pr].x1 + (lv_area_get_width(&ext->button_areas[ext->btn_id_pr]) >> 1);
|
||||
lv_coord_t pr_center = ext->button_areas[ext->btn_id_pr].x1 +
|
||||
(lv_area_get_width(&ext->button_areas[ext->btn_id_pr]) >> 1);
|
||||
|
||||
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 &&
|
||||
@ -887,17 +870,14 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
}
|
||||
}
|
||||
if(area_above >= 0) ext->btn_id_pr = area_above;
|
||||
|
||||
}
|
||||
ext->btn_id_act = ext->btn_id_pr;
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
bool * editable = (bool *)param;
|
||||
*editable = 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*/
|
||||
@ -906,7 +886,6 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
buf->type[i] = "lv_btnm";
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1048,15 +1027,12 @@ static void invalidate_button_area(const lv_obj_t * btnm, uint16_t btn_idx)
|
||||
*/
|
||||
static bool maps_are_identical(const char ** map1, const char ** map2)
|
||||
{
|
||||
if (map1 == map2)
|
||||
return true;
|
||||
if (map1 == NULL || map2 == NULL)
|
||||
return map1 == map2;
|
||||
if(map1 == map2) return true;
|
||||
if(map1 == NULL || map2 == NULL) return map1 == map2;
|
||||
|
||||
uint16_t i = 0;
|
||||
while(map1[i][0] != '\0' && map2[i][0] != '\0') {
|
||||
if (strcmp(map1[i], map2[i]) !=0 )
|
||||
return false;
|
||||
if(strcmp(map1[i], map2[i]) != 0) return false;
|
||||
i++;
|
||||
}
|
||||
return map1[i][0] == '\0' && map2[i][0] == '\0';
|
||||
@ -1075,8 +1051,7 @@ static void make_one_button_toggled(lv_obj_t *btnm, uint16_t btn_idx)
|
||||
|
||||
lv_btnm_set_btn_ctrl_all(btnm, LV_BTNM_CTRL_TGL_STATE, false);
|
||||
|
||||
if(was_toggled)
|
||||
lv_btnm_set_btn_ctrl(btnm, btn_idx, LV_BTNM_CTRL_TGL_STATE, true);
|
||||
if(was_toggled) lv_btnm_set_btn_ctrl(btnm, btn_idx, LV_BTNM_CTRL_TGL_STATE, true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -3,7 +3,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LV_BTNM_H
|
||||
#define LV_BTNM_H
|
||||
|
||||
@ -58,7 +57,8 @@ typedef struct
|
||||
lv_style_t * styles_btn[LV_BTN_STATE_NUM]; /*Styles of buttons in each state*/
|
||||
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
|
||||
uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNM_BTN_NONE*/
|
||||
uint16_t btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNM_BTN_NONE */
|
||||
uint16_t
|
||||
btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNM_BTN_NONE */
|
||||
uint8_t recolor : 1; /*Enable button recoloring*/
|
||||
uint8_t one_toggle : 1; /*Single button toggled at once*/
|
||||
} lv_btnm_ext_t;
|
||||
@ -80,7 +80,8 @@ typedef uint8_t lv_btnm_style_t;
|
||||
/**
|
||||
* Create a button matrix objects
|
||||
* @param par pointer to an object, it will be the parent of the new button matrix
|
||||
* @param copy pointer to a button matrix object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a button matrix object, if not NULL then the new object will be copied
|
||||
* from it
|
||||
* @return pointer to the created button matrix
|
||||
*/
|
||||
lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
@ -219,7 +220,8 @@ uint16_t lv_btnm_get_pressed_btn(const lv_obj_t * btnm);
|
||||
/**
|
||||
* Get the button's text
|
||||
* @param btnm pointer to button matrix object
|
||||
* @param btn_id the index a button not counting new line characters. (The return value of lv_btnm_get_pressed/released)
|
||||
* @param btn_id the index a button not counting new line characters. (The return value of
|
||||
* lv_btnm_get_pressed/released)
|
||||
* @return text of btn_index` button
|
||||
*/
|
||||
const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id);
|
||||
@ -227,7 +229,8 @@ const char * lv_btnm_get_btn_text(const lv_obj_t * btnm, uint16_t btn_id);
|
||||
/**
|
||||
* Get the whether a control value is enabled or disabled for button of a button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param btn_id the index a button not counting new line characters. (E.g. the return value of lv_btnm_get_pressed/released)
|
||||
* @param btn_id the index a button not counting new line characters. (E.g. the return value of
|
||||
* lv_btnm_get_pressed/released)
|
||||
* @param ctrl control values to check (ORed value can be used)
|
||||
* @return true: long press repeat is disabled; false: long press repeat enabled
|
||||
*/
|
||||
|
@ -48,7 +48,6 @@ static const char * get_month_name(lv_obj_t * calendar, int32_t month);
|
||||
static uint8_t get_month_length(int32_t year, int32_t month);
|
||||
static uint8_t is_leap_year(uint32_t year);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@ -57,8 +56,7 @@ static lv_design_cb_t ancestor_design;
|
||||
static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
|
||||
static const char * month_name[12] = {"January", "February", "March", "April",
|
||||
"May", "June", "July", "August",
|
||||
"September", "October", "November", "December"
|
||||
};
|
||||
"September", "October", "November", "December"};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -127,13 +125,20 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->style.calendar.bg);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->style.calendar.header);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->style.calendar.header_pr);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->style.calendar.day_names);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->style.calendar.week_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->style.calendar.today_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->style.calendar.highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->style.calendar.inactive_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER,
|
||||
th->style.calendar.header);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR,
|
||||
th->style.calendar.header_pr);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES,
|
||||
th->style.calendar.day_names);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX,
|
||||
th->style.calendar.week_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX,
|
||||
th->style.calendar.today_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS,
|
||||
th->style.calendar.highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS,
|
||||
th->style.calendar.inactive_days);
|
||||
} else {
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header);
|
||||
@ -141,8 +146,10 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, ext->style_day_names);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, ext->style_week_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, ext->style_today_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, ext->style_highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, ext->style_inactive_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS,
|
||||
ext->style_highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS,
|
||||
ext->style_inactive_days);
|
||||
}
|
||||
}
|
||||
/*Copy an existing calendar*/
|
||||
@ -185,7 +192,6 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
* New object specific "add" or "remove" functions come here
|
||||
*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
@ -193,7 +199,8 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/**
|
||||
* Set the today's date
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param today pointer to an `lv_calendar_date_t` variable containing the date of today. The value will be saved it can be local variable too.
|
||||
* @param today pointer to an `lv_calendar_date_t` variable containing the date of today. The value
|
||||
* will be saved it can be local variable too.
|
||||
*/
|
||||
void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today)
|
||||
{
|
||||
@ -208,7 +215,8 @@ void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today)
|
||||
/**
|
||||
* Set the currently showed
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param showed pointer to an `lv_calendar_date_t` variable containing the date to show. The value will be saved it can be local variable too.
|
||||
* @param showed pointer to an `lv_calendar_date_t` variable containing the date to show. The value
|
||||
* will be saved it can be local variable too.
|
||||
*/
|
||||
void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showed)
|
||||
{
|
||||
@ -223,10 +231,12 @@ void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showe
|
||||
/**
|
||||
* Set the the highlighted dates
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. ONLY A POINTER WILL BE SAVED! CAN'T BE LOCAL ARRAY.
|
||||
* @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. ONLY A POINTER
|
||||
* WILL BE SAVED! CAN'T BE LOCAL ARRAY.
|
||||
* @param date_num number of dates in the array
|
||||
*/
|
||||
void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, uint16_t date_num)
|
||||
void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted,
|
||||
uint16_t date_num)
|
||||
{
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
ext->highlighted_dates = highlighted;
|
||||
@ -235,12 +245,12 @@ void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t *
|
||||
lv_obj_invalidate(calendar);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the name of the days
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param day_names pointer to an array with the names. E.g. `const char * days[7] = {"Sun", "Mon", ...}`
|
||||
* Only the pointer will be saved so this variable can't be local which will be destroyed later.
|
||||
* @param day_names pointer to an array with the names. E.g. `const char * days[7] = {"Sun", "Mon",
|
||||
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
||||
* later.
|
||||
*/
|
||||
void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names)
|
||||
{
|
||||
@ -252,8 +262,9 @@ void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names)
|
||||
/**
|
||||
* Set the name of the month
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param day_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb", ...}`
|
||||
* Only the pointer will be saved so this variable can't be local which will be destroyed later.
|
||||
* @param day_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb",
|
||||
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
||||
* later.
|
||||
*/
|
||||
void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** day_names)
|
||||
{
|
||||
@ -273,30 +284,14 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_sty
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
|
||||
switch(type) {
|
||||
case LV_CALENDAR_STYLE_BG:
|
||||
lv_obj_set_style(calendar, style);
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_DAY_NAMES:
|
||||
ext->style_day_names = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_HEADER:
|
||||
ext->style_header = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_HEADER_PR:
|
||||
ext->style_header_pr = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
|
||||
ext->style_highlighted_days = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
|
||||
ext->style_inactive_days = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_TODAY_BOX:
|
||||
ext->style_today_box = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_WEEK_BOX:
|
||||
ext->style_week_box = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_BG: lv_obj_set_style(calendar, style); break;
|
||||
case LV_CALENDAR_STYLE_DAY_NAMES: ext->style_day_names = style; break;
|
||||
case LV_CALENDAR_STYLE_HEADER: ext->style_header = style; break;
|
||||
case LV_CALENDAR_STYLE_HEADER_PR: ext->style_header_pr = style; break;
|
||||
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS: ext->style_highlighted_days = style; break;
|
||||
case LV_CALENDAR_STYLE_INACTIVE_DAYS: ext->style_inactive_days = style; break;
|
||||
case LV_CALENDAR_STYLE_TODAY_BOX: ext->style_today_box = style; break;
|
||||
case LV_CALENDAR_STYLE_WEEK_BOX: ext->style_week_box = style; break;
|
||||
}
|
||||
|
||||
lv_obj_invalidate(calendar);
|
||||
@ -395,33 +390,15 @@ lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
|
||||
switch(type) {
|
||||
case LV_CALENDAR_STYLE_BG:
|
||||
style = lv_obj_get_style(calendar);
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_HEADER:
|
||||
style = ext->style_header;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_HEADER_PR:
|
||||
style = ext->style_header_pr;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_DAY_NAMES:
|
||||
style = ext->style_day_names;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
|
||||
style = ext->style_highlighted_days;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
|
||||
style = ext->style_inactive_days;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_WEEK_BOX:
|
||||
style = ext->style_week_box;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_TODAY_BOX:
|
||||
style = ext->style_today_box;
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_BG: style = lv_obj_get_style(calendar); break;
|
||||
case LV_CALENDAR_STYLE_HEADER: style = ext->style_header; break;
|
||||
case LV_CALENDAR_STYLE_HEADER_PR: style = ext->style_header_pr; break;
|
||||
case LV_CALENDAR_STYLE_DAY_NAMES: style = ext->style_day_names; break;
|
||||
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS: style = ext->style_highlighted_days; break;
|
||||
case LV_CALENDAR_STYLE_INACTIVE_DAYS: style = ext->style_inactive_days; break;
|
||||
case LV_CALENDAR_STYLE_WEEK_BOX: style = ext->style_week_box; break;
|
||||
case LV_CALENDAR_STYLE_TODAY_BOX: style = ext->style_today_box; break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -458,7 +435,8 @@ static bool lv_calendar_design(lv_obj_t * calendar, const lv_area_t * mask, lv_d
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar);
|
||||
lv_draw_rect(&calendar->coords, mask, lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG), opa_scale);
|
||||
lv_draw_rect(&calendar->coords, mask, lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG),
|
||||
opa_scale);
|
||||
|
||||
draw_header(calendar, mask);
|
||||
draw_day_names(calendar, mask);
|
||||
@ -467,7 +445,6 @@ static bool lv_calendar_design(lv_obj_t * calendar, const lv_area_t * mask, lv_d
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -488,7 +465,6 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
|
||||
res = ancestor_signal(calendar, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
@ -541,9 +517,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
|
||||
} else {
|
||||
ext->showed_date.month++;
|
||||
}
|
||||
}
|
||||
else if(ext->pressed_date.year != 0)
|
||||
{
|
||||
} else if(ext->pressed_date.year != 0) {
|
||||
res = lv_event_send(calendar, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
@ -598,7 +572,8 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche
|
||||
lv_style_t * style_bg = lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG);
|
||||
days_area.x1 += style_bg->body.padding.left;
|
||||
days_area.x2 -= style_bg->body.padding.right;
|
||||
days_area.y1 = calendar->coords.y1 + get_header_height(calendar) + get_day_names_height(calendar) - style_bg->body.padding.top;
|
||||
days_area.y1 = calendar->coords.y1 + get_header_height(calendar) +
|
||||
get_day_names_height(calendar) - style_bg->body.padding.top;
|
||||
|
||||
if(lv_area_is_point_on(&days_area, touched_point)) {
|
||||
lv_coord_t w = (days_area.x2 - days_area.x1 + 1) / 7;
|
||||
@ -615,21 +590,24 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
if(i_pos < get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1)) {
|
||||
ext->pressed_date.year = ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0);
|
||||
ext->pressed_date.month = ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1);
|
||||
ext->pressed_date.day = get_month_length(ext->pressed_date.year, ext->pressed_date.month) -
|
||||
ext->pressed_date.month =
|
||||
ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1);
|
||||
ext->pressed_date.day =
|
||||
get_month_length(ext->pressed_date.year, ext->pressed_date.month) -
|
||||
get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos;
|
||||
}
|
||||
else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) +
|
||||
} else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) +
|
||||
get_month_length(ext->showed_date.year, ext->showed_date.month))) {
|
||||
ext->pressed_date.year = ext->showed_date.year;
|
||||
ext->pressed_date.month = ext->showed_date.month;
|
||||
ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1);
|
||||
}
|
||||
else if(i_pos < 42) {
|
||||
ext->pressed_date.day =
|
||||
i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1);
|
||||
} else if(i_pos < 42) {
|
||||
ext->pressed_date.year = ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0);
|
||||
ext->pressed_date.month = ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1);
|
||||
ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1)
|
||||
- get_month_length(ext->showed_date.year, ext->showed_date.month);
|
||||
ext->pressed_date.month =
|
||||
ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1);
|
||||
ext->pressed_date.day =
|
||||
i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) -
|
||||
get_month_length(ext->showed_date.year, ext->showed_date.month);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -646,7 +624,8 @@ static lv_coord_t get_header_height(lv_obj_t * calendar)
|
||||
{
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
|
||||
return lv_font_get_height(ext->style_header->text.font) + ext->style_header->body.padding.top + ext->style_header->body.padding.bottom ;
|
||||
return lv_font_get_height(ext->style_header->text.font) + ext->style_header->body.padding.top +
|
||||
ext->style_header->body.padding.bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -658,7 +637,8 @@ static lv_coord_t get_day_names_height(lv_obj_t * calendar)
|
||||
{
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
|
||||
return lv_font_get_height(ext->style_day_names->text.font) + ext->style_day_names->body.padding.top + ext->style_day_names->body.padding.bottom;
|
||||
return lv_font_get_height(ext->style_day_names->text.font) +
|
||||
ext->style_day_names->body.padding.top + ext->style_day_names->body.padding.bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -686,20 +666,23 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
txt_buf[5] = '\0';
|
||||
strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month));
|
||||
header_area.y1 += ext->style_header->body.padding.top;
|
||||
lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf, LV_TXT_FLAG_CENTER, NULL, -1, -1);
|
||||
lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf, LV_TXT_FLAG_CENTER,
|
||||
NULL, -1, -1);
|
||||
|
||||
/*Add the left arrow*/
|
||||
lv_style_t * arrow_style = ext->btn_pressing < 0 ? ext->style_header_pr : ext->style_header;
|
||||
header_area.x1 += ext->style_header->body.padding.left;
|
||||
lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_LEFT, LV_TXT_FLAG_NONE, NULL, -1, -1);
|
||||
lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_LEFT, LV_TXT_FLAG_NONE,
|
||||
NULL, -1, -1);
|
||||
|
||||
/*Add the right arrow*/
|
||||
arrow_style = ext->btn_pressing > 0 ? ext->style_header_pr : ext->style_header;
|
||||
header_area.x1 = header_area.x2 - ext->style_header->body.padding.right -
|
||||
header_area.x1 =
|
||||
header_area.x2 - ext->style_header->body.padding.right -
|
||||
lv_txt_get_width(LV_SYMBOL_RIGHT, strlen(LV_SYMBOL_RIGHT), arrow_style->text.font,
|
||||
arrow_style->text.line_space, LV_TXT_FLAG_NONE);
|
||||
lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_RIGHT, LV_TXT_FLAG_NONE, NULL, -1, -1);
|
||||
|
||||
lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_RIGHT, LV_TXT_FLAG_NONE,
|
||||
NULL, -1, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -713,18 +696,20 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar);
|
||||
|
||||
lv_coord_t l_pad = ext->style_day_names->body.padding.left;
|
||||
lv_coord_t w = lv_obj_get_width(calendar) - ext->style_day_names->body.padding.left - ext->style_day_names->body.padding.right;
|
||||
lv_coord_t w = lv_obj_get_width(calendar) - ext->style_day_names->body.padding.left -
|
||||
ext->style_day_names->body.padding.right;
|
||||
lv_coord_t box_w = w / 7;
|
||||
lv_area_t label_area;
|
||||
label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + ext->style_day_names->body.padding.top;
|
||||
label_area.y1 =
|
||||
calendar->coords.y1 + get_header_height(calendar) + ext->style_day_names->body.padding.top;
|
||||
label_area.y2 = label_area.y1 + lv_font_get_height(ext->style_day_names->text.font);
|
||||
uint32_t i;
|
||||
for(i = 0; i < 7; i++) {
|
||||
label_area.x1 = calendar->coords.x1 + (w * i) / 7 + l_pad;
|
||||
label_area.x2 = label_area.x1 + box_w;
|
||||
lv_draw_label(&label_area, mask, ext->style_day_names, opa_scale, get_day_name(calendar, i), LV_TXT_FLAG_CENTER, NULL, -1, -1);
|
||||
lv_draw_label(&label_area, mask, ext->style_day_names, opa_scale, get_day_name(calendar, i),
|
||||
LV_TXT_FLAG_CENTER, NULL, -1, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -739,11 +724,13 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
lv_area_t label_area;
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar);
|
||||
label_area.y1 = calendar->coords.y1 + get_header_height(calendar) +
|
||||
ext->style_day_names->body.padding.top + lv_font_get_height(ext->style_day_names->text.font) +
|
||||
ext->style_day_names->body.padding.top +
|
||||
lv_font_get_height(ext->style_day_names->text.font) +
|
||||
ext->style_day_names->body.padding.bottom;
|
||||
label_area.y2 = label_area.y1 + lv_font_get_height(style_bg->text.font);
|
||||
|
||||
lv_coord_t w = lv_obj_get_width(calendar) - style_bg->body.padding.left - style_bg->body.padding.right;
|
||||
lv_coord_t w =
|
||||
lv_obj_get_width(calendar) - style_bg->body.padding.left - style_bg->body.padding.right;
|
||||
lv_coord_t h = calendar->coords.y2 - label_area.y1 - style_bg->body.padding.bottom;
|
||||
lv_coord_t box_w = w / 7;
|
||||
lv_coord_t vert_space = (h - (6 * lv_font_get_height(style_bg->text.font))) / 5;
|
||||
@ -761,15 +748,14 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
act_style = style_bg;
|
||||
} else {
|
||||
draw_state = DAY_DRAW_PREV_MONTH;
|
||||
day_cnt = get_month_length(ext->showed_date.year, ext->showed_date.month - 1); /*Length of the previous month*/
|
||||
day_cnt = get_month_length(ext->showed_date.year,
|
||||
ext->showed_date.month - 1); /*Length of the previous month*/
|
||||
day_cnt -= month_start_day - 1; /*First visible number of the previous month*/
|
||||
act_style = ext->style_inactive_days;
|
||||
}
|
||||
|
||||
|
||||
bool month_of_today_shown = false;
|
||||
if(ext->showed_date.year == ext->today.year &&
|
||||
ext->showed_date.month == ext->today.month) {
|
||||
if(ext->showed_date.year == ext->today.year && ext->showed_date.month == ext->today.month) {
|
||||
month_of_today_shown = true;
|
||||
}
|
||||
|
||||
@ -780,13 +766,16 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
for(week = 0; week < 6; week++) {
|
||||
|
||||
/*Draw the "week box"*/
|
||||
if(month_of_today_shown &&
|
||||
((draw_state == DAY_DRAW_ACT_MONTH && ext->today.day >= day_cnt && ext->today.day < day_cnt + 7) ||
|
||||
(draw_state == DAY_DRAW_PREV_MONTH && ext->today.day <= 7 - month_start_day && week == 0))) {
|
||||
if(month_of_today_shown && ((draw_state == DAY_DRAW_ACT_MONTH &&
|
||||
ext->today.day >= day_cnt && ext->today.day < day_cnt + 7) ||
|
||||
(draw_state == DAY_DRAW_PREV_MONTH &&
|
||||
ext->today.day <= 7 - month_start_day && week == 0))) {
|
||||
lv_area_t week_box_area;
|
||||
lv_area_copy(&week_box_area, &label_area); /*'label_area' is already set for this row*/
|
||||
week_box_area.x1 = calendar->coords.x1 + style_bg->body.padding.left - ext->style_week_box->body.padding.left;
|
||||
week_box_area.x2 = calendar->coords.x2 - style_bg->body.padding.right + ext->style_week_box->body.padding.right;
|
||||
week_box_area.x1 = calendar->coords.x1 + style_bg->body.padding.left -
|
||||
ext->style_week_box->body.padding.left;
|
||||
week_box_area.x2 = calendar->coords.x2 - style_bg->body.padding.right +
|
||||
ext->style_week_box->body.padding.right;
|
||||
|
||||
week_box_area.y1 -= ext->style_week_box->body.padding.top;
|
||||
week_box_area.y2 += ext->style_week_box->body.padding.bottom;
|
||||
@ -814,11 +803,13 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
act_style = ext->style_inactive_days;
|
||||
}
|
||||
|
||||
label_area.x1 = calendar->coords.x1 + (w * day) / 7 + style_bg->body.padding.left + style_bg->body.padding.right;
|
||||
label_area.x1 = calendar->coords.x1 + (w * day) / 7 + style_bg->body.padding.left +
|
||||
style_bg->body.padding.right;
|
||||
label_area.x2 = label_area.x1 + box_w;
|
||||
|
||||
/*Draw the "today box"*/
|
||||
if(draw_state == DAY_DRAW_ACT_MONTH && month_of_today_shown && ext->today.day == day_cnt) {
|
||||
if(draw_state == DAY_DRAW_ACT_MONTH && month_of_today_shown &&
|
||||
ext->today.day == day_cnt) {
|
||||
lv_area_t today_box_area;
|
||||
lv_area_copy(&today_box_area, &label_area);
|
||||
today_box_area.x1 = label_area.x1;
|
||||
@ -832,31 +823,34 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
/*Get the final style : highlighted/week box/today box/normal*/
|
||||
lv_style_t * final_style;
|
||||
if(draw_state == DAY_DRAW_PREV_MONTH &&
|
||||
is_highlighted(calendar, ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0),
|
||||
ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1,
|
||||
day_cnt)) {
|
||||
is_highlighted(
|
||||
calendar, ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0),
|
||||
ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1, day_cnt)) {
|
||||
final_style = ext->style_highlighted_days;
|
||||
} else if(draw_state == DAY_DRAW_ACT_MONTH &&
|
||||
is_highlighted(calendar, ext->showed_date.year,
|
||||
ext->showed_date.month,
|
||||
is_highlighted(calendar, ext->showed_date.year, ext->showed_date.month,
|
||||
day_cnt)) {
|
||||
final_style = ext->style_highlighted_days;
|
||||
} else if(draw_state == DAY_DRAW_NEXT_MONTH &&
|
||||
is_highlighted(calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0),
|
||||
ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1,
|
||||
day_cnt)) {
|
||||
is_highlighted(
|
||||
calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0),
|
||||
ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1, day_cnt)) {
|
||||
final_style = ext->style_highlighted_days;
|
||||
} else if(month_of_today_shown && day_cnt == ext->today.day && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_today_box;
|
||||
else if(in_week_box && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_week_box;
|
||||
else final_style = act_style;
|
||||
} else if(month_of_today_shown && day_cnt == ext->today.day &&
|
||||
draw_state == DAY_DRAW_ACT_MONTH)
|
||||
final_style = ext->style_today_box;
|
||||
else if(in_week_box && draw_state == DAY_DRAW_ACT_MONTH)
|
||||
final_style = ext->style_week_box;
|
||||
else
|
||||
final_style = act_style;
|
||||
|
||||
/*Write the day's number*/
|
||||
lv_utils_num_to_str(day_cnt, buf);
|
||||
lv_draw_label(&label_area, mask, final_style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1);
|
||||
lv_draw_label(&label_area, mask, final_style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL,
|
||||
-1, -1);
|
||||
|
||||
/*Go to the next day*/
|
||||
day_cnt++;
|
||||
|
||||
}
|
||||
|
||||
/*Got to the next weeks row*/
|
||||
@ -881,8 +875,7 @@ static bool is_highlighted(lv_obj_t * calendar, int32_t year, int32_t month, int
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->highlighted_dates_num; i++) {
|
||||
if(ext->highlighted_dates[i].year == year &&
|
||||
ext->highlighted_dates[i].month == month &&
|
||||
if(ext->highlighted_dates[i].year == year && ext->highlighted_dates[i].month == month &&
|
||||
ext->highlighted_dates[i].day == day) {
|
||||
return true;
|
||||
}
|
||||
@ -901,14 +894,17 @@ static const char * get_day_name(lv_obj_t * calendar, uint8_t day)
|
||||
{
|
||||
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
if(ext->day_names) return ext->day_names[day];
|
||||
else return day_name[day];
|
||||
if(ext->day_names)
|
||||
return ext->day_names[day];
|
||||
else
|
||||
return day_name[day];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the month name
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param month a month. The range is basically [1..12] but [-11..1] is also supported to handle previous year
|
||||
* @param month a month. The range is basically [1..12] but [-11..1] is also supported to handle
|
||||
* previous year
|
||||
* @return
|
||||
*/
|
||||
static const char * get_month_name(lv_obj_t * calendar, int32_t month)
|
||||
@ -917,14 +913,17 @@ static const char * get_month_name(lv_obj_t * calendar, int32_t month)
|
||||
if(month < 0) month = 12 + month;
|
||||
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
if(ext->month_names) return ext->month_names[month];
|
||||
else return month_name[month];
|
||||
if(ext->month_names)
|
||||
return ext->month_names[month];
|
||||
else
|
||||
return month_name[month];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of days in a month
|
||||
* @param year a year
|
||||
* @param month a month. The range is basically [1..12] but [-11..1] is also supported to handle previous year
|
||||
* @param month a month. The range is basically [1..12] but [-11..1] is also supported to handle
|
||||
* previous year
|
||||
* @return [28..31]
|
||||
*/
|
||||
static uint8_t get_month_length(int32_t year, int32_t month)
|
||||
@ -941,8 +940,6 @@ static uint8_t get_month_length(int32_t year, int32_t month)
|
||||
|
||||
/*month == 1 is february*/
|
||||
return (month == 1) ? (28 + is_leap_year(year)) : 31 - month % 7 % 2;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -967,8 +964,8 @@ static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day)
|
||||
uint32_t a = month < 3 ? 1 : 0;
|
||||
uint32_t b = year - a;
|
||||
|
||||
uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) +
|
||||
b + (b / 4) - (b / 100) + (b / 400)) % 7;
|
||||
uint32_t day_of_week =
|
||||
(day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7;
|
||||
|
||||
return day_of_week;
|
||||
}
|
||||
|
@ -31,24 +31,29 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
uint16_t year;
|
||||
int8_t month;
|
||||
int8_t day;
|
||||
} lv_calendar_date_t;
|
||||
|
||||
/*Data of calendar*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
/*None*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_calendar_date_t today; /*Date of today*/
|
||||
lv_calendar_date_t showed_date; /*Currently visible month (day is ignored)*/
|
||||
lv_calendar_date_t * highlighted_dates; /*Apply different style on these days (pointer to an array defined by the user)*/
|
||||
lv_calendar_date_t * highlighted_dates; /*Apply different style on these days (pointer to an
|
||||
array defined by the user)*/
|
||||
uint8_t highlighted_dates_num; /*Number of elements in `highlighted_days`*/
|
||||
int8_t btn_pressing; /*-1: prev month pressing, +1 next month pressing on the header*/
|
||||
lv_calendar_date_t pressed_date;
|
||||
const char ** day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/
|
||||
const char ** month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/
|
||||
const char **
|
||||
day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/
|
||||
const char **
|
||||
month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/
|
||||
|
||||
/*Styles*/
|
||||
lv_style_t * style_header;
|
||||
@ -73,9 +78,6 @@ enum {
|
||||
};
|
||||
typedef uint8_t lv_calendar_style_t;
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -92,7 +94,6 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
@ -100,39 +101,44 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
/**
|
||||
* Set the today's date
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param today pointer to an `lv_calendar_date_t` variable containing the date of today. The value will be saved it can be local variable too.
|
||||
* @param today pointer to an `lv_calendar_date_t` variable containing the date of today. The value
|
||||
* will be saved it can be local variable too.
|
||||
*/
|
||||
void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today);
|
||||
|
||||
/**
|
||||
* Set the currently showed
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param showed pointer to an `lv_calendar_date_t` variable containing the date to show. The value will be saved it can be local variable too.
|
||||
* @param showed pointer to an `lv_calendar_date_t` variable containing the date to show. The value
|
||||
* will be saved it can be local variable too.
|
||||
*/
|
||||
void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showed);
|
||||
|
||||
/**
|
||||
* Set the the highlighted dates
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. ONLY A POINTER WILL BE SAVED! CAN'T BE LOCAL ARRAY.
|
||||
* @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. ONLY A POINTER
|
||||
* WILL BE SAVED! CAN'T BE LOCAL ARRAY.
|
||||
* @param date_num number of dates in the array
|
||||
*/
|
||||
void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, uint16_t date_num);
|
||||
|
||||
void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted,
|
||||
uint16_t date_num);
|
||||
|
||||
/**
|
||||
* Set the name of the days
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param day_names pointer to an array with the names. E.g. `const char * days[7] = {"Sun", "Mon", ...}`
|
||||
* Only the pointer will be saved so this variable can't be local which will be destroyed later.
|
||||
* @param day_names pointer to an array with the names. E.g. `const char * days[7] = {"Sun", "Mon",
|
||||
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
||||
* later.
|
||||
*/
|
||||
void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names);
|
||||
|
||||
/**
|
||||
* Set the name of the month
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param day_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb", ...}`
|
||||
* Only the pointer will be saved so this variable can't be local which will be destroyed later.
|
||||
* @param day_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb",
|
||||
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
||||
* later.
|
||||
*/
|
||||
void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** day_names);
|
||||
|
||||
@ -183,7 +189,6 @@ lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar
|
||||
*/
|
||||
uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar);
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of the days
|
||||
* @param calendar pointer to a calendar object
|
||||
|
@ -133,7 +133,6 @@ void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t
|
||||
|
||||
lv_img_buf_set_px_color(&ext->dsc, x, y, c);
|
||||
lv_obj_invalidate(canvas);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,9 +144,7 @@ void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t
|
||||
void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, lv_style_t * style)
|
||||
{
|
||||
switch(type) {
|
||||
case LV_CANVAS_STYLE_MAIN:
|
||||
lv_img_set_style(canvas, style);
|
||||
break;
|
||||
case LV_CANVAS_STYLE_MAIN: lv_img_set_style(canvas, style); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,11 +191,8 @@ lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type
|
||||
lv_style_t * style = NULL;
|
||||
|
||||
switch(type) {
|
||||
case LV_CANVAS_STYLE_MAIN:
|
||||
style = lv_img_get_style(canvas);
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
case LV_CANVAS_STYLE_MAIN: style = lv_img_get_style(canvas); break;
|
||||
default: style = NULL;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -211,13 +205,15 @@ lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type
|
||||
/**
|
||||
* Copy a buffer to the canvas
|
||||
* @param canvas pointer to a canvas object
|
||||
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color format
|
||||
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color
|
||||
* format
|
||||
* @param w width of the buffer to copy
|
||||
* @param h height of the buffer to copy
|
||||
* @param x left side of the destination position
|
||||
* @param y top side of the destination position
|
||||
*/
|
||||
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y)
|
||||
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h,
|
||||
lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) {
|
||||
@ -245,7 +241,8 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, l
|
||||
* @param x left side of the destination position
|
||||
* @param y top side of the destination position
|
||||
*/
|
||||
void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y)
|
||||
void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x,
|
||||
lv_coord_t y)
|
||||
{
|
||||
lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas);
|
||||
if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) {
|
||||
@ -268,25 +265,40 @@ void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coor
|
||||
for(i = 0; i < h; i++) {
|
||||
for(j = 0; j < w; j++) {
|
||||
#if LV_COLOR_DEPTH == 32
|
||||
canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 8;
|
||||
canvas_buf_color[j].ch.green = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >> 8;
|
||||
canvas_buf_color[j].ch.blue = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 8;
|
||||
canvas_buf_color[j].ch.red =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 8;
|
||||
canvas_buf_color[j].ch.green =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >>
|
||||
8;
|
||||
canvas_buf_color[j].ch.blue =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 8;
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
|
||||
canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 5;
|
||||
canvas_buf_color[j].ch.blue = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 5;
|
||||
canvas_buf_color[j].ch.red =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 5;
|
||||
canvas_buf_color[j].ch.blue =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 5;
|
||||
#if LV_COLOR_16_SWAP == 0
|
||||
canvas_buf_color[j].ch.green = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >> 6;
|
||||
canvas_buf_color[j].ch.green =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >>
|
||||
6;
|
||||
#else
|
||||
canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 6;
|
||||
canvas_buf_color[j].ch.blue = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 6;
|
||||
canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 6;
|
||||
canvas_buf_color[j].ch.red =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 6;
|
||||
canvas_buf_color[j].ch.blue =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 6;
|
||||
canvas_buf_color[j].ch.red =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 6;
|
||||
#endif /*LV_COLOR_16_SWAP*/
|
||||
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 3;
|
||||
canvas_buf_color[j].ch.green = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >> 3;
|
||||
canvas_buf_color[j].ch.blue = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 2;
|
||||
canvas_buf_color[j].ch.red =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 3;
|
||||
canvas_buf_color[j].ch.green =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >>
|
||||
3;
|
||||
canvas_buf_color[j].ch.blue =
|
||||
(uint16_t)((uint16_t)canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 2;
|
||||
#endif
|
||||
}
|
||||
copy_buf_color += w;
|
||||
@ -307,7 +319,8 @@ void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coor
|
||||
* @param pivot_y pivot Y of rotation. Relative to the source canvas
|
||||
* Set to `source height / 2` to rotate around the center
|
||||
*/
|
||||
void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_coord_t offset_x, lv_coord_t offset_y, int32_t pivot_x, int32_t pivot_y)
|
||||
void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_coord_t offset_x,
|
||||
lv_coord_t offset_y, int32_t pivot_x, int32_t pivot_y)
|
||||
{
|
||||
lv_canvas_ext_t * ext_dst = lv_obj_get_ext_attr(canvas);
|
||||
lv_style_t * style = lv_canvas_get_style(canvas, LV_CANVAS_STYLE_MAIN);
|
||||
@ -335,13 +348,15 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_co
|
||||
int xs_int = xs >> 8;
|
||||
int ys_int = ys >> 8;
|
||||
|
||||
if(xs_int >= img_width)
|
||||
continue;
|
||||
else if(xs_int < 0)
|
||||
continue;
|
||||
|
||||
if(xs_int >= img_width) continue;
|
||||
else if(xs_int < 0) continue;
|
||||
|
||||
|
||||
if(ys_int >= img_height) continue;
|
||||
else if(ys_int < 0) continue;
|
||||
if(ys_int >= img_height)
|
||||
continue;
|
||||
else if(ys_int < 0)
|
||||
continue;
|
||||
|
||||
/*Get the fractional part of the source pixel*/
|
||||
int xs_fract = xs & 0xff;
|
||||
@ -356,38 +371,38 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_co
|
||||
if(xs_fract < 0x70) {
|
||||
xn = xs_int - 1;
|
||||
xr = xs_fract * 2;
|
||||
}
|
||||
else if(xs_fract > 0x90) {
|
||||
} else if(xs_fract > 0x90) {
|
||||
xn = xs_int + 1;
|
||||
xr = (0xFF - xs_fract) * 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
xn = xs_int;
|
||||
xr = 0xFF;
|
||||
}
|
||||
|
||||
/*Handle under/overflow*/
|
||||
if(xn >= img_width) continue;
|
||||
else if(xn < 0) continue;
|
||||
if(xn >= img_width)
|
||||
continue;
|
||||
else if(xn < 0)
|
||||
continue;
|
||||
|
||||
int yn; /*y neightboor*/
|
||||
lv_opa_t yr; /*y mix ratio*/
|
||||
if(ys_fract < 0x70) {
|
||||
yn = ys_int - 1;
|
||||
yr = ys_fract * 2;
|
||||
}
|
||||
else if(ys_fract > 0x90) {
|
||||
} else if(ys_fract > 0x90) {
|
||||
yn = ys_int + 1;
|
||||
yr = (0xFF - ys_fract) * 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
yn = ys_int;
|
||||
yr = 0xFF;
|
||||
}
|
||||
|
||||
/*Handle under/overflow*/
|
||||
if(yn >= img_height) continue;
|
||||
else if(yn < 0) continue;
|
||||
if(yn >= img_height)
|
||||
continue;
|
||||
else if(yn < 0)
|
||||
continue;
|
||||
|
||||
/*Get the mixture of the original source and the neightboor pixels in both directions*/
|
||||
lv_color_t c_dest_int = lv_img_buf_get_px_color(img, xs_int, ys_int, style);
|
||||
@ -403,8 +418,8 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_co
|
||||
lv_color_t y_dest = lv_color_mix(c_dest_int, c_dest_yn, yr);
|
||||
lv_color_t color_res = lv_color_mix(x_dest, y_dest, LV_OPA_50);
|
||||
|
||||
if (x + offset_x >= 0 && x + offset_x < dest_width && y + offset_y >= 0 && y + offset_y < dest_height)
|
||||
{
|
||||
if(x + offset_x >= 0 && x + offset_x < dest_width && y + offset_y >= 0 &&
|
||||
y + offset_y < dest_height) {
|
||||
/*If the image has no alpha channel just simple set the result color on the canvas*/
|
||||
if(lv_img_color_format_has_alpha(img->header.cf) == false) {
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, color_res);
|
||||
@ -418,39 +433,52 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_co
|
||||
lv_opa_t opa_res = (opa_x + opa_y) / 2;
|
||||
if(opa_res <= LV_OPA_MIN) continue;
|
||||
|
||||
lv_color_t bg_color = lv_img_buf_get_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, style);
|
||||
lv_color_t bg_color =
|
||||
lv_img_buf_get_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, style);
|
||||
|
||||
/*If the canvas has no alpha but the image has mix the image's color with canvas*/
|
||||
/*If the canvas has no alpha but the image has mix the image's color with
|
||||
* canvas*/
|
||||
if(lv_img_color_format_has_alpha(ext_dst->dsc.header.cf) == false) {
|
||||
if(opa_res < LV_OPA_MAX) color_res = lv_color_mix(color_res, bg_color, opa_res);
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, color_res);
|
||||
if(opa_res < LV_OPA_MAX)
|
||||
color_res = lv_color_mix(color_res, bg_color, opa_res);
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y,
|
||||
color_res);
|
||||
}
|
||||
/*Both the image and canvas has alpha channel. Some extra calculation is required*/
|
||||
/*Both the image and canvas has alpha channel. Some extra calculation is
|
||||
required*/
|
||||
else {
|
||||
lv_opa_t bg_opa = lv_img_buf_get_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y);
|
||||
/* Pick the foreground if it's fully opaque or the Background is fully transparent*/
|
||||
lv_opa_t bg_opa =
|
||||
lv_img_buf_get_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y);
|
||||
/* Pick the foreground if it's fully opaque or the Background is fully
|
||||
* transparent*/
|
||||
if(opa_res >= LV_OPA_MAX || bg_opa <= LV_OPA_MIN) {
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, color_res);
|
||||
lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y, opa_res);
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y,
|
||||
color_res);
|
||||
lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y,
|
||||
opa_res);
|
||||
}
|
||||
/*Opaque background: use simple mix*/
|
||||
else if(bg_opa >= LV_OPA_MAX) {
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, lv_color_mix(color_res, bg_color, opa_res));
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y,
|
||||
lv_color_mix(color_res, bg_color, opa_res));
|
||||
}
|
||||
/*Both colors have alpha. Expensive calculation need to be applied*/
|
||||
else {
|
||||
|
||||
/*Info: https://en.wikipedia.org/wiki/Alpha_compositing#Analytical_derivation_of_the_over_operator*/
|
||||
lv_opa_t opa_res_2 = 255 - ((uint16_t)((uint16_t)(255 - opa_res) * (255 - bg_opa)) >> 8);
|
||||
/*Info:
|
||||
* https://en.wikipedia.org/wiki/Alpha_compositing#Analytical_derivation_of_the_over_operator*/
|
||||
lv_opa_t opa_res_2 =
|
||||
255 - ((uint16_t)((uint16_t)(255 - opa_res) * (255 - bg_opa)) >> 8);
|
||||
if(opa_res_2 == 0) {
|
||||
opa_res_2 = 1; /*never happens, just to be sure*/
|
||||
}
|
||||
lv_opa_t ratio = (uint16_t)((uint16_t)opa_res * 255) / opa_res_2;
|
||||
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, lv_color_mix(color_res, bg_color, ratio));
|
||||
lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y, opa_res_2);
|
||||
lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y,
|
||||
lv_color_mix(color_res, bg_color, ratio));
|
||||
lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y,
|
||||
opa_res_2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -458,7 +486,6 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_co
|
||||
}
|
||||
|
||||
lv_obj_invalidate(canvas);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -469,14 +496,14 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_co
|
||||
* @param radius radius of the circle
|
||||
* @param color border color of the circle
|
||||
*/
|
||||
void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_coord_t radius, lv_color_t color)
|
||||
void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_coord_t radius,
|
||||
lv_color_t color)
|
||||
{
|
||||
int x = radius;
|
||||
int y = 0;
|
||||
int err = 0;
|
||||
|
||||
while (x >= y)
|
||||
{
|
||||
while(x >= y) {
|
||||
lv_canvas_set_px(canvas, x0 + x, y0 + y, color);
|
||||
lv_canvas_set_px(canvas, x0 + y, y0 + x, color);
|
||||
lv_canvas_set_px(canvas, x0 - y, y0 + x, color);
|
||||
@ -486,14 +513,12 @@ void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_c
|
||||
lv_canvas_set_px(canvas, x0 + y, y0 - x, color);
|
||||
lv_canvas_set_px(canvas, x0 + x, y0 - y, color);
|
||||
|
||||
if (err <= 0)
|
||||
{
|
||||
if(err <= 0) {
|
||||
y += 1;
|
||||
err += 2 * y + 1;
|
||||
}
|
||||
|
||||
if (err > 0)
|
||||
{
|
||||
if(err > 0) {
|
||||
x -= 1;
|
||||
err -= 2 * x + 1;
|
||||
}
|
||||
@ -527,8 +552,14 @@ void lv_canvas_draw_line(lv_obj_t * canvas, lv_point_t point1, lv_point_t point2
|
||||
|
||||
if(x0 == x1 && y0 == y1) break;
|
||||
e2 = err;
|
||||
if (e2 >-dx) { err -= dy; x0 += sx; }
|
||||
if (e2 < dy) { err += dx; y0 += sy; }
|
||||
if(e2 > -dx) {
|
||||
err -= dy;
|
||||
x0 += sx;
|
||||
}
|
||||
if(e2 < dy) {
|
||||
err += dx;
|
||||
y0 += sy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,7 +611,8 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
|
||||
* @param boundary_color line color of the polygon
|
||||
* @param fill_color fill color of the polygon
|
||||
*/
|
||||
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t boundary_color, lv_color_t fill_color)
|
||||
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
|
||||
lv_color_t boundary_color, lv_color_t fill_color)
|
||||
{
|
||||
uint32_t x = 0, y = 0;
|
||||
uint8_t i;
|
||||
@ -604,15 +636,14 @@ void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
|
||||
* @param boundary_color edge/boundary color of the area
|
||||
* @param fill_color fill color of the area
|
||||
*/
|
||||
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t boundary_color, lv_color_t fill_color)
|
||||
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t boundary_color, lv_color_t fill_color)
|
||||
{
|
||||
lv_color_t c;
|
||||
|
||||
c = lv_canvas_get_px(canvas, x, y);
|
||||
|
||||
if(c.full != boundary_color.full &&
|
||||
c.full != fill_color.full)
|
||||
{
|
||||
if(c.full != boundary_color.full && c.full != fill_color.full) {
|
||||
lv_canvas_set_px(canvas, x, y, fill_color);
|
||||
|
||||
lv_canvas_boundary_fill4(canvas, x + 1, y, boundary_color, fill_color);
|
||||
@ -630,14 +661,14 @@ void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_
|
||||
* @param fill_color fill color of the area
|
||||
* @param bg_color background color of the area
|
||||
*/
|
||||
void lv_canvas_flood_fill(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color, lv_color_t bg_color)
|
||||
void lv_canvas_flood_fill(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color,
|
||||
lv_color_t bg_color)
|
||||
{
|
||||
lv_color_t c;
|
||||
|
||||
c = lv_canvas_get_px(canvas, x, y);
|
||||
|
||||
if(c.full == bg_color.full)
|
||||
{
|
||||
if(c.full == bg_color.full) {
|
||||
lv_canvas_set_px(canvas, x, y, fill_color);
|
||||
|
||||
lv_canvas_flood_fill(canvas, x + 1, y, fill_color, bg_color);
|
||||
|
@ -32,20 +32,19 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of canvas*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
lv_img_ext_t img; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_img_dsc_t dsc;
|
||||
} lv_canvas_ext_t;
|
||||
|
||||
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_CANVAS_STYLE_MAIN,
|
||||
};
|
||||
typedef uint8_t lv_canvas_style_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -75,7 +74,8 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
* @param cf color format. The following formats are supported:
|
||||
* LV_IMG_CF_TRUE_COLOR, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, LV_IMG_CF_INDEXES_1/2/4/8BIT
|
||||
*/
|
||||
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
|
||||
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h,
|
||||
lv_img_cf_t cf);
|
||||
|
||||
/**
|
||||
* Set the color of a pixel on the canvas
|
||||
@ -129,13 +129,15 @@ lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type
|
||||
/**
|
||||
* Copy a buffer to the canvas
|
||||
* @param canvas pointer to a canvas object
|
||||
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color format
|
||||
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color
|
||||
* format
|
||||
* @param w width of the buffer to copy
|
||||
* @param h height of the buffer to copy
|
||||
* @param x left side of the destination position
|
||||
* @param y top side of the destination position
|
||||
*/
|
||||
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y);
|
||||
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h,
|
||||
lv_coord_t x, lv_coord_t y);
|
||||
|
||||
/**
|
||||
* Multiply a buffer with the canvas
|
||||
@ -146,7 +148,8 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, l
|
||||
* @param x left side of the destination position
|
||||
* @param y top side of the destination position
|
||||
*/
|
||||
void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y);
|
||||
void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x,
|
||||
lv_coord_t y);
|
||||
|
||||
/**
|
||||
* Rotate and image and store the result on a canvas.
|
||||
@ -161,7 +164,8 @@ void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coor
|
||||
* @param pivot_y pivot Y of rotation. Relative to the source canvas
|
||||
* Set to `source height / 2` to rotate around the center
|
||||
*/
|
||||
void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_coord_t offset_x, lv_coord_t offset_y, int32_t pivot_x, int32_t pivot_y);
|
||||
void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_coord_t offset_x,
|
||||
lv_coord_t offset_y, int32_t pivot_x, int32_t pivot_y);
|
||||
|
||||
/**
|
||||
* Draw circle function of the canvas
|
||||
@ -171,7 +175,8 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle,lv_co
|
||||
* @param radius radius of the circle
|
||||
* @param color border color of the circle
|
||||
*/
|
||||
void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_coord_t radius, lv_color_t color);
|
||||
void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_coord_t radius,
|
||||
lv_color_t color);
|
||||
|
||||
/**
|
||||
* Draw line function of the canvas
|
||||
@ -217,7 +222,8 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
|
||||
* @param boundary_color line color of the polygon
|
||||
* @param fill_color fill color of the polygon
|
||||
*/
|
||||
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t boundary_color, lv_color_t fill_color);
|
||||
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
|
||||
lv_color_t boundary_color, lv_color_t fill_color);
|
||||
/**
|
||||
* Boundary fill function of the canvas
|
||||
* @param canvas pointer to a canvas object
|
||||
@ -226,7 +232,8 @@ void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
|
||||
* @param boundary_color edge/boundary color of the area
|
||||
* @param fill_color fill color of the area
|
||||
*/
|
||||
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t boundary_color, lv_color_t fill_color);
|
||||
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t boundary_color, lv_color_t fill_color);
|
||||
|
||||
/**
|
||||
* Flood fill function of the canvas
|
||||
@ -236,7 +243,8 @@ void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_
|
||||
* @param fill_color fill color of the area
|
||||
* @param bg_color background color of the area
|
||||
*/
|
||||
void lv_canvas_flood_fill(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color, lv_color_t bg_color);
|
||||
void lv_canvas_flood_fill(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color,
|
||||
lv_color_t bg_color);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -245,17 +253,27 @@ void lv_canvas_flood_fill(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_colo
|
||||
#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) ((LV_COLOR_SIZE / 8) * w * h)
|
||||
#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) (LV_IMG_PX_SIZE_ALPHA_BYTE * w * h)
|
||||
|
||||
#define LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w,h) ((((w / 8) + 1) * h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w,h) (LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w,h) + 4 * 2) /*4 * 2: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) \
|
||||
((((w / 8) + 1) * \
|
||||
h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h) \
|
||||
(LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) + 4 * 2) /*4 * 2: palette*/
|
||||
|
||||
#define LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w,h) ((((w / 4) + 1) * h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w,h) (LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w,h) + 4 * 4) /*4 * 4: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) \
|
||||
((((w / 4) + 1) * \
|
||||
h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w, h) \
|
||||
(LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) + 4 * 4) /*4 * 4: palette*/
|
||||
|
||||
#define LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w,h) ((((w / 2) + 1) * h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w,h) (LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w,h) + 4 * 16) /*4 * 16: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) \
|
||||
((((w / 2) + 1) * \
|
||||
h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w, h) \
|
||||
(LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) + 4 * 16) /*4 * 16: palette*/
|
||||
|
||||
#define LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) ((w * h))
|
||||
#define LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w,h) (LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w,h) + 4 * 256) /*4 * 256: palette*/
|
||||
#define LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w, h) \
|
||||
(LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) + 4 * 256) /*4 * 256: palette*/
|
||||
|
||||
#endif /*LV_USE_CANVAS*/
|
||||
|
||||
|
@ -74,7 +74,8 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Init the new checkbox object*/
|
||||
if(copy == NULL) {
|
||||
ext->bullet = lv_btn_create(new_cb, NULL);
|
||||
if(ancestor_bullet_design == NULL) ancestor_bullet_design = lv_obj_get_design_func(ext->bullet);
|
||||
if(ancestor_bullet_design == NULL)
|
||||
ancestor_bullet_design = lv_obj_get_design_func(ext->bullet);
|
||||
lv_obj_set_click(ext->bullet, false);
|
||||
|
||||
ext->label = lv_label_create(new_cb, NULL);
|
||||
@ -109,7 +110,6 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_obj_set_design_cb(ext->bullet, lv_bullet_design);
|
||||
|
||||
|
||||
LV_LOG_INFO("check box created");
|
||||
|
||||
return new_cb;
|
||||
@ -137,7 +137,8 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
||||
* @param cb pointer to a check box
|
||||
* @param txt the text of the check box. NULL to refresh with the current text.
|
||||
*/
|
||||
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt) {
|
||||
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
lv_label_set_static_text(ext->label, txt);
|
||||
}
|
||||
@ -160,26 +161,18 @@ void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t * style)
|
||||
lv_btn_set_style(cb, LV_BTN_STYLE_TGL_PR, style);
|
||||
lv_btn_set_style(cb, LV_BTN_STYLE_INA, style);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_REL:
|
||||
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_REL, style);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_PR:
|
||||
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_PR, style);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_REL: lv_btn_set_style(ext->bullet, LV_BTN_STYLE_REL, style); break;
|
||||
case LV_CB_STYLE_BOX_PR: lv_btn_set_style(ext->bullet, LV_BTN_STYLE_PR, style); break;
|
||||
case LV_CB_STYLE_BOX_TGL_REL:
|
||||
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_REL, style);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_TGL_PR:
|
||||
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_PR, style);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_INA:
|
||||
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_INA, style);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_INA: lv_btn_set_style(ext->bullet, LV_BTN_STYLE_INA, style); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -195,7 +188,6 @@ const char * lv_cb_get_text(const lv_obj_t * cb)
|
||||
return lv_label_get_text(ext->label);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a style of a button
|
||||
* @param cb pointer to check box object
|
||||
@ -208,24 +200,16 @@ lv_style_t * lv_cb_get_style(const 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:
|
||||
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_PR:
|
||||
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_REL: style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL); break;
|
||||
case LV_CB_STYLE_BOX_PR: style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR); break;
|
||||
case LV_CB_STYLE_BOX_TGL_REL:
|
||||
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_TGL_PR:
|
||||
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_INA:
|
||||
style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_CB_STYLE_BOX_INA: style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA); break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -311,7 +295,6 @@ static bool lv_bullet_design(lv_obj_t * bullet, const lv_area_t * mask, lv_desig
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signal function of the check box
|
||||
* @param cb pointer to a check box object
|
||||
@ -331,16 +314,16 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
||||
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_style_t * label_style = lv_label_get_style(ext->label);
|
||||
lv_obj_set_size(ext->bullet, lv_font_get_height(label_style->text.font), lv_font_get_height(label_style->text.font));
|
||||
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 ||
|
||||
} else if(sign == LV_SIGNAL_PRESSED || 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_CONTROL) {
|
||||
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) {
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN || c == LV_GROUP_KEY_LEFT ||
|
||||
c == LV_GROUP_KEY_UP) {
|
||||
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
|
@ -60,7 +60,8 @@ static lv_signal_cb_t ancestor_signal;
|
||||
/**
|
||||
* Create a chart background objects
|
||||
* @param par pointer to an object, it will be the parent of the new chart background
|
||||
* @param copy pointer to a chart background object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a chart background object, if not NULL then the new object will be copied
|
||||
* from it
|
||||
* @return pointer to the created chart background
|
||||
*/
|
||||
lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
@ -129,7 +130,6 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
LV_LOG_INFO("chart created");
|
||||
|
||||
|
||||
return new_chart;
|
||||
}
|
||||
|
||||
@ -185,19 +185,16 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
||||
*/
|
||||
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
|
||||
{
|
||||
if(chart == NULL || serie == NULL)
|
||||
return;
|
||||
if(chart == NULL || serie == NULL) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext == NULL) return;
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->point_cnt; i++)
|
||||
{
|
||||
for(i = 0; i < ext->point_cnt; i++) {
|
||||
serie->points[i] = LV_CHART_POINT_DEF;
|
||||
}
|
||||
|
||||
serie->start_point = 0;
|
||||
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -270,7 +267,8 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
||||
|
||||
if(point_cnt < 1) point_cnt = 1;
|
||||
|
||||
LV_LL_READ_BACK(ext->series_ll, ser) {
|
||||
LV_LL_READ_BACK(ext->series_ll, ser)
|
||||
{
|
||||
if(ser->start_point != 0) {
|
||||
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
|
||||
lv_mem_assert(new_points);
|
||||
@ -278,14 +276,16 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
||||
|
||||
if(point_cnt >= point_cnt_old) {
|
||||
for(i = 0; i < point_cnt_old; i++) {
|
||||
new_points[i] = ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
new_points[i] = ser->points[(i + ser->start_point) %
|
||||
point_cnt_old]; /*Copy old contents to new array*/
|
||||
}
|
||||
for(i = point_cnt_old; i < point_cnt; i++) {
|
||||
new_points[i] = def; /*Fill up the rest with default value*/
|
||||
}
|
||||
} else {
|
||||
for(i = 0; i < point_cnt; i++) {
|
||||
new_points[i] = ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
new_points[i] = ser->points[(i + ser->start_point) %
|
||||
point_cnt_old]; /*Copy old contents to new array*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,7 +394,8 @@ 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);
|
||||
|
||||
ser->points[ser->start_point] = y; /*This was the place of the former left most value, after shifting it is the rightmost*/
|
||||
ser->points[ser->start_point] =
|
||||
y; /*This was the place of the former left most value, after shifting it is the rightmost*/
|
||||
ser->start_point = (ser->start_point + 1) % ext->point_cnt;
|
||||
|
||||
lv_chart_refresh(chart);
|
||||
@ -421,11 +422,8 @@ void lv_chart_set_margin(lv_obj_t* chart, uint16_t margin)
|
||||
* @param minor_tick_len the length of the minor tick, AUTO if 0
|
||||
* @param options extra options
|
||||
*/
|
||||
void lv_chart_set_x_ticks( lv_obj_t* chart,
|
||||
const char* list_of_values,
|
||||
uint8_t num_tick_marks,
|
||||
uint8_t major_tick_len,
|
||||
uint8_t minor_tick_len,
|
||||
void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||
uint8_t major_tick_len, uint8_t minor_tick_len,
|
||||
lv_chart_axis_options_t options)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
@ -436,11 +434,8 @@ void lv_chart_set_x_ticks( lv_obj_t* chart,
|
||||
ext->x_axis.options = options;
|
||||
}
|
||||
|
||||
void lv_chart_set_y_ticks( lv_obj_t* chart,
|
||||
const char* list_of_values,
|
||||
uint8_t num_tick_marks,
|
||||
uint8_t major_tick_len,
|
||||
uint8_t minor_tick_len,
|
||||
void lv_chart_set_y_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||
uint8_t major_tick_len, uint8_t minor_tick_len,
|
||||
lv_chart_axis_options_t options)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
@ -589,7 +584,8 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_coord_t ** datal;
|
||||
LV_LL_READ(ext->series_ll, datal) {
|
||||
LV_LL_READ(ext->series_ll, datal)
|
||||
{
|
||||
lv_mem_free(*datal);
|
||||
}
|
||||
lv_ll_clear(&ext->series_ll);
|
||||
@ -644,8 +640,10 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
for(div_i = div_i_start; div_i <= div_i_end; div_i++) {
|
||||
p1.y = (int32_t)((int32_t)h * div_i) / (ext->hdiv_cnt + 1);
|
||||
p1.y += y_ofs;
|
||||
if(div_i == div_i_start) p1.y += (style->line.width >> 1) + 1; /*The first line might not be visible*/
|
||||
if(div_i == div_i_end) p1.y -= (style->line.width >> 1) + 1; /*The last line might not be visible*/
|
||||
if(div_i == div_i_start)
|
||||
p1.y += (style->line.width >> 1) + 1; /*The first line might not be visible*/
|
||||
if(div_i == div_i_end)
|
||||
p1.y -= (style->line.width >> 1) + 1; /*The last line might not be visible*/
|
||||
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
@ -667,8 +665,10 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask)
|
||||
for(div_i = div_i_start; div_i <= div_i_end; div_i++) {
|
||||
p1.x = (int32_t)((int32_t)w * div_i) / (ext->vdiv_cnt + 1);
|
||||
p1.x += x_ofs;
|
||||
if(div_i == div_i_start) p1.x += (style->line.width >> 1) + 1; /*The first line might not be visible*/
|
||||
if(div_i == div_i_end) p1.x -= (style->line.width >> 1) + 1; /*The last line might not be visible*/
|
||||
if(div_i == div_i_start)
|
||||
p1.x += (style->line.width >> 1) + 1; /*The first line might not be visible*/
|
||||
if(div_i == div_i_end)
|
||||
p1.x -= (style->line.width >> 1) + 1; /*The last line might not be visible*/
|
||||
p2.x = p1.x;
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
}
|
||||
@ -701,7 +701,8 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
|
||||
style.line.width = ext->series.width;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LV_LL_READ_BACK(ext->series_ll, ser) {
|
||||
LV_LL_READ_BACK(ext->series_ll, ser)
|
||||
{
|
||||
style.line.color = ser->color;
|
||||
|
||||
p1.x = 0 + x_ofs;
|
||||
@ -724,7 +725,8 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask)
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
if(ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF)
|
||||
if(ser->points[p_prev] != LV_CHART_POINT_DEF &&
|
||||
ser->points[p_act] != LV_CHART_POINT_DEF)
|
||||
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
|
||||
|
||||
p_prev = p_act;
|
||||
@ -760,7 +762,8 @@ static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask)
|
||||
style_point.body.radius = ext->series.width;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LV_LL_READ_BACK(ext->series_ll, ser) {
|
||||
LV_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);
|
||||
|
||||
@ -800,7 +803,8 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
|
||||
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 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);
|
||||
@ -818,7 +822,8 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
|
||||
x_act += chart->coords.x1 + x_ofs;
|
||||
|
||||
/*Draw the current point of all data line*/
|
||||
LV_LL_READ_BACK(ext->series_ll, ser) {
|
||||
LV_LL_READ_BACK(ext->series_ll, ser)
|
||||
{
|
||||
rects.body.main_color = ser->color;
|
||||
rects.body.grad_color = lv_color_mix(LV_COLOR_BLACK, ser->color, ext->series.dark);
|
||||
col_a.x1 = x_act;
|
||||
@ -868,7 +873,8 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas
|
||||
style.line.width = ext->series.width;
|
||||
|
||||
/*Go through all data lines*/
|
||||
LV_LL_READ_BACK(ext->series_ll, ser) {
|
||||
LV_LL_READ_BACK(ext->series_ll, ser)
|
||||
{
|
||||
style.line.color = ser->color;
|
||||
|
||||
p1.x = 0 + x_ofs;
|
||||
@ -878,15 +884,13 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
p1.y = p2.y;
|
||||
|
||||
for(i = 0; i < ext->point_cnt; i++)
|
||||
{
|
||||
for(i = 0; i < ext->point_cnt; i++) {
|
||||
|
||||
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;
|
||||
|
||||
if(p1.y == p2.y)
|
||||
{
|
||||
if(p1.y == p2.y) {
|
||||
p2.x++;
|
||||
}
|
||||
|
||||
@ -925,7 +929,8 @@ static void lv_chart_draw_areas(lv_obj_t * chart, const lv_area_t * mask)
|
||||
lv_style_copy(&style, &lv_style_plain);
|
||||
|
||||
/*Go through all data lines*/
|
||||
LV_LL_READ_BACK(ext->series_ll, ser) {
|
||||
LV_LL_READ_BACK(ext->series_ll, ser)
|
||||
{
|
||||
style.body.main_color = ser->color;
|
||||
|
||||
p1.x = 0 + x_ofs;
|
||||
@ -947,7 +952,8 @@ static void lv_chart_draw_areas(lv_obj_t * chart, const lv_area_t * mask)
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
if(ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF) {
|
||||
if(ser->points[p_prev] != LV_CHART_POINT_DEF &&
|
||||
ser->points[p_act] != LV_CHART_POINT_DEF) {
|
||||
lv_point_t triangle_points[3];
|
||||
triangle_points[0] = p1;
|
||||
triangle_points[1].x = p2.x;
|
||||
@ -983,7 +989,8 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
lv_coord_t y_ofs = chart->coords.y1;
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN+1]; /* up to N symbols per label + null terminator */
|
||||
char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN +
|
||||
1]; /* up to N symbols per label + null terminator */
|
||||
|
||||
/* calculate the size of tick marks */
|
||||
if(ext->y_axis.major_tick_len == 0)
|
||||
@ -999,19 +1006,16 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
/* count the '\n'-s to determine the number of options */
|
||||
list_index = 0;
|
||||
num_of_labels = 0;
|
||||
if(ext->y_axis.list_of_values != NULL)
|
||||
{
|
||||
if(ext->y_axis.list_of_values != NULL) {
|
||||
for(j = 0; ext->y_axis.list_of_values[j] != '\0'; j++) {
|
||||
if(ext->y_axis.list_of_values[j] == '\n')
|
||||
num_of_labels++;
|
||||
if(ext->y_axis.list_of_values[j] == '\n') num_of_labels++;
|
||||
}
|
||||
|
||||
num_of_labels++; /* last option in the at row*/
|
||||
}
|
||||
|
||||
/* we can't have string labels without ticks step, set to 1 if not specified */
|
||||
if(ext->y_axis.num_tick_marks == 0)
|
||||
ext->y_axis.num_tick_marks = 1;
|
||||
if(ext->y_axis.num_tick_marks == 0) ext->y_axis.num_tick_marks = 1;
|
||||
|
||||
/* calculate total number of ticks */
|
||||
if(num_of_labels < 2)
|
||||
@ -1019,7 +1023,8 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
else
|
||||
num_scale_ticks = (ext->y_axis.num_tick_marks * (num_of_labels - 1));
|
||||
|
||||
for(i = 0; i < (num_scale_ticks + 1); i++ ) { /* one extra loop - it may not exist in the list, empty label */
|
||||
for(i = 0; i < (num_scale_ticks + 1);
|
||||
i++) { /* one extra loop - it may not exist in the list, empty label */
|
||||
/* first point of the tick */
|
||||
p1.x = 0 + x_ofs;
|
||||
|
||||
@ -1030,25 +1035,22 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
p2.x = p1.x - minor_tick_len; /* minor tick */
|
||||
|
||||
/* draw a line at moving y position */
|
||||
p2.y = p1.y = y_ofs + h - (int32_t)(((int32_t)h * i) / num_scale_ticks + 1) - LV_CHART_AXIS_Y_TICK_OFFSET_FIX;
|
||||
p2.y = p1.y = y_ofs + h - (int32_t)(((int32_t)h * i) / num_scale_ticks + 1) -
|
||||
LV_CHART_AXIS_Y_TICK_OFFSET_FIX;
|
||||
|
||||
if(i != num_scale_ticks)
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
else
|
||||
if( (ext->y_axis.options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0 )
|
||||
else if((ext->y_axis.options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
|
||||
/* draw values if available */
|
||||
if (num_of_labels != 0)
|
||||
{
|
||||
if(num_of_labels != 0) {
|
||||
/* add text only to major tick */
|
||||
if( i == 0 || i % ext->y_axis.num_tick_marks == 0 )
|
||||
{
|
||||
if(i == 0 || i % ext->y_axis.num_tick_marks == 0) {
|
||||
/* search for tick string */
|
||||
j = 0;
|
||||
while(ext->y_axis.list_of_values[list_index] != '\n' &&
|
||||
ext->y_axis.list_of_values[list_index] != '\0')
|
||||
{
|
||||
ext->y_axis.list_of_values[list_index] != '\0') {
|
||||
/* do not overflow the buffer, but move to the end of the current label */
|
||||
if(j < LV_CHART_AXIS_TICK_LABEL_MAX_LEN)
|
||||
buf[j++] = ext->y_axis.list_of_values[list_index++];
|
||||
@ -1057,19 +1059,22 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
}
|
||||
|
||||
/* this was a string, but not end of the list, so jump to the next string */
|
||||
if(ext->y_axis.list_of_values[list_index] == '\n')
|
||||
list_index++;
|
||||
if(ext->y_axis.list_of_values[list_index] == '\n') list_index++;
|
||||
|
||||
/* terminate the string */
|
||||
buf[j] = '\0';
|
||||
|
||||
/* reserve appropriate area */
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_CENTER);
|
||||
lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space,
|
||||
style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_CENTER);
|
||||
|
||||
/* set the area at some distance of the major tick len left of the tick */
|
||||
lv_area_t a = {(p2.x - size.x - LV_CHART_AXIS_TO_LABEL_DISTANCE) , (p2.y - size.y/2), (p2.x - LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.y + size.y/2) };
|
||||
lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1);
|
||||
lv_area_t a = {(p2.x - size.x - LV_CHART_AXIS_TO_LABEL_DISTANCE),
|
||||
(p2.y - size.y / 2), (p2.x - LV_CHART_AXIS_TO_LABEL_DISTANCE),
|
||||
(p2.y + size.y / 2)};
|
||||
lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1097,7 +1102,8 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
lv_coord_t y_ofs = chart->coords.y1;
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN+1]; /* up to N symbols per label + null terminator */
|
||||
char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN +
|
||||
1]; /* up to N symbols per label + null terminator */
|
||||
|
||||
/* calculate the size of tick marks */
|
||||
if(ext->x_axis.major_tick_len == 0)
|
||||
@ -1113,19 +1119,16 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
/* count the '\n'-s to determine the number of options */
|
||||
list_index = 0;
|
||||
num_of_labels = 0;
|
||||
if(ext->x_axis.list_of_values != NULL)
|
||||
{
|
||||
if(ext->x_axis.list_of_values != NULL) {
|
||||
for(j = 0; ext->x_axis.list_of_values[j] != '\0'; j++) {
|
||||
if(ext->x_axis.list_of_values[j] == '\n')
|
||||
num_of_labels++;
|
||||
if(ext->x_axis.list_of_values[j] == '\n') num_of_labels++;
|
||||
}
|
||||
|
||||
num_of_labels++; /* last option in the at row*/
|
||||
}
|
||||
|
||||
/* we can't have string labels without ticks step, set to 1 if not specified */
|
||||
if(ext->x_axis.num_tick_marks == 0)
|
||||
ext->x_axis.num_tick_marks = 1;
|
||||
if(ext->x_axis.num_tick_marks == 0) ext->x_axis.num_tick_marks = 1;
|
||||
|
||||
/* calculate total number of marks */
|
||||
if(num_of_labels < 2)
|
||||
@ -1133,7 +1136,8 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
else
|
||||
num_scale_ticks = (ext->x_axis.num_tick_marks * (num_of_labels - 1));
|
||||
|
||||
for(i = 0; i < (num_scale_ticks + 1); i++ ) { /* one extra loop - it may not exist in the list, empty label */
|
||||
for(i = 0; i < (num_scale_ticks + 1);
|
||||
i++) { /* one extra loop - it may not exist in the list, empty label */
|
||||
/* first point of the tick */
|
||||
p1.y = h + y_ofs;
|
||||
|
||||
@ -1144,25 +1148,22 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
p2.y = p1.y + minor_tick_len; /* minor tick */
|
||||
|
||||
/* draw a line at moving x position */
|
||||
p2.x = p1.x = x_ofs + (int32_t)(((int32_t)w * i) / num_scale_ticks + 1) - LV_CHART_AXIS_X_TICK_OFFSET_FIX;
|
||||
p2.x = p1.x = x_ofs + (int32_t)(((int32_t)w * i) / num_scale_ticks + 1) -
|
||||
LV_CHART_AXIS_X_TICK_OFFSET_FIX;
|
||||
|
||||
if(i != num_scale_ticks)
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
else
|
||||
if( (ext->x_axis.options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0 )
|
||||
else if((ext->x_axis.options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
|
||||
lv_draw_line(&p1, &p2, mask, style, opa_scale);
|
||||
|
||||
/* draw values if available */
|
||||
if (num_of_labels != 0)
|
||||
{
|
||||
if(num_of_labels != 0) {
|
||||
/* add text only to major tick */
|
||||
if( i == 0 || i % ext->x_axis.num_tick_marks == 0 )
|
||||
{
|
||||
if(i == 0 || i % ext->x_axis.num_tick_marks == 0) {
|
||||
/* search for tick string */
|
||||
j = 0;
|
||||
while(ext->x_axis.list_of_values[list_index] != '\n' &&
|
||||
ext->x_axis.list_of_values[list_index] != '\0')
|
||||
{
|
||||
ext->x_axis.list_of_values[list_index] != '\0') {
|
||||
/* do not overflow the buffer, but move to the end of the current label */
|
||||
if(j < LV_CHART_AXIS_TICK_LABEL_MAX_LEN)
|
||||
buf[j++] = ext->x_axis.list_of_values[list_index++];
|
||||
@ -1171,19 +1172,22 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask)
|
||||
}
|
||||
|
||||
/* this was a string, but not end of the list, so jump to the next string */
|
||||
if(ext->x_axis.list_of_values[list_index] == '\n')
|
||||
list_index++;
|
||||
if(ext->x_axis.list_of_values[list_index] == '\n') list_index++;
|
||||
|
||||
/* terminate the string */
|
||||
buf[j] = '\0';
|
||||
|
||||
/* reserve appropriate area */
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_CENTER);
|
||||
lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space,
|
||||
style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_CENTER);
|
||||
|
||||
/* set the area at some distance of the major tick len under of the tick */
|
||||
lv_area_t a = { (p2.x - size.x/2) , (p2.y + LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.x + size.x/2), (p2.y + size.y + LV_CHART_AXIS_TO_LABEL_DISTANCE) };
|
||||
lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1);
|
||||
lv_area_t a = {(p2.x - size.x / 2), (p2.y + LV_CHART_AXIS_TO_LABEL_DISTANCE),
|
||||
(p2.x + size.x / 2),
|
||||
(p2.y + size.y + LV_CHART_AXIS_TO_LABEL_DISTANCE)};
|
||||
lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
/*Chart types*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/
|
||||
LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/
|
||||
LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/
|
||||
LV_CHART_TYPE_VERTICAL_LINE = 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/
|
||||
LV_CHART_TYPE_VERTICAL_LINE =
|
||||
0x08, /*Draw vertical lines on points (useful when chart width == point count)*/
|
||||
LV_CHART_TYPE_AREA = 0x10, /*Draw area chart*/
|
||||
};
|
||||
typedef uint8_t lv_chart_type_t;
|
||||
@ -52,8 +52,7 @@ typedef struct
|
||||
} lv_chart_series_t;
|
||||
|
||||
/*Data of axis */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_CHART_AXIS_DRAW_LAST_TICK = 0x01 /* draw the last tick */
|
||||
};
|
||||
typedef uint8_t lv_chart_axis_options_t;
|
||||
@ -82,7 +81,8 @@ typedef struct
|
||||
lv_chart_axis_cfg_t y_axis;
|
||||
lv_chart_axis_cfg_t x_axis;
|
||||
uint16_t margin;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
lv_coord_t width; /*Line width or point radius*/
|
||||
uint8_t num; /*Number of data lines in dl_ll*/
|
||||
lv_opa_t opa; /*Opacity of data lines*/
|
||||
@ -90,8 +90,6 @@ typedef struct
|
||||
} series;
|
||||
} lv_chart_ext_t;
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -99,7 +97,8 @@ typedef struct
|
||||
/**
|
||||
* Create a chart background objects
|
||||
* @param par pointer to an object, it will be the parent of the new chart background
|
||||
* @param copy pointer to a chart background object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a chart background object, if not NULL then the new object will be copied
|
||||
* from it
|
||||
* @return pointer to the created chart background
|
||||
*/
|
||||
lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
@ -229,18 +228,12 @@ void lv_chart_set_margin(lv_obj_t* chart, uint16_t margin);
|
||||
* @param minor_tick_len the length of the minor tick, AUTO if 0
|
||||
* @param options extra options
|
||||
*/
|
||||
void lv_chart_set_x_ticks( lv_obj_t* chart,
|
||||
const char* list_of_values,
|
||||
uint8_t num_tick_marks,
|
||||
uint8_t major_tick_len,
|
||||
uint8_t minor_tick_len,
|
||||
void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||
uint8_t major_tick_len, uint8_t minor_tick_len,
|
||||
lv_chart_axis_options_t options);
|
||||
|
||||
void lv_chart_set_y_ticks( lv_obj_t* chart,
|
||||
const char* list_of_values,
|
||||
uint8_t num_tick_marks,
|
||||
uint8_t major_tick_len,
|
||||
uint8_t minor_tick_len,
|
||||
void lv_chart_set_y_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||
uint8_t major_tick_len, uint8_t minor_tick_len,
|
||||
lv_chart_axis_options_t options);
|
||||
|
||||
/*=====================
|
||||
|
@ -63,7 +63,6 @@ static lv_signal_cb_t ancestor_signal;
|
||||
lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
{
|
||||
|
||||
|
||||
LV_LOG_TRACE("container create started");
|
||||
|
||||
/*Create a basic object*/
|
||||
@ -147,11 +146,8 @@ void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t t
|
||||
{
|
||||
lv_obj_invalidate(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
if(ext->fit_left == left &&
|
||||
ext->fit_right == right &&
|
||||
ext->fit_top == top &&
|
||||
ext->fit_bottom == bottom)
|
||||
{
|
||||
if(ext->fit_left == left && ext->fit_right == right && ext->fit_top == top &&
|
||||
ext->fit_bottom == bottom) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -270,7 +266,6 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Refresh the layout of a container
|
||||
* @param cont pointer to an object which layout should be refreshed
|
||||
@ -335,9 +330,10 @@ static void lv_cont_layout_col(lv_obj_t * cont)
|
||||
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = style->body.padding.top;
|
||||
LV_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_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, hpad_corr, last_cord);
|
||||
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
@ -385,9 +381,10 @@ static void lv_cont_layout_row(lv_obj_t * cont)
|
||||
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = style->body.padding.left;
|
||||
LV_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_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;
|
||||
@ -407,9 +404,10 @@ static void lv_cont_layout_center(lv_obj_t * cont)
|
||||
uint32_t obj_num = 0;
|
||||
lv_coord_t h_tot = 0;
|
||||
|
||||
LV_LL_READ(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false ||
|
||||
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
LV_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++;
|
||||
}
|
||||
@ -424,9 +422,10 @@ static void lv_cont_layout_center(lv_obj_t * cont)
|
||||
|
||||
/* Align the children */
|
||||
lv_coord_t last_cord = -(h_tot / 2);
|
||||
LV_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_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, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
|
||||
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
@ -459,7 +458,8 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
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.left + style->body.padding.right; /*The width is at least the left+right hpad*/
|
||||
lv_coord_t w_row = style->body.padding.left +
|
||||
style->body.padding.right; /*The width is at least the left+right hpad*/
|
||||
uint32_t obj_num = 0;
|
||||
|
||||
/*Find the row closer object and collect some data*/
|
||||
@ -468,27 +468,33 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
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*/
|
||||
/*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*/
|
||||
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*/
|
||||
|
||||
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 */
|
||||
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*/
|
||||
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*/
|
||||
@ -501,8 +507,10 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
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);
|
||||
lv_coord_t pad = (w_obj - w_row) / 3;
|
||||
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);
|
||||
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 {
|
||||
@ -513,13 +521,13 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
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);
|
||||
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;
|
||||
@ -545,7 +553,9 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
(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 - style->body.padding.left - style->body.padding.right) - (obj_row * w_obj)) / (obj_row - 1);
|
||||
x_ofs = (w_obj + (w_tot - style->body.padding.left - style->body.padding.right) -
|
||||
(obj_row * w_obj)) /
|
||||
(obj_row - 1);
|
||||
} else {
|
||||
x_ofs = w_tot / 2 - w_obj / 2;
|
||||
}
|
||||
@ -559,9 +569,10 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
lv_coord_t act_x = style->body.padding.left;
|
||||
lv_coord_t act_y = style->body.padding.top;
|
||||
uint16_t obj_cnt = 0;
|
||||
LV_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_LL_READ_BACK(cont->child_ll, child)
|
||||
{
|
||||
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false)
|
||||
continue;
|
||||
|
||||
if(obj_row > 1) {
|
||||
lv_obj_set_pos(child, act_x, act_y);
|
||||
@ -589,11 +600,8 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
|
||||
if(ext->fit_left == LV_FIT_NONE &&
|
||||
ext->fit_right == LV_FIT_NONE &&
|
||||
ext->fit_top == LV_FIT_NONE &&
|
||||
ext->fit_bottom == LV_FIT_NONE)
|
||||
{
|
||||
if(ext->fit_left == LV_FIT_NONE && ext->fit_right == LV_FIT_NONE &&
|
||||
ext->fit_top == LV_FIT_NONE && ext->fit_bottom == LV_FIT_NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -623,7 +631,8 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
tight_area.x2 = LV_COORD_MIN;
|
||||
tight_area.y2 = LV_COORD_MIN;
|
||||
|
||||
LV_LL_READ(cont->child_ll, child_i) {
|
||||
LV_LL_READ(cont->child_ll, child_i)
|
||||
{
|
||||
if(lv_obj_get_hidden(child_i) != false) continue;
|
||||
tight_area.x1 = LV_MATH_MIN(tight_area.x1, child_i->coords.x1);
|
||||
tight_area.y1 = LV_MATH_MIN(tight_area.y1, child_i->coords.y1);
|
||||
@ -643,37 +652,42 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
switch(ext->fit_left) {
|
||||
case LV_FIT_TIGHT: new_area.x1 = tight_area.x1; break;
|
||||
case LV_FIT_FLOOD: new_area.x1 = flood_area.x1; break;
|
||||
case LV_FIT_FILL: new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1; break;
|
||||
case LV_FIT_FILL:
|
||||
new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(ext->fit_right) {
|
||||
case LV_FIT_TIGHT: new_area.x2 = tight_area.x2; break;
|
||||
case LV_FIT_FLOOD: new_area.x2 = flood_area.x2; break;
|
||||
case LV_FIT_FILL: new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2; break;
|
||||
case LV_FIT_FILL:
|
||||
new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(ext->fit_top) {
|
||||
case LV_FIT_TIGHT: new_area.y1 = tight_area.y1; break;
|
||||
case LV_FIT_FLOOD: new_area.y1 = flood_area.y1; break;
|
||||
case LV_FIT_FILL: new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1; break;
|
||||
case LV_FIT_FILL:
|
||||
new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(ext->fit_bottom) {
|
||||
case LV_FIT_TIGHT: new_area.y2 = tight_area.y2; break;
|
||||
case LV_FIT_FLOOD: new_area.y2 = flood_area.y2; break;
|
||||
case LV_FIT_FILL: new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2; break;
|
||||
case LV_FIT_FILL:
|
||||
new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
/*Do nothing if the coordinates are not changed*/
|
||||
if(cont->coords.x1 != new_area.x1 ||
|
||||
cont->coords.y1 != new_area.y1 ||
|
||||
cont->coords.x2 != new_area.x2 ||
|
||||
cont->coords.y2 != new_area.y2)
|
||||
{
|
||||
if(cont->coords.x1 != new_area.x1 || cont->coords.y1 != new_area.y1 ||
|
||||
cont->coords.x2 != new_area.x2 || cont->coords.y2 != new_area.y2) {
|
||||
|
||||
lv_obj_invalidate(cont);
|
||||
lv_area_copy(&cont->coords, &new_area);
|
||||
@ -686,11 +700,11 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
|
||||
/*Tell the children the parent's size has changed*/
|
||||
LV_LL_READ(cont->child_ll, child_i) {
|
||||
LV_LL_READ(cont->child_ll, child_i)
|
||||
{
|
||||
child_i->signal_cb(child_i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -32,8 +32,7 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
/*Layout options*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_LAYOUT_OFF = 0,
|
||||
LV_LAYOUT_CENTER,
|
||||
LV_LAYOUT_COL_L, /*Column left align*/
|
||||
@ -47,12 +46,12 @@ enum
|
||||
};
|
||||
typedef uint8_t lv_layout_t;
|
||||
|
||||
|
||||
enum {
|
||||
LV_FIT_NONE, /*Do not change the size automatically*/
|
||||
LV_FIT_TIGHT, /*Involve the children*/
|
||||
LV_FIT_FLOOD, /*Align the size to the parent's edge*/
|
||||
LV_FIT_FILL, /*Align the size to the parent's edge first but if there is an object out of it then involve it*/
|
||||
LV_FIT_FILL, /*Align the size to the parent's edge first but if there is an object out of it
|
||||
then involve it*/
|
||||
};
|
||||
typedef uint8_t lv_fit_t;
|
||||
|
||||
@ -67,7 +66,6 @@ typedef struct
|
||||
uint8_t fit_bottom : 2; /*A fit type from `lv_fit_t` enum */
|
||||
} lv_cont_ext_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -100,7 +98,8 @@ void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout);
|
||||
* @param top bottom fit policy from `lv_fit_t`
|
||||
* @param bottom bottom fit policy from `lv_fit_t`
|
||||
*/
|
||||
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom);
|
||||
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top,
|
||||
lv_fit_t bottom);
|
||||
|
||||
/**
|
||||
* Set the fit policy horizontally and vertically separately.
|
||||
@ -114,7 +113,6 @@ static inline void lv_cont_set_fit2(lv_obj_t * cont, lv_fit_t hor, lv_fit_t ver)
|
||||
lv_cont_set_fit4(cont, hor, hor, ver, ver);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the fit policyin all 4 direction at once.
|
||||
* It tell how to change the container's size automatically.
|
||||
@ -126,7 +124,6 @@ static inline void lv_cont_set_fit(lv_obj_t * cont, lv_fit_t fit)
|
||||
lv_cont_set_fit4(cont, fit, fit, fit, fit);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the style of a container
|
||||
* @param cont pointer to a container object
|
||||
|
@ -3,7 +3,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -65,7 +64,8 @@ static lv_design_cb_t ancestor_design;
|
||||
/**
|
||||
* Create a drop down list objects
|
||||
* @param par pointer to an object, it will be the parent of the new drop down list
|
||||
* @param copy pointer to a drop down list object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a drop down list object, if not NULL then the new object will be copied
|
||||
* from it
|
||||
* @return pointer to the created drop down list
|
||||
*/
|
||||
lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
@ -78,7 +78,8 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(new_ddlist == NULL) return NULL;
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_ddlist);
|
||||
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_func(lv_page_get_scrl(new_ddlist));
|
||||
if(ancestor_scrl_signal == NULL)
|
||||
ancestor_scrl_signal = lv_obj_get_signal_func(lv_page_get_scrl(new_ddlist));
|
||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_ddlist);
|
||||
|
||||
/*Allocate the drop down list type specific extended data*/
|
||||
@ -148,7 +149,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
LV_LOG_INFO("drop down list created");
|
||||
|
||||
|
||||
return new_ddlist;
|
||||
}
|
||||
|
||||
@ -228,7 +228,6 @@ void lv_ddlist_set_fit(lv_obj_t * ddlist, lv_fit_t fit)
|
||||
lv_page_set_scrl_fit2(ddlist, LV_FIT_FLOOD, LV_FIT_NONE);
|
||||
} else {
|
||||
lv_page_set_scrl_fit2(ddlist, LV_FIT_TIGHT, LV_FIT_NONE);
|
||||
|
||||
}
|
||||
|
||||
lv_ddlist_refr_size(ddlist, false);
|
||||
@ -260,7 +259,6 @@ void lv_ddlist_set_stay_open(lv_obj_t * ddlist, bool en)
|
||||
ext->stay_open = en ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the open/close animation time.
|
||||
* @param ddlist pointer to a drop down list
|
||||
@ -287,12 +285,8 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, lv_style_t *
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
switch(type) {
|
||||
case LV_DDLIST_STYLE_BG:
|
||||
lv_page_set_style(ddlist, LV_PAGE_STYLE_BG, style);
|
||||
break;
|
||||
case LV_DDLIST_STYLE_SB:
|
||||
lv_page_set_style(ddlist, LV_PAGE_STYLE_SB, style);
|
||||
break;
|
||||
case LV_DDLIST_STYLE_BG: lv_page_set_style(ddlist, LV_PAGE_STYLE_BG, style); break;
|
||||
case LV_DDLIST_STYLE_SB: lv_page_set_style(ddlist, LV_PAGE_STYLE_SB, style); break;
|
||||
case LV_DDLIST_STYLE_SEL:
|
||||
ext->sel_style = style;
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ddlist);
|
||||
@ -311,7 +305,6 @@ void lv_ddlist_set_align(lv_obj_t *ddlist, lv_label_align_t align)
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
/**
|
||||
* Get the options of a drop down list
|
||||
* @param ddlist pointer to drop down list object
|
||||
@ -350,7 +343,6 @@ void lv_ddlist_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t bu
|
||||
const char * opt_txt = lv_label_get_text(ext->label);
|
||||
uint16_t txt_len = strlen(opt_txt);
|
||||
|
||||
|
||||
for(i = 0; i < txt_len && line != ext->sel_opt_id; i++) {
|
||||
if(opt_txt[i] == '\n') line++;
|
||||
}
|
||||
@ -422,14 +414,10 @@ lv_style_t * lv_ddlist_get_style(const 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;
|
||||
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*/
|
||||
@ -497,15 +485,11 @@ static lv_txt_flag_t lv_ddlist_get_txt_flag(const lv_obj_t *ddlist)
|
||||
|
||||
lv_label_align_t align = lv_label_get_align(ext->label);
|
||||
|
||||
switch(align)
|
||||
{
|
||||
switch(align) {
|
||||
default:
|
||||
case LV_LABEL_ALIGN_LEFT:
|
||||
return LV_TXT_FLAG_NONE;
|
||||
case LV_LABEL_ALIGN_CENTER:
|
||||
return LV_TXT_FLAG_CENTER;
|
||||
case LV_LABEL_ALIGN_RIGHT:
|
||||
return LV_TXT_FLAG_RIGHT;
|
||||
case LV_LABEL_ALIGN_LEFT: return LV_TXT_FLAG_NONE;
|
||||
case LV_LABEL_ALIGN_CENTER: return LV_TXT_FLAG_CENTER;
|
||||
case LV_LABEL_ALIGN_RIGHT: return LV_TXT_FLAG_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -586,11 +570,9 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
}
|
||||
|
||||
/*Add a down symbol in ddlist when closed*/
|
||||
else
|
||||
{
|
||||
else {
|
||||
/*Draw a arrow in ddlist if enabled*/
|
||||
if(ext->draw_arrow)
|
||||
{
|
||||
if(ext->draw_arrow) {
|
||||
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
const lv_font_t * font = style->text.font;
|
||||
lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
@ -601,19 +583,21 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
new_style.text.opa = sel_style->text.opa;
|
||||
lv_area_t area_arrow;
|
||||
area_arrow.x2 = ddlist->coords.x2 - style->body.padding.right;
|
||||
area_arrow.x1 = area_arrow.x2 - lv_txt_get_width(LV_SYMBOL_DOWN, strlen(LV_SYMBOL_DOWN), sel_style->text.font, 0, 0);
|
||||
area_arrow.x1 =
|
||||
area_arrow.x2 - lv_txt_get_width(LV_SYMBOL_DOWN, strlen(LV_SYMBOL_DOWN),
|
||||
sel_style->text.font, 0, 0);
|
||||
|
||||
area_arrow.y1 = ddlist->coords.y1 + style->text.line_space;
|
||||
area_arrow.y2 = area_arrow.y1 + font_h;
|
||||
|
||||
|
||||
lv_area_t mask_arrow;
|
||||
bool area_ok;
|
||||
area_ok = lv_area_intersect(&mask_arrow, mask, &area_arrow);
|
||||
if (area_ok)
|
||||
{
|
||||
lv_draw_label(&area_arrow, &mask_arrow, &new_style, opa_scale,
|
||||
LV_SYMBOL_DOWN, LV_TXT_FLAG_NONE, NULL, -1, -1); /*Use a down arrow in ddlist, you can replace it with your custom symbol*/
|
||||
if(area_ok) {
|
||||
lv_draw_label(&area_arrow, &mask_arrow, &new_style, opa_scale, LV_SYMBOL_DOWN,
|
||||
LV_TXT_FLAG_NONE, NULL, -1,
|
||||
-1); /*Use a down arrow in ddlist, you can replace it with your
|
||||
custom symbol*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -663,22 +647,20 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
ext->opened = false;
|
||||
ext->sel_opt_id = ext->sel_opt_id_ori;
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
|
||||
}
|
||||
} else {
|
||||
/*Open the list if closed*/
|
||||
if(!ext->opened) {
|
||||
ext->opened = true;
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id; /*Save the current value. Used to revert this state if ENER wont't be pressed*/
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id; /*Save the current value. Used to revert this
|
||||
state if ENER wont't be pressed*/
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
release_handler(ddlist);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
if(ext->opened) {
|
||||
ext->opened = false;
|
||||
ext->sel_opt_id = ext->sel_opt_id_ori;
|
||||
@ -753,13 +735,11 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
|
||||
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||
lv_coord_t hpad = LV_MATH_MAX(style->body.padding.left, style->body.padding.right);
|
||||
if(scrl->ext_size < hpad) scrl->ext_size = hpad;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
||||
release_handler(ddlist);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
} 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*/
|
||||
}
|
||||
@ -792,7 +772,8 @@ static lv_res_t release_handler(lv_obj_t * ddlist)
|
||||
}
|
||||
|
||||
/*Search the clicked option (For KEYPAD and ENCODER the new value should be already set)*/
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER ||
|
||||
lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
|
||||
lv_point_t p;
|
||||
lv_indev_get_point(indev, &p);
|
||||
p.y -= ext->label->coords.y1;
|
||||
@ -807,7 +788,8 @@ static lv_res_t release_handler(lv_obj_t * ddlist)
|
||||
uint32_t letter;
|
||||
for(line_cnt = 0; line_cnt < letter_i; line_cnt++) {
|
||||
letter = lv_txt_encoded_next(txt, &i);
|
||||
/*Count he lines to reach the clicked letter. But ignore the last '\n' because it still belongs to the clicked line*/
|
||||
/*Count he lines to reach the clicked letter. But ignore the last '\n' because it
|
||||
* still belongs to the clicked line*/
|
||||
if(letter == '\n' && i != letter_i) new_opt++;
|
||||
}
|
||||
|
||||
@ -829,7 +811,6 @@ static lv_res_t release_handler(lv_obj_t * ddlist)
|
||||
}
|
||||
|
||||
return LV_RES_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -846,9 +827,11 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
lv_style_t * style = lv_obj_get_style(ddlist);
|
||||
lv_coord_t new_height;
|
||||
if(ext->opened) { /*Open the list*/
|
||||
if(ext->fix_height == 0) new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) +
|
||||
style->body.padding.top + style->body.padding.bottom;
|
||||
else new_height = ext->fix_height;
|
||||
if(ext->fix_height == 0)
|
||||
new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + style->body.padding.top +
|
||||
style->body.padding.bottom;
|
||||
else
|
||||
new_height = ext->fix_height;
|
||||
|
||||
} else { /*Close the list*/
|
||||
const lv_font_t * font = style->text.font;
|
||||
@ -864,7 +847,8 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
lv_ddlist_pos_current_option(ddlist);
|
||||
if(ext->opened) lv_page_set_sb_mode(ddlist, LV_SB_MODE_UNHIDE);
|
||||
#if LV_USE_ANIMATION
|
||||
lv_anim_del(ddlist, (lv_anim_fp_t)lv_obj_set_height); /*If an animation is in progress then it will overwrite this changes*/
|
||||
lv_anim_del(ddlist, (lv_anim_fp_t)lv_obj_set_height); /*If an animation is in progress then
|
||||
it will overwrite this changes*/
|
||||
} else {
|
||||
lv_anim_t a;
|
||||
a.var = ddlist;
|
||||
@ -891,7 +875,8 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
* Called at end of list animation.
|
||||
* @param ddlist pointer to a drop down list
|
||||
*/
|
||||
static void lv_ddlist_anim_cb(lv_obj_t * ddlist) {
|
||||
static void lv_ddlist_anim_cb(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
lv_ddlist_pos_current_option(ddlist);
|
||||
@ -907,7 +892,8 @@ static void lv_ddlist_anim_cb(lv_obj_t * ddlist) {
|
||||
* @param ddlist Drop down list object
|
||||
* @param height New drop down list height
|
||||
*/
|
||||
static void lv_ddlist_adjust_height(lv_obj_t * ddlist, int32_t height) {
|
||||
static void lv_ddlist_adjust_height(lv_obj_t * ddlist, int32_t height)
|
||||
{
|
||||
lv_obj_set_height(ddlist, height);
|
||||
lv_ddlist_pos_current_option(ddlist);
|
||||
}
|
||||
@ -926,10 +912,10 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist)
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ddlist);
|
||||
|
||||
lv_coord_t h = lv_obj_get_height(ddlist);
|
||||
lv_coord_t line_y1 = ext->sel_opt_id * (font_h + label_style->text.line_space) + ext->label->coords.y1 - scrl->coords.y1;
|
||||
lv_coord_t line_y1 = ext->sel_opt_id * (font_h + label_style->text.line_space) +
|
||||
ext->label->coords.y1 - scrl->coords.y1;
|
||||
|
||||
lv_obj_set_y(scrl, -line_y1 + (h - font_h) / 2);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -72,7 +72,8 @@ typedef uint8_t lv_ddlist_style_t;
|
||||
/**
|
||||
* Create a drop down list objects
|
||||
* @param par pointer to an object, it will be the parent of the new drop down list
|
||||
* @param copy pointer to a drop down list object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a drop down list object, if not NULL then the new object will be copied
|
||||
* from it
|
||||
* @return pointer to the created drop down list
|
||||
*/
|
||||
lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
@ -103,7 +104,6 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
|
||||
*/
|
||||
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h);
|
||||
|
||||
|
||||
/**
|
||||
* Enable or disable the horizontal fit to the content
|
||||
* @param ddlist pointer to a drop down list
|
||||
@ -142,7 +142,6 @@ static inline void lv_ddlist_set_sb_mode(lv_obj_t * ddlist, lv_sb_mode_t mode)
|
||||
*/
|
||||
void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time);
|
||||
|
||||
|
||||
/**
|
||||
* Set a style of a drop down list
|
||||
* @param ddlist pointer to a drop down list object
|
||||
@ -162,7 +161,6 @@ void lv_ddlist_set_align(lv_obj_t *ddlist, lv_label_align_t align);
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
/**
|
||||
* Get the options of a drop down list
|
||||
* @param ddlist pointer to drop down list object
|
||||
|
@ -3,7 +3,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -88,7 +87,8 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new gauge gauge*/
|
||||
if(copy == NULL) {
|
||||
lv_gauge_set_scale(new_gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT, LV_GAUGE_DEF_LABEL_COUNT);
|
||||
lv_gauge_set_scale(new_gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT,
|
||||
LV_GAUGE_DEF_LABEL_COUNT);
|
||||
lv_gauge_set_needle_count(new_gauge, 1, NULL);
|
||||
lv_gauge_set_critical_value(new_gauge, 80);
|
||||
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
|
||||
@ -170,26 +170,26 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int16_t value)
|
||||
if(needle_id >= ext->needle_count) return;
|
||||
if(ext->values[needle_id] == value) return;
|
||||
|
||||
|
||||
int16_t min = lv_gauge_get_min_value(gauge);
|
||||
int16_t max = lv_gauge_get_max_value(gauge);
|
||||
|
||||
if(value > max) value = max;
|
||||
else if(value < min) value = min;
|
||||
if(value > max)
|
||||
value = max;
|
||||
else if(value < min)
|
||||
value = min;
|
||||
|
||||
ext->values[needle_id] = value;
|
||||
|
||||
|
||||
lv_obj_invalidate(gauge);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the scale settings of a gauge
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param angle angle of the scale (0..360)
|
||||
* @param line_cnt count of scale lines.
|
||||
* The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) * (label_cnt - 1) + 1
|
||||
* The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) * (label_cnt - 1) +
|
||||
* 1
|
||||
* @param label_cnt count of scale labels.
|
||||
*/
|
||||
void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt)
|
||||
@ -350,7 +350,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
lv_style_t * style = lv_obj_get_style(gauge);
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(gauge);
|
||||
lv_coord_t r = lv_obj_get_width(gauge) / 2 - (3 * style->body.padding.left) - style->body.padding.inner;
|
||||
lv_coord_t r =
|
||||
lv_obj_get_width(gauge) / 2 - (3 * style->body.padding.left) - style->body.padding.inner;
|
||||
lv_coord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1;
|
||||
lv_coord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1;
|
||||
int16_t scale_angle = lv_lmeter_get_scale_angle(gauge);
|
||||
@ -376,8 +377,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
/*Draw the label*/
|
||||
label_cord.x1 = x - label_size.x / 2;
|
||||
@ -385,7 +386,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
label_cord.x2 = label_cord.x1 + label_size.x;
|
||||
label_cord.y2 = label_cord.y1 + label_size.y;
|
||||
|
||||
lv_draw_label(&label_cord, mask, style, opa_scale, scale_txt, LV_TXT_FLAG_NONE, NULL, -1, -1);
|
||||
lv_draw_label(&label_cord, mask, style, opa_scale, scale_txt, LV_TXT_FLAG_NONE, NULL, -1,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -419,13 +421,12 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
p_mid.y = y_ofs;
|
||||
for(i = 0; i < ext->needle_count; i++) {
|
||||
/*Calculate the end point of a needle*/
|
||||
int16_t needle_angle = (ext->values[i] - min) * angle * (1 << LV_GAUGE_INTERPOLATE_SHIFT) / (max - min); //+ angle_ofs;
|
||||
|
||||
int16_t needle_angle = (ext->values[i] - min) * angle * (1 << LV_GAUGE_INTERPOLATE_SHIFT) /
|
||||
(max - min); //+ angle_ofs;
|
||||
|
||||
int16_t needle_angle_low = (needle_angle >> LV_GAUGE_INTERPOLATE_SHIFT) + angle_ofs;
|
||||
int16_t needle_angle_high = needle_angle_low + 1;
|
||||
|
||||
|
||||
p_end_low.y = (lv_trigo_sin(needle_angle_low) * r) / LV_TRIGO_SIN_MAX + y_ofs;
|
||||
p_end_low.x = (lv_trigo_sin(needle_angle_low + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
|
||||
|
||||
@ -433,8 +434,10 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
p_end_high.x = (lv_trigo_sin(needle_angle_high + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
|
||||
|
||||
uint16_t rem = needle_angle & ((1 << LV_GAUGE_INTERPOLATE_SHIFT) - 1);
|
||||
int16_t x_mod = ((LV_MATH_ABS(p_end_high.x - p_end_low.x)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT;
|
||||
int16_t y_mod = ((LV_MATH_ABS(p_end_high.y - p_end_low.y)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT;
|
||||
int16_t x_mod =
|
||||
((LV_MATH_ABS(p_end_high.x - p_end_low.x)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT;
|
||||
int16_t y_mod =
|
||||
((LV_MATH_ABS(p_end_high.y - p_end_low.y)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT;
|
||||
|
||||
if(p_end_high.x < p_end_low.x) x_mod = -x_mod;
|
||||
if(p_end_high.y < p_end_low.y) y_mod = -y_mod;
|
||||
@ -443,8 +446,10 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask)
|
||||
p_end.y = p_end_low.y + y_mod;
|
||||
|
||||
/*Draw the needle with the corresponding color*/
|
||||
if(ext->needle_colors == NULL) style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR;
|
||||
else style_needle.line.color = ext->needle_colors[i];
|
||||
if(ext->needle_colors == NULL)
|
||||
style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR;
|
||||
else
|
||||
style_needle.line.color = ext->needle_colors[i];
|
||||
|
||||
lv_draw_line(&p_mid, &p_end, mask, &style_needle, opa_scale);
|
||||
}
|
||||
|
@ -108,7 +108,8 @@ static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int16_t value)
|
||||
* @param gauge pointer to a gauge object
|
||||
* @param angle angle of the scale (0..360)
|
||||
* @param line_cnt count of scale lines.
|
||||
* The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) * (label_cnt - 1) + 1
|
||||
* The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) * (label_cnt - 1) +
|
||||
* 1
|
||||
* @param label_cnt count of scale labels.
|
||||
*/
|
||||
void lv_gauge_set_scale(lv_obj_t * gauge, uint16_t angle, uint8_t line_cnt, uint8_t label_cnt);
|
||||
|
@ -79,7 +79,6 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->offset.x = 0;
|
||||
ext->offset.y = 0;
|
||||
|
||||
|
||||
/*Init the new object*/
|
||||
lv_obj_set_signal_cb(new_img, lv_img_signal);
|
||||
lv_obj_set_design_cb(new_img, lv_img_design);
|
||||
@ -105,18 +104,15 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_refresh_style(new_img);
|
||||
}
|
||||
|
||||
|
||||
LV_LOG_INFO("image created");
|
||||
|
||||
return new_img;
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
/**
|
||||
* Set the pixel map to display by the image
|
||||
* @param img pointer to an image object
|
||||
@ -129,17 +125,14 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||
|
||||
#if LV_USE_LOG && LV_LOG_LEVEL >= LV_LOG_LEVEL_INFO
|
||||
switch(src_type) {
|
||||
case LV_IMG_SRC_FILE:
|
||||
LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_FILE` type found");
|
||||
break;
|
||||
case LV_IMG_SRC_FILE: LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_FILE` type found"); break;
|
||||
case LV_IMG_SRC_VARIABLE:
|
||||
LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_VARIABLE` type found");
|
||||
break;
|
||||
case LV_IMG_SRC_SYMBOL:
|
||||
LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_SYMBOL` type found");
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("lv_img_set_src: unknown type");
|
||||
default: LV_LOG_WARN("lv_img_set_src: unknown type");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -157,8 +150,6 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||
lv_img_header_t header;
|
||||
lv_img_dsc_get_info(src_img, &header);
|
||||
|
||||
|
||||
|
||||
/*Save the source*/
|
||||
if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||
LV_LOG_INFO("lv_img_set_src: `LV_IMG_SRC_VARIABLE` type found");
|
||||
@ -187,7 +178,8 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||
/*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/
|
||||
lv_style_t * style = lv_img_get_style(img);
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space,
|
||||
style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
header.w = size.x;
|
||||
header.h = size.y;
|
||||
}
|
||||
@ -249,7 +241,6 @@ void lv_img_set_offset_x(lv_obj_t *img, lv_coord_t x)
|
||||
ext->offset.x = x;
|
||||
lv_obj_invalidate(img);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -272,7 +263,6 @@ void lv_img_set_offset_y(lv_obj_t *img, lv_coord_t y)
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
/**
|
||||
* Get the source of the image
|
||||
* @param img pointer to an image object
|
||||
@ -294,8 +284,10 @@ const char * lv_img_get_file_name(const lv_obj_t * img)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
if(ext->src_type == LV_IMG_SRC_FILE) return ext->src;
|
||||
else return "";
|
||||
if(ext->src_type == LV_IMG_SRC_FILE)
|
||||
return ext->src;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -357,7 +349,8 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
bool cover = false;
|
||||
if(ext->src_type == LV_IMG_SRC_UNKNOWN || ext->src_type == LV_IMG_SRC_SYMBOL) return false;
|
||||
|
||||
if(ext->cf == LV_IMG_CF_TRUE_COLOR || ext->cf == LV_IMG_CF_RAW) cover = lv_area_is_in(mask, &img->coords);
|
||||
if(ext->cf == LV_IMG_CF_TRUE_COLOR || ext->cf == LV_IMG_CF_RAW)
|
||||
cover = lv_area_is_in(mask, &img->coords);
|
||||
|
||||
return cover;
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
@ -388,7 +381,8 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
lv_style_t style_mod;
|
||||
lv_style_copy(&style_mod, style);
|
||||
style_mod.text.color = style->image.color;
|
||||
lv_draw_label(&coords, mask, &style_mod, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL, -1, -1);
|
||||
lv_draw_label(&coords, mask, &style_mod, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL,
|
||||
-1, -1);
|
||||
} else {
|
||||
/*Trigger the error handler of image drawer*/
|
||||
LV_LOG_WARN("lv_img_design: image source type is unknown");
|
||||
@ -399,7 +393,6 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signal function of the image
|
||||
* @param img pointer to an image object
|
||||
@ -426,7 +419,6 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
||||
/*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) {
|
||||
lv_obj_type_t * buf = param;
|
||||
|
@ -41,7 +41,8 @@ static lv_design_cb_t ancestor_design;
|
||||
/**
|
||||
* Create a image button object
|
||||
* @param par pointer to an object, it will be the parent of the new image button
|
||||
* @param copy pointer to a image button object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a image button object, if not NULL then the new object will be copied from
|
||||
* it
|
||||
* @return pointer to the created image button
|
||||
*/
|
||||
lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
@ -123,11 +124,15 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src
|
||||
* Set images for a state of the image button
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param state for which state set the new image (from `lv_btn_state_t`) `
|
||||
* @param src_left pointer to an image source for the left side of the button (a C array or path to a file)
|
||||
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C array or path to a file)
|
||||
* @param src_right pointer to an image source for the right side of the button (a C array or path to a file)
|
||||
* @param src_left pointer to an image source for the left side of the button (a C array or path to
|
||||
* a file)
|
||||
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C
|
||||
* array or path to a file)
|
||||
* @param src_right pointer to an image source for the right side of the button (a C array or path
|
||||
* to a file)
|
||||
*/
|
||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid, const void * src_right)
|
||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left,
|
||||
const void * src_mid, const void * src_right)
|
||||
{
|
||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||
|
||||
@ -314,13 +319,11 @@ static bool lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * mask, lv_desig
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -342,8 +345,8 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/* If the style changed then the button was clicked, released etc. so probably the state was changed as well
|
||||
* Set the new image for the new state.*/
|
||||
/* If the style changed then the button was clicked, released etc. so probably the state was
|
||||
* changed as well Set the new image for the new state.*/
|
||||
refr_img(imgbtn);
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
@ -359,7 +362,6 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static void refr_img(lv_obj_t * imgbtn)
|
||||
{
|
||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||
|
@ -38,7 +38,8 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of image button*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
lv_btn_ext_t btn; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
#if LV_IMGBTN_TILED == 0
|
||||
@ -51,7 +52,6 @@ typedef struct {
|
||||
lv_img_cf_t act_cf; /*Color format of the currently active image*/
|
||||
} lv_imgbtn_ext_t;
|
||||
|
||||
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_IMGBTN_STYLE_REL,
|
||||
@ -62,7 +62,6 @@ enum {
|
||||
};
|
||||
typedef uint8_t lv_imgbtn_style_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -70,7 +69,8 @@ typedef uint8_t lv_imgbtn_style_t;
|
||||
/**
|
||||
* Create a image button objects
|
||||
* @param par pointer to an object, it will be the parent of the new image button
|
||||
* @param copy pointer to a image button object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a image button object, if not NULL then the new object will be copied from
|
||||
* it
|
||||
* @return pointer to the created image button
|
||||
*/
|
||||
lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
@ -79,7 +79,6 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
@ -97,11 +96,15 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src
|
||||
* Set images for a state of the image button
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param state for which state set the new image (from `lv_btn_state_t`) `
|
||||
* @param src_left pointer to an image source for the left side of the button (a C array or path to a file)
|
||||
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C array or path to a file)
|
||||
* @param src_right pointer to an image source for the right side of the button (a C array or path to a file)
|
||||
* @param src_left pointer to an image source for the left side of the button (a C array or path to
|
||||
* a file)
|
||||
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C
|
||||
* array or path to a file)
|
||||
* @param src_right pointer to an image source for the right side of the button (a C array or path
|
||||
* to a file)
|
||||
*/
|
||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid, const void * src_right);
|
||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left,
|
||||
const void * src_mid, const void * src_right);
|
||||
|
||||
#endif
|
||||
|
||||
@ -146,7 +149,6 @@ void lv_imgbtn_set_style(lv_obj_t * imgbtn, lv_imgbtn_style_t type, lv_style_t *
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
#if LV_IMGBTN_TILED == 0
|
||||
/**
|
||||
* Get the images in a given state
|
||||
|
@ -31,61 +31,182 @@ static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param);
|
||||
**********************/
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
|
||||
static const char * kb_map_lc[] = {
|
||||
"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "Bksp", "\n",
|
||||
"ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", "Enter", "\n",
|
||||
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
|
||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""
|
||||
};
|
||||
static const char * kb_map_lc[] = {"1#",
|
||||
"q",
|
||||
"w",
|
||||
"e",
|
||||
"r",
|
||||
"t",
|
||||
"y",
|
||||
"u",
|
||||
"i",
|
||||
"o",
|
||||
"p",
|
||||
"Bksp",
|
||||
"\n",
|
||||
"ABC",
|
||||
"a",
|
||||
"s",
|
||||
"d",
|
||||
"f",
|
||||
"g",
|
||||
"h",
|
||||
"j",
|
||||
"k",
|
||||
"l",
|
||||
"Enter",
|
||||
"\n",
|
||||
"_",
|
||||
"-",
|
||||
"z",
|
||||
"x",
|
||||
"c",
|
||||
"v",
|
||||
"b",
|
||||
"n",
|
||||
"m",
|
||||
".",
|
||||
",",
|
||||
":",
|
||||
"\n",
|
||||
LV_SYMBOL_CLOSE,
|
||||
LV_SYMBOL_LEFT,
|
||||
" ",
|
||||
LV_SYMBOL_RIGHT,
|
||||
LV_SYMBOL_OK,
|
||||
""};
|
||||
|
||||
static const lv_btnm_ctrl_t kb_ctrl_lc_map[] = {
|
||||
5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
|
||||
(6 | LV_BTNM_CTRL_NO_REPEAT), 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 6, 2, 2
|
||||
};
|
||||
5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, (6 | LV_BTNM_CTRL_NO_REPEAT),
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 6, 2,
|
||||
2};
|
||||
|
||||
static const char * kb_map_uc[] = {
|
||||
"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "Bksp", "\n",
|
||||
"abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Enter", "\n",
|
||||
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
|
||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""
|
||||
};
|
||||
static const char * kb_map_uc[] = {"1#",
|
||||
"Q",
|
||||
"W",
|
||||
"E",
|
||||
"R",
|
||||
"T",
|
||||
"Y",
|
||||
"U",
|
||||
"I",
|
||||
"O",
|
||||
"P",
|
||||
"Bksp",
|
||||
"\n",
|
||||
"abc",
|
||||
"A",
|
||||
"S",
|
||||
"D",
|
||||
"F",
|
||||
"G",
|
||||
"H",
|
||||
"J",
|
||||
"K",
|
||||
"L",
|
||||
"Enter",
|
||||
"\n",
|
||||
"_",
|
||||
"-",
|
||||
"Z",
|
||||
"X",
|
||||
"C",
|
||||
"V",
|
||||
"B",
|
||||
"N",
|
||||
"M",
|
||||
".",
|
||||
",",
|
||||
":",
|
||||
"\n",
|
||||
LV_SYMBOL_CLOSE,
|
||||
LV_SYMBOL_LEFT,
|
||||
" ",
|
||||
LV_SYMBOL_RIGHT,
|
||||
LV_SYMBOL_OK,
|
||||
""};
|
||||
|
||||
static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = {
|
||||
5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
|
||||
(6 | LV_BTNM_CTRL_NO_REPEAT), 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 6, 2, 2
|
||||
};
|
||||
5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, (6 | LV_BTNM_CTRL_NO_REPEAT),
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 6, 2,
|
||||
2};
|
||||
|
||||
static const char * kb_map_spec[] = {
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Bksp", "\n",
|
||||
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
||||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""
|
||||
};
|
||||
static const char * kb_map_spec[] = {"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"Bksp",
|
||||
"\n",
|
||||
"abc",
|
||||
"+",
|
||||
"-",
|
||||
"/",
|
||||
"*",
|
||||
"=",
|
||||
"%",
|
||||
"!",
|
||||
"?",
|
||||
"#",
|
||||
"<",
|
||||
">",
|
||||
"\n",
|
||||
"\\",
|
||||
"@",
|
||||
"$",
|
||||
"(",
|
||||
")",
|
||||
"{",
|
||||
"}",
|
||||
"[",
|
||||
"]",
|
||||
";",
|
||||
"\"",
|
||||
"'",
|
||||
"\n",
|
||||
LV_SYMBOL_CLOSE,
|
||||
LV_SYMBOL_LEFT,
|
||||
" ",
|
||||
LV_SYMBOL_RIGHT,
|
||||
LV_SYMBOL_OK,
|
||||
""};
|
||||
|
||||
static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
|
||||
(2 | LV_BTNM_CTRL_NO_REPEAT), 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, (2 | LV_BTNM_CTRL_NO_REPEAT),
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
2, 2, 6, 2, 2
|
||||
};
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
|
||||
2, 6, 2, 2};
|
||||
|
||||
static const char * kb_map_num[] = {
|
||||
"1", "2", "3", "\202"LV_SYMBOL_CLOSE, "\n",
|
||||
"4", "5", "6", "\202"LV_SYMBOL_OK, "\n",
|
||||
"7", "8", "9", "\202Bksp", "\n",
|
||||
"+/-", "0", ".", LV_SYMBOL_LEFT, LV_SYMBOL_RIGHT, ""
|
||||
};
|
||||
static const char * kb_map_num[] = {"1",
|
||||
"2",
|
||||
"3",
|
||||
"\202" LV_SYMBOL_CLOSE,
|
||||
"\n",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"\202" LV_SYMBOL_OK,
|
||||
"\n",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"\202Bksp",
|
||||
"\n",
|
||||
"+/-",
|
||||
"0",
|
||||
".",
|
||||
LV_SYMBOL_LEFT,
|
||||
LV_SYMBOL_RIGHT,
|
||||
""};
|
||||
|
||||
static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {
|
||||
1, 1, 1, 2,
|
||||
1, 1, 1, 2,
|
||||
1, 1, 1, 2,
|
||||
1, 1, 1, 1, 1
|
||||
};
|
||||
static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1};
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -158,10 +279,8 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_refresh_style(new_kb);
|
||||
}
|
||||
|
||||
|
||||
LV_LOG_INFO("keyboard created");
|
||||
|
||||
|
||||
return new_kb;
|
||||
}
|
||||
|
||||
@ -208,14 +327,12 @@ void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode)
|
||||
if(mode == LV_KB_MODE_TEXT) {
|
||||
lv_btnm_set_map(kb, kb_map_lc);
|
||||
lv_btnm_set_ctrl_map(kb, kb_ctrl_lc_map);
|
||||
}
|
||||
else if(mode == LV_KB_MODE_NUM) {
|
||||
} else if(mode == LV_KB_MODE_NUM) {
|
||||
lv_btnm_set_map(kb, kb_map_num);
|
||||
lv_btnm_set_ctrl_map(kb, kb_ctrl_num_map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Automatically hide or show the cursor of Text Area
|
||||
* @param kb pointer to a Keyboard object
|
||||
@ -249,24 +366,14 @@ void lv_kb_set_cursor_manage(lv_obj_t * kb, bool en)
|
||||
void lv_kb_set_style(lv_obj_t * kb, lv_kb_style_t type, lv_style_t * style)
|
||||
{
|
||||
switch(type) {
|
||||
case LV_KB_STYLE_BG:
|
||||
lv_btnm_set_style(kb, LV_BTNM_STYLE_BG, style);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_REL:
|
||||
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_REL, style);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_PR:
|
||||
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_PR, style);
|
||||
break;
|
||||
case LV_KB_STYLE_BG: lv_btnm_set_style(kb, LV_BTNM_STYLE_BG, style); break;
|
||||
case LV_KB_STYLE_BTN_REL: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_REL, style); break;
|
||||
case LV_KB_STYLE_BTN_PR: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_PR, style); break;
|
||||
case LV_KB_STYLE_BTN_TGL_REL:
|
||||
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_TGL_REL, style);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_TGL_PR:
|
||||
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_TGL_PR, style);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_INA:
|
||||
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_INA, style);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_TGL_PR: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_TGL_PR, style); break;
|
||||
case LV_KB_STYLE_BTN_INA: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_INA, style); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,7 +403,6 @@ lv_kb_mode_t lv_kb_get_mode(const lv_obj_t * kb)
|
||||
return ext->mode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current cursor manage mode.
|
||||
* @param kb pointer to a Keyboard object
|
||||
@ -319,27 +425,15 @@ lv_style_t * lv_kb_get_style(const lv_obj_t * kb, lv_kb_style_t type)
|
||||
lv_style_t * style = NULL;
|
||||
|
||||
switch(type) {
|
||||
case LV_KB_STYLE_BG:
|
||||
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BG);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_REL:
|
||||
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_REL);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_PR:
|
||||
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_PR);
|
||||
break;
|
||||
case LV_KB_STYLE_BG: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BG); break;
|
||||
case LV_KB_STYLE_BTN_REL: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_REL); break;
|
||||
case LV_KB_STYLE_BTN_PR: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_PR); break;
|
||||
case LV_KB_STYLE_BTN_TGL_REL:
|
||||
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_REL);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_TGL_PR:
|
||||
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_PR);
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_INA:
|
||||
style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_INA);
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_KB_STYLE_BTN_TGL_PR: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_PR); break;
|
||||
case LV_KB_STYLE_BTN_INA: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_INA); break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -351,7 +445,8 @@ lv_style_t * lv_kb_get_style(const lv_obj_t * kb, lv_kb_style_t type)
|
||||
|
||||
/**
|
||||
* Default keyboard event to add characters to the Text area and change the map.
|
||||
* If a custom `event_cb` is added to the keyboard this function be called from it to handle the button clicks
|
||||
* If a custom `event_cb` is added to the keyboard this function be called from it to handle the
|
||||
* button clicks
|
||||
* @param kb pointer to a keyboard
|
||||
* @param event the triggering event
|
||||
*/
|
||||
@ -363,7 +458,9 @@ void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event)
|
||||
uint16_t btn_id = lv_btnm_get_active_btn(kb);
|
||||
if(btn_id == LV_BTNM_BTN_NONE) return;
|
||||
if(lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_HIDDEN | LV_BTNM_CTRL_INACTIVE)) return;
|
||||
if(lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return;
|
||||
if(lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) &&
|
||||
event == LV_EVENT_LONG_PRESSED_REPEAT)
|
||||
return;
|
||||
|
||||
const char * txt = lv_btnm_get_active_btn_text(kb);
|
||||
if(txt == NULL) return;
|
||||
@ -384,25 +481,30 @@ void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event)
|
||||
} else if(strcmp(txt, LV_SYMBOL_CLOSE) == 0) {
|
||||
if(kb->event_cb) {
|
||||
lv_event_send(kb, LV_EVENT_CANCEL, NULL);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
||||
lv_obj_del(kb);
|
||||
}
|
||||
return;
|
||||
} else if(strcmp(txt, LV_SYMBOL_OK) == 0) {
|
||||
if(kb->event_cb) lv_event_send(kb, LV_EVENT_APPLY, NULL);
|
||||
else lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
||||
if(kb->event_cb)
|
||||
lv_event_send(kb, LV_EVENT_APPLY, NULL);
|
||||
else
|
||||
lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*Add the characters to the text area if set*/
|
||||
if(ext->ta == NULL) return;
|
||||
|
||||
if(strcmp(txt, "Enter") == 0)lv_ta_add_char(ext->ta, '\n');
|
||||
else if(strcmp(txt, LV_SYMBOL_LEFT) == 0) lv_ta_cursor_left(ext->ta);
|
||||
else if(strcmp(txt, LV_SYMBOL_RIGHT) == 0) lv_ta_cursor_right(ext->ta);
|
||||
else if(strcmp(txt, "Bksp") == 0) lv_ta_del_char(ext->ta);
|
||||
if(strcmp(txt, "Enter") == 0)
|
||||
lv_ta_add_char(ext->ta, '\n');
|
||||
else if(strcmp(txt, LV_SYMBOL_LEFT) == 0)
|
||||
lv_ta_cursor_left(ext->ta);
|
||||
else if(strcmp(txt, LV_SYMBOL_RIGHT) == 0)
|
||||
lv_ta_cursor_right(ext->ta);
|
||||
else if(strcmp(txt, "Bksp") == 0)
|
||||
lv_ta_del_char(ext->ta);
|
||||
else if(strcmp(txt, "+/-") == 0) {
|
||||
uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
|
||||
const char * ta_txt = lv_ta_get_text(ext->ta);
|
||||
@ -447,24 +549,21 @@ 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_FOCUS) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
/*Show the cursor of the new Text area if cursor management is enabled*/
|
||||
if(ext->ta && ext->cursor_mng) {
|
||||
lv_cursor_type_t cur_type = lv_ta_get_cursor_type(ext->ta);
|
||||
lv_ta_set_cursor_type(ext->ta, cur_type & (~LV_CURSOR_HIDDEN));
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
/*Show the cursor of the new Text area if cursor management is enabled*/
|
||||
if(ext->ta && ext->cursor_mng) {
|
||||
lv_cursor_type_t cur_type = lv_ta_get_cursor_type(ext->ta);
|
||||
lv_ta_set_cursor_type(ext->ta, cur_type | LV_CURSOR_HIDDEN);
|
||||
}
|
||||
}
|
||||
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*/
|
||||
|
@ -48,12 +48,14 @@ enum {
|
||||
typedef uint8_t lv_kb_mode_t;
|
||||
|
||||
/*Data of keyboard*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
lv_btnm_ext_t btnm; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_obj_t * ta; /*Pointer to the assigned text area*/
|
||||
lv_kb_mode_t mode; /*Key map type*/
|
||||
uint8_t cursor_mng :1; /*1: automatically show/hide cursor when a text area is assigned or left*/
|
||||
uint8_t
|
||||
cursor_mng : 1; /*1: automatically show/hide cursor when a text area is assigned or left*/
|
||||
} lv_kb_ext_t;
|
||||
|
||||
enum {
|
||||
@ -66,7 +68,6 @@ enum {
|
||||
};
|
||||
typedef uint8_t lv_kb_style_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -175,7 +176,8 @@ lv_style_t * lv_kb_get_style(const lv_obj_t *kb, lv_kb_style_t type);
|
||||
|
||||
/**
|
||||
* Default keyboard event to add characters to the Text area and change the map.
|
||||
* If a custom `event_cb` is added to the keyboard this function be called from it to handle the button clicks
|
||||
* If a custom `event_cb` is added to the keyboard this function be called from it to handle the
|
||||
* button clicks
|
||||
* @param kb pointer to a keyboard
|
||||
* @param event the triggering event
|
||||
*/
|
||||
|
@ -20,7 +20,8 @@
|
||||
*********************/
|
||||
/*Test configurations*/
|
||||
#ifndef LV_LABEL_SCROLL_SPEED
|
||||
#define LV_LABEL_DEF_SCROLL_SPEED (25) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
|
||||
#define LV_LABEL_DEF_SCROLL_SPEED \
|
||||
(25) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
|
||||
#endif
|
||||
|
||||
#define ANIM_WAIT_CHAR_COUNT 3
|
||||
@ -110,8 +111,10 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_label_set_recolor(new_label, lv_label_get_recolor(copy));
|
||||
lv_label_set_body_draw(new_label, lv_label_get_body_draw(copy));
|
||||
lv_label_set_align(new_label, lv_label_get_align(copy));
|
||||
if(copy_ext->static_txt == 0) lv_label_set_text(new_label, lv_label_get_text(copy));
|
||||
else lv_label_set_static_text(new_label, lv_label_get_text(copy));
|
||||
if(copy_ext->static_txt == 0)
|
||||
lv_label_set_text(new_label, lv_label_get_text(copy));
|
||||
else
|
||||
lv_label_set_static_text(new_label, lv_label_get_text(copy));
|
||||
|
||||
/*In DOT mode save the text byte-to-byte because a '\0' can be in the middle*/
|
||||
if(copy_ext->long_mode == LV_LABEL_LONG_DOT) {
|
||||
@ -128,7 +131,6 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_refresh_style(new_label);
|
||||
}
|
||||
|
||||
|
||||
LV_LOG_INFO("label created");
|
||||
|
||||
return new_label;
|
||||
@ -240,7 +242,8 @@ void lv_label_set_static_text(lv_obj_t * label, const char * text)
|
||||
* Set the behavior of the label with longer text then the object size
|
||||
* @param label pointer to a label object
|
||||
* @param long_mode the new mode from 'lv_label_long_mode' enum.
|
||||
* In LV_LONG_BREAK/LONG/ROLL the size of the label should be set AFTER this function
|
||||
* In LV_LONG_BREAK/LONG/ROLL the size of the label should be set AFTER this
|
||||
* function
|
||||
*/
|
||||
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
||||
{
|
||||
@ -256,8 +259,11 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
||||
ext->offset.x = 0;
|
||||
ext->offset.y = 0;
|
||||
|
||||
if(long_mode == LV_LABEL_LONG_ROLL || long_mode == LV_LABEL_LONG_ROLL_CIRC || long_mode == LV_LABEL_LONG_CROP) ext->expand = 1;
|
||||
else ext->expand = 0;
|
||||
if(long_mode == LV_LABEL_LONG_ROLL || long_mode == LV_LABEL_LONG_ROLL_CIRC ||
|
||||
long_mode == LV_LABEL_LONG_CROP)
|
||||
ext->expand = 1;
|
||||
else
|
||||
ext->expand = 0;
|
||||
|
||||
/*Restore the character under the dots*/
|
||||
if(ext->long_mode == LV_LABEL_LONG_DOT && ext->dot_end != LV_LABEL_DOT_END_INV) {
|
||||
@ -280,7 +286,8 @@ void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
|
||||
|
||||
ext->align = align;
|
||||
|
||||
lv_obj_invalidate(label); /*Enough to invalidate because alignment is only drawing related (lv_refr_label_text() not required)*/
|
||||
lv_obj_invalidate(label); /*Enough to invalidate because alignment is only drawing related
|
||||
(lv_refr_label_text() not required)*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -295,7 +302,8 @@ void lv_label_set_recolor(lv_obj_t * label, bool en)
|
||||
|
||||
ext->recolor = en == false ? 0 : 1;
|
||||
|
||||
lv_label_refr_text(label); /*Refresh the text because the potential colo codes in text needs to be hided or revealed*/
|
||||
lv_label_refr_text(label); /*Refresh the text because the potential colo codes in text needs to
|
||||
be hided or revealed*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -406,7 +414,8 @@ uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
|
||||
/**
|
||||
* Get the relative x and y coordinates of a letter
|
||||
* @param label pointer to a label object
|
||||
* @param index index of the letter [0 ... text length]. Expressed in character index, not byte index (different in UTF-8)
|
||||
* @param index index of the letter [0 ... text length]. Expressed in character index, not byte
|
||||
* index (different in UTF-8)
|
||||
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
|
||||
*/
|
||||
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos)
|
||||
@ -435,8 +444,10 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
|
||||
|
||||
/*Search the line of the index letter */;
|
||||
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'*/
|
||||
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'*/
|
||||
|
||||
y += letter_height + style->text.line_space;
|
||||
line_start = new_line_start;
|
||||
@ -451,21 +462,21 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
|
||||
}
|
||||
|
||||
/*Calculate the x coordinate*/
|
||||
lv_coord_t x = lv_txt_get_width(&txt[line_start], index - line_start,
|
||||
font, style->text.letter_space, flag);
|
||||
lv_coord_t x = lv_txt_get_width(&txt[line_start], index - line_start, font,
|
||||
style->text.letter_space, flag);
|
||||
|
||||
if(index != line_start) x += style->text.letter_space;
|
||||
|
||||
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);
|
||||
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;
|
||||
|
||||
} else if(ext->align == LV_LABEL_ALIGN_RIGHT) {
|
||||
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);
|
||||
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) - line_w;
|
||||
}
|
||||
@ -504,7 +515,8 @@ uint16_t lv_label_get_letter_on(const 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);
|
||||
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;
|
||||
@ -516,8 +528,8 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
lv_coord_t x = 0;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -526,7 +538,8 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
uint32_t i_current = i;
|
||||
uint32_t letter;
|
||||
while(i <= new_line_start - 1) {
|
||||
letter = lv_txt_encoded_next(txt, &i); /*Be careful 'i' already points to the next character*/
|
||||
letter =
|
||||
lv_txt_encoded_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) {
|
||||
@ -552,7 +565,8 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
* @param pos Point to check for characte under
|
||||
* @return whether a character is drawn under the point
|
||||
*/
|
||||
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) {
|
||||
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
|
||||
{
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
uint32_t line_start = 0;
|
||||
@ -575,7 +589,8 @@ bool lv_label_is_char_under_pos(const 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);
|
||||
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;
|
||||
@ -588,8 +603,8 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) {
|
||||
lv_coord_t last_x = 0;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -598,7 +613,8 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) {
|
||||
uint32_t i_current = i;
|
||||
uint32_t letter = 0;
|
||||
while(i <= new_line_start - 1) {
|
||||
letter = lv_txt_encoded_next(txt, &i); /*Be careful 'i' already points to the next character*/
|
||||
letter =
|
||||
lv_txt_encoded_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) {
|
||||
@ -619,7 +635,6 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) {
|
||||
return (pos->x >= (last_x - style->text.letter_space) && pos->x <= (last_x + max_diff));
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
@ -627,9 +642,8 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) {
|
||||
/**
|
||||
* Insert a text to the label. The label text can not be static.
|
||||
* @param label pointer to a label object
|
||||
* @param pos character index to insert. Expressed in character index and not byte index (Different in UTF-8)
|
||||
* 0: before first char.
|
||||
* LV_LABEL_POS_LAST: after last char.
|
||||
* @param pos character index to insert. Expressed in character index and not byte index (Different
|
||||
* in UTF-8) 0: before first char. LV_LABEL_POS_LAST: after last char.
|
||||
* @param txt pointer to the text to insert
|
||||
*/
|
||||
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
||||
@ -661,8 +675,8 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
||||
/**
|
||||
* Delete characters from a label. The label text can not be static.
|
||||
* @param label pointer to a label object
|
||||
* @param pos character index to insert. Expressed in character index and not byte index (Different in UTF-8)
|
||||
* 0: before first char.
|
||||
* @param pos character index to insert. Expressed in character index and not byte index (Different
|
||||
* in UTF-8) 0: before first char.
|
||||
* @param cnt number of characters to cut
|
||||
*/
|
||||
void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt)
|
||||
@ -699,7 +713,8 @@ void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt)
|
||||
static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/* A label never covers an area */
|
||||
if(mode == LV_DESIGN_COVER_CHK) return false;
|
||||
if(mode == LV_DESIGN_COVER_CHK)
|
||||
return false;
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_area_t coords;
|
||||
lv_style_t * style = lv_obj_get_style(label);
|
||||
@ -740,40 +755,44 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
|
||||
if((ext->long_mode == LV_LABEL_LONG_ROLL || ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) &&
|
||||
(ext->align == LV_LABEL_ALIGN_CENTER || ext->align == LV_LABEL_ALIGN_RIGHT)) {
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, flag);
|
||||
lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space,
|
||||
style->text.line_space, LV_COORD_MAX, flag);
|
||||
if(size.x > lv_obj_get_width(label)) {
|
||||
flag &= ~LV_TXT_FLAG_RIGHT;
|
||||
flag &= ~LV_TXT_FLAG_CENTER;
|
||||
}
|
||||
}
|
||||
|
||||
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ext->offset, ext->selection_start, ext->selection_end);
|
||||
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ext->offset,
|
||||
ext->selection_start, ext->selection_end);
|
||||
|
||||
if(ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) {
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, flag);
|
||||
lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space,
|
||||
style->text.line_space, LV_COORD_MAX, flag);
|
||||
|
||||
lv_point_t ofs;
|
||||
/*Draw the text again next to the original to make an circular effect */
|
||||
if(size.x > lv_obj_get_width(label)) {
|
||||
ofs.x = ext->offset.x + size.x + lv_font_get_width(style->text.font, ' ') * ANIM_WAIT_CHAR_COUNT;
|
||||
ofs.x = ext->offset.x + size.x +
|
||||
lv_font_get_width(style->text.font, ' ') * ANIM_WAIT_CHAR_COUNT;
|
||||
ofs.y = ext->offset.y;
|
||||
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs, ext->selection_start, ext->selection_end);
|
||||
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs,
|
||||
ext->selection_start, ext->selection_end);
|
||||
}
|
||||
|
||||
/*Draw the text again below the original to make an circular effect */
|
||||
if(size.y > lv_obj_get_height(label)) {
|
||||
ofs.x = ext->offset.x;
|
||||
ofs.y = ext->offset.y + size.y + lv_font_get_height(style->text.font);
|
||||
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs, ext->selection_start, ext->selection_end);
|
||||
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs,
|
||||
ext->selection_start, ext->selection_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Signal function of the label
|
||||
* @param label pointer to a label object
|
||||
@ -850,7 +869,8 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
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;
|
||||
lv_txt_get_size(&size, ext->text, font, style->text.letter_space, style->text.line_space, max_w, flag);
|
||||
lv_txt_get_size(&size, ext->text, font, style->text.letter_space, style->text.line_space, max_w,
|
||||
flag);
|
||||
|
||||
/*Set the full size in expand mode*/
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND) {
|
||||
@ -867,7 +887,11 @@ 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;
|
||||
@ -936,17 +960,20 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
} 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_encoded_length(ext->text) <= LV_LABEL_DOT_NUM) { /*Don't turn to dots all the characters*/
|
||||
} else if(lv_txt_get_encoded_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.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 -= 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);
|
||||
|
||||
|
||||
/*Save letters under the dots and replace them with dots*/
|
||||
uint32_t i;
|
||||
uint32_t byte_id = lv_txt_encoded_get_byte_id(ext->text, letter_id);
|
||||
@ -977,7 +1004,6 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
/*Do nothing*/
|
||||
}
|
||||
|
||||
|
||||
lv_obj_invalidate(label);
|
||||
}
|
||||
|
||||
|
@ -37,10 +37,10 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
/*Long mode behaviors. Used in 'lv_label_ext_t' */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/
|
||||
LV_LABEL_LONG_BREAK, /*Keep the object width, break the too long lines and expand the object height*/
|
||||
LV_LABEL_LONG_BREAK, /*Keep the object width, break the too long lines and expand the object
|
||||
height*/
|
||||
LV_LABEL_LONG_DOT, /*Keep the size and write dots at the end if the text is too long*/
|
||||
LV_LABEL_LONG_ROLL, /*Keep the size and roll the text back and forth*/
|
||||
LV_LABEL_LONG_ROLL_CIRC, /*Keep the size and roll the text circularly*/
|
||||
@ -63,7 +63,8 @@ typedef struct
|
||||
/*New data for this type */
|
||||
char * text; /*Text of the label*/
|
||||
lv_label_long_mode_t long_mode; /*Determinate what to do with the long texts*/
|
||||
char dot_tmp[LV_LABEL_DOT_NUM * 4 + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
|
||||
char dot_tmp[LV_LABEL_DOT_NUM * 4 +
|
||||
1]; /*Store the character which are replaced by dots (Handled by the library)*/
|
||||
|
||||
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
|
||||
uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/
|
||||
@ -81,7 +82,6 @@ typedef struct
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Create a label objects
|
||||
* @param par pointer to an object, it will be the parent of the new label
|
||||
@ -122,7 +122,8 @@ void lv_label_set_static_text(lv_obj_t * label, const char * text);
|
||||
* Set the behavior of the label with longer text then the object size
|
||||
* @param label pointer to a label object
|
||||
* @param long_mode the new mode from 'lv_label_long_mode' enum.
|
||||
* In LV_LONG_BREAK/LONG/ROLL the size of the label should be set AFTER this function
|
||||
* In LV_LONG_BREAK/LONG/ROLL the size of the label should be set AFTER this
|
||||
* function
|
||||
*/
|
||||
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode);
|
||||
|
||||
@ -212,7 +213,8 @@ uint16_t lv_label_get_anim_speed(const lv_obj_t *label);
|
||||
/**
|
||||
* Get the relative x and y coordinates of a letter
|
||||
* @param label pointer to a label object
|
||||
* @param index index of the letter [0 ... text length]. Expressed in character index, not byte index (different in UTF-8)
|
||||
* @param index index of the letter [0 ... text length]. Expressed in character index, not byte
|
||||
* index (different in UTF-8)
|
||||
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
|
||||
*/
|
||||
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos);
|
||||
@ -251,9 +253,8 @@ static inline lv_style_t* lv_label_get_style(const lv_obj_t *label)
|
||||
/**
|
||||
* Insert a text to the label. The label text can not be static.
|
||||
* @param label pointer to a label object
|
||||
* @param pos character index to insert. Expressed in character index and not byte index (Different in UTF-8)
|
||||
* 0: before first char.
|
||||
* LV_LABEL_POS_LAST: after last char.
|
||||
* @param pos character index to insert. Expressed in character index and not byte index (Different
|
||||
* in UTF-8) 0: before first char. LV_LABEL_POS_LAST: after last char.
|
||||
* @param txt pointer to the text to insert
|
||||
*/
|
||||
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt);
|
||||
@ -261,8 +262,8 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt);
|
||||
/**
|
||||
* Delete characters from a label. The label text can not be static.
|
||||
* @param label pointer to a label object
|
||||
* @param pos character index to insert. Expressed in character index and not byte index (Different in UTF-8)
|
||||
* 0: before first char.
|
||||
* @param pos character index to insert. Expressed in character index and not byte index (Different
|
||||
* in UTF-8) 0: before first char.
|
||||
* @param cnt number of characters to cut
|
||||
*/
|
||||
void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt);
|
||||
|
@ -93,7 +93,6 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_refresh_style(new_led);
|
||||
}
|
||||
|
||||
|
||||
LV_LOG_INFO("led created");
|
||||
|
||||
return new_led;
|
||||
@ -138,7 +137,6 @@ void lv_led_off(lv_obj_t * led)
|
||||
lv_led_set_bright(led, LV_LED_BRIGHT_OFF);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggle the state of a LED
|
||||
* @param led pointer to a LED object
|
||||
@ -146,8 +144,10 @@ 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);
|
||||
if(bright > (LV_LED_BRIGHT_OFF + LV_LED_BRIGHT_ON) >> 1)
|
||||
lv_led_off(led);
|
||||
else
|
||||
lv_led_on(led);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -199,13 +199,18 @@ static bool lv_led_design(lv_obj_t * led, const lv_area_t * mask, lv_design_mode
|
||||
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);
|
||||
leds_tmp.body.border.color = lv_color_mix(leds_tmp.body.border.color, LV_COLOR_BLACK, ext->bright);
|
||||
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*/
|
||||
/*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);
|
||||
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);
|
||||
@ -229,7 +234,6 @@ static lv_res_t lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param)
|
||||
res = ancestor_signal(led, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
|
||||
if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -74,7 +73,9 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const 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_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);
|
||||
}
|
||||
@ -89,7 +90,6 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_refresh_style(new_line);
|
||||
}
|
||||
|
||||
|
||||
LV_LOG_INFO("line created");
|
||||
|
||||
return new_line;
|
||||
@ -207,7 +207,8 @@ bool lv_line_get_y_invert(const lv_obj_t * line)
|
||||
static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
/*A line never covers an area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) return false;
|
||||
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);
|
||||
|
||||
@ -249,8 +250,10 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
|
||||
|
||||
/*Draw circle on the joints if enabled*/
|
||||
if(style->line.rounded) {
|
||||
circle_area.x1 = p1.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
|
||||
circle_area.y1 = p1.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
|
||||
circle_area.x1 =
|
||||
p1.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
|
||||
circle_area.y1 =
|
||||
p1.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
|
||||
circle_area.x2 = p1.x + ((style->line.width - 1) >> 1);
|
||||
circle_area.y2 = p1.y + ((style->line.width - 1) >> 1);
|
||||
lv_draw_rect(&circle_area, mask, &circle_style, opa_scale);
|
||||
@ -259,8 +262,10 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo
|
||||
|
||||
/*Draw circle on the last point too if enabled*/
|
||||
if(style->line.rounded) {
|
||||
circle_area.x1 = p2.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
|
||||
circle_area.y1 = p2.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
|
||||
circle_area.x1 =
|
||||
p2.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
|
||||
circle_area.y1 =
|
||||
p2.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
|
||||
circle_area.x2 = p2.x + ((style->line.width - 1) >> 1);
|
||||
circle_area.y2 = p2.y + ((style->line.width - 1) >> 1);
|
||||
lv_draw_rect(&circle_area, mask, &circle_style, opa_scale);
|
||||
@ -283,7 +288,6 @@ static lv_res_t lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param)
|
||||
res = ancestor_signal(line, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
|
||||
if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
@ -296,7 +300,6 @@ static lv_res_t lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param)
|
||||
if(line->ext_size < style->line.width) line->ext_size = style->line.width;
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
@ -45,7 +45,6 @@ typedef struct
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Create a line objects
|
||||
* @param par pointer to an object, it will be the parent of the new line
|
||||
@ -83,7 +82,9 @@ void lv_line_set_auto_size(lv_obj_t * line, bool en);
|
||||
*/
|
||||
void lv_line_set_y_invert(lv_obj_t * line, bool en);
|
||||
|
||||
#define lv_line_set_y_inv lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will work */
|
||||
#define lv_line_set_y_inv \
|
||||
lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will \
|
||||
work */
|
||||
|
||||
/**
|
||||
* Set the style of a line
|
||||
@ -144,7 +145,6 @@ static inline bool lv_line_get_upscale(const lv_obj_t * line)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -21,7 +21,8 @@
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
#ifndef LV_LIST_FOCUS_TIME
|
||||
# define LV_LIST_DEF_ANIM_TIME 100 /*Animation time of focusing to the a list element [ms] (0: no animation) */
|
||||
#define LV_LIST_DEF_ANIM_TIME \
|
||||
100 /*Animation time of focusing to the a list element [ms] (0: no animation) */
|
||||
#endif
|
||||
#else
|
||||
#undef LV_LIST_DEF_ANIM_TIME
|
||||
@ -49,7 +50,8 @@ static lv_signal_cb_t label_signal;
|
||||
static lv_signal_cb_t ancestor_page_signal;
|
||||
static lv_signal_cb_t ancestor_btn_signal;
|
||||
#if LV_USE_GROUP
|
||||
/*Used to make the last clicked button pressed (selected) when the list become focused and `click_focus == 1`*/
|
||||
/*Used to make the last clicked button pressed (selected) when the list become focused and
|
||||
* `click_focus == 1`*/
|
||||
static lv_obj_t * last_clicked_btn;
|
||||
#endif
|
||||
|
||||
@ -137,18 +139,18 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, copy_ext->styles_btn[LV_BTN_STATE_REL]);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, copy_ext->styles_btn[LV_BTN_STATE_PR]);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL,
|
||||
copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR,
|
||||
copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, copy_ext->styles_btn[LV_BTN_STATE_INA]);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_list);
|
||||
}
|
||||
|
||||
|
||||
LV_LOG_INFO("list created");
|
||||
|
||||
|
||||
return new_list;
|
||||
}
|
||||
|
||||
@ -176,7 +178,8 @@ void lv_list_clean(lv_obj_t * obj)
|
||||
* @param event_cb specify the an event handler function. NULL if unused
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_event_cb_t event_cb)
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
|
||||
lv_event_cb_t event_cb)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
ext->size++;
|
||||
@ -238,7 +241,8 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
|
||||
/**
|
||||
* Remove the index of the button in the list
|
||||
* @param list pointer to a list object
|
||||
* @param index pointer to a the button's index in the list, index must be 0 <= index < lv_list_ext_t.size
|
||||
* @param index pointer to a the button's index in the list, index must be 0 <= index <
|
||||
* lv_list_ext_t.size
|
||||
* @return true: successfully deleted
|
||||
*/
|
||||
bool lv_list_remove(const lv_obj_t * list, uint32_t index)
|
||||
@ -288,8 +292,10 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
|
||||
|
||||
if(ext->selected_btn) {
|
||||
lv_btn_state_t s = lv_btn_get_state(ext->selected_btn);
|
||||
if(s == LV_BTN_STATE_PR) lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_REL);
|
||||
else if(s == LV_BTN_STATE_TGL_PR) lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_TGL_REL);
|
||||
if(s == LV_BTN_STATE_PR)
|
||||
lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_REL);
|
||||
else if(s == LV_BTN_STATE_TGL_PR)
|
||||
lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_TGL_REL);
|
||||
}
|
||||
|
||||
ext->selected_btn = btn;
|
||||
@ -299,8 +305,10 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
|
||||
|
||||
if(ext->selected_btn) {
|
||||
lv_btn_state_t s = lv_btn_get_state(ext->selected_btn);
|
||||
if(s == LV_BTN_STATE_REL) lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_PR);
|
||||
else if(s == LV_BTN_STATE_TGL_REL) lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_TGL_PR);
|
||||
if(s == LV_BTN_STATE_REL)
|
||||
lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_PR);
|
||||
else if(s == LV_BTN_STATE_TGL_REL)
|
||||
lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_TGL_PR);
|
||||
|
||||
lv_page_focus(list, ext->selected_btn, ext->anim_time);
|
||||
}
|
||||
@ -341,12 +349,8 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, lv_style_t * style
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_BG, style);
|
||||
/*style change signal will call 'refr_btn_width' */
|
||||
break;
|
||||
case LV_LIST_STYLE_SCRL:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_SCRL, style);
|
||||
break;
|
||||
case LV_LIST_STYLE_SB:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_SB, style);
|
||||
break;
|
||||
case LV_LIST_STYLE_SCRL: lv_page_set_style(list, LV_PAGE_STYLE_SCRL, style); break;
|
||||
case LV_LIST_STYLE_SB: lv_page_set_style(list, LV_PAGE_STYLE_SB, style); break;
|
||||
case LV_LIST_STYLE_EDGE_FLASH:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_EDGE_FLASH, style);
|
||||
break;
|
||||
@ -372,7 +376,6 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, lv_style_t * style
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*Refresh existing buttons' style*/
|
||||
if(type == LV_LIST_STYLE_BTN_PR || type == LV_LIST_STYLE_BTN_REL ||
|
||||
type == LV_LIST_STYLE_BTN_TGL_REL || type == LV_LIST_STYLE_BTN_TGL_PR ||
|
||||
@ -477,8 +480,6 @@ lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
return btn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the next button from list. (Starts from the bottom button)
|
||||
* @param list pointer to a list object
|
||||
@ -576,36 +577,18 @@ lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type)
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
switch(type) {
|
||||
case LV_LIST_STYLE_BG:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_BG);
|
||||
break;
|
||||
case LV_LIST_STYLE_SCRL:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_SB);
|
||||
break;
|
||||
case LV_LIST_STYLE_SB:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_SCRL);
|
||||
break;
|
||||
case LV_LIST_STYLE_BG: style = lv_page_get_style(list, LV_PAGE_STYLE_BG); break;
|
||||
case LV_LIST_STYLE_SCRL: style = lv_page_get_style(list, LV_PAGE_STYLE_SB); break;
|
||||
case LV_LIST_STYLE_SB: style = lv_page_get_style(list, LV_PAGE_STYLE_SCRL); break;
|
||||
case LV_LIST_STYLE_EDGE_FLASH:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_EDGE_FLASH);
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_REL:
|
||||
style = ext->styles_btn[LV_BTN_STATE_REL];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_PR:
|
||||
style = ext->styles_btn[LV_BTN_STATE_PR];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_REL:
|
||||
style = ext->styles_btn[LV_BTN_STATE_TGL_REL];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_PR:
|
||||
style = ext->styles_btn[LV_BTN_STATE_TGL_PR];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_INA:
|
||||
style = ext->styles_btn[LV_BTN_STATE_INA];
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_REL: style = ext->styles_btn[LV_BTN_STATE_REL]; break;
|
||||
case LV_LIST_STYLE_BTN_PR: style = ext->styles_btn[LV_BTN_STATE_PR]; break;
|
||||
case LV_LIST_STYLE_BTN_TGL_REL: style = ext->styles_btn[LV_BTN_STATE_TGL_REL]; break;
|
||||
case LV_LIST_STYLE_BTN_TGL_PR: style = ext->styles_btn[LV_BTN_STATE_TGL_PR]; break;
|
||||
case LV_LIST_STYLE_BTN_INA: style = ext->styles_btn[LV_BTN_STATE_INA]; break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -629,7 +612,8 @@ void lv_list_up(const lv_obj_t * list)
|
||||
while(e != NULL) {
|
||||
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_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);
|
||||
if(ext->anim_time == 0) {
|
||||
lv_obj_set_y(scrl, new_y);
|
||||
@ -737,18 +721,13 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
res = ancestor_page_signal(list, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
if(sign == LV_SIGNAL_RELEASED ||
|
||||
sign == LV_SIGNAL_PRESSED ||
|
||||
sign == LV_SIGNAL_PRESSING ||
|
||||
sign == LV_SIGNAL_LONG_PRESS ||
|
||||
sign == LV_SIGNAL_LONG_PRESS_REP)
|
||||
{
|
||||
if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING ||
|
||||
sign == LV_SIGNAL_LONG_PRESS || sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
/*If pressed/released etc by a KEYPAD or ENCODER delegate signal to the button*/
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_KEYPAD ||
|
||||
(indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(list))))
|
||||
{
|
||||
(indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(list)))) {
|
||||
/*Get the 'pressed' button*/
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_list_get_prev_btn(list, btn);
|
||||
@ -762,26 +741,23 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
bool drag = lv_indev_is_dragging(lv_indev_get_act());
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
lv_event_send(btn, LV_EVENT_PRESSED, NULL);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
} else if(sign == LV_SIGNAL_PRESSING) {
|
||||
lv_event_send(btn, LV_EVENT_PRESSING, NULL);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS && !drag) {
|
||||
} else if(sign == LV_SIGNAL_LONG_PRESS && !drag) {
|
||||
lv_event_send(btn, LV_EVENT_LONG_PRESSED, NULL);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS_REP && !drag) {
|
||||
} else if(sign == LV_SIGNAL_LONG_PRESS_REP && !drag) {
|
||||
lv_event_send(btn, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED && !drag) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED && !drag) {
|
||||
ext->last_sel = btn;
|
||||
if(indev->proc.long_pr_sent == 0) lv_event_send(btn, LV_EVENT_SHORT_CLICKED, NULL);
|
||||
if(lv_indev_is_dragging(indev) == false) lv_event_send(btn, LV_EVENT_CLICKED, NULL);
|
||||
if(indev->proc.long_pr_sent == 0)
|
||||
lv_event_send(btn, LV_EVENT_SHORT_CLICKED, NULL);
|
||||
if(lv_indev_is_dragging(indev) == false)
|
||||
lv_event_send(btn, LV_EVENT_CLICKED, NULL);
|
||||
lv_event_send(btn, LV_EVENT_RELEASED, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
|
||||
#if LV_USE_GROUP
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
@ -793,8 +769,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
if(ext->last_sel) {
|
||||
/* Select the last used button */
|
||||
lv_list_set_btn_selected(list, ext->last_sel);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/*Get the first button and mark it as selected*/
|
||||
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
|
||||
}
|
||||
@ -812,8 +787,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
if(ext->last_sel) {
|
||||
/* Select the last used button */
|
||||
lv_list_set_btn_selected(list, ext->last_sel);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/*Get the first button and mark it as selected*/
|
||||
lv_list_set_btn_selected(list, lv_list_get_next_btn(list, NULL));
|
||||
}
|
||||
@ -846,7 +820,10 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
/*If there is no selected button the make the first selected*/
|
||||
else {
|
||||
lv_obj_t * btn = lv_list_get_next_btn(list, NULL);
|
||||
if(btn) lv_list_set_btn_selected(list, btn); /*If there are no buttons on the list then there is no first button*/
|
||||
if(btn)
|
||||
lv_list_set_btn_selected(
|
||||
list,
|
||||
btn); /*If there are no buttons on the list then there is no first button*/
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
@ -873,7 +850,6 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Signal function of the list buttons
|
||||
* @param btn pointer to a button on the list
|
||||
@ -902,8 +878,10 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
|
||||
lv_obj_t * btn_i = lv_list_get_prev_btn(list, NULL);
|
||||
while(btn_i) {
|
||||
lv_btn_state_t s = lv_btn_get_state(btn_i);
|
||||
if(s == LV_BTN_STATE_PR) lv_btn_set_state(btn_i, LV_BTN_STATE_REL);
|
||||
else if(s == LV_BTN_STATE_TGL_PR) lv_btn_set_state(btn_i, LV_BTN_STATE_TGL_REL);
|
||||
if(s == LV_BTN_STATE_PR)
|
||||
lv_btn_set_state(btn_i, LV_BTN_STATE_REL);
|
||||
else if(s == LV_BTN_STATE_TGL_PR)
|
||||
lv_btn_set_state(btn_i, LV_BTN_STATE_TGL_REL);
|
||||
btn_i = lv_list_get_prev_btn(list, btn_i);
|
||||
}
|
||||
|
||||
@ -915,17 +893,14 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
|
||||
* to mark it as selected (pressed state)*/
|
||||
last_clicked_btn = btn;
|
||||
#endif
|
||||
if(lv_indev_is_dragging(lv_indev_get_act()) == false && ext->single_mode)
|
||||
{
|
||||
if(lv_indev_is_dragging(lv_indev_get_act()) == false && ext->single_mode) {
|
||||
lv_list_btn_single_selected(btn);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
} else if(sign == LV_SIGNAL_PRESS_LOST) {
|
||||
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
ext->page.scroll_prop_ip = 0;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
|
||||
#if LV_USE_GROUP
|
||||
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
|
||||
@ -934,12 +909,12 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a single button selected in the list, deselect others, should be called in list btns call back.
|
||||
* Make a single button selected in the list, deselect others, should be called in list btns call
|
||||
* back.
|
||||
* @param btn pointer to the currently pressed list btn object
|
||||
*/
|
||||
static void lv_list_btn_single_selected(lv_obj_t * btn)
|
||||
@ -947,14 +922,10 @@ static void lv_list_btn_single_selected(lv_obj_t *btn)
|
||||
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
|
||||
|
||||
lv_obj_t * e = lv_list_get_next_btn(list, NULL);
|
||||
do
|
||||
{
|
||||
if(e == btn)
|
||||
{
|
||||
do {
|
||||
if(e == btn) {
|
||||
lv_btn_set_state(e, LV_BTN_STATE_TGL_REL);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
lv_btn_set_state(e, LV_BTN_STATE_REL);
|
||||
}
|
||||
e = lv_list_get_next_btn(list, e);
|
||||
|
@ -34,7 +34,6 @@ extern "C" {
|
||||
#error "lv_list: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
|
||||
#endif
|
||||
|
||||
|
||||
#include "../lv_core/lv_obj.h"
|
||||
#include "lv_page.h"
|
||||
#include "lv_btn.h"
|
||||
@ -59,7 +58,8 @@ typedef struct
|
||||
uint32_t size; /*the number of items(buttons) in the list*/
|
||||
bool single_mode; /* whether single selected mode is enabled */
|
||||
#if LV_USE_GROUP
|
||||
lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */
|
||||
lv_obj_t *
|
||||
last_sel; /* The last selected button. It will be reverted when the list is focused again */
|
||||
lv_obj_t * selected_btn; /* The button is currently being selected*/
|
||||
#endif
|
||||
} lv_list_ext_t;
|
||||
@ -77,7 +77,6 @@ enum {
|
||||
};
|
||||
typedef uint8_t lv_list_style_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -108,12 +107,14 @@ void lv_list_clean(lv_obj_t *obj);
|
||||
* @param event_cb specify the an event handler function. NULL if unused
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_event_cb_t event_cb);
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
|
||||
lv_event_cb_t event_cb);
|
||||
|
||||
/**
|
||||
* Remove the index of the button in the list
|
||||
* @param list pointer to a list object
|
||||
* @param index pointer to a the button's index in the list, index must be 0 <= index < lv_list_ext_t.size
|
||||
* @param index pointer to a the button's index in the list, index must be 0 <= index <
|
||||
* lv_list_ext_t.size
|
||||
* @return true: successfully deleted
|
||||
*/
|
||||
bool lv_list_remove(const lv_obj_t * list, uint32_t index);
|
||||
@ -157,7 +158,8 @@ static inline void lv_list_set_sb_mode(lv_obj_t * list, lv_sb_mode_t mode)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the scroll propagation feature. If enabled then the List will move its parent if there is no more space to scroll.
|
||||
* Enable the scroll propagation feature. If enabled then the List will move its parent if there is
|
||||
* no more space to scroll.
|
||||
* @param list pointer to a List
|
||||
* @param en true or false to enable/disable scroll propagation
|
||||
*/
|
||||
@ -254,7 +256,6 @@ uint32_t lv_list_get_size(const lv_obj_t * list);
|
||||
lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Get scroll animation duration
|
||||
* @param list pointer to a list object
|
||||
@ -262,7 +263,6 @@ lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list);
|
||||
*/
|
||||
uint16_t lv_list_get_anim_time(const lv_obj_t * list);
|
||||
|
||||
|
||||
/**
|
||||
* Get the scroll bar mode of a list
|
||||
* @param list pointer to a list object
|
||||
|
@ -47,7 +47,8 @@ static lv_signal_cb_t ancestor_signal;
|
||||
/**
|
||||
* Create a line meter objects
|
||||
* @param par pointer to an object, it will be the parent of the new line meter
|
||||
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from
|
||||
* it
|
||||
* @return pointer to the created line meter
|
||||
*/
|
||||
lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
@ -167,7 +168,6 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt)
|
||||
lv_obj_invalidate(lmeter);
|
||||
}
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -231,7 +231,6 @@ uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the line meters
|
||||
* @param lmeter pointer to an object
|
||||
@ -256,7 +255,6 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
lv_style_t style_tmp;
|
||||
memcpy(&style_tmp, style, sizeof(lv_style_t));
|
||||
|
||||
|
||||
#if LV_USE_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(lmeter);
|
||||
if(lv_group_get_focused(g) == lmeter) {
|
||||
@ -271,7 +269,8 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
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);
|
||||
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;
|
||||
@ -285,7 +284,8 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
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 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;
|
||||
|
||||
@ -304,9 +304,11 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
p1.x = x_out + x_ofs;
|
||||
p1.y = y_out + y_ofs;
|
||||
|
||||
if(i >= level) style_tmp.line.color = style->line.color;
|
||||
if(i >= level)
|
||||
style_tmp.line.color = style->line.color;
|
||||
else {
|
||||
style_tmp.line.color = lv_color_mix(style->body.grad_color, style->body.main_color, (255 * i) / ext->line_cnt);
|
||||
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, opa_scale);
|
||||
@ -315,7 +317,6 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -369,7 +370,8 @@ static lv_coord_t lv_lmeter_coord_round(int32_t x)
|
||||
x = -x;
|
||||
}
|
||||
|
||||
x = (x >> LV_LMETER_LINE_UPSCALE) + ((x & LV_LMETER_LINE_UPSCALE_MASK) >> (LV_LMETER_LINE_UPSCALE - 1));
|
||||
x = (x >> LV_LMETER_LINE_UPSCALE) +
|
||||
((x & LV_LMETER_LINE_UPSCALE_MASK) >> (LV_LMETER_LINE_UPSCALE - 1));
|
||||
|
||||
if(was_negative) x = -x;
|
||||
|
||||
|
@ -49,7 +49,8 @@ typedef struct
|
||||
/**
|
||||
* Create a line meter objects
|
||||
* @param par pointer to an object, it will be the parent of the new line meter
|
||||
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a line meter object, if not NULL then the new object will be copied from
|
||||
* it
|
||||
* @return pointer to the created line meter
|
||||
*/
|
||||
lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
|
@ -3,7 +3,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -56,7 +55,8 @@ static lv_signal_cb_t ancestor_signal;
|
||||
/**
|
||||
* Create a message box objects
|
||||
* @param par pointer to an object, it will be the parent of the new message box
|
||||
* @param copy pointer to a message box object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a message box object, if not NULL then the new object will be copied from
|
||||
* it
|
||||
* @return pointer to the created message box
|
||||
*/
|
||||
lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
@ -117,7 +117,6 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_refresh_style(new_mbox);
|
||||
}
|
||||
|
||||
|
||||
LV_LOG_INFO("mesasge box created");
|
||||
|
||||
return new_mbox;
|
||||
@ -204,7 +203,8 @@ 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, lv_mbox_close_end_cb);
|
||||
lv_obj_animate(mbox, LV_ANIM_GROW_V | LV_ANIM_OUT, ext->anim_time, delay,
|
||||
lv_mbox_close_end_cb);
|
||||
|
||||
/*Disable fit to let shrinking work*/
|
||||
lv_cont_set_fit(mbox, LV_FIT_NONE);
|
||||
@ -241,18 +241,12 @@ 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);
|
||||
|
||||
switch(type) {
|
||||
case LV_MBOX_STYLE_BG:
|
||||
lv_obj_set_style(mbox, style);
|
||||
break;
|
||||
case LV_MBOX_STYLE_BTN_BG:
|
||||
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, style);
|
||||
break;
|
||||
case LV_MBOX_STYLE_BG: lv_obj_set_style(mbox, style); break;
|
||||
case LV_MBOX_STYLE_BTN_BG: lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, style); break;
|
||||
case LV_MBOX_STYLE_BTN_REL:
|
||||
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_REL, style);
|
||||
break;
|
||||
case LV_MBOX_STYLE_BTN_PR:
|
||||
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_PR, style);
|
||||
break;
|
||||
case LV_MBOX_STYLE_BTN_PR: lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_PR, style); break;
|
||||
case LV_MBOX_STYLE_BTN_TGL_REL:
|
||||
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_REL, style);
|
||||
break;
|
||||
@ -265,7 +259,6 @@ void lv_mbox_set_style(lv_obj_t * mbox, lv_mbox_style_t type, lv_style_t * style
|
||||
}
|
||||
|
||||
mbox_realign(mbox);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -277,8 +270,7 @@ void lv_mbox_set_recolor(lv_obj_t * mbox, bool en)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
if(ext->btnm)
|
||||
lv_btnm_set_recolor(ext->btnm, en);
|
||||
if(ext->btnm) lv_btnm_set_recolor(ext->btnm, en);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -306,8 +298,10 @@ const char * lv_mbox_get_text(const lv_obj_t * mbox)
|
||||
uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
if(ext->btnm) return lv_btnm_get_active_btn(ext->btnm);
|
||||
else return LV_BTNM_BTN_NONE;
|
||||
if(ext->btnm)
|
||||
return lv_btnm_get_active_btn(ext->btnm);
|
||||
else
|
||||
return LV_BTNM_BTN_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,8 +313,10 @@ uint16_t lv_mbox_get_active_btn(lv_obj_t * mbox)
|
||||
const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
if(ext->btnm) return lv_btnm_get_active_btn_text(ext->btnm);
|
||||
else return NULL;
|
||||
if(ext->btnm)
|
||||
return lv_btnm_get_active_btn_text(ext->btnm);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -346,12 +342,8 @@ lv_style_t * lv_mbox_get_style(const lv_obj_t * mbox, lv_mbox_style_t type)
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
switch(type) {
|
||||
case LV_MBOX_STYLE_BG:
|
||||
style = lv_obj_get_style(mbox);
|
||||
break;
|
||||
case LV_MBOX_STYLE_BTN_BG:
|
||||
style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BG);
|
||||
break;
|
||||
case LV_MBOX_STYLE_BG: style = lv_obj_get_style(mbox); break;
|
||||
case LV_MBOX_STYLE_BTN_BG: style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BG); break;
|
||||
case LV_MBOX_STYLE_BTN_REL:
|
||||
style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_REL);
|
||||
break;
|
||||
@ -367,9 +359,7 @@ lv_style_t * lv_mbox_get_style(const lv_obj_t * mbox, lv_mbox_style_t type)
|
||||
case LV_MBOX_STYLE_BTN_INA:
|
||||
style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_INA);
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -384,8 +374,7 @@ bool lv_mbox_get_recolor(const lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
if(!ext->btnm)
|
||||
return false;
|
||||
if(!ext->btnm) return false;
|
||||
|
||||
return lv_btnm_get_recolor(ext->btnm);
|
||||
}
|
||||
@ -436,23 +425,20 @@ 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_RELEASED) {
|
||||
} else if(sign == LV_SIGNAL_RELEASED) {
|
||||
uint16_t btn_id = lv_btnm_get_active_btn(ext->btnm);
|
||||
if(btn_id != LV_BTNM_BTN_NONE) lv_event_send(mbox, LV_EVENT_SELECTED, &btn_id);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS ||
|
||||
sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL ||
|
||||
sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
if(ext->btnm) {
|
||||
ext->btnm->signal_cb(ext->btnm, sign, param);
|
||||
}
|
||||
|
||||
/* The button matrix with ENCODER input supposes it's in a group but in this case it isn't (Only the message box's container)
|
||||
* So so some actions here instead*/
|
||||
/* The button matrix with ENCODER input supposes it's in a group but in this case it isn't
|
||||
* (Only the message box's container) So so some actions here instead*/
|
||||
if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if LV_USE_GROUP
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
@ -460,8 +446,10 @@ static lv_res_t lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
/*In navigation mode don't select any button but in edit mode select the fist*/
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btnm);
|
||||
if(lv_group_get_editing(lv_obj_get_group(mbox))) btnm_ext->btn_id_pr = 0;
|
||||
else btnm_ext->btn_id_pr = LV_BTNM_BTN_NONE;
|
||||
if(lv_group_get_editing(lv_obj_get_group(mbox)))
|
||||
btnm_ext->btn_id_pr = 0;
|
||||
else
|
||||
btnm_ext->btn_id_pr = LV_BTNM_BTN_NONE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -496,8 +484,10 @@ static void mbox_realign(lv_obj_t * mbox)
|
||||
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 + btn_rel_style->body.padding.top + btn_rel_style->body.padding.bottom +
|
||||
btn_bg_style->body.padding.top + btn_bg_style->body.padding.bottom);
|
||||
lv_obj_set_size(ext->btnm, w,
|
||||
font_h + btn_rel_style->body.padding.top +
|
||||
btn_rel_style->body.padding.bottom + btn_bg_style->body.padding.top +
|
||||
btn_bg_style->body.padding.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
@ -506,7 +496,6 @@ static void lv_mbox_close_end_cb(lv_obj_t * mbox)
|
||||
lv_obj_del(mbox);
|
||||
}
|
||||
|
||||
|
||||
static void lv_mbox_default_event_cb(lv_obj_t * mbox, lv_event_t event)
|
||||
{
|
||||
if(event != LV_EVENT_CLICKED) return;
|
||||
@ -515,7 +504,6 @@ static void lv_mbox_default_event_cb(lv_obj_t * mbox, lv_event_t event)
|
||||
if(btn_id == LV_BTNM_BTN_NONE) return;
|
||||
|
||||
lv_mbox_start_auto_close(mbox, 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -34,7 +34,6 @@ extern "C" {
|
||||
#error "lv_mbox: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
|
||||
#endif
|
||||
|
||||
|
||||
#include "../lv_core/lv_obj.h"
|
||||
#include "lv_cont.h"
|
||||
#include "lv_btnm.h"
|
||||
@ -76,7 +75,8 @@ typedef uint8_t lv_mbox_style_t;
|
||||
/**
|
||||
* Create a message box objects
|
||||
* @param par pointer to an object, it will be the parent of the new message box
|
||||
* @param copy pointer to a message box object, if not NULL then the new object will be copied from it
|
||||
* @param copy pointer to a message box object, if not NULL then the new object will be copied from
|
||||
* it
|
||||
* @return pointer to the created message box
|
||||
*/
|
||||
lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
@ -173,7 +173,6 @@ const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox);
|
||||
*/
|
||||
uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox);
|
||||
|
||||
|
||||
/**
|
||||
* Get a style of a message box
|
||||
* @param mbox pointer to a message box object
|
||||
@ -201,7 +200,6 @@ lv_obj_t * lv_mbox_get_btnm(lv_obj_t * mbox);
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#endif /*LV_USE_MBOX*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -8,8 +8,8 @@
|
||||
* templ -> object short name with lower case(e.g. btn, label etc)
|
||||
* TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.)
|
||||
*
|
||||
* You can remove the defined() clause from the #if statement below. This exists because LV_USE_TEMPL
|
||||
* is not in lv_conf.h or lv_conf_templ.h by default.
|
||||
* You can remove the defined() clause from the #if statement below. This exists because
|
||||
* LV_USE_TEMPL is not in lv_conf.h or lv_conf_templ.h by default.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
@ -102,7 +102,6 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
* New object specific "add" or "remove" functions come here
|
||||
*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
@ -111,7 +110,6 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
* New object specific "set" functions come here
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Set a style of a template.
|
||||
* @param templ pointer to template object
|
||||
@ -123,10 +121,8 @@ void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, lv_style_t * st
|
||||
lv_templ_ext_t * ext = lv_obj_get_ext_attr(templ);
|
||||
|
||||
switch(type) {
|
||||
case LV_TEMPL_STYLE_X:
|
||||
break;
|
||||
case LV_TEMPL_STYLE_Y:
|
||||
break;
|
||||
case LV_TEMPL_STYLE_X: break;
|
||||
case LV_TEMPL_STYLE_Y: break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,12 +146,9 @@ lv_style_t * lv_templ_get_style(const lv_obj_t * templ, lv_templ_style_t type)
|
||||
lv_style_t * style = NULL;
|
||||
|
||||
switch(type) {
|
||||
case LV_TEMPL_STYLE_X:
|
||||
style = NULL; /*Replace NULL with a pointer to the style*/
|
||||
case LV_TEMPL_STYLE_Y:
|
||||
style = NULL; /*Replace NULL with a pointer to the style*/
|
||||
default:
|
||||
style = NULL;
|
||||
case LV_TEMPL_STYLE_X: style = NULL; /*Replace NULL with a pointer to the style*/
|
||||
case LV_TEMPL_STYLE_Y: style = NULL; /*Replace NULL with a pointer to the style*/
|
||||
default: style = NULL;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -195,7 +188,6 @@ static bool lv_templ_design(lv_obj_t * templ, const lv_area_t * mask, lv_design_
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -216,7 +208,6 @@ static lv_res_t lv_templ_signal(lv_obj_t * templ, lv_signal_t sign, void * param
|
||||
res = ancestor_signal(templ, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* TODO Remove these instructions
|
||||
* Search an replace: template -> object normal name with lower case (e.g. button, label etc.)
|
||||
* templ -> object short name with lower case(e.g. btn, label etc)
|
||||
@ -39,12 +38,12 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of template*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
lv_ANCESTOR_ext_t ANCESTOR; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
} lv_templ_ext_t;
|
||||
|
||||
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_TEMPL_STYLE_X,
|
||||
@ -52,7 +51,6 @@ enum {
|
||||
};
|
||||
typedef uint8_t lv_templ_style_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@ -69,7 +67,6 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
@ -20,7 +20,8 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_PAGE_SB_MIN_SIZE (LV_DPI / 8)
|
||||
#define LV_PAGE_SCROLL_ANIM_TIME 200 /*[ms] Scroll anim time on `lv_page_scroll_up/down/left/rigth`*/
|
||||
#define LV_PAGE_SCROLL_ANIM_TIME \
|
||||
200 /*[ms] Scroll anim time on `lv_page_scroll_up/down/left/rigth`*/
|
||||
#define LV_PAGE_END_FLASH_SIZE (LV_DPI / 4)
|
||||
#define LV_PAGE_END_ANIM_TIME 300
|
||||
#define LV_PAGE_END_ANIM_WAIT_TIME 300
|
||||
@ -103,7 +104,8 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
||||
lv_cont_set_fit4(ext->scrl, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL);
|
||||
lv_obj_set_event_cb(ext->scrl, scrl_def_event_cb); /*Propagate some event to the background object by default for convenience */
|
||||
lv_obj_set_event_cb(ext->scrl, scrl_def_event_cb); /*Propagate some event to the background
|
||||
object by default for convenience */
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
@ -121,7 +123,6 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
} else {
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.page.bg);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->style.page.scrl);
|
||||
|
||||
}
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->style.page.sb);
|
||||
} else {
|
||||
@ -138,9 +139,9 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
|
||||
lv_page_set_arrow_scroll(new_page, copy_ext->arrow_scroll);
|
||||
|
||||
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, lv_page_get_style(copy, LV_PAGE_STYLE_BG));
|
||||
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_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
|
||||
@ -183,8 +184,10 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
if(ext->sb.mode == sb_mode) return;
|
||||
|
||||
if(sb_mode == LV_SB_MODE_HIDE) ext->sb.mode |= LV_SB_MODE_HIDE; /*Set the hidden flag*/
|
||||
else if(sb_mode == LV_SB_MODE_UNHIDE) ext->sb.mode &= (~LV_SB_MODE_HIDE); /*Clear the hidden flag*/
|
||||
if(sb_mode == LV_SB_MODE_HIDE)
|
||||
ext->sb.mode |= LV_SB_MODE_HIDE; /*Set the hidden flag*/
|
||||
else if(sb_mode == LV_SB_MODE_UNHIDE)
|
||||
ext->sb.mode &= (~LV_SB_MODE_HIDE); /*Clear the hidden flag*/
|
||||
else {
|
||||
if(ext->sb.mode & LV_SB_MODE_HIDE) sb_mode |= LV_SB_MODE_HIDE;
|
||||
ext->sb.mode = sb_mode;
|
||||
@ -198,7 +201,8 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable scrolling with arrows if the page is in group (arrows: LV_GROUP_KEY_LEFT/RIGHT/UP/DOWN)
|
||||
* Enable/Disable scrolling with arrows if the page is in group (arrows:
|
||||
* LV_GROUP_KEY_LEFT/RIGHT/UP/DOWN)
|
||||
* @param page pointer to a page object
|
||||
* @param en true: enable scrolling with arrows
|
||||
*/
|
||||
@ -209,7 +213,8 @@ void lv_page_set_arrow_scroll(lv_obj_t * page, bool en)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the scroll propagation feature. If enabled then the page will move its parent if there is no more space to scroll.
|
||||
* Enable the scroll propagation feature. If enabled then the page will move its parent if there is
|
||||
* no more space to scroll.
|
||||
* @param page pointer to a Page
|
||||
* @param en true or false to enable/disable scroll propagation
|
||||
*/
|
||||
@ -241,12 +246,8 @@ 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) {
|
||||
case LV_PAGE_STYLE_BG:
|
||||
lv_obj_set_style(page, style);
|
||||
break;
|
||||
case LV_PAGE_STYLE_SCRL:
|
||||
lv_obj_set_style(ext->scrl, style);
|
||||
break;
|
||||
case LV_PAGE_STYLE_BG: lv_obj_set_style(page, style); break;
|
||||
case LV_PAGE_STYLE_SCRL: lv_obj_set_style(ext->scrl, style); break;
|
||||
case LV_PAGE_STYLE_SB:
|
||||
ext->sb.style = style;
|
||||
lv_area_set_height(&ext->sb.hor_area, ext->sb.style->body.padding.inner);
|
||||
@ -255,9 +256,7 @@ void lv_page_set_style(lv_obj_t * page, lv_page_style_t type, lv_style_t * style
|
||||
lv_obj_refresh_ext_size(page);
|
||||
lv_obj_invalidate(page);
|
||||
break;
|
||||
case LV_PAGE_STYLE_EDGE_FLASH:
|
||||
ext->edge_flash.style = style;
|
||||
break;
|
||||
case LV_PAGE_STYLE_EDGE_FLASH: ext->edge_flash.style = style; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,8 +330,7 @@ lv_coord_t lv_page_get_fit_width(lv_obj_t * page)
|
||||
lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
||||
|
||||
return lv_obj_get_width(page) -
|
||||
bg_style->body.padding.left - bg_style->body.padding.right -
|
||||
return lv_obj_get_width(page) - bg_style->body.padding.left - bg_style->body.padding.right -
|
||||
scrl_style->body.padding.left - scrl_style->body.padding.right;
|
||||
}
|
||||
|
||||
@ -346,8 +344,7 @@ lv_coord_t lv_page_get_fit_height(lv_obj_t * page)
|
||||
lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
||||
|
||||
return lv_obj_get_height(page) -
|
||||
bg_style->body.padding.top - bg_style->body.padding.bottom -
|
||||
return lv_obj_get_height(page) - bg_style->body.padding.top - bg_style->body.padding.bottom -
|
||||
scrl_style->body.padding.top - scrl_style->body.padding.bottom;
|
||||
}
|
||||
|
||||
@ -363,21 +360,11 @@ lv_style_t * lv_page_get_style(const 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:
|
||||
style = lv_obj_get_style(page);
|
||||
break;
|
||||
case LV_PAGE_STYLE_SCRL:
|
||||
style = lv_obj_get_style(ext->scrl);
|
||||
break;
|
||||
case LV_PAGE_STYLE_SB:
|
||||
style = ext->sb.style;
|
||||
break;
|
||||
case LV_PAGE_STYLE_EDGE_FLASH:
|
||||
style = ext->edge_flash.style;
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_PAGE_STYLE_BG: style = lv_obj_get_style(page); break;
|
||||
case LV_PAGE_STYLE_SCRL: style = lv_obj_get_style(ext->scrl); break;
|
||||
case LV_PAGE_STYLE_SB: style = ext->sb.style; break;
|
||||
case LV_PAGE_STYLE_EDGE_FLASH: style = ext->edge_flash.style; break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@ -393,7 +380,8 @@ lv_style_t * lv_page_get_style(const lv_obj_t * page, lv_page_style_t type)
|
||||
* @param edge Edge to check
|
||||
* @return true if the page is on the specified edge
|
||||
*/
|
||||
bool lv_page_on_edge(lv_obj_t *page, lv_page_edge_t edge) {
|
||||
bool lv_page_on_edge(lv_obj_t * page, lv_page_edge_t edge)
|
||||
{
|
||||
lv_style_t * page_style = lv_obj_get_style(page);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(page);
|
||||
lv_area_t page_coords;
|
||||
@ -404,11 +392,14 @@ bool lv_page_on_edge(lv_obj_t *page, lv_page_edge_t edge) {
|
||||
|
||||
if(edge == LV_PAGE_EDGE_TOP && scrl_coords.y1 == page_coords.y1 + page_style->body.padding.top)
|
||||
return true;
|
||||
else if(edge == LV_PAGE_EDGE_BOTTOM && scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom)
|
||||
else if(edge == LV_PAGE_EDGE_BOTTOM &&
|
||||
scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom)
|
||||
return true;
|
||||
else if(edge == LV_PAGE_EDGE_LEFT && scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left)
|
||||
else if(edge == LV_PAGE_EDGE_LEFT &&
|
||||
scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left)
|
||||
return true;
|
||||
else if(edge == LV_PAGE_EDGE_RIGHT && scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right)
|
||||
else if(edge == LV_PAGE_EDGE_RIGHT &&
|
||||
scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -461,15 +452,13 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time)
|
||||
lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h;
|
||||
|
||||
/*Out of the page on the top*/
|
||||
if((obj_h <= page_h && top_err > 0) ||
|
||||
(obj_h > page_h && top_err < bot_err)) {
|
||||
if((obj_h <= page_h && top_err > 0) || (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.top - style->body.padding.top);
|
||||
scrlable_y += style_scrl->body.padding.top;
|
||||
}
|
||||
/*Out of the page on the bottom*/
|
||||
else if((obj_h <= page_h && bot_err > 0) ||
|
||||
(obj_h > page_h && top_err >= bot_err)) {
|
||||
else if((obj_h <= page_h && bot_err > 0) || (obj_h > page_h && top_err >= bot_err)) {
|
||||
/*Calculate a new position and let some space below*/
|
||||
scrlable_y = -(obj_y + style_scrl->body.padding.bottom + style->body.padding.bottom);
|
||||
scrlable_y -= style_scrl->body.padding.bottom;
|
||||
@ -486,15 +475,13 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time)
|
||||
lv_coord_t right_err = scrlable_x + obj_x + obj_w - page_w;
|
||||
|
||||
/*Out of the page on the left*/
|
||||
if((obj_w <= page_w && left_err > 0) ||
|
||||
(obj_w > page_w && left_err < right_err)) {
|
||||
if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) {
|
||||
/*Calculate a new position and let some space above*/
|
||||
scrlable_x = -(obj_x - style_scrl->body.padding.left - style->body.padding.left);
|
||||
scrlable_x += style_scrl->body.padding.left;
|
||||
}
|
||||
/*Out of the page on the rigth*/
|
||||
else if((obj_w <= page_w && right_err > 0) ||
|
||||
(obj_w > page_w && left_err >= right_err)) {
|
||||
else if((obj_w <= page_w && right_err > 0) || (obj_w > page_w && left_err >= right_err)) {
|
||||
/*Calculate a new position and let some space below*/
|
||||
scrlable_x = -(obj_x + style_scrl->body.padding.right + style->body.padding.right);
|
||||
scrlable_x -= style_scrl->body.padding.right;
|
||||
@ -613,7 +600,6 @@ void lv_page_start_edge_flash(lv_obj_t * page)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -676,7 +662,6 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
|
||||
lv_draw_rect(&sb_area, mask, ext->sb.style, lv_obj_get_opa_scale(page));
|
||||
}
|
||||
|
||||
|
||||
lv_coord_t page_w = lv_obj_get_width(page);
|
||||
lv_coord_t page_h = lv_obj_get_height(page);
|
||||
lv_area_t flash_area;
|
||||
@ -686,27 +671,25 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
|
||||
flash_area.x2 = page->coords.x2 + page_w;
|
||||
flash_area.y1 = page->coords.y1 - 3 * page_w + ext->edge_flash.state;
|
||||
flash_area.y2 = page->coords.y1 + ext->edge_flash.state;
|
||||
}
|
||||
else if(ext->edge_flash.bottom_ip) {
|
||||
} else if(ext->edge_flash.bottom_ip) {
|
||||
flash_area.x1 = page->coords.x1 - page_w;
|
||||
flash_area.x2 = page->coords.x2 + page_w;
|
||||
flash_area.y1 = page->coords.y2 - ext->edge_flash.state;
|
||||
flash_area.y2 = page->coords.y2 + 3 * page_w - ext->edge_flash.state;
|
||||
}
|
||||
else if(ext->edge_flash.right_ip) {
|
||||
} else if(ext->edge_flash.right_ip) {
|
||||
flash_area.x1 = page->coords.x2 - ext->edge_flash.state;
|
||||
flash_area.x2 = page->coords.x2 + 3 * page_h - ext->edge_flash.state;
|
||||
flash_area.y1 = page->coords.y1 - page_h;
|
||||
flash_area.y2 = page->coords.y2 + page_h;
|
||||
}
|
||||
else if(ext->edge_flash.left_ip) {
|
||||
} else if(ext->edge_flash.left_ip) {
|
||||
flash_area.x1 = page->coords.x1 - 3 * page_h + ext->edge_flash.state;
|
||||
flash_area.x2 = page->coords.x1 + ext->edge_flash.state;
|
||||
flash_area.y1 = page->coords.y1 - page_h;
|
||||
flash_area.y2 = page->coords.y2 + page_h;
|
||||
}
|
||||
|
||||
if(ext->edge_flash.left_ip || ext->edge_flash.right_ip || ext->edge_flash.top_ip || ext->edge_flash.bottom_ip) {
|
||||
if(ext->edge_flash.left_ip || ext->edge_flash.right_ip || ext->edge_flash.top_ip ||
|
||||
ext->edge_flash.bottom_ip) {
|
||||
lv_style_t flash_style;
|
||||
lv_style_copy(&flash_style, ext->edge_flash.style);
|
||||
flash_style.body.radius = LV_RADIUS_CIRCLE;
|
||||
@ -714,7 +697,6 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
|
||||
flash_style.body.opa = opa;
|
||||
lv_draw_rect(&flash_area, mask, &flash_style, lv_obj_get_opa_scale(page));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -743,7 +725,8 @@ static bool lv_scrl_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mo
|
||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
||||
lv_style_t * style_page = lv_obj_get_style(page);
|
||||
lv_group_t * g = lv_obj_get_group(page);
|
||||
if((style_page->body.opa == LV_OPA_TRANSP) && style_page->body.border.width == 0) { /*Is the background visible?*/
|
||||
if((style_page->body.opa == LV_OPA_TRANSP) &&
|
||||
style_page->body.border.width == 0) { /*Is the background visible?*/
|
||||
if(lv_group_get_focused(g) == page) {
|
||||
lv_style_t * style_mod;
|
||||
style_mod = lv_group_mod_style(g, style_scrl_ori);
|
||||
@ -754,7 +737,6 @@ static bool lv_scrl_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mo
|
||||
style_mod = lv_group_mod_style(g, style_mod);
|
||||
}
|
||||
|
||||
|
||||
scrl->style_p = style_mod; /*Temporally change the style to the activated */
|
||||
}
|
||||
}
|
||||
@ -827,8 +809,10 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
}
|
||||
} 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.right)) page->ext_size = -ext->sb.style->body.padding.right;
|
||||
if(page->ext_size < (-ext->sb.style->body.padding.bottom)) page->ext_size = -ext->sb.style->body.padding.bottom;
|
||||
if(page->ext_size < (-ext->sb.style->body.padding.right))
|
||||
page->ext_size = -ext->sb.style->body.padding.right;
|
||||
if(page->ext_size < (-ext->sb.style->body.padding.bottom))
|
||||
page->ext_size = -ext->sb.style->body.padding.bottom;
|
||||
} else if(sign == LV_SIGNAL_CONTROL) {
|
||||
uint32_t c = *((uint32_t *)param);
|
||||
|
||||
@ -837,13 +821,19 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
} else if((c == LV_GROUP_KEY_UP) && ext->arrow_scroll) {
|
||||
lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
|
||||
} else if((c == LV_GROUP_KEY_RIGHT) && ext->arrow_scroll) {
|
||||
/*If the page can't be scrolled horizontally because it's not wide enough then scroll it vertically*/
|
||||
if(lv_page_get_scrl_width(page) <= lv_obj_get_width(page)) lv_page_scroll_ver(page, - lv_obj_get_height(page) / 4);
|
||||
else lv_page_scroll_hor(page, - lv_obj_get_width(page) / 4);
|
||||
/*If the page can't be scrolled horizontally because it's not wide enough then scroll it
|
||||
* vertically*/
|
||||
if(lv_page_get_scrl_width(page) <= lv_obj_get_width(page))
|
||||
lv_page_scroll_ver(page, -lv_obj_get_height(page) / 4);
|
||||
else
|
||||
lv_page_scroll_hor(page, -lv_obj_get_width(page) / 4);
|
||||
} else if((c == LV_GROUP_KEY_LEFT) && ext->arrow_scroll) {
|
||||
/*If the page can't be scrolled horizontally because it's not wide enough then scroll it vertically*/
|
||||
if(lv_page_get_scrl_width(page) <= lv_obj_get_width(page)) lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
|
||||
else lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
|
||||
/*If the page can't be scrolled horizontally because it's not wide enough then scroll it
|
||||
* vertically*/
|
||||
if(lv_page_get_scrl_width(page) <= lv_obj_get_width(page))
|
||||
lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
|
||||
else
|
||||
lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
||||
bool * editable = (bool *)param;
|
||||
@ -902,17 +892,22 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
lv_point_t drag_vect;
|
||||
lv_indev_get_vect(indev, &drag_vect);
|
||||
|
||||
/* Start the scroll propagation if there is drag vector on the indev, but the drag is not
|
||||
* started yet and the scrollable is in a corner. It will enable the scroll propagation only
|
||||
* when a new scroll begins and not when the scrollable is already being scrolled.*/
|
||||
if(page_ext->scroll_prop && page_ext->scroll_prop_ip == 0 &&
|
||||
lv_indev_is_dragging(indev) == false) {
|
||||
if(((drag_vect.y > 0 &&
|
||||
scrl_coords.y1 == page_coords.y1 + page_style->body.padding.top) ||
|
||||
(drag_vect.y < 0 &&
|
||||
scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom)) &&
|
||||
((drag_vect.x > 0 &&
|
||||
scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left) ||
|
||||
(drag_vect.x < 0 &&
|
||||
scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right))) {
|
||||
|
||||
/* Start the scroll propagation if there is drag vector on the indev, but the drag is not started yet
|
||||
* and the scrollable is in a corner. It will enable the scroll propagation only when a new scroll begins and not
|
||||
* when the scrollable is already being scrolled.*/
|
||||
if(page_ext->scroll_prop && page_ext->scroll_prop_ip == 0 && lv_indev_is_dragging(indev) == false) {
|
||||
if(((drag_vect.y > 0 && scrl_coords.y1 == page_coords.y1 + page_style->body.padding.top) ||
|
||||
(drag_vect.y < 0 && scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom)) &&
|
||||
((drag_vect.x > 0 && scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left) ||
|
||||
(drag_vect.x < 0 && scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right))) {
|
||||
|
||||
if(lv_obj_get_parent(page_parent) != NULL) { /*Do not propagate the scroll to a screen*/
|
||||
if(lv_obj_get_parent(page_parent) !=
|
||||
NULL) { /*Do not propagate the scroll to a screen*/
|
||||
page_ext->scroll_prop_ip = 1;
|
||||
}
|
||||
}
|
||||
@ -925,30 +920,32 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
refr_x = true;
|
||||
}
|
||||
} else {
|
||||
/*If the scroll propagation is in progress revert the original coordinates (don't let the page scroll)*/
|
||||
/*If the scroll propagation is in progress revert the original coordinates (don't let
|
||||
* the page scroll)*/
|
||||
if(page_ext->scroll_prop_ip) {
|
||||
if(drag_vect.x == diff_x) { /*`scrl` is bouncing: drag pos. it somewhere and here it is reverted. Handle only the pos. because of drag*/
|
||||
if(drag_vect.x == diff_x) { /*`scrl` is bouncing: drag pos. it somewhere and here it
|
||||
is reverted. Handle only the pos. because of drag*/
|
||||
new_x = ori_coords->x1 - page_coords.x1;
|
||||
refr_x = true;
|
||||
}
|
||||
}
|
||||
/*The edges of the scrollable can not be in the page (minus hpad) */
|
||||
else if(scrl_coords.x2 < page_coords.x2 - page_style->body.padding.right) {
|
||||
new_x = lv_area_get_width(&page_coords) - lv_area_get_width(&scrl_coords) - page_style->body.padding.right; /* Right align */
|
||||
new_x = lv_area_get_width(&page_coords) - lv_area_get_width(&scrl_coords) -
|
||||
page_style->body.padding.right; /* Right align */
|
||||
refr_x = true;
|
||||
if(page_ext->edge_flash.enabled &&
|
||||
page_ext->edge_flash.left_ip == 0 && page_ext->edge_flash.right_ip == 0 &&
|
||||
page_ext->edge_flash.top_ip == 0 && page_ext->edge_flash.bottom_ip == 0) {
|
||||
if(page_ext->edge_flash.enabled && page_ext->edge_flash.left_ip == 0 &&
|
||||
page_ext->edge_flash.right_ip == 0 && page_ext->edge_flash.top_ip == 0 &&
|
||||
page_ext->edge_flash.bottom_ip == 0) {
|
||||
lv_page_start_edge_flash(page);
|
||||
page_ext->edge_flash.right_ip = 1;
|
||||
}
|
||||
}
|
||||
else if(scrl_coords.x1 > page_coords.x1 + page_style->body.padding.left) {
|
||||
} else if(scrl_coords.x1 > page_coords.x1 + page_style->body.padding.left) {
|
||||
new_x = page_style->body.padding.left; /*Left align*/
|
||||
refr_x = true;
|
||||
if(page_ext->edge_flash.enabled &&
|
||||
page_ext->edge_flash.left_ip == 0 && page_ext->edge_flash.right_ip == 0 &&
|
||||
page_ext->edge_flash.top_ip == 0 && page_ext->edge_flash.bottom_ip == 0) {
|
||||
if(page_ext->edge_flash.enabled && page_ext->edge_flash.left_ip == 0 &&
|
||||
page_ext->edge_flash.right_ip == 0 && page_ext->edge_flash.top_ip == 0 &&
|
||||
page_ext->edge_flash.bottom_ip == 0) {
|
||||
lv_page_start_edge_flash(page);
|
||||
page_ext->edge_flash.left_ip = 1;
|
||||
}
|
||||
@ -962,30 +959,32 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
refr_y = true;
|
||||
}
|
||||
} else {
|
||||
/*If the scroll propagation is in progress revert the original coordinates (don't let the page scroll)*/
|
||||
/*If the scroll propagation is in progress revert the original coordinates (don't let
|
||||
* the page scroll)*/
|
||||
if(page_ext->scroll_prop_ip) {
|
||||
if(drag_vect.y == diff_y) { /*`scrl` is bouncing: drag pos. it somewhere and here it is reverted. Handle only the pos. because of drag*/
|
||||
if(drag_vect.y == diff_y) { /*`scrl` is bouncing: drag pos. it somewhere and here it
|
||||
is reverted. Handle only the pos. because of drag*/
|
||||
new_y = ori_coords->y1 - page_coords.y1;
|
||||
refr_y = true;
|
||||
}
|
||||
}
|
||||
/*The edges of the scrollable can not be in the page (minus vpad) */
|
||||
else if(scrl_coords.y2 < page_coords.y2 - page_style->body.padding.bottom) {
|
||||
new_y = lv_area_get_height(&page_coords) - lv_area_get_height(&scrl_coords) - page_style->body.padding.bottom; /* Bottom align */
|
||||
new_y = lv_area_get_height(&page_coords) - lv_area_get_height(&scrl_coords) -
|
||||
page_style->body.padding.bottom; /* Bottom align */
|
||||
refr_y = true;
|
||||
if(page_ext->edge_flash.enabled &&
|
||||
page_ext->edge_flash.left_ip == 0 && page_ext->edge_flash.right_ip == 0 &&
|
||||
page_ext->edge_flash.top_ip == 0 && page_ext->edge_flash.bottom_ip == 0) {
|
||||
if(page_ext->edge_flash.enabled && page_ext->edge_flash.left_ip == 0 &&
|
||||
page_ext->edge_flash.right_ip == 0 && page_ext->edge_flash.top_ip == 0 &&
|
||||
page_ext->edge_flash.bottom_ip == 0) {
|
||||
lv_page_start_edge_flash(page);
|
||||
page_ext->edge_flash.bottom_ip = 1;
|
||||
}
|
||||
}
|
||||
else if(scrl_coords.y1 > page_coords.y1 + page_style->body.padding.top) {
|
||||
} else if(scrl_coords.y1 > page_coords.y1 + page_style->body.padding.top) {
|
||||
new_y = page_style->body.padding.top; /*Top align*/
|
||||
refr_y = true;
|
||||
if(page_ext->edge_flash.enabled &&
|
||||
page_ext->edge_flash.left_ip == 0 && page_ext->edge_flash.right_ip == 0 &&
|
||||
page_ext->edge_flash.top_ip == 0 && page_ext->edge_flash.bottom_ip == 0) {
|
||||
if(page_ext->edge_flash.enabled && page_ext->edge_flash.left_ip == 0 &&
|
||||
page_ext->edge_flash.right_ip == 0 && page_ext->edge_flash.top_ip == 0 &&
|
||||
page_ext->edge_flash.bottom_ip == 0) {
|
||||
lv_page_start_edge_flash(page);
|
||||
page_ext->edge_flash.top_ip = 1;
|
||||
}
|
||||
@ -1002,8 +1001,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) {
|
||||
|
||||
/*Scroll propagation is finished on drag end*/
|
||||
page_ext->scroll_prop_ip = 0;
|
||||
@ -1036,7 +1034,6 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Propagate the input device related event of the scrollable to the parent page background
|
||||
* It is used by default if the scrollable's event is not specified
|
||||
@ -1048,18 +1045,11 @@ static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event)
|
||||
{
|
||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
||||
|
||||
if(event == LV_EVENT_PRESSED ||
|
||||
event == LV_EVENT_PRESSING ||
|
||||
event == LV_EVENT_PRESS_LOST ||
|
||||
event == LV_EVENT_RELEASED ||
|
||||
event == LV_EVENT_SHORT_CLICKED ||
|
||||
event == LV_EVENT_LONG_PRESSED ||
|
||||
event == LV_EVENT_LONG_PRESSED_REPEAT ||
|
||||
event == LV_EVENT_LONG_HOVER_IN ||
|
||||
event == LV_EVENT_LONG_HOVER_OUT ||
|
||||
event == LV_EVENT_FOCUSED ||
|
||||
event == LV_EVENT_DEFOCUSED)
|
||||
{
|
||||
if(event == LV_EVENT_PRESSED || event == LV_EVENT_PRESSING || event == LV_EVENT_PRESS_LOST ||
|
||||
event == LV_EVENT_RELEASED || event == LV_EVENT_SHORT_CLICKED ||
|
||||
event == LV_EVENT_LONG_PRESSED || event == LV_EVENT_LONG_PRESSED_REPEAT ||
|
||||
event == LV_EVENT_LONG_HOVER_IN || event == LV_EVENT_LONG_HOVER_OUT ||
|
||||
event == LV_EVENT_FOCUSED || event == LV_EVENT_DEFOCUSED) {
|
||||
lv_event_send(page, event, lv_event_get_data());
|
||||
}
|
||||
}
|
||||
@ -1083,8 +1073,10 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
* else:
|
||||
* - horizontal and vertical scrollbars can overlap on the corners
|
||||
* - if the page has radius the scrollbar can be out of the radius */
|
||||
lv_coord_t sb_hor_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.right);
|
||||
lv_coord_t sb_ver_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.bottom);
|
||||
lv_coord_t sb_hor_pad =
|
||||
LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.right);
|
||||
lv_coord_t sb_ver_pad =
|
||||
LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.bottom);
|
||||
|
||||
if(ext->sb.mode == LV_SB_MODE_OFF) return;
|
||||
|
||||
@ -1113,26 +1105,31 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
}
|
||||
|
||||
|
||||
if(ext->sb.mode == LV_SB_MODE_DRAG && lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
||||
ext->sb.hor_draw = 0;
|
||||
ext->sb.ver_draw = 0;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/*Horizontal scrollbar*/
|
||||
if(scrl_w <= obj_w - style->body.padding.left - style->body.padding.right) { /*Full sized scroll bar*/
|
||||
if(scrl_w <=
|
||||
obj_w - style->body.padding.left - style->body.padding.right) { /*Full sized scroll bar*/
|
||||
lv_area_set_width(&ext->sb.hor_area, obj_w - 2 * sb_hor_pad);
|
||||
lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad, obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom);
|
||||
lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad,
|
||||
obj_h - ext->sb.style->body.padding.inner -
|
||||
ext->sb.style->body.padding.bottom);
|
||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 0;
|
||||
} else {
|
||||
size_tmp = (obj_w * (obj_w - (2 * sb_hor_pad))) / (scrl_w + style->body.padding.left + style->body.padding.right);
|
||||
size_tmp = (obj_w * (obj_w - (2 * sb_hor_pad))) /
|
||||
(scrl_w + style->body.padding.left + style->body.padding.right);
|
||||
if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
|
||||
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) - style->body.padding.left) * (obj_w - size_tmp - 2 * sb_hor_pad)) /
|
||||
lv_area_set_pos(
|
||||
&ext->sb.hor_area,
|
||||
sb_hor_pad +
|
||||
(-(lv_obj_get_x(scrl) - style->body.padding.left) *
|
||||
(obj_w - size_tmp - 2 * sb_hor_pad)) /
|
||||
(scrl_w + style->body.padding.left + style->body.padding.right - obj_w),
|
||||
obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom);
|
||||
|
||||
@ -1140,18 +1137,26 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
}
|
||||
|
||||
/*Vertical scrollbar*/
|
||||
if(scrl_h <= obj_h - style->body.padding.top - style->body.padding.bottom) { /*Full sized scroll bar*/
|
||||
if(scrl_h <=
|
||||
obj_h - style->body.padding.top - style->body.padding.bottom) { /*Full sized scroll bar*/
|
||||
lv_area_set_height(&ext->sb.ver_area, obj_h - 2 * sb_ver_pad);
|
||||
lv_area_set_pos(&ext->sb.ver_area, obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right, sb_ver_pad);
|
||||
lv_area_set_pos(&ext->sb.ver_area,
|
||||
obj_w - ext->sb.style->body.padding.inner -
|
||||
ext->sb.style->body.padding.right,
|
||||
sb_ver_pad);
|
||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 0;
|
||||
} else {
|
||||
size_tmp = (obj_h * (obj_h - (2 * sb_ver_pad))) / (scrl_h + style->body.padding.top + style->body.padding.bottom);
|
||||
size_tmp = (obj_h * (obj_h - (2 * sb_ver_pad))) /
|
||||
(scrl_h + style->body.padding.top + style->body.padding.bottom);
|
||||
if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
|
||||
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.bottom,
|
||||
lv_area_set_pos(
|
||||
&ext->sb.ver_area,
|
||||
obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom,
|
||||
sb_ver_pad +
|
||||
(-(lv_obj_get_y(scrl) - ext->sb.style->body.padding.bottom) * (obj_h - size_tmp - 2 * sb_ver_pad)) /
|
||||
(-(lv_obj_get_y(scrl) - ext->sb.style->body.padding.bottom) *
|
||||
(obj_h - size_tmp - 2 * sb_ver_pad)) /
|
||||
(scrl_h + style->body.padding.top + style->body.padding.bottom - obj_h));
|
||||
|
||||
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 1;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user