mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
further style renames + remove LV_DOWNSCALE
This commit is contained in:
parent
8c9d4b58ed
commit
2ea1af59b9
@ -14,9 +14,9 @@
|
||||
|
||||
/* Horizontal and vertical resolution of the library.
|
||||
* Screen resolution multiplied by LV_DOWN_SCALE*/
|
||||
#define LV_HOR_RES (320 * LV_DOWNSCALE)
|
||||
#define LV_VER_RES (240 * LV_DOWNSCALE)
|
||||
#define LV_DPI (80 * LV_DOWNSCALE)
|
||||
#define LV_HOR_RES (320 << LV_ANTIALIAS)
|
||||
#define LV_VER_RES (240 << LV_ANTIALIAS)
|
||||
#define LV_DPI (80 << LV_ANTIALIAS)
|
||||
/* Enable anti-aliasing
|
||||
* If enabled everything will half-sized
|
||||
* Use LV_DOWNSCALE to compensate he down scaling effect of anti-aliasing*/
|
||||
@ -40,7 +40,7 @@
|
||||
/*Display Input settings*/
|
||||
#define LV_INDEV_READ_PERIOD 50 /*Input device read period milliseconds*/
|
||||
#define LV_INDEV_TP_MARKER 0 /*Mark the pressed points (Value means marker point size)*/
|
||||
#define LV_INDEV_DRAG_LIMIT (10 * LV_DOWNSCALE) /*Drag threshold in pixels */
|
||||
#define LV_INDEV_DRAG_LIMIT (10 << LV_ANTIALIAS) /*Drag threshold in pixels */
|
||||
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
|
||||
#define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
|
||||
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
||||
@ -65,8 +65,8 @@
|
||||
/*Label (dependencies: -*/
|
||||
#define USE_LV_LABEL 1
|
||||
#if USE_LV_LABEL != 0
|
||||
#define LV_LABEL_SCROLL_SPEED (25 * LV_DOWNSCALE) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL' mode*/
|
||||
#define LV_LABEL_SCROLL_SPEED_VER (10 * LV_DOWNSCALE) /*Ver. scroll speed if hor. scroll is applied too*/
|
||||
#define LV_LABEL_SCROLL_SPEED (25 << LV_ANTIALIAS) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL' mode*/
|
||||
#define LV_LABEL_SCROLL_SPEED_VER (10 << LV_ANTIALIAS) /*Ver. scroll speed if hor. scroll is applied too*/
|
||||
#define LV_LABEL_SCROLL_PLAYBACK_PAUSE 500 /*Wait before the scroll turns back in ms*/
|
||||
#define LV_LABEL_SCROLL_REPEAT_PAUSE 500 /*Wait before the scroll begins again in ms*/
|
||||
#endif
|
||||
|
@ -96,7 +96,7 @@ void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_
|
||||
{
|
||||
if(area_get_height(cords_p) < 1 || area_get_width(cords_p) < 1) return;
|
||||
|
||||
if(style_p->shadow.width != 0) {
|
||||
if(style_p->body.shadow.width != 0) {
|
||||
lv_draw_rect_shadow(cords_p, mask_p, style_p);
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_
|
||||
}
|
||||
}
|
||||
|
||||
if(style_p->border.width != 0) {
|
||||
if(style_p->body.border.width != 0) {
|
||||
lv_draw_rect_border_straight(cords_p, mask_p, style_p);
|
||||
|
||||
if(style_p->body.radius != 0) {
|
||||
@ -356,8 +356,8 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
const lv_style_t * style, const char * fn)
|
||||
{
|
||||
if(fn == NULL) {
|
||||
lv_draw_rect(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_draw_label(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN, NULL), "No data", TXT_FLAG_NONE, NULL);
|
||||
lv_draw_rect(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN));
|
||||
lv_draw_label(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN), "No data", TXT_FLAG_NONE, NULL);
|
||||
} else {
|
||||
fs_file_t file;
|
||||
fs_res_t res = fs_open(&file, fn, FS_MODE_RD);
|
||||
@ -443,8 +443,8 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
fs_close(&file);
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_draw_rect(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_draw_label(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN, NULL), "No data", TXT_FLAG_NONE, NULL);
|
||||
lv_draw_rect(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN));
|
||||
lv_draw_label(cords_p, mask_p, lv_style_get(LV_STYLE_PLAIN), "No data", TXT_FLAG_NONE, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -815,8 +815,8 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t *
|
||||
|
||||
cord_t width = area_get_width(cords_p);
|
||||
cord_t height = area_get_height(cords_p);
|
||||
uint16_t bwidth = style_p->border.width;
|
||||
opa_t bopa = (uint16_t)((uint16_t) style_p->opacity * style_p->border.opa) >> 8;
|
||||
uint16_t bwidth = style_p->body.border.width;
|
||||
opa_t bopa = (uint16_t)((uint16_t) style_p->opacity * style_p->body.border.opa) >> 8;
|
||||
area_t work_area;
|
||||
cord_t length_corr = 0;
|
||||
cord_t corner_size = 0;
|
||||
@ -836,7 +836,7 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t *
|
||||
/* Modify the corner_size if corner is drawn */
|
||||
corner_size ++;
|
||||
|
||||
color_t b_color = style_p->border.color;
|
||||
color_t b_color = style_p->body.border.color;
|
||||
|
||||
/*Left border*/
|
||||
work_area.x1 = cords_p->x1;
|
||||
@ -928,9 +928,9 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t *
|
||||
static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style)
|
||||
{
|
||||
uint16_t radius = style->body.radius;
|
||||
uint16_t bwidth = style->border.width;
|
||||
color_t bcolor = style->border.color;
|
||||
opa_t bopa = (uint16_t)((uint16_t) style->opacity * style->border.opa ) >> 8;
|
||||
uint16_t bwidth = style->body.border.width;
|
||||
color_t bcolor = style->body.border.color;
|
||||
opa_t bopa = (uint16_t)((uint16_t) style->opacity * style->body.border.opa ) >> 8;
|
||||
|
||||
/*0 px border width drawn as 1 px, so decrement the bwidth*/
|
||||
bwidth--;
|
||||
@ -1080,9 +1080,9 @@ static void lv_draw_rect_shadow(const area_t * cords_p, const area_t * mask_p, c
|
||||
area_tmp.y2 -= radius;
|
||||
if(area_is_in(mask_p, &area_tmp) != false) return;
|
||||
|
||||
if(style->shadow.type == LV_SHADOW_FULL) {
|
||||
if(style->body.shadow.type == LV_SHADOW_FULL) {
|
||||
lv_draw_cont_shadow_full(cords_p, mask_p, style);
|
||||
} else if(style->shadow.type == LV_SHADOW_BOTTOM) {
|
||||
} else if(style->body.shadow.type == LV_SHADOW_BOTTOM) {
|
||||
lv_draw_cont_shadow_bottom(cords_p, mask_p, style);
|
||||
}
|
||||
}
|
||||
@ -1109,7 +1109,7 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask
|
||||
int16_t row;
|
||||
|
||||
uint16_t opa_h_result[LV_HOR_RES];
|
||||
int16_t filter_size = 2 * style->shadow.width + 1;
|
||||
int16_t filter_size = 2 * style->body.shadow.width + 1;
|
||||
|
||||
for(row = 0; row < filter_size; row++) {
|
||||
opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->opacity * 2) / (filter_size);
|
||||
@ -1139,13 +1139,13 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask
|
||||
ofs_lt.y = cords_p->y1 + radius;
|
||||
|
||||
|
||||
for(row = 0; row < radius + style->shadow.width; row++) {
|
||||
for(p = 0; p < radius + style->shadow.width; p++) {
|
||||
for(row = 0; row < radius + style->body.shadow.width; row++) {
|
||||
for(p = 0; p < radius + style->body.shadow.width; p++) {
|
||||
int16_t v;
|
||||
uint32_t opa_tmp = 0;
|
||||
int16_t row_v;
|
||||
bool swidth_out = false;
|
||||
for(v = -style->shadow.width; v < style->shadow.width; v++) {
|
||||
for(v = -style->body.shadow.width; v < style->body.shadow.width; v++) {
|
||||
row_v = row + v;
|
||||
if(row_v < 0) row_v = 0; /*Rows above the corner*/
|
||||
|
||||
@ -1156,19 +1156,19 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask
|
||||
else
|
||||
{
|
||||
int16_t p_tmp = p - (cruve_x[row_v] - cruve_x[row]);
|
||||
if(p_tmp < -style->shadow.width) { /*Cols before the filtered shadow (still not blurred)*/
|
||||
if(p_tmp < -style->body.shadow.width) { /*Cols before the filtered shadow (still not blurred)*/
|
||||
opa_tmp += style->opacity * 2;
|
||||
}
|
||||
/*Cols after the filtered shadow (already no effect) */
|
||||
else if (p_tmp > style->shadow.width) {
|
||||
else if (p_tmp > style->body.shadow.width) {
|
||||
/* If on the current point the filter top point is already out of swidth then
|
||||
* the remaining part will not do not anything on this point*/
|
||||
if(v == -style->shadow.width) { /*Is the first point?*/
|
||||
if(v == -style->body.shadow.width) { /*Is the first point?*/
|
||||
swidth_out = true;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
opa_tmp += opa_h_result[p_tmp + style->shadow.width];
|
||||
opa_tmp += opa_h_result[p_tmp + style->body.shadow.width];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1197,19 +1197,19 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask
|
||||
for(d = 0; d < p; d++) {
|
||||
|
||||
if(point_rt.x != point_lt.x) {
|
||||
px_fp(point_lt.x,point_lt.y , mask_p, style->shadow.color, opa_v_result[d]);
|
||||
px_fp(point_lt.x,point_lt.y , mask_p, style->body.shadow.color, opa_v_result[d]);
|
||||
}
|
||||
|
||||
if(point_rb.x != point_lb.x && point_lt.y != point_lb.y) {
|
||||
px_fp(point_lb.x,point_lb.y , mask_p, style->shadow.color, opa_v_result[d]);
|
||||
px_fp(point_lb.x,point_lb.y , mask_p, style->body.shadow.color, opa_v_result[d]);
|
||||
}
|
||||
|
||||
if(point_lt.y != point_lb.y) {
|
||||
px_fp(point_rb.x,point_rb.y , mask_p, style->shadow.color, opa_v_result[d]);
|
||||
px_fp(point_rb.x,point_rb.y , mask_p, style->body.shadow.color, opa_v_result[d]);
|
||||
}
|
||||
|
||||
|
||||
px_fp(point_rt.x,point_rt.y , mask_p, style->shadow.color, opa_v_result[d]);
|
||||
px_fp(point_rt.x,point_rt.y , mask_p, style->body.shadow.color, opa_v_result[d]);
|
||||
|
||||
|
||||
point_rb.x++;
|
||||
@ -1249,7 +1249,7 @@ static void lv_draw_cont_shadow_bottom(const area_t * cords_p, const area_t * ma
|
||||
int16_t row;
|
||||
|
||||
opa_t opa_h_result[LV_HOR_RES];
|
||||
int16_t filter_size = 2 * style->shadow.width + 1;
|
||||
int16_t filter_size = 2 * style->body.shadow.width + 1;
|
||||
|
||||
for(row = 0; row < filter_size; row++) {
|
||||
opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->opacity) / (filter_size);
|
||||
@ -1275,11 +1275,11 @@ static void lv_draw_cont_shadow_bottom(const area_t * cords_p, const area_t * ma
|
||||
point_r.y = ofs2.y + cruve_x[row];
|
||||
|
||||
uint16_t d;
|
||||
for(d= style->shadow.width; d < filter_size; d++) {
|
||||
px_fp(point_l.x, point_l.y, mask_p, style->shadow.color, opa_h_result[d]);
|
||||
for(d= style->body.shadow.width; d < filter_size; d++) {
|
||||
px_fp(point_l.x, point_l.y, mask_p, style->body.shadow.color, opa_h_result[d]);
|
||||
point_l.y ++;
|
||||
|
||||
px_fp(point_r.x, point_r.y, mask_p, style->shadow.color, opa_h_result[d]);
|
||||
px_fp(point_r.x, point_r.y, mask_p, style->body.shadow.color, opa_h_result[d]);
|
||||
point_r.y ++;
|
||||
}
|
||||
|
||||
@ -1291,8 +1291,8 @@ static void lv_draw_cont_shadow_bottom(const area_t * cords_p, const area_t * ma
|
||||
area_mid.y2 = area_mid.y1;
|
||||
|
||||
uint16_t d;
|
||||
for(d= style->shadow.width; d < filter_size; d++) {
|
||||
fill_fp(&area_mid, mask_p, style->shadow.color, opa_h_result[d]);
|
||||
for(d= style->body.shadow.width; d < filter_size; d++) {
|
||||
fill_fp(&area_mid, mask_p, style->body.shadow.color, opa_h_result[d]);
|
||||
area_mid.y1 ++;
|
||||
area_mid.y2 ++;
|
||||
}
|
||||
@ -1333,20 +1333,20 @@ static void lv_draw_cont_shadow_full_straight(const area_t * cords_p, const area
|
||||
sideb_area.y2 = sideb_area.y1;
|
||||
|
||||
int16_t d;
|
||||
for(d = 0; d < style->shadow.width; d++) {
|
||||
fill_fp(&sider_area, mask_p, style->shadow.color, map[d]);
|
||||
for(d = 0; d < style->body.shadow.width; d++) {
|
||||
fill_fp(&sider_area, mask_p, style->body.shadow.color, map[d]);
|
||||
sider_area.x1++;
|
||||
sider_area.x2++;
|
||||
|
||||
fill_fp(&sidel_area, mask_p, style->shadow.color, map[d]);
|
||||
fill_fp(&sidel_area, mask_p, style->body.shadow.color, map[d]);
|
||||
sidel_area.x1--;
|
||||
sidel_area.x2--;
|
||||
|
||||
fill_fp(&sidet_area, mask_p, style->shadow.color, map[d]);
|
||||
fill_fp(&sidet_area, mask_p, style->body.shadow.color, map[d]);
|
||||
sidet_area.y1--;
|
||||
sidet_area.y2--;
|
||||
|
||||
fill_fp(&sideb_area, mask_p, style->shadow.color, map[d]);
|
||||
fill_fp(&sideb_area, mask_p, style->body.shadow.color, map[d]);
|
||||
sideb_area.y1++;
|
||||
sideb_area.y2++;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ void lv_ex_objects(void)
|
||||
lv_obj_t * chart = lv_chart_create(lv_scr_act(), NULL); /*Craete the chart*/
|
||||
lv_obj_set_size(chart, lv_obj_get_width(scr) / 2, lv_obj_get_width(scr) / 4); /*Set the size*/
|
||||
lv_obj_align(chart, slider, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20); /*Align below the slider*/
|
||||
lv_chart_set_dl_width(chart, 3 * LV_DOWNSCALE); /*Set the line width (LV_DOWNSCALE compensates anti-aliasing if enabled)*/
|
||||
lv_chart_set_dl_width(chart, 3 << LV_ANTIALIAS); /*Set the line width (LV_DOWNSCALE compensates anti-aliasing if enabled)*/
|
||||
|
||||
/*Add a RED data line and set some points*/
|
||||
lv_chart_dl_t * dl1 = lv_chart_add_data_line(chart, COLOR_RED);
|
||||
|
@ -109,15 +109,15 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
||||
LL_READ(g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
if(g->obj_focus != NULL) {
|
||||
(*g->obj_focus)->signal_f(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_inv(*g->obj_focus);
|
||||
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*g->obj_focus);
|
||||
}
|
||||
|
||||
g->obj_focus = i;
|
||||
|
||||
if(g->obj_focus != NULL){
|
||||
(*g->obj_focus)->signal_f(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_inv(*g->obj_focus);
|
||||
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*g->obj_focus);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -133,8 +133,8 @@ void lv_group_focus_next(lv_group_t * group)
|
||||
if(group->frozen != 0) return;
|
||||
|
||||
if(group->obj_focus != NULL) {
|
||||
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_inv(*group->obj_focus);
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
lv_obj_t ** obj_next;
|
||||
@ -145,8 +145,8 @@ void lv_group_focus_next(lv_group_t * group)
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus != NULL){
|
||||
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_inv(*group->obj_focus);
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,8 +159,8 @@ void lv_group_focus_prev(lv_group_t * group)
|
||||
if(group->frozen != 0) return;
|
||||
|
||||
if(group->obj_focus != NULL) {
|
||||
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_inv(*group->obj_focus);
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
lv_obj_t ** obj_next;
|
||||
@ -171,8 +171,8 @@ void lv_group_focus_prev(lv_group_t * group)
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus != NULL){
|
||||
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_inv(*group->obj_focus);
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
}
|
||||
@ -198,7 +198,7 @@ void lv_group_send(lv_group_t * group, char c)
|
||||
lv_obj_t * act = lv_group_get_focused(group);
|
||||
if(act == NULL) return;
|
||||
|
||||
act->signal_f(act, LV_SIGNAL_CONTROLL, &c);
|
||||
act->signal_func(act, LV_SIGNAL_CONTROLL, &c);
|
||||
}
|
||||
|
||||
|
||||
@ -210,7 +210,7 @@ void lv_group_send(lv_group_t * group, char c)
|
||||
void lv_group_set_style_mod_cb(lv_group_t * group, void (*style_cb)(lv_style_t * style))
|
||||
{
|
||||
group->style_mod = style_cb;
|
||||
if(group->obj_focus != NULL) lv_obj_inv(*group->obj_focus);
|
||||
if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +221,7 @@ void lv_group_set_style_mod_cb(lv_group_t * group, void (*style_cb)(lv_style_t *
|
||||
*/
|
||||
lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style)
|
||||
{
|
||||
lv_style_cpy(&group->style_tmp, style);
|
||||
lv_style_copy(&group->style_tmp, style);
|
||||
|
||||
if(group->style_mod != NULL) group->style_mod(&group->style_tmp);
|
||||
else style_mod_def(&group->style_tmp);
|
||||
@ -253,10 +253,10 @@ lv_obj_t * lv_group_get_focused(lv_group_t * group)
|
||||
static void style_mod_def(lv_style_t * style)
|
||||
{
|
||||
/*Make the style a little bit orange*/
|
||||
style->border.color = COLOR_ORANGE;
|
||||
style->border.opa = OPA_COVER;
|
||||
if(style->border.width == 0 && style->body.empty == 0) style->border.width = 2 * LV_DOWNSCALE; /*Add border to not transparent styles*/
|
||||
else style->border.width = style->border.width * 2; /*Make the border thicker*/
|
||||
style->body.border.color = COLOR_ORANGE;
|
||||
style->body.border.opa = OPA_COVER;
|
||||
if(style->body.border.width == 0 && style->body.empty == 0) style->body.border.width = 2 << LV_ANTIALIAS; /*Add border to not transparent styles*/
|
||||
else style->body.border.width = style->body.border.width * 2; /*Make the border thicker*/
|
||||
style->body.color_main = color_mix(style->body.color_main, COLOR_ORANGE, OPA_80);
|
||||
style->body.color_gradient = color_mix(style->body.color_gradient, COLOR_ORANGE, OPA_80);
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ static void indev_proc_task(void * param)
|
||||
(i->state.last_point.x != data.point.x ||
|
||||
i->state.last_point.y != data.point.y))
|
||||
{
|
||||
lv_obj_set_pos_us(i->cursor, data.point.x, data.point.y);
|
||||
lv_obj_set_pos_scale(i->cursor, data.point.x, data.point.y);
|
||||
}
|
||||
|
||||
/*Process the current point*/
|
||||
@ -245,8 +245,8 @@ static void indev_proc_task(void * param)
|
||||
static void indev_proc_point(lv_indev_state_t * indev, cord_t x, cord_t y)
|
||||
{
|
||||
#if LV_ANTIALIAS != 0 && LV_VDB_SIZE != 0
|
||||
indev->act_point.x = x * LV_DOWNSCALE;
|
||||
indev->act_point.y = y * LV_DOWNSCALE;
|
||||
indev->act_point.x = x << LV_ANTIALIAS;
|
||||
indev->act_point.y = y << LV_ANTIALIAS;
|
||||
#else
|
||||
indev->act_point.x = x;
|
||||
indev->act_point.y = y;
|
||||
@ -283,12 +283,12 @@ static void indev_proc_press(lv_indev_state_t * state)
|
||||
/*If there is no last object then search*/
|
||||
if(state->act_obj == NULL) {
|
||||
pr_obj = indev_search_obj(state, lv_layer_top());
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(state, lv_scr_act());
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(state, lv_screen_act());
|
||||
}
|
||||
/*If there is last object but it is not dragged also search*/
|
||||
else if(state->drag_in_prog == 0) {/*Now act_obj != NULL*/
|
||||
pr_obj = indev_search_obj(state, lv_layer_top());
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(state, lv_scr_act());
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(state, lv_screen_act());
|
||||
}
|
||||
/*If a dragable object was the last then keep it*/
|
||||
else {
|
||||
@ -303,7 +303,7 @@ static void indev_proc_press(lv_indev_state_t * state)
|
||||
|
||||
/*If a new object found the previous was lost, so send a signal*/
|
||||
if(state->act_obj != NULL) {
|
||||
state->act_obj->signal_f(state->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
state->act_obj->signal_func(state->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
if(state->reset_qry != 0) return;
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ static void indev_proc_press(lv_indev_state_t * state)
|
||||
lv_obj_t * i = pr_obj;
|
||||
lv_obj_t * last_top = NULL;
|
||||
while(i != NULL){
|
||||
if(i->top_en != 0) last_top = i;
|
||||
if(i->top != 0) last_top = i;
|
||||
i = lv_obj_get_parent(i);
|
||||
}
|
||||
|
||||
@ -330,11 +330,11 @@ static void indev_proc_press(lv_indev_state_t * state)
|
||||
lv_obj_t * par = lv_obj_get_parent(last_top);
|
||||
/*After list change it will be the new head*/
|
||||
ll_chg_list(&par->child_ll, &par->child_ll, last_top);
|
||||
lv_obj_inv(last_top);
|
||||
lv_obj_invalidate(last_top);
|
||||
}
|
||||
|
||||
/*Send a signal about the press*/
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_PRESSED, indev_act);
|
||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_PRESSED, indev_act);
|
||||
if(state->reset_qry != 0) return;
|
||||
}
|
||||
}
|
||||
@ -348,7 +348,7 @@ static void indev_proc_press(lv_indev_state_t * state)
|
||||
|
||||
/*If there is active object and it can be dragged run the drag*/
|
||||
if(state->act_obj != NULL) {
|
||||
state->act_obj->signal_f(state->act_obj, LV_SIGNAL_PRESSING, indev_act);
|
||||
state->act_obj->signal_func(state->act_obj, LV_SIGNAL_PRESSING, indev_act);
|
||||
if(state->reset_qry != 0) return;
|
||||
|
||||
indev_drag(state);
|
||||
@ -358,7 +358,7 @@ static void indev_proc_press(lv_indev_state_t * state)
|
||||
if(state->drag_in_prog == 0 && state->long_press_sent == 0) {
|
||||
/*Send a signal about the long press if enough time elapsed*/
|
||||
if(lv_tick_elaps(state->press_time_stamp) > LV_INDEV_LONG_PRESS_TIME) {
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
|
||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
|
||||
if(state->reset_qry != 0) return;
|
||||
|
||||
/*Mark the signal sending to do not send it again*/
|
||||
@ -372,7 +372,7 @@ static void indev_proc_press(lv_indev_state_t * state)
|
||||
if(state->drag_in_prog == 0 && state->long_press_sent == 1) {
|
||||
/*Send a signal about the long press repeate if enough time elapsed*/
|
||||
if(lv_tick_elaps(state->lpr_rep_time_stamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
|
||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
|
||||
if(state->reset_qry != 0) return;
|
||||
state->lpr_rep_time_stamp = lv_tick_get();
|
||||
|
||||
@ -397,7 +397,7 @@ static void disi_proc_release(lv_indev_state_t * state)
|
||||
|
||||
/*Forgot the act obj and send a released signal */
|
||||
if(state->act_obj != NULL) {
|
||||
state->act_obj->signal_f(state->act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
state->act_obj->signal_func(state->act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
if(state->reset_qry != 0) return;
|
||||
state->act_obj = NULL;
|
||||
state->press_time_stamp = 0;
|
||||
@ -424,7 +424,7 @@ static lv_obj_t * indev_search_obj(const lv_indev_state_t * indev, lv_obj_t * ob
|
||||
|
||||
/*If the point is on this object*/
|
||||
/*Check its children too*/
|
||||
if(area_is_point_on(&obj->cords, &indev->act_point)) {
|
||||
if(area_is_point_on(&obj->coords, &indev->act_point)) {
|
||||
lv_obj_t * i;
|
||||
|
||||
LL_READ(obj->child_ll, i) {
|
||||
@ -498,7 +498,7 @@ static void indev_drag(lv_indev_state_t * state)
|
||||
/*Set the drag in progress flag if the object is really moved*/
|
||||
if(lv_obj_get_x(drag_obj) != act_x || lv_obj_get_y(drag_obj) != act_y) {
|
||||
if(state->drag_range_out != 0) { /*Send the drag begin signal on first move*/
|
||||
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act);
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act);
|
||||
if(state->reset_qry != 0) return;
|
||||
}
|
||||
state->drag_in_prog = 1;
|
||||
@ -531,7 +531,7 @@ static void indev_drag_throw(lv_indev_state_t * state)
|
||||
/*Return if the drag throw is not enabled*/
|
||||
if(lv_obj_get_drag_throw(drag_obj) == false ){
|
||||
state->drag_in_prog = 0;
|
||||
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -550,6 +550,6 @@ static void indev_drag_throw(lv_indev_state_t * state)
|
||||
/*If the vectors become 0 -> drag_in_prog = 0 and send a drag end signal*/
|
||||
else {
|
||||
state->drag_in_prog = 0;
|
||||
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
}
|
||||
}
|
||||
|
343
lv_obj/lv_obj.c
343
lv_obj/lv_obj.c
@ -33,10 +33,10 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_obj_pos_child_refr(lv_obj_t * obj, cord_t x_diff, cord_t y_diff);
|
||||
static void refresh_childen_position(lv_obj_t * obj, cord_t x_diff, cord_t y_diff);
|
||||
static void lv_style_refr_core(void * style_p, lv_obj_t * obj);
|
||||
static void lv_child_refr_style(lv_obj_t * obj);
|
||||
static void lv_obj_del_child(lv_obj_t * obj);
|
||||
static void refresh_childen_style(lv_obj_t * obj);
|
||||
static void delete_children(lv_obj_t * obj);
|
||||
static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
@ -46,7 +46,7 @@ static lv_obj_t * def_scr = NULL;
|
||||
static lv_obj_t * act_scr = NULL;
|
||||
static lv_obj_t * top_layer = NULL;
|
||||
static lv_obj_t * sys_layer = NULL;
|
||||
static ll_dsc_t scr_ll;
|
||||
static ll_dsc_t scr_ll; /*Linked list of screens*/
|
||||
|
||||
#ifdef LV_IMG_DEF_WALLPAPER
|
||||
LV_IMG_DECLARE(LV_IMG_DEF_WALLPAPER);
|
||||
@ -90,13 +90,13 @@ void lv_init(void)
|
||||
act_scr = def_scr;
|
||||
|
||||
top_layer = lv_obj_create(NULL, NULL);
|
||||
lv_obj_set_style(top_layer, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT, NULL));
|
||||
lv_obj_set_style(top_layer, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT));
|
||||
|
||||
sys_layer = lv_obj_create(NULL, NULL);
|
||||
lv_obj_set_style(sys_layer, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT, NULL));
|
||||
lv_obj_set_style(sys_layer, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT));
|
||||
|
||||
/*Refresh the screen*/
|
||||
lv_obj_inv(act_scr);
|
||||
lv_obj_invalidate(act_scr);
|
||||
|
||||
#if LV_INDEV_READ_PERIOD != 0
|
||||
/*Init the input device handling*/
|
||||
@ -132,18 +132,18 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
||||
|
||||
/*Set coordinates to full screen size*/
|
||||
new_obj->cords.x1 = 0;
|
||||
new_obj->cords.y1 = 0;
|
||||
new_obj->cords.x2 = LV_HOR_RES - 1;
|
||||
new_obj->cords.y2 = LV_VER_RES - 1;
|
||||
new_obj->coords.x1 = 0;
|
||||
new_obj->coords.y1 = 0;
|
||||
new_obj->coords.x2 = LV_HOR_RES - 1;
|
||||
new_obj->coords.y2 = LV_VER_RES - 1;
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Set appearance*/
|
||||
new_obj->style_p = lv_style_get(LV_STYLE_SCREEN, NULL);
|
||||
new_obj->style_p = lv_style_get(LV_STYLE_SCREEN);
|
||||
|
||||
/*Set virtual functions*/
|
||||
lv_obj_set_signal_f(new_obj, lv_obj_signal);
|
||||
lv_obj_set_design_f(new_obj, lv_obj_design);
|
||||
lv_obj_set_signal_func(new_obj, lv_obj_signal);
|
||||
lv_obj_set_design_func(new_obj, lv_obj_design);
|
||||
|
||||
/*Set free data*/
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
@ -151,22 +151,22 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
new_obj->free_p = NULL;
|
||||
new_obj->free_ptr = NULL;
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_GROUP != 0
|
||||
new_obj->group_p = NULL;
|
||||
#endif
|
||||
/*Set attributes*/
|
||||
new_obj->click_en = 0;
|
||||
new_obj->drag_en = 0;
|
||||
new_obj->drag_throw_en = 0;
|
||||
new_obj->click = 0;
|
||||
new_obj->drag = 0;
|
||||
new_obj->drag_throw = 0;
|
||||
new_obj->drag_parent = 0;
|
||||
new_obj->hidden = 0;
|
||||
new_obj->top_en = 0;
|
||||
new_obj->top = 0;
|
||||
new_obj->protect = LV_PROTECT_NONE;
|
||||
|
||||
new_obj->ext = NULL;
|
||||
new_obj->ext_attr = NULL;
|
||||
}
|
||||
/*parent != NULL create normal obj. on a parent*/
|
||||
else
|
||||
@ -177,46 +177,46 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
ll_init(&(new_obj->child_ll), sizeof(lv_obj_t));
|
||||
|
||||
/*Set coordinates left top corner of parent*/
|
||||
new_obj->cords.x1 = parent->cords.x1;
|
||||
new_obj->cords.y1 = parent->cords.y1;
|
||||
new_obj->cords.x2 = parent->cords.x1 +
|
||||
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->cords.y2 = parent->cords.y1 +
|
||||
new_obj->coords.y2 = parent->coords.y1 +
|
||||
LV_OBJ_DEF_HEIGHT;
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Set appearance*/
|
||||
new_obj->style_p = lv_style_get(LV_STYLE_PLAIN, NULL);
|
||||
new_obj->style_p = lv_style_get(LV_STYLE_PLAIN);
|
||||
|
||||
/*Set virtual functions*/
|
||||
lv_obj_set_signal_f(new_obj, lv_obj_signal);
|
||||
lv_obj_set_design_f(new_obj, lv_obj_design);
|
||||
lv_obj_set_signal_func(new_obj, lv_obj_signal);
|
||||
lv_obj_set_design_func(new_obj, lv_obj_design);
|
||||
|
||||
/*Set free data*/
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
new_obj->free_num = 0;
|
||||
#endif
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
new_obj->free_p = NULL;
|
||||
new_obj->free_ptr = NULL;
|
||||
#endif
|
||||
#if LV_OBJ_GROUP != 0
|
||||
new_obj->group_p = NULL;
|
||||
#endif
|
||||
|
||||
/*Set attributes*/
|
||||
new_obj->click_en = 1;
|
||||
new_obj->drag_en = 0;
|
||||
new_obj->drag_throw_en = 0;
|
||||
new_obj->click = 1;
|
||||
new_obj->drag = 0;
|
||||
new_obj->drag_throw = 0;
|
||||
new_obj->drag_parent = 0;
|
||||
new_obj->hidden = 0;
|
||||
new_obj->top_en = 0;
|
||||
new_obj->top = 0;
|
||||
new_obj->protect = LV_PROTECT_NONE;
|
||||
|
||||
new_obj->ext = NULL;
|
||||
new_obj->ext_attr = NULL;
|
||||
}
|
||||
|
||||
if(copy != NULL) {
|
||||
area_cpy(&new_obj->cords, ©->cords);
|
||||
area_cpy(&new_obj->coords, ©->coords);
|
||||
new_obj->ext_size = copy->ext_size;
|
||||
|
||||
/*Set free data*/
|
||||
@ -224,15 +224,15 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->free_num = copy->free_num;
|
||||
#endif
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
new_obj->free_p = copy->free_p;
|
||||
new_obj->free_ptr = copy->free_ptr;
|
||||
#endif
|
||||
/*Set attributes*/
|
||||
new_obj->click_en = copy->click_en;
|
||||
new_obj->drag_en = copy->drag_en;
|
||||
new_obj->drag_throw_en = copy->drag_throw_en;
|
||||
new_obj->click = copy->click;
|
||||
new_obj->drag = copy->drag;
|
||||
new_obj->drag_throw = copy->drag_throw;
|
||||
new_obj->drag_parent = copy->drag_parent;
|
||||
new_obj->hidden = copy->hidden;
|
||||
new_obj->top_en = copy->top_en;
|
||||
new_obj->top = copy->top;
|
||||
new_obj->protect = copy->protect;
|
||||
|
||||
new_obj->style_p = copy->style_p;
|
||||
@ -250,10 +250,10 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
|
||||
/*Send a signal to the parent to notify it about the new child*/
|
||||
if(parent != NULL) {
|
||||
parent->signal_f(parent, LV_SIGNAL_CHILD_CHG, new_obj);
|
||||
parent->signal_func(parent, LV_SIGNAL_CHILD_CHG, new_obj);
|
||||
|
||||
/*Invalidate the area if not screen created*/
|
||||
lv_obj_inv(new_obj);
|
||||
lv_obj_invalidate(new_obj);
|
||||
}
|
||||
|
||||
return new_obj;
|
||||
@ -265,7 +265,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
*/
|
||||
void lv_obj_del(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
/*Recursively delete the children*/
|
||||
lv_obj_t * i;
|
||||
@ -276,7 +276,7 @@ void lv_obj_del(lv_obj_t * obj)
|
||||
i_next = ll_get_next(&(obj->child_ll), i);
|
||||
|
||||
/*Call the recursive del to the child too*/
|
||||
lv_obj_del_child(i);
|
||||
delete_children(i);
|
||||
|
||||
/*Set i to the next node*/
|
||||
i = i_next;
|
||||
@ -295,10 +295,10 @@ void lv_obj_del(lv_obj_t * obj)
|
||||
|
||||
/* All children deleted.
|
||||
* Now clean up the object specific data*/
|
||||
obj->signal_f(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||
obj->signal_func(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||
|
||||
/*Delete the base objects*/
|
||||
if(obj->ext != NULL) dm_free(obj->ext);
|
||||
if(obj->ext_attr != NULL) dm_free(obj->ext_attr);
|
||||
dm_free(obj); /*Free the object itself*/
|
||||
|
||||
/* Reset all display input (indev_proc) if
|
||||
@ -321,7 +321,7 @@ void lv_obj_del(lv_obj_t * obj)
|
||||
|
||||
/*Send a signal to the parent to notify it about the child delete*/
|
||||
if(par != NULL) {
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,10 +343,10 @@ bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) valid = false;
|
||||
break;
|
||||
case LV_SIGNAL_REFR_EXT_SIZE:
|
||||
if(style->shadow.width > obj->ext_size) obj->ext_size = style->shadow.width;
|
||||
if(style->body.shadow.width > obj->ext_size) obj->ext_size = style->body.shadow.width;
|
||||
break;
|
||||
case LV_SIGNAL_STYLE_CHG:
|
||||
lv_obj_refr_ext_size(obj);
|
||||
lv_obj_refresh_ext_size(obj);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -360,11 +360,11 @@ bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj)
|
||||
void lv_obj_invalidate(lv_obj_t * obj)
|
||||
{
|
||||
/*Invalidate the object only if it belongs to the 'act_scr'*/
|
||||
lv_obj_t * obj_scr = lv_obj_get_scr(obj);
|
||||
if(obj_scr == lv_scr_act() ||
|
||||
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
|
||||
if(obj_scr == lv_screen_act() ||
|
||||
obj_scr == lv_layer_top() ||
|
||||
obj_scr == lv_layer_sys()) {
|
||||
/*Truncate recursively to the parents*/
|
||||
@ -373,7 +373,7 @@ void lv_obj_inv(lv_obj_t * obj)
|
||||
bool union_ok = true;
|
||||
/*Start with the original coordinates*/
|
||||
cord_t ext_size = obj->ext_size;
|
||||
area_cpy(&area_trunc, &obj->cords);
|
||||
area_cpy(&area_trunc, &obj->coords);
|
||||
area_trunc.x1 -= ext_size;
|
||||
area_trunc.y1 -= ext_size;
|
||||
area_trunc.x2 += ext_size;
|
||||
@ -381,7 +381,7 @@ void lv_obj_inv(lv_obj_t * obj)
|
||||
|
||||
/*Check through all parents*/
|
||||
while(par != NULL) {
|
||||
union_ok = area_union(&area_trunc, &area_trunc, &par->cords);
|
||||
union_ok = area_union(&area_trunc, &area_trunc, &par->coords);
|
||||
if(union_ok == false) break; /*If no common parts with parent break;*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
@ -404,11 +404,11 @@ void lv_obj_inv(lv_obj_t * obj)
|
||||
* Load a new screen
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_scr_load(lv_obj_t * scr)
|
||||
void lv_screen_load(lv_obj_t * scr)
|
||||
{
|
||||
act_scr = scr;
|
||||
|
||||
lv_obj_inv(act_scr);
|
||||
lv_obj_invalidate(act_scr);
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
@ -422,7 +422,7 @@ void lv_scr_load(lv_obj_t * scr)
|
||||
*/
|
||||
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
||||
{
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
point_t old_pos;
|
||||
old_pos.x = lv_obj_get_x(obj);
|
||||
@ -435,12 +435,12 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
||||
lv_obj_set_pos(obj, old_pos.x, old_pos.y);
|
||||
|
||||
/*Notify the original parent because one of its children is lost*/
|
||||
old_par->signal_f(old_par, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
old_par->signal_func(old_par, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
|
||||
/*Notify the new parent about the child*/
|
||||
parent->signal_f(parent, LV_SIGNAL_CHILD_CHG, obj);
|
||||
parent->signal_func(parent, LV_SIGNAL_CHILD_CHG, obj);
|
||||
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
@ -457,13 +457,13 @@ void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y)
|
||||
{
|
||||
/*Convert x and y to absolute coordinates*/
|
||||
lv_obj_t * par = obj->par;
|
||||
x = x + par->cords.x1;
|
||||
y = y + par->cords.y1;
|
||||
x = x + par->coords.x1;
|
||||
y = y + par->coords.y1;
|
||||
|
||||
/*Calculate and set the movement*/
|
||||
point_t diff;
|
||||
diff.x = x - obj->cords.x1;
|
||||
diff.y = y - obj->cords.y1;
|
||||
diff.x = x - obj->coords.x1;
|
||||
diff.y = y - obj->coords.y1;
|
||||
|
||||
/* Do nothing if the position is not changed */
|
||||
/* It is very important else recursive positioning can
|
||||
@ -471,27 +471,27 @@ void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y)
|
||||
if(diff.x == 0 && diff.y == 0) return;
|
||||
|
||||
/*Invalidate the original area*/
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
/*Save the original coordinates*/
|
||||
area_t ori;
|
||||
lv_obj_get_cords(obj, &ori);
|
||||
lv_obj_get_coords(obj, &ori);
|
||||
|
||||
obj->cords.x1 += diff.x;
|
||||
obj->cords.y1 += diff.y;
|
||||
obj->cords.x2 += diff.x;
|
||||
obj->cords.y2 += diff.y;
|
||||
obj->coords.x1 += diff.x;
|
||||
obj->coords.y1 += diff.y;
|
||||
obj->coords.x2 += diff.x;
|
||||
obj->coords.y2 += diff.y;
|
||||
|
||||
lv_obj_pos_child_refr(obj, diff.x, diff.y);
|
||||
refresh_childen_position(obj, diff.x, diff.y);
|
||||
|
||||
/*Inform the object about its new coordinates*/
|
||||
obj->signal_f(obj, LV_SIGNAL_CORD_CHG, &ori);
|
||||
obj->signal_func(obj, LV_SIGNAL_CORD_CHG, &ori);
|
||||
|
||||
/*Send a signal to the parent too*/
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
|
||||
/*Invalidate the new area*/
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -501,9 +501,9 @@ void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y)
|
||||
* @param x new distance from the left side of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_pos_us(lv_obj_t * obj, cord_t x, cord_t y)
|
||||
void lv_obj_set_pos_scale(lv_obj_t * obj, cord_t x, cord_t y)
|
||||
{
|
||||
lv_obj_set_pos(obj, x * LV_DOWNSCALE, y * LV_DOWNSCALE);
|
||||
lv_obj_set_pos(obj, x << LV_ANTIALIAS, y << LV_ANTIALIAS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -522,9 +522,9 @@ void lv_obj_set_x(lv_obj_t * obj, cord_t x)
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_x_us(lv_obj_t * obj, cord_t x)
|
||||
void lv_obj_set_x_scale(lv_obj_t * obj, cord_t x)
|
||||
{
|
||||
lv_obj_set_pos(obj, x * LV_DOWNSCALE, lv_obj_get_y(obj));
|
||||
lv_obj_set_pos(obj, x << LV_ANTIALIAS, lv_obj_get_y(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -543,9 +543,9 @@ void lv_obj_set_y(lv_obj_t * obj, cord_t y)
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_y_us(lv_obj_t * obj, cord_t y)
|
||||
void lv_obj_set_y_scale(lv_obj_t * obj, cord_t y)
|
||||
{
|
||||
lv_obj_set_pos(obj, lv_obj_get_x(obj), y * LV_DOWNSCALE);
|
||||
lv_obj_set_pos(obj, lv_obj_get_x(obj), y << LV_ANTIALIAS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -565,26 +565,26 @@ void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h)
|
||||
}
|
||||
|
||||
/*Invalidate the original area*/
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
/*Save the original coordinates*/
|
||||
area_t ori;
|
||||
lv_obj_get_cords(obj, &ori);
|
||||
lv_obj_get_coords(obj, &ori);
|
||||
|
||||
//Set the length and height
|
||||
obj->cords.x2 = obj->cords.x1 + w - 1;
|
||||
obj->cords.y2 = obj->cords.y1 + h - 1;
|
||||
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_f(obj, LV_SIGNAL_CORD_CHG, &ori);
|
||||
obj->signal_func(obj, LV_SIGNAL_CORD_CHG, &ori);
|
||||
|
||||
/*Send a signal to the parent too*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
if(par != NULL) par->signal_f(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
if(par != NULL) par->signal_func(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
|
||||
/*Invalidate the new area*/
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -593,9 +593,9 @@ void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h)
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_size_us(lv_obj_t * obj, cord_t w, cord_t h)
|
||||
void lv_obj_set_size_scale(lv_obj_t * obj, cord_t w, cord_t h)
|
||||
{
|
||||
lv_obj_set_size(obj, w * LV_DOWNSCALE, h * LV_DOWNSCALE);
|
||||
lv_obj_set_size(obj, w << LV_ANTIALIAS, h << LV_ANTIALIAS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -613,9 +613,9 @@ void lv_obj_set_width(lv_obj_t * obj, cord_t w)
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_width_us(lv_obj_t * obj, cord_t w)
|
||||
void lv_obj_set_width_scale(lv_obj_t * obj, cord_t w)
|
||||
{
|
||||
lv_obj_set_size(obj, w * LV_DOWNSCALE, lv_obj_get_height(obj));
|
||||
lv_obj_set_size(obj, w << LV_ANTIALIAS, lv_obj_get_height(obj));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -633,9 +633,9 @@ void lv_obj_set_height(lv_obj_t * obj, cord_t h)
|
||||
* @param obj pointer to an object
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_height_us(lv_obj_t * obj, cord_t h)
|
||||
void lv_obj_set_height_scale(lv_obj_t * obj, cord_t h)
|
||||
{
|
||||
lv_obj_set_size(obj, lv_obj_get_width(obj), h * LV_DOWNSCALE);
|
||||
lv_obj_set_size(obj, lv_obj_get_width(obj), h << LV_ANTIALIAS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -763,10 +763,10 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod
|
||||
|
||||
/*Bring together the coordination system of base and obj*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
cord_t base_abs_x = base->cords.x1;
|
||||
cord_t base_abs_y = base->cords.y1;
|
||||
cord_t par_abs_x = par->cords.x1;
|
||||
cord_t par_abs_y = par->cords.y1;
|
||||
cord_t base_abs_x = base->coords.x1;
|
||||
cord_t base_abs_y = base->coords.y1;
|
||||
cord_t par_abs_x = par->coords.x1;
|
||||
cord_t par_abs_y = par->coords.y1;
|
||||
new_x += x_mod + base_abs_x;
|
||||
new_y += y_mod + base_abs_y;
|
||||
new_x -= par_abs_x;
|
||||
@ -784,9 +784,9 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod
|
||||
* @param x_mod x coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y_mod y coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod)
|
||||
void lv_obj_align_scale(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod)
|
||||
{
|
||||
lv_obj_align(obj, base, align, x_mod * LV_DOWNSCALE, y_mod * LV_DOWNSCALE);
|
||||
lv_obj_align(obj, base, align, x_mod << LV_ANTIALIAS, y_mod << LV_ANTIALIAS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -798,7 +798,7 @@ void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size)
|
||||
{
|
||||
obj->ext_size = ext_size;
|
||||
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/*---------------------
|
||||
@ -815,10 +815,10 @@ void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style)
|
||||
obj->style_p = style;
|
||||
|
||||
/*Send a signal about style change to every children with NULL style*/
|
||||
lv_child_refr_style(obj);
|
||||
refresh_childen_style(obj);
|
||||
|
||||
/*Notify the object about the style change too*/
|
||||
lv_obj_refr_style(obj);
|
||||
lv_obj_refresh_style(obj);
|
||||
|
||||
}
|
||||
|
||||
@ -826,14 +826,16 @@ void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style)
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_style(lv_obj_t * obj)
|
||||
void lv_obj_refresh_style(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_inv(obj);
|
||||
obj->signal_f(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
obj->signal_func(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*TODO move this function out of here*/
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pointer to a style. Only the objects with this style will be notified
|
||||
@ -862,9 +864,9 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
||||
obj->hidden = en == false ? 0 : 1;
|
||||
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -874,7 +876,7 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
||||
*/
|
||||
void lv_obj_set_click(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->click_en = (en == true ? 1 : 0);
|
||||
obj->click = (en == true ? 1 : 0);
|
||||
|
||||
}
|
||||
|
||||
@ -886,7 +888,7 @@ void lv_obj_set_click(lv_obj_t * obj, bool en)
|
||||
*/
|
||||
void lv_obj_set_top(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->top_en= (en == true ? 1 : 0);
|
||||
obj->top = (en == true ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -896,7 +898,7 @@ void lv_obj_set_top(lv_obj_t * obj, bool en)
|
||||
*/
|
||||
void lv_obj_set_drag(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->drag_en = (en == true ? 1 : 0);
|
||||
obj->drag = (en == true ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -906,7 +908,7 @@ void lv_obj_set_drag(lv_obj_t * obj, bool en)
|
||||
*/
|
||||
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en)
|
||||
{
|
||||
obj->drag_throw_en = (en == true ? 1 : 0);
|
||||
obj->drag_throw = (en == true ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -935,7 +937,7 @@ void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot)
|
||||
* @param obj pointer to an object
|
||||
* @param prot 'OR'-ed values from lv_obj_prot_t
|
||||
*/
|
||||
void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot)
|
||||
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot)
|
||||
{
|
||||
prot = (~prot) & 0xFF;
|
||||
obj->protect &= prot;
|
||||
@ -947,9 +949,9 @@ void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot)
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new signal function
|
||||
*/
|
||||
void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp)
|
||||
void lv_obj_set_signal_func(lv_obj_t * obj, lv_signal_func_t fp)
|
||||
{
|
||||
obj->signal_f = fp;
|
||||
obj->signal_func = fp;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -957,9 +959,9 @@ void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp)
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new design function
|
||||
*/
|
||||
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp)
|
||||
void lv_obj_set_design_func(lv_obj_t * obj, lv_design_func_t fp)
|
||||
{
|
||||
obj->design_f = fp;
|
||||
obj->design_func = fp;
|
||||
}
|
||||
|
||||
/*----------------
|
||||
@ -972,26 +974,26 @@ void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp)
|
||||
* @param ext_size the size of the new ext. data
|
||||
* @return Normal pointer to the allocated ext
|
||||
*/
|
||||
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size)
|
||||
void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size)
|
||||
{
|
||||
obj->ext = dm_realloc(obj->ext, ext_size);
|
||||
obj->ext_attr = dm_realloc(obj->ext_attr, ext_size);
|
||||
|
||||
return (void*)obj->ext;
|
||||
return (void*)obj->ext_attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_ext_size(lv_obj_t * obj)
|
||||
void lv_obj_refresh_ext_size(lv_obj_t * obj)
|
||||
{
|
||||
obj->ext_size = 0;
|
||||
obj->signal_f(obj, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
obj->signal_func(obj, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
|
||||
lv_obj_inv(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
#if LV_OBJ_FREE_NUMBER != 0
|
||||
/**
|
||||
* Set an application specific number for an object.
|
||||
* It can help to identify objects in the application.
|
||||
@ -1004,16 +1006,16 @@ void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
#if LV_OBJ_FREE_POINTER != 0
|
||||
/**
|
||||
* Set an application specific pointer for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_p the new free pinter
|
||||
*/
|
||||
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p)
|
||||
void lv_obj_set_free_ptr(lv_obj_t * obj, void * free_p)
|
||||
{
|
||||
obj->free_p = free_p;
|
||||
obj->free_ptr = free_p;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1025,7 +1027,7 @@ void lv_obj_set_free_p(lv_obj_t * obj, void * free_p)
|
||||
* @param delay delay before the animation in milliseconds
|
||||
* @param cb a function to call when the animation is ready
|
||||
*/
|
||||
void lv_obj_anim(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);
|
||||
|
||||
@ -1106,7 +1108,7 @@ void lv_obj_anim(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t
|
||||
* Return with the actual screen
|
||||
* @return pointer to the actual screen object
|
||||
*/
|
||||
lv_obj_t * lv_scr_act(void)
|
||||
lv_obj_t * lv_screen_act(void)
|
||||
{
|
||||
return act_scr;
|
||||
}
|
||||
@ -1135,14 +1137,14 @@ lv_obj_t * lv_layer_sys(void)
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a screen
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_scr(lv_obj_t * obj)
|
||||
lv_obj_t * lv_obj_get_screen(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * par = obj;
|
||||
lv_obj_t * act_p;
|
||||
|
||||
do {
|
||||
act_p = par;
|
||||
par = lv_obj_get_parent(act_p);
|
||||
par = lv_obj_get_parent(act_p);
|
||||
}
|
||||
while(par != NULL);
|
||||
|
||||
@ -1187,7 +1189,7 @@ lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child)
|
||||
* @param obj pointer to an object
|
||||
* @return children number of 'obj'
|
||||
*/
|
||||
uint16_t lv_obj_get_child_num(lv_obj_t * obj)
|
||||
uint16_t lv_obj_count_children(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
uint16_t cnt = 0;
|
||||
@ -1206,9 +1208,9 @@ uint16_t lv_obj_get_child_num(lv_obj_t * obj)
|
||||
* @param obj pointer to an object
|
||||
* @param cords_p pointer to an area to store the coordinates
|
||||
*/
|
||||
void lv_obj_get_cords(lv_obj_t * obj, area_t * cords_p)
|
||||
void lv_obj_get_coords(lv_obj_t * obj, area_t * cords_p)
|
||||
{
|
||||
area_cpy(cords_p, &obj->cords);
|
||||
area_cpy(cords_p, &obj->coords);
|
||||
}
|
||||
|
||||
|
||||
@ -1221,7 +1223,7 @@ cord_t lv_obj_get_x(lv_obj_t * obj)
|
||||
{
|
||||
cord_t rel_x;
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
rel_x = obj->cords.x1 - parent->cords.x1;
|
||||
rel_x = obj->coords.x1 - parent->coords.x1;
|
||||
|
||||
return rel_x;
|
||||
}
|
||||
@ -1235,7 +1237,7 @@ cord_t lv_obj_get_y(lv_obj_t * obj)
|
||||
{
|
||||
cord_t rel_y;
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
rel_y = obj->cords.y1 - parent->cords.y1;
|
||||
rel_y = obj->coords.y1 - parent->coords.y1;
|
||||
|
||||
return rel_y;
|
||||
}
|
||||
@ -1247,7 +1249,7 @@ cord_t lv_obj_get_y(lv_obj_t * obj)
|
||||
*/
|
||||
cord_t lv_obj_get_width(lv_obj_t * obj)
|
||||
{
|
||||
return area_get_width(&obj->cords);
|
||||
return area_get_width(&obj->coords);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1257,7 +1259,7 @@ cord_t lv_obj_get_width(lv_obj_t * obj)
|
||||
*/
|
||||
cord_t lv_obj_get_height(lv_obj_t * obj)
|
||||
{
|
||||
return area_get_height(&obj->cords);
|
||||
return area_get_height(&obj->coords);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1303,7 +1305,7 @@ lv_style_t * lv_obj_get_style(lv_obj_t * obj)
|
||||
}
|
||||
#endif
|
||||
|
||||
if(style_act == NULL) style_act = lv_style_get(LV_STYLE_PLAIN, NULL);
|
||||
if(style_act == NULL) style_act = lv_style_get(LV_STYLE_PLAIN);
|
||||
|
||||
return style_act;
|
||||
}
|
||||
@ -1329,7 +1331,7 @@ bool lv_obj_get_hidden(lv_obj_t * obj)
|
||||
*/
|
||||
bool lv_obj_get_click(lv_obj_t * obj)
|
||||
{
|
||||
return obj->click_en == 0 ? false : true;;
|
||||
return obj->click == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1339,7 +1341,7 @@ bool lv_obj_get_click(lv_obj_t * obj)
|
||||
*/
|
||||
bool lv_obj_get_top(lv_obj_t * obj)
|
||||
{
|
||||
return obj->top_en == 0 ? false : true;;
|
||||
return obj->top == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1349,7 +1351,7 @@ bool lv_obj_get_top(lv_obj_t * obj)
|
||||
*/
|
||||
bool lv_obj_get_drag(lv_obj_t * obj)
|
||||
{
|
||||
return obj->drag_en == 0 ? false : true;
|
||||
return obj->drag == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1359,7 +1361,7 @@ bool lv_obj_get_drag(lv_obj_t * obj)
|
||||
*/
|
||||
bool lv_obj_get_drag_throw(lv_obj_t * obj)
|
||||
{
|
||||
return obj->drag_throw_en == 0 ? false : true;
|
||||
return obj->drag_throw == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1398,9 +1400,9 @@ bool lv_obj_is_protected(lv_obj_t * obj, uint8_t prot)
|
||||
* @param obj pointer to an object
|
||||
* @return the signal function
|
||||
*/
|
||||
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj)
|
||||
lv_signal_func_t lv_obj_get_signal_func(lv_obj_t * obj)
|
||||
{
|
||||
return obj->signal_f;
|
||||
return obj->signal_func;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1408,9 +1410,9 @@ lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj)
|
||||
* @param obj pointer to an object
|
||||
* @return the design function
|
||||
*/
|
||||
lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj)
|
||||
lv_design_func_t lv_obj_get_design_func(lv_obj_t * obj)
|
||||
{
|
||||
return obj->design_f;
|
||||
return obj->design_func;
|
||||
}
|
||||
|
||||
|
||||
@ -1424,12 +1426,12 @@ lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj)
|
||||
* @return the ext pointer but not the dynamic version
|
||||
* Use it as ext->data1, and NOT da(ext)->data1
|
||||
*/
|
||||
void * lv_obj_get_ext(lv_obj_t * obj)
|
||||
void * lv_obj_get_ext_attr(lv_obj_t * obj)
|
||||
{
|
||||
return obj->ext;
|
||||
return obj->ext_attr;
|
||||
}
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
#if LV_OBJ_FREE_NUMBER != 0
|
||||
/**
|
||||
* Get the free number
|
||||
* @param obj pointer to an object
|
||||
@ -1441,15 +1443,15 @@ uint8_t lv_obj_get_free_num(lv_obj_t * obj)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
#if LV_OBJ_FREE_POINTER != 0
|
||||
/**
|
||||
* Get the free pointer
|
||||
* @param obj pointer to an object
|
||||
* @return the free pointer
|
||||
*/
|
||||
void * lv_obj_get_free_p(lv_obj_t * obj)
|
||||
void * lv_obj_get_free_ptr(lv_obj_t * obj)
|
||||
{
|
||||
return obj->free_p;
|
||||
return obj->free_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1494,20 +1496,20 @@ static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode
|
||||
area_t area_tmp;
|
||||
|
||||
/*Check horizontally without radius*/
|
||||
lv_obj_get_cords(obj, &area_tmp);
|
||||
lv_obj_get_coords(obj, &area_tmp);
|
||||
area_tmp.x1 += r;
|
||||
area_tmp.x2 -= r;
|
||||
if(area_is_in(mask_p, &area_tmp) == false) return false;
|
||||
|
||||
/*Check vertically without radius*/
|
||||
lv_obj_get_cords(obj, &area_tmp);
|
||||
lv_obj_get_coords(obj, &area_tmp);
|
||||
area_tmp.y1 += r;
|
||||
area_tmp.y2 -= r;
|
||||
if(area_is_in(mask_p, &area_tmp) == false) return false;
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
lv_draw_rect(&obj->cords, mask_p, style);
|
||||
lv_draw_rect(&obj->coords, mask_p, style);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1518,19 +1520,20 @@ static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode
|
||||
* @param x_diff x coordinate shift
|
||||
* @param y_diff y coordinate shift
|
||||
*/
|
||||
static void lv_obj_pos_child_refr(lv_obj_t * obj, cord_t x_diff, cord_t y_diff)
|
||||
static void refresh_childen_position(lv_obj_t * obj, cord_t x_diff, cord_t y_diff)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LL_READ(obj->child_ll, i) {
|
||||
i->cords.x1 += x_diff;
|
||||
i->cords.y1 += y_diff;
|
||||
i->cords.x2 += x_diff;
|
||||
i->cords.y2 += y_diff;
|
||||
i->coords.x1 += x_diff;
|
||||
i->coords.y1 += y_diff;
|
||||
i->coords.x2 += x_diff;
|
||||
i->coords.y2 += y_diff;
|
||||
|
||||
lv_obj_pos_child_refr(i, x_diff, y_diff);
|
||||
refresh_childen_position(i, x_diff, y_diff);
|
||||
}
|
||||
}
|
||||
|
||||
/*TODO move this function out of here*/
|
||||
/**
|
||||
* Refresh the style of all children of an object. (Called recursively)
|
||||
* @param style_p refresh objects only with this style. (ignore is if NULL)
|
||||
@ -1541,7 +1544,7 @@ static void lv_style_refr_core(void * style_p, lv_obj_t * obj)
|
||||
lv_obj_t * i;
|
||||
LL_READ(obj->child_ll, i) {
|
||||
if(i->style_p == style_p || style_p == NULL) {
|
||||
lv_child_refr_style(i);
|
||||
refresh_childen_style(i);
|
||||
}
|
||||
|
||||
lv_style_refr_core(style_p, i);
|
||||
@ -1554,16 +1557,16 @@ static void lv_style_refr_core(void * style_p, lv_obj_t * obj)
|
||||
* because the NULL styles are inherited from the parent
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
static void lv_child_refr_style(lv_obj_t * obj)
|
||||
static void refresh_childen_style(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
while(child != NULL) {
|
||||
if(child->style_p == NULL) {
|
||||
lv_child_refr_style(child); /*Check children too*/
|
||||
lv_obj_refr_style(child); /*Notify the child about the style change*/
|
||||
refresh_childen_style(child); /*Check children too*/
|
||||
lv_obj_refresh_style(child); /*Notify the child about the style change*/
|
||||
} else if(child->style_p->glass) {
|
||||
/*Children with 'glass' parent might be effected if their style == NULL*/
|
||||
lv_child_refr_style(child);
|
||||
refresh_childen_style(child);
|
||||
}
|
||||
child = lv_obj_get_child(child, NULL);
|
||||
}
|
||||
@ -1573,7 +1576,7 @@ static void lv_child_refr_style(lv_obj_t * obj)
|
||||
* Called by 'lv_obj_del' to delete the children objects
|
||||
* @param obj pointer to an object (all of its children will be deleted)
|
||||
*/
|
||||
static void lv_obj_del_child(lv_obj_t * obj)
|
||||
static void delete_children(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * i_next;
|
||||
@ -1583,7 +1586,7 @@ static void lv_obj_del_child(lv_obj_t * obj)
|
||||
i_next = ll_get_next(&(obj->child_ll), i);
|
||||
|
||||
/*Call the recursive del to the child too*/
|
||||
lv_obj_del_child(i);
|
||||
delete_children(i);
|
||||
|
||||
/*Set i to the next node*/
|
||||
i = i_next;
|
||||
@ -1602,10 +1605,10 @@ static void lv_obj_del_child(lv_obj_t * obj)
|
||||
ll_rem(&(par->child_ll), obj);
|
||||
|
||||
/* Clean up the object specific data*/
|
||||
obj->signal_f(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||
obj->signal_func(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||
|
||||
/*Delete the base objects*/
|
||||
if(obj->ext != NULL) dm_free(obj->ext);
|
||||
if(obj->ext_attr != NULL) dm_free(obj->ext_attr);
|
||||
dm_free(obj); /*Free the object itself*/
|
||||
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ extern "C" {
|
||||
#error "LV: LV_HOR_RES and LV_VER_RES must be greater then 0"
|
||||
#endif
|
||||
|
||||
#if LV_DOWNSCALE != 1 && LV_DOWNSCALE != 2
|
||||
#error "LV: LV_DOWNSCALE can be only 1 or 2"
|
||||
#if LV_ANTIALIAS != 0 && LV_ANTIALIAS != 1
|
||||
#error "LV: LV_ATIALIAS can be only 0 or 1"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE == 0 && LV_ANTIALIAS != 0
|
||||
@ -48,8 +48,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*New defines*/
|
||||
#define LV_OBJ_DEF_WIDTH (80 * LV_DOWNSCALE)
|
||||
#define LV_OBJ_DEF_HEIGHT (60 * LV_DOWNSCALE)
|
||||
#define LV_OBJ_DEF_WIDTH (80 << LV_ANTIALIAS)
|
||||
#define LV_OBJ_DEF_HEIGHT (60 << LV_ANTIALIAS)
|
||||
|
||||
#define ANIM_IN 0x00 /*Animation to show an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define ANIM_OUT 0x80 /*Animation to hide an object. 'OR' it with lv_anim_builtin_t*/
|
||||
@ -68,7 +68,7 @@ typedef enum
|
||||
LV_DESIGN_COVER_CHK,
|
||||
}lv_design_mode_t;
|
||||
|
||||
typedef bool (* lv_design_f_t) (struct __LV_OBJ_T * obj, const area_t * mask_p, lv_design_mode_t mode);
|
||||
typedef bool (* lv_design_func_t) (struct __LV_OBJ_T * obj, const area_t * mask_p, lv_design_mode_t mode);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -95,41 +95,41 @@ typedef enum
|
||||
LV_SIGNAL_CONTROLL,
|
||||
}lv_signal_t;
|
||||
|
||||
typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void * param);
|
||||
typedef bool (* lv_signal_func_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void * param);
|
||||
|
||||
typedef struct __LV_OBJ_T
|
||||
{
|
||||
struct __LV_OBJ_T * par; /*Pointer to the parent object*/
|
||||
ll_dsc_t child_ll; /*Linked list to store the children objects*/
|
||||
|
||||
area_t cords; /*Coordinates of the object (x1, y1, x2, y2)*/
|
||||
area_t coords; /*Coordinates of the object (x1, y1, x2, y2)*/
|
||||
|
||||
lv_signal_f_t signal_f; /*Object type specific signal function*/
|
||||
lv_design_f_t design_f; /*Object type specific design function*/
|
||||
lv_signal_func_t signal_func; /*Object type specific signal function*/
|
||||
lv_design_func_t design_func; /*Object type specific design function*/
|
||||
|
||||
void * ext; /*Object type specific extended data*/
|
||||
void * ext_attr; /*Object type specific extended data*/
|
||||
lv_style_t * style_p; /*Pointer to the object's style*/
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
void * free_p; /*Application specific pointer (set it freely)*/
|
||||
#if LV_OBJ_FREE_POINTER != 0
|
||||
void * free_ptr; /*Application specific pointer (set it freely)*/
|
||||
#endif
|
||||
|
||||
void * group_p; /*Pointer to the group of the object*/
|
||||
|
||||
/*Attributes and states*/
|
||||
uint8_t click_en :1; /*1: Can be pressed by an input device*/
|
||||
uint8_t drag_en :1; /*1: Enable the dragging*/
|
||||
uint8_t drag_throw_en:1; /*1: Enable throwing with drag*/
|
||||
uint8_t click :1; /*1: Can be pressed by an input device*/
|
||||
uint8_t drag :1; /*1: Enable the dragging*/
|
||||
uint8_t drag_throw:1; /*1: Enable throwing with drag*/
|
||||
uint8_t drag_parent :1; /*1: Parent will be dragged instead*/
|
||||
uint8_t hidden :1; /*1: Object is hidden*/
|
||||
uint8_t top_en :1; /*1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t top :1; /*1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t reserved :1;
|
||||
|
||||
uint8_t protect; /*Automatically happening actions can be prevented. 'OR'ed values from lv_obj_prot_t*/
|
||||
|
||||
cord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
#if LV_OBJ_FREE_NUMBER != 0
|
||||
uint8_t free_num; /*Application specific identifier (set it freely)*/
|
||||
#endif
|
||||
}lv_obj_t;
|
||||
@ -217,13 +217,13 @@ bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj);
|
||||
void lv_obj_invalidate(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Load a new screen
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_scr_load(lv_obj_t * scr);
|
||||
void lv_screen_load(lv_obj_t * scr);
|
||||
|
||||
/**
|
||||
* Set a new parent for an object. Its relative position will be the same.
|
||||
@ -247,7 +247,7 @@ void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
* @param x new distance from the left side of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_pos_us(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
void lv_obj_set_pos_scale(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object
|
||||
@ -262,7 +262,7 @@ void lv_obj_set_x(lv_obj_t * obj, cord_t x);
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_x_us(lv_obj_t * obj, cord_t x);
|
||||
void lv_obj_set_x_scale(lv_obj_t * obj, cord_t x);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object
|
||||
@ -277,7 +277,7 @@ void lv_obj_set_y(lv_obj_t * obj, cord_t y);
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_y_us(lv_obj_t * obj, cord_t y);
|
||||
void lv_obj_set_y_scale(lv_obj_t * obj, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the size of an object
|
||||
@ -293,7 +293,7 @@ void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_size_us(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
void lv_obj_set_size_scale(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the width of an object
|
||||
@ -307,7 +307,7 @@ void lv_obj_set_width(lv_obj_t * obj, cord_t w);
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_width_us(lv_obj_t * obj, cord_t w);
|
||||
void lv_obj_set_width_scale(lv_obj_t * obj, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an object
|
||||
@ -321,7 +321,7 @@ void lv_obj_set_height(lv_obj_t * obj, cord_t h);
|
||||
* @param obj pointer to an object
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_height_us(lv_obj_t * obj, cord_t h);
|
||||
void lv_obj_set_height_scale(lv_obj_t * obj, cord_t h);
|
||||
|
||||
/**
|
||||
* Align an object to an other object.
|
||||
@ -341,7 +341,7 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod
|
||||
* @param x_mod x coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y_mod y coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
void lv_obj_align_scale(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
|
||||
/**
|
||||
* Set the extended size of an object
|
||||
@ -361,7 +361,7 @@ void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style);
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_style(lv_obj_t * obj);
|
||||
void lv_obj_refresh_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
@ -426,7 +426,7 @@ void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
|
||||
* @param obj pointer to an object
|
||||
* @param prot 'OR'-ed values from lv_obj_prot_t
|
||||
*/
|
||||
void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot);
|
||||
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot);
|
||||
|
||||
/**
|
||||
* Set the signal function of an object.
|
||||
@ -434,14 +434,14 @@ void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot);
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new signal function
|
||||
*/
|
||||
void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp);
|
||||
void lv_obj_set_signal_func(lv_obj_t * obj, lv_signal_func_t fp);
|
||||
|
||||
/**
|
||||
* Set a new design function for an object
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new design function
|
||||
*/
|
||||
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
|
||||
void lv_obj_set_design_func(lv_obj_t * obj, lv_design_func_t fp);
|
||||
|
||||
/**
|
||||
* Allocate a new ext. data for an object
|
||||
@ -449,32 +449,32 @@ void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
|
||||
* @param ext_size the size of the new ext. data
|
||||
* @return Normal pointer to the allocated ext
|
||||
*/
|
||||
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size);
|
||||
void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size);
|
||||
|
||||
/**
|
||||
* Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_ext_size(lv_obj_t * obj);
|
||||
void lv_obj_refresh_ext_size(lv_obj_t * obj);
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
#if LV_OBJ_FREE_NUMBER != 0
|
||||
/**
|
||||
* Set an application specific number for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_num the new free number
|
||||
*/
|
||||
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
|
||||
void lv_obj_set_free_number(lv_obj_t * obj, uint8_t free_number);
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
#if LV_OBJ_FREE_POINTER != 0
|
||||
/**
|
||||
* Set an application specific pointer for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_p the new free pinter
|
||||
*/
|
||||
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
void lv_obj_set_free_pointer(lv_obj_t * obj, void * free_pointer);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -485,13 +485,13 @@ void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
* @param delay delay before the animation in milliseconds
|
||||
* @param cb a function to call when the animation is ready
|
||||
*/
|
||||
void lv_obj_anim(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 *));
|
||||
|
||||
/**
|
||||
* Return with the actual screen
|
||||
* @return pointer to to the actual screen object
|
||||
*/
|
||||
lv_obj_t * lv_scr_act(void);lv_obj_t * lv_layer_top(void);
|
||||
lv_obj_t * lv_screen_act(void);lv_obj_t * lv_layer_top(void);
|
||||
|
||||
/**
|
||||
* Return with the system layer. (Same on every screen and it is above the all other layers)
|
||||
@ -505,7 +505,7 @@ lv_obj_t * lv_layer_sys(void);
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a screen
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_scr(lv_obj_t * obj);
|
||||
lv_obj_t * lv_obj_get_screen(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Returns with the parent of an object
|
||||
@ -528,14 +528,14 @@ lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child);
|
||||
* @param obj pointer to an object
|
||||
* @return children number of 'obj'
|
||||
*/
|
||||
uint16_t lv_obj_get_child_num(lv_obj_t * obj);
|
||||
uint16_t lv_obj_count_children(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Copy the coordinates of an object to an area
|
||||
* @param obj pointer to an object
|
||||
* @param cords_p pointer to an area to store the coordinates
|
||||
*/
|
||||
void lv_obj_get_cords(lv_obj_t * obj, area_t * cords_p);
|
||||
void lv_obj_get_coords(lv_obj_t * obj, area_t * cords_p);
|
||||
|
||||
/**
|
||||
* Get the x coordinate of object
|
||||
@ -641,22 +641,22 @@ bool lv_obj_is_protected(lv_obj_t * obj, uint8_t prot);
|
||||
* @param obj pointer to an object
|
||||
* @return the signal function
|
||||
*/
|
||||
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj);
|
||||
lv_signal_func_t lv_obj_get_signal_func(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the design function of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the design function
|
||||
*/
|
||||
lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj);
|
||||
lv_design_func_t lv_obj_get_design_func(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the ext pointer
|
||||
* @param obj pointer to an object
|
||||
* @return the ext pointer but not the dynamic version
|
||||
* Use it as ext->data1, and NOT da(ext)->data1
|
||||
* Use it as ext->data1, and NOT da(ext_attr)->data1
|
||||
*/
|
||||
void * lv_obj_get_ext(lv_obj_t * obj);
|
||||
void * lv_obj_get_ext_attr(lv_obj_t * obj);
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
/**
|
||||
|
@ -242,7 +242,7 @@ static void lv_refr_area_no_vdb(const area_t * area_p)
|
||||
lv_obj_t * top_p;
|
||||
|
||||
/*Get top object which is not covered by others*/
|
||||
top_p = lv_refr_get_top_obj(area_p, lv_scr_act());
|
||||
top_p = lv_refr_get_top_obj(area_p, lv_screen_act());
|
||||
|
||||
/*Do the refreshing*/
|
||||
lv_refr_make(top_p, area_p);
|
||||
@ -310,7 +310,7 @@ static void lv_refr_area_part_vdb(const area_t * area_p)
|
||||
area_union(&start_mask, area_p, &vdb_p->area);
|
||||
|
||||
/*Get the most top object which is not covered by others*/
|
||||
top_p = lv_refr_get_top_obj(&start_mask, lv_scr_act());
|
||||
top_p = lv_refr_get_top_obj(&start_mask, lv_screen_act());
|
||||
|
||||
/*Do the refreshing from the top object*/
|
||||
lv_refr_make(top_p, &start_mask);
|
||||
@ -338,7 +338,7 @@ static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
lv_obj_t * found_p = NULL;
|
||||
|
||||
/*If this object is fully cover the draw area check the children too */
|
||||
if(area_is_in(area_p, &obj->cords) && obj->hidden == 0)
|
||||
if(area_is_in(area_p, &obj->coords) && obj->hidden == 0)
|
||||
{
|
||||
LL_READ(obj->child_ll, i) {
|
||||
found_p = lv_refr_get_top_obj(area_p, i);
|
||||
@ -353,7 +353,7 @@ static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
if(found_p == NULL) {
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->opacity == OPA_COVER &&
|
||||
obj->design_f(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
obj->design_func(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
found_p = obj;
|
||||
}
|
||||
}
|
||||
@ -372,7 +372,7 @@ static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p)
|
||||
/* Normally always will be a top_obj (at least the screen)
|
||||
* but in special cases (e.g. if the screen has alpha) it won't.
|
||||
* In this case use the screen directly */
|
||||
if(top_p == NULL) top_p = lv_scr_act();
|
||||
if(top_p == NULL) top_p = lv_screen_act();
|
||||
|
||||
/*Refresh the top object and its children*/
|
||||
lv_refr_obj(top_p, mask_p);
|
||||
@ -405,7 +405,7 @@ static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p)
|
||||
/*Call the post draw design function of the parents of the to object*/
|
||||
par = lv_obj_get_parent(top_p);
|
||||
while(par != NULL) {
|
||||
par->design_f(par, mask_p, LV_DESIGN_DRAW_POST);
|
||||
par->design_func(par, mask_p, LV_DESIGN_DRAW_POST);
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
}
|
||||
@ -427,7 +427,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
area_t obj_ext_mask;
|
||||
area_t obj_area;
|
||||
cord_t ext_size = obj->ext_size;
|
||||
lv_obj_get_cords(obj, &obj_area);
|
||||
lv_obj_get_coords(obj, &obj_area);
|
||||
obj_area.x1 -= ext_size;
|
||||
obj_area.y1 -= ext_size;
|
||||
obj_area.x2 += ext_size;
|
||||
@ -440,12 +440,12 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
/* Redraw the object */
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->opacity != OPA_TRANSP) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||
//tick_wait_ms(100); /*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_cords(obj, &obj_area);
|
||||
lv_obj_get_coords(obj, &obj_area);
|
||||
union_ok = area_union(&obj_mask, mask_ori_p, &obj_area);
|
||||
if(union_ok != false) {
|
||||
area_t mask_child; /*Mask from obj and its child*/
|
||||
@ -453,7 +453,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
area_t child_area;
|
||||
LL_READ_BACK(obj->child_ll, child_p)
|
||||
{
|
||||
lv_obj_get_cords(child_p, &child_area);
|
||||
lv_obj_get_coords(child_p, &child_area);
|
||||
ext_size = child_p->ext_size;
|
||||
child_area.x1 -= ext_size;
|
||||
child_area.y1 -= ext_size;
|
||||
@ -473,7 +473,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
|
||||
/* If all the children are redrawn make 'post draw' design */
|
||||
if(style->opacity != OPA_TRANSP) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,25 +78,25 @@ void lv_style_init (void)
|
||||
lv_style_scr.body.empty = 0;
|
||||
lv_style_scr.glass = 0;
|
||||
|
||||
lv_style_scr.border.color = COLOR_BLACK;
|
||||
lv_style_scr.border.opa = OPA_COVER;
|
||||
lv_style_scr.border.width = 0;
|
||||
lv_style_scr.body.border.color = COLOR_BLACK;
|
||||
lv_style_scr.body.border.opa = OPA_COVER;
|
||||
lv_style_scr.body.border.width = 0;
|
||||
|
||||
lv_style_scr.shadow.color = COLOR_GRAY;
|
||||
lv_style_scr.shadow.type = LV_SHADOW_FULL;
|
||||
lv_style_scr.shadow.width = 0;
|
||||
lv_style_scr.body.shadow.color = COLOR_GRAY;
|
||||
lv_style_scr.body.shadow.type = LV_SHADOW_FULL;
|
||||
lv_style_scr.body.shadow.width = 0;
|
||||
|
||||
lv_style_scr.text.color = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_scr.text.font = font_get(FONT_DEFAULT);
|
||||
lv_style_scr.text.space_letter = 1 * LV_DOWNSCALE;
|
||||
lv_style_scr.text.space_line = 2 * LV_DOWNSCALE;
|
||||
lv_style_scr.text.space_letter = 1 << LV_ANTIALIAS;
|
||||
lv_style_scr.text.space_line = 2 << LV_ANTIALIAS;
|
||||
lv_style_scr.text.align = LV_TXT_ALIGN_LEFT;
|
||||
|
||||
lv_style_scr.image.color = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_scr.image.intense = OPA_TRANSP;
|
||||
|
||||
lv_style_scr.line.color = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_scr.line.width = 1 * LV_DOWNSCALE;
|
||||
lv_style_scr.line.width = 1 << LV_ANTIALIAS;
|
||||
|
||||
/*Plain style (by default near the same as the screen style)*/
|
||||
memcpy(&lv_style_plain, &lv_style_scr, sizeof(lv_style_t));
|
||||
@ -117,9 +117,9 @@ void lv_style_init (void)
|
||||
lv_style_pretty.body.color_main = COLOR_WHITE;
|
||||
lv_style_pretty.body.color_gradient = COLOR_SILVER;
|
||||
lv_style_pretty.body.radius = LV_DPI / 15;
|
||||
lv_style_pretty.border.color = COLOR_MAKE(0x40, 0x40, 0x40);
|
||||
lv_style_pretty.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_pretty.border.opa = OPA_50;
|
||||
lv_style_pretty.body.border.color = COLOR_MAKE(0x40, 0x40, 0x40);
|
||||
lv_style_pretty.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_pretty.body.border.opa = OPA_50;
|
||||
|
||||
/*Pretty color style*/
|
||||
memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t));
|
||||
@ -128,13 +128,13 @@ void lv_style_init (void)
|
||||
lv_style_pretty_color.line.color = COLOR_MAKE(0xe0, 0xe0, 0xe0);
|
||||
lv_style_pretty_color.body.color_main = COLOR_MAKE(0x6b, 0x9a, 0xc7);
|
||||
lv_style_pretty_color.body.color_gradient = COLOR_MAKE(0x2b, 0x59, 0x8b);
|
||||
lv_style_pretty_color.border.color = COLOR_MAKE(0x15, 0x2c, 0x42);
|
||||
lv_style_pretty_color.body.border.color = COLOR_MAKE(0x15, 0x2c, 0x42);
|
||||
|
||||
/*Transparent style*/
|
||||
memcpy(&lv_style_transparent, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_transparent.body.empty = 1;
|
||||
lv_style_transparent.glass = 1;
|
||||
lv_style_transparent.border.width = 0;
|
||||
lv_style_transparent.body.border.width = 0;
|
||||
|
||||
/*Transparent tight style*/
|
||||
memcpy(&lv_style_transparent_tight, &lv_style_transparent, sizeof(lv_style_t));
|
||||
@ -149,13 +149,13 @@ void lv_style_init (void)
|
||||
lv_style_button_off_released.body.padding.horizontal = LV_DPI / 4;
|
||||
lv_style_button_off_released.body.padding.vertical = LV_DPI / 6;
|
||||
lv_style_button_off_released.body.padding.inner = LV_DPI / 10;
|
||||
lv_style_button_off_released.border.color = COLOR_MAKE(0x0b, 0x19, 0x28);
|
||||
lv_style_button_off_released.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_button_off_released.border.opa = OPA_70;
|
||||
lv_style_button_off_released.body.border.color = COLOR_MAKE(0x0b, 0x19, 0x28);
|
||||
lv_style_button_off_released.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_button_off_released.body.border.opa = OPA_70;
|
||||
lv_style_button_off_released.text.color = COLOR_MAKE(0xff, 0xff, 0xff);
|
||||
lv_style_button_off_released.text.align = LV_TXT_ALIGN_MID;
|
||||
lv_style_button_off_released.shadow.color = COLOR_GRAY;
|
||||
lv_style_button_off_released.shadow.width = 0;
|
||||
lv_style_button_off_released.body.shadow.color = COLOR_GRAY;
|
||||
lv_style_button_off_released.body.shadow.width = 0;
|
||||
|
||||
/*Button pressed style*/
|
||||
memcpy(&lv_style_button_off_pressed, &lv_style_button_off_released, sizeof(lv_style_t));
|
||||
@ -169,7 +169,7 @@ void lv_style_init (void)
|
||||
memcpy(&lv_style_button_on_released, &lv_style_button_off_released, sizeof(lv_style_t));
|
||||
lv_style_button_on_released.body.color_main = COLOR_MAKE(0x0a, 0x11, 0x22);
|
||||
lv_style_button_on_released.body.color_gradient = COLOR_MAKE(0x37, 0x62, 0x90);
|
||||
lv_style_button_on_released.border.color = COLOR_MAKE(0x01, 0x07, 0x0d);
|
||||
lv_style_button_on_released.body.border.color = COLOR_MAKE(0x01, 0x07, 0x0d);
|
||||
lv_style_button_on_released.text.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
|
||||
lv_style_button_on_released.image.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
|
||||
lv_style_button_on_released.line.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
|
||||
@ -186,7 +186,7 @@ void lv_style_init (void)
|
||||
memcpy(&lv_style_button_inactive, &lv_style_button_off_released, sizeof(lv_style_t));
|
||||
lv_style_button_inactive.body.color_main = COLOR_MAKE(0xd8, 0xd8, 0xd8);
|
||||
lv_style_button_inactive.body.color_gradient = COLOR_MAKE(0xd8, 0xd8, 0xd8);
|
||||
lv_style_button_inactive.border.color = COLOR_MAKE(0x90, 0x90, 0x90);
|
||||
lv_style_button_inactive.body.border.color = COLOR_MAKE(0x90, 0x90, 0x90);
|
||||
lv_style_button_inactive.text.color = COLOR_MAKE(0x70, 0x70, 0x70);
|
||||
lv_style_button_inactive.image.color = COLOR_MAKE(0x70, 0x70, 0x70);
|
||||
lv_style_button_inactive.line.color = COLOR_MAKE(0x70, 0x70, 0x70);
|
||||
@ -198,7 +198,7 @@ void lv_style_init (void)
|
||||
* @param style_name an element of the 'lv_style_name_t' enum
|
||||
* @return pointer to the requested style (lv_style_def by default)
|
||||
*/
|
||||
lv_style_t * lv_style_get(lv_style_name_t style_name, lv_style_t * copy)
|
||||
lv_style_t * lv_style_get(lv_style_name_t style_name)
|
||||
{
|
||||
lv_style_t * style = &lv_style_plain;
|
||||
|
||||
@ -243,8 +243,6 @@ lv_style_t * lv_style_get(lv_style_name_t style_name, lv_style_t * copy)
|
||||
style = &lv_style_plain;
|
||||
}
|
||||
|
||||
if(copy != NULL) memcpy(copy, style, sizeof(lv_style_t));
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
@ -253,7 +251,7 @@ lv_style_t * lv_style_get(lv_style_name_t style_name, lv_style_t * copy)
|
||||
* @param dest pointer to the destination style
|
||||
* @param src pointer to the source style
|
||||
*/
|
||||
void lv_style_cpy(lv_style_t * dest, const lv_style_t * src)
|
||||
void lv_style_copy(lv_style_t * dest, const lv_style_t * src)
|
||||
{
|
||||
memcpy(dest, src, sizeof(lv_style_t));
|
||||
}
|
||||
@ -304,8 +302,8 @@ static void lv_style_aimator(lv_style_anim_dsc_t * dsc, int32_t val)
|
||||
|
||||
STYLE_ATTR_ANIM(opacity, val);
|
||||
STYLE_ATTR_ANIM(body.radius, val);
|
||||
STYLE_ATTR_ANIM(border.width, val);
|
||||
STYLE_ATTR_ANIM(shadow.width, val);
|
||||
STYLE_ATTR_ANIM(body.border.width, val);
|
||||
STYLE_ATTR_ANIM(body.shadow.width, val);
|
||||
STYLE_ATTR_ANIM(body.padding.horizontal, val);
|
||||
STYLE_ATTR_ANIM(body.padding.vertical, val);
|
||||
STYLE_ATTR_ANIM(body.padding.inner, val);
|
||||
@ -316,8 +314,8 @@ static void lv_style_aimator(lv_style_anim_dsc_t * dsc, int32_t val)
|
||||
|
||||
act->body.color_main = color_mix(end->body.color_main, start->body.color_main, val);
|
||||
act->body.color_gradient = color_mix(end->body.color_gradient, start->body.color_gradient, val);
|
||||
act->border.color = color_mix(end->border.color, start->border.color, val);
|
||||
act->shadow.color = color_mix(end->shadow.color, start->shadow.color, val);
|
||||
act->body.border.color = color_mix(end->body.border.color, start->body.border.color, val);
|
||||
act->body.shadow.color = color_mix(end->body.shadow.color, start->body.shadow.color, val);
|
||||
act->text.color = color_mix(end->text.color, start->text.color, val);
|
||||
act->image.color = color_mix(end->image.color, start->image.color, val);
|
||||
act->line.color = color_mix(end->line.color, start->line.color, val);
|
||||
@ -327,7 +325,7 @@ static void lv_style_aimator(lv_style_anim_dsc_t * dsc, int32_t val)
|
||||
act->body.empty = start->body.empty;
|
||||
act->glass = start->glass;
|
||||
act->text.font = start->text.font;
|
||||
act->shadow.type = start->shadow.type;
|
||||
act->body.shadow.type = start->body.shadow.type;
|
||||
act->text.align = start->text.align;
|
||||
}
|
||||
|
||||
@ -335,7 +333,7 @@ static void lv_style_aimator(lv_style_anim_dsc_t * dsc, int32_t val)
|
||||
act->body.empty = end->body.empty;
|
||||
act->glass = end->glass;
|
||||
act->text.font = end->text.font;
|
||||
act->shadow.type = end->shadow.type;
|
||||
act->body.shadow.type = end->body.shadow.type;
|
||||
act->text.align = end->text.align;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,19 @@ typedef struct
|
||||
color_t color_main;
|
||||
color_t color_gradient;
|
||||
cord_t radius; /*Corner radius of background*/
|
||||
|
||||
struct {
|
||||
color_t color;
|
||||
cord_t width;
|
||||
opa_t opa; /*Opacity of background border*/
|
||||
}border;
|
||||
|
||||
struct {
|
||||
color_t color;
|
||||
cord_t width;
|
||||
uint8_t type;
|
||||
}shadow;
|
||||
|
||||
struct {
|
||||
cord_t vertical;
|
||||
cord_t horizontal;
|
||||
@ -58,17 +71,6 @@ typedef struct
|
||||
uint8_t empty :1; /*Transparent background (border still drawn)*/
|
||||
}body;
|
||||
|
||||
struct {
|
||||
color_t color;
|
||||
cord_t width;
|
||||
opa_t opa; /*Opacity of background border*/
|
||||
}border;
|
||||
|
||||
struct {
|
||||
color_t color;
|
||||
cord_t width;
|
||||
uint8_t type;
|
||||
}shadow;
|
||||
|
||||
struct {
|
||||
color_t color;
|
||||
@ -147,7 +149,7 @@ void lv_style_init (void);
|
||||
* @param style_name an element of the 'lv_style_name_t' enum
|
||||
* @return pointer to the requested style (lv_style_def by default)
|
||||
*/
|
||||
lv_style_t * lv_style_get(lv_style_name_t style_name, lv_style_t * copy);
|
||||
lv_style_t * lv_style_get(lv_style_name_t style_name);
|
||||
|
||||
|
||||
/**
|
||||
@ -155,7 +157,7 @@ lv_style_t * lv_style_get(lv_style_name_t style_name, lv_style_t * copy);
|
||||
* @param dest pointer to the destination style
|
||||
* @param src pointer to the source style
|
||||
*/
|
||||
void lv_style_cpy(lv_style_t * dest, const lv_style_t * src);
|
||||
void lv_style_copy(lv_style_t * dest, const lv_style_t * src);
|
||||
|
||||
/**
|
||||
* Create an animation from a pre-configured 'lv_style_anim_t' variable
|
||||
|
@ -32,7 +32,7 @@ static bool lv_bar_design(lv_obj_t * bar, const area_t * mask, lv_design_mode_t
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -59,34 +59,34 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_bar);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_bar_ext_t * ext = lv_obj_alloc_ext(new_bar, sizeof(lv_bar_ext_t));
|
||||
lv_bar_ext_t * ext = lv_obj_allocate_ext_attr(new_bar, sizeof(lv_bar_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->min_value = 0;
|
||||
ext->max_value = 100;
|
||||
ext->act_value = 0;
|
||||
ext->style_indic = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
ext->style_indic = lv_style_get(LV_STYLE_PRETTY_COLOR);
|
||||
|
||||
/* Save the ancient design function.
|
||||
* It will be used in the bar design function*/
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_bar);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_bar);
|
||||
|
||||
lv_obj_set_signal_f(new_bar, lv_bar_signal);
|
||||
lv_obj_set_design_f(new_bar, lv_bar_design);
|
||||
lv_obj_set_signal_func(new_bar, lv_bar_signal);
|
||||
lv_obj_set_design_func(new_bar, lv_bar_design);
|
||||
|
||||
/*Init the new bar object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_click(new_bar, false);
|
||||
lv_obj_set_size(new_bar, LV_DPI * 2, LV_DPI / 3);
|
||||
lv_obj_set_style(new_bar, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_bar, lv_style_get(LV_STYLE_PRETTY));
|
||||
lv_bar_set_value(new_bar, ext->act_value);
|
||||
} else {
|
||||
lv_bar_ext_t * ext_copy = lv_obj_get_ext(copy);
|
||||
lv_bar_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
|
||||
ext->min_value = ext_copy->min_value;
|
||||
ext->max_value = ext_copy->max_value;
|
||||
ext->act_value = ext_copy->act_value;
|
||||
ext->style_indic = ext_copy->style_indic;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_bar);
|
||||
lv_obj_refresh_style(new_bar);
|
||||
|
||||
lv_bar_set_value(new_bar, ext->act_value);
|
||||
}
|
||||
@ -111,7 +111,7 @@ bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
||||
if(valid != false) {
|
||||
if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
lv_style_t * style_indic = lv_bar_get_style_indic(bar);
|
||||
if(style_indic->shadow.width > bar->ext_size) bar->ext_size = style_indic->shadow.width;
|
||||
if(style_indic->body.shadow.width > bar->ext_size) bar->ext_size = style_indic->body.shadow.width;
|
||||
}
|
||||
|
||||
}
|
||||
@ -130,10 +130,10 @@ bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_bar_set_value(lv_obj_t * bar, int16_t value)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
ext->act_value = value > ext->max_value ? ext->max_value : value;
|
||||
ext->act_value = ext->act_value < ext->min_value ? ext->min_value : ext->act_value;
|
||||
lv_obj_inv(bar);
|
||||
lv_obj_invalidate(bar);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,7 +145,7 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value)
|
||||
void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time)
|
||||
{
|
||||
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
int16_t new_value;
|
||||
new_value = value > ext->max_value ? ext->max_value : value;
|
||||
new_value = new_value < ext->min_value ? ext->min_value : new_value;
|
||||
@ -177,7 +177,7 @@ void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time)
|
||||
*/
|
||||
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
ext->max_value = max;
|
||||
ext->min_value = min;
|
||||
if(ext->act_value > max) {
|
||||
@ -188,7 +188,7 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
||||
ext->act_value = min;
|
||||
lv_bar_set_value(bar, ext->act_value);
|
||||
}
|
||||
lv_obj_inv(bar);
|
||||
lv_obj_invalidate(bar);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,13 +198,13 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
|
||||
*/
|
||||
void lv_bar_set_style_indic(lv_obj_t * bar, lv_style_t * style)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
ext->style_indic = style;
|
||||
|
||||
bar->signal_f(bar, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
bar->signal_func(bar, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
|
||||
lv_obj_inv(bar);
|
||||
lv_obj_invalidate(bar);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -218,7 +218,7 @@ void lv_bar_set_style_indic(lv_obj_t * bar, lv_style_t * style)
|
||||
*/
|
||||
int16_t lv_bar_get_value(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
return ext->act_value;
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ int16_t lv_bar_get_value(lv_obj_t * bar)
|
||||
*/
|
||||
int16_t lv_bar_get_min_value(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
return ext->min_value;
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ int16_t lv_bar_get_min_value(lv_obj_t * bar)
|
||||
*/
|
||||
int16_t lv_bar_get_max_value(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
return ext->max_value;
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ int16_t lv_bar_get_max_value(lv_obj_t * bar)
|
||||
*/
|
||||
lv_style_t * lv_bar_get_style_indic(lv_obj_t * bar)
|
||||
{
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
if(ext->style_indic == NULL) return lv_obj_get_style(bar);
|
||||
|
||||
@ -280,11 +280,11 @@ static bool lv_bar_design(lv_obj_t * bar, const area_t * mask, lv_design_mode_t
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(bar, mask, mode);
|
||||
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
|
||||
|
||||
lv_style_t * style_indic = lv_bar_get_style_indic(bar);
|
||||
area_t indic_area;
|
||||
area_cpy(&indic_area, &bar->cords);
|
||||
area_cpy(&indic_area, &bar->coords);
|
||||
indic_area.x1 += style_indic->body.padding.horizontal;
|
||||
indic_area.x2 -= style_indic->body.padding.horizontal;
|
||||
indic_area.y1 += style_indic->body.padding.vertical;
|
||||
|
276
lv_objx/lv_btn.c
276
lv_objx/lv_btn.c
@ -8,7 +8,7 @@
|
||||
*********************/
|
||||
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_BTN != 0
|
||||
#if USE_LV_BUTTON != 0
|
||||
|
||||
#include "lv_btn.h"
|
||||
#include "../lv_obj/lv_group.h"
|
||||
@ -58,45 +58,41 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
new_btn = lv_cont_create(par, copy);
|
||||
dm_assert(new_btn);
|
||||
/*Allocate the extended data*/
|
||||
lv_btn_ext_t * ext = lv_obj_alloc_ext(new_btn, sizeof(lv_btn_ext_t));
|
||||
lv_btn_ext_t * ext = lv_obj_allocate_ext_attr(new_btn, sizeof(lv_btn_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->state = LV_BTN_STATE_REL;
|
||||
ext->pr_action = NULL;
|
||||
ext->rel_action = NULL;
|
||||
ext->lpr_action = NULL;
|
||||
ext->lpr_rep_action = NULL;
|
||||
ext->styles[LV_BTN_STATE_REL] = lv_style_get(LV_STYLE_BUTTON_OFF_RELEASED, NULL);
|
||||
ext->styles[LV_BTN_STATE_PR] = lv_style_get(LV_STYLE_BUTTON_OFF_PRESSED, NULL);
|
||||
ext->styles[LV_BTN_STATE_TREL] = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED, NULL);
|
||||
ext->styles[LV_BTN_STATE_TPR] = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED, NULL);
|
||||
ext->styles[LV_BTN_STATE_INA] = lv_style_get(LV_STYLE_BUTTON_INACTIVE, NULL);
|
||||
ext->lpr_exec = 0;
|
||||
ext->tgl = 0;
|
||||
ext->state = LV_BTN_STATE_OFF_RELEASED;
|
||||
|
||||
lv_obj_set_signal_f(new_btn, lv_btn_signal);
|
||||
ext->actions[LV_BTN_ACTION_PRESS] = NULL;
|
||||
ext->actions[LV_BTN_ACTION_RELEASE] = NULL;
|
||||
ext->actions[LV_BTN_ACTION_LONG_PRESS] = NULL;
|
||||
ext->actions[LV_BTN_ACTION_LONG_PRESS_REPEATE] = NULL;
|
||||
|
||||
ext->styles[LV_BTN_STATE_OFF_RELEASED] = lv_style_get(LV_STYLE_BUTTON_OFF_RELEASED);
|
||||
ext->styles[LV_BTN_STATE_OFF_PRESSED] = lv_style_get(LV_STYLE_BUTTON_OFF_PRESSED);
|
||||
ext->styles[LV_BTN_STATE_ON_RELEASED] = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED);
|
||||
ext->styles[LV_BTN_STATE_ON_PRESSED] = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED);
|
||||
ext->styles[LV_BTN_STATE_INACTIVE] = lv_style_get(LV_STYLE_BUTTON_INACTIVE);
|
||||
|
||||
ext->long_press_action_executed = 0;
|
||||
ext->toggle = 0;
|
||||
|
||||
lv_obj_set_signal_func(new_btn, lv_btn_signal);
|
||||
|
||||
/*If no copy do the basic initialization*/
|
||||
if(copy == NULL) {
|
||||
lv_cont_set_layout(new_btn, LV_CONT_LAYOUT_CENTER);
|
||||
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
|
||||
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_OFF_RELEASED]);
|
||||
}
|
||||
/*Copy 'copy'*/
|
||||
else {
|
||||
lv_btn_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_btn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->state = copy_ext->state;
|
||||
ext->pr_action = copy_ext->pr_action;
|
||||
ext->rel_action = copy_ext->rel_action;
|
||||
ext->lpr_action = copy_ext->lpr_action;
|
||||
ext->lpr_rep_action = copy_ext->lpr_action;
|
||||
ext->styles[LV_BTN_STATE_REL] = copy_ext->styles[LV_BTN_STATE_REL];
|
||||
ext->styles[LV_BTN_STATE_PR] = copy_ext->styles[LV_BTN_STATE_PR];
|
||||
ext->styles[LV_BTN_STATE_TREL] = copy_ext->styles[LV_BTN_STATE_TREL];
|
||||
ext->styles[LV_BTN_STATE_TPR] = copy_ext->styles[LV_BTN_STATE_TPR];
|
||||
ext->styles[LV_BTN_STATE_INA] = copy_ext->styles[LV_BTN_STATE_INA];
|
||||
ext->tgl = copy_ext->tgl;
|
||||
ext->toggle = copy_ext->toggle;
|
||||
memcpy(ext->actions, copy_ext->actions, sizeof(ext->actions));
|
||||
memcpy(ext->styles, copy_ext->styles, sizeof(ext->styles));
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_btn);
|
||||
lv_obj_refresh_style(new_btn);
|
||||
}
|
||||
|
||||
return new_btn;
|
||||
@ -118,94 +114,94 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
lv_btn_state_t state = lv_btn_get_state(btn);
|
||||
bool tgl = lv_btn_get_tgl(btn);
|
||||
bool tgl = lv_btn_get_toggle(btn);
|
||||
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
/*Refresh the state*/
|
||||
if(ext->state == LV_BTN_STATE_REL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_PR);
|
||||
} else if(ext->state == LV_BTN_STATE_TREL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TPR);
|
||||
if(ext->state == LV_BTN_STATE_OFF_RELEASED) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_PRESSED);
|
||||
} else if(ext->state == LV_BTN_STATE_ON_RELEASED) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_ON_PRESSED);
|
||||
}
|
||||
|
||||
ext->lpr_exec = 0;
|
||||
ext->long_press_action_executed = 0;
|
||||
/*Call the press action, 'param' is the caller indev_proc*/
|
||||
if(ext->pr_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
valid = ext->pr_action(btn);
|
||||
if(ext->actions[LV_BTN_ACTION_PRESS] && state != LV_BTN_STATE_INACTIVE) {
|
||||
valid = ext->actions[LV_BTN_ACTION_PRESS](btn);
|
||||
}
|
||||
}
|
||||
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_TPR) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
if(ext->state == LV_BTN_STATE_OFF_PRESSED) lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
else if(ext->state == LV_BTN_STATE_ON_PRESSED) lv_btn_set_state(btn, LV_BTN_STATE_ON_RELEASED);
|
||||
}
|
||||
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_TPR) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
if(ext->state == LV_BTN_STATE_OFF_PRESSED) lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
else if(ext->state == LV_BTN_STATE_ON_PRESSED) lv_btn_set_state(btn, LV_BTN_STATE_ON_RELEASED);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
/*If not dragged and it was not long press action then
|
||||
*change state and run the action*/
|
||||
if(lv_indev_is_dragging(param) == false && ext->lpr_exec == 0) {
|
||||
if(ext->state == LV_BTN_STATE_PR && tgl == false) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
} else if(ext->state == LV_BTN_STATE_TPR && tgl == false) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
} else if(ext->state == LV_BTN_STATE_PR && tgl == true) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
} else if(ext->state == LV_BTN_STATE_TPR && tgl == true) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
if(lv_indev_is_dragging(param) == false && ext->long_press_action_executed == 0) {
|
||||
if(ext->state == LV_BTN_STATE_OFF_PRESSED && tgl == false) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
} else if(ext->state == LV_BTN_STATE_ON_PRESSED && tgl == false) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_ON_RELEASED);
|
||||
} else if(ext->state == LV_BTN_STATE_OFF_PRESSED && tgl == true) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_ON_RELEASED);
|
||||
} else if(ext->state == LV_BTN_STATE_ON_PRESSED && tgl == true) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
}
|
||||
|
||||
if(ext->rel_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
valid = ext->rel_action(btn);
|
||||
if(ext->actions[LV_BTN_ACTION_RELEASE] && state != LV_BTN_STATE_INACTIVE) {
|
||||
valid = ext->actions[LV_BTN_ACTION_RELEASE](btn);
|
||||
}
|
||||
} else { /*If dragged change back 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_TPR) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
if(ext->state == LV_BTN_STATE_OFF_PRESSED) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
} else if(ext->state == LV_BTN_STATE_ON_PRESSED) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_ON_RELEASED);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS) {
|
||||
if(ext->lpr_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
ext->lpr_exec = 1;
|
||||
valid = ext->lpr_action(btn);
|
||||
if(ext->actions[LV_BTN_ACTION_LONG_PRESS] && state != LV_BTN_STATE_INACTIVE) {
|
||||
ext->long_press_action_executed = 1;
|
||||
valid = ext->actions[LV_BTN_ACTION_LONG_PRESS](btn);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
if(ext->lpr_rep_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
valid = ext->lpr_rep_action(btn);
|
||||
if(ext->actions[LV_BTN_ACTION_LONG_PRESS_REPEATE] && state != LV_BTN_STATE_INACTIVE) {
|
||||
valid = ext->actions[LV_BTN_ACTION_LONG_PRESS_REPEATE](btn);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char*)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
if(lv_btn_get_tgl(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
|
||||
valid = ext->rel_action(btn);
|
||||
if(lv_btn_get_toggle(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_ON_RELEASED);
|
||||
if(ext->actions[LV_BTN_ACTION_RELEASE] && lv_btn_get_state(btn) != LV_BTN_STATE_INACTIVE) {
|
||||
valid = ext->actions[LV_BTN_ACTION_RELEASE];
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
|
||||
if(lv_btn_get_tgl(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
|
||||
valid = ext->rel_action(btn);
|
||||
if(lv_btn_get_toggle(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
if(ext->actions[LV_BTN_ACTION_RELEASE] && lv_btn_get_state(btn) != LV_BTN_STATE_INACTIVE) {
|
||||
valid = ext->actions[LV_BTN_ACTION_RELEASE](btn);
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
if(lv_btn_get_tgl(btn) != false) {
|
||||
if(lv_btn_get_toggle(btn) != false) {
|
||||
lv_btn_state_t state = lv_btn_get_state(btn);
|
||||
if(state == LV_BTN_STATE_REL) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else if(state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TPR);
|
||||
else if(state == LV_BTN_STATE_TREL) lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
else if(state == LV_BTN_STATE_TPR) lv_btn_set_state(btn, LV_BTN_STATE_PR);
|
||||
if(state == LV_BTN_STATE_OFF_RELEASED) lv_btn_set_state(btn, LV_BTN_STATE_ON_RELEASED);
|
||||
else if(state == LV_BTN_STATE_OFF_PRESSED) lv_btn_set_state(btn, LV_BTN_STATE_ON_PRESSED);
|
||||
else if(state == LV_BTN_STATE_ON_RELEASED) lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
else if(state == LV_BTN_STATE_ON_PRESSED) lv_btn_set_state(btn, LV_BTN_STATE_OFF_PRESSED);
|
||||
}
|
||||
if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
|
||||
valid = ext->rel_action(btn);
|
||||
if(ext->actions[LV_BTN_ACTION_RELEASE] && lv_btn_get_state(btn) != LV_BTN_STATE_INACTIVE) {
|
||||
valid = ext->actions[LV_BTN_ACTION_RELEASE](btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -223,11 +219,11 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
* @param btn pointer to a button object
|
||||
* @param tgl true: enable toggled states, false: disable
|
||||
*/
|
||||
void lv_btn_set_tgl(lv_obj_t * btn, bool tgl)
|
||||
void lv_btn_set_toggle(lv_obj_t * btn, bool tgl)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
|
||||
ext->tgl = tgl != false ? 1 : 0;
|
||||
ext->toggle = tgl != false ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,7 +233,7 @@ void lv_btn_set_tgl(lv_obj_t * btn, bool tgl)
|
||||
*/
|
||||
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
if(ext->state != state) {
|
||||
ext->state = state;
|
||||
lv_obj_set_style(btn, ext->styles[state]);
|
||||
@ -249,49 +245,13 @@ void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
|
||||
* @param btn pointer to a button object
|
||||
* @param pr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_pr_action(lv_obj_t * btn, lv_action_t pr_action)
|
||||
void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
ext->pr_action = pr_action;
|
||||
if(type >= LV_BTN_ACTION_NUM) return;
|
||||
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
ext->actions[type] = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is released
|
||||
* @param btn pointer to a button object
|
||||
* @param rel_action pointer to functionREL
|
||||
*/
|
||||
void lv_btn_set_rel_action(lv_obj_t * btn, lv_action_t rel_action)
|
||||
{
|
||||
lv_btn_ext_t * btn_p = lv_obj_get_ext(btn);
|
||||
|
||||
btn_p->rel_action = rel_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is long pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_action(lv_obj_t * btn, lv_action_t lpr_action)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
ext->lpr_action = lpr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to called periodically after long press.
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_rep_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_t lpr_rep_action)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
ext->lpr_rep_action = lpr_rep_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set styles of a button is each state. Use NULL for any style which are not be changed.
|
||||
* @param btn pointer to button object
|
||||
@ -301,21 +261,21 @@ void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_t lpr_rep_action)
|
||||
* @param tpr pointer to a style for toggled pressed state
|
||||
* @param ina pointer to a style for inactive state
|
||||
*/
|
||||
void lv_btn_set_styles(lv_obj_t * btn, lv_style_t * rel, lv_style_t * pr,
|
||||
lv_style_t * trel, lv_style_t * tpr,
|
||||
lv_style_t * ina)
|
||||
void lv_btn_set_style(lv_obj_t * btn, lv_btn_state_t state, lv_style_t * style)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
if(state >= LV_BTN_STATE_NUM) return;
|
||||
|
||||
if(rel != NULL) ext->styles[LV_BTN_STATE_REL] = rel;
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
ext->styles[state] = style;
|
||||
|
||||
if(pr != NULL) ext->styles[LV_BTN_STATE_PR] = pr;
|
||||
if(ext->state == state) lv_obj_set_style(btn, ext->styles[ext->state]);
|
||||
}
|
||||
|
||||
if(trel) ext->styles[LV_BTN_STATE_TREL] = trel;
|
||||
|
||||
if(tpr) ext->styles[LV_BTN_STATE_TPR] = tpr;
|
||||
|
||||
if(ina) ext->styles[LV_BTN_STATE_INA] = ina;
|
||||
void lv_btn_set_style_all(lv_obj_t * btn, lv_style_t ** style_array)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
memcpy(ext->styles, style_array, sizeof(ext->styles));
|
||||
|
||||
lv_obj_set_style(btn, ext->styles[ext->state]);
|
||||
}
|
||||
@ -331,8 +291,7 @@ void lv_btn_set_styles(lv_obj_t * btn, lv_style_t * rel, lv_style_t * pr,
|
||||
*/
|
||||
lv_btn_state_t lv_btn_get_state(lv_obj_t * btn)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
return ext->state;
|
||||
}
|
||||
|
||||
@ -341,11 +300,11 @@ lv_btn_state_t lv_btn_get_state(lv_obj_t * btn)
|
||||
* @param btn pointer to a button object
|
||||
* @return ture: toggle enabled, false: disabled
|
||||
*/
|
||||
bool lv_btn_get_tgl(lv_obj_t * btn)
|
||||
bool lv_btn_get_toggle(lv_obj_t * btn)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
|
||||
return ext->tgl != 0 ? true : false;
|
||||
return ext->toggle != 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,43 +312,12 @@ bool lv_btn_get_tgl(lv_obj_t * btn)
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the release action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_rel_action(lv_obj_t * btn)
|
||||
lv_action_t lv_btn_get_action(lv_obj_t * btn, lv_btn_action_t type)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
return ext->rel_action;
|
||||
}
|
||||
if(type >= LV_BTN_ACTION_NUM) return NULL;
|
||||
|
||||
/**
|
||||
* Get the press action of a button
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the press action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_pr_action(lv_obj_t * btn)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
return ext->pr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the long press action of a button
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the release action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_lpr_action(lv_obj_t * btn)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
return ext->lpr_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the long press repeat action of a button
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the long press repeat action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_lpr_rep_action(lv_obj_t * btn)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
return ext->lpr_rep_action;
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
return ext->actions[type];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,10 +328,10 @@ lv_action_t lv_btn_get_lpr_rep_action(lv_obj_t * btn)
|
||||
*/
|
||||
lv_style_t * lv_btn_get_style(lv_obj_t * btn, lv_btn_state_t state)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
|
||||
if(ext->styles[state] == NULL) return lv_obj_get_style(btn->par);
|
||||
if(state >= LV_BTN_STATE_NUM) return lv_obj_get_style(lv_obj_get_parent(btn));
|
||||
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
|
||||
if(ext->styles[state] == NULL) return lv_obj_get_style(lv_obj_get_parent(btn));
|
||||
return ext->styles[state];
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file lv_btn.h
|
||||
* @file lv_button.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_BTN_H
|
||||
#define LV_BTN_H
|
||||
#ifndef lv_btn_H
|
||||
#define lv_btn_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -14,7 +14,7 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_BTN != 0
|
||||
#if USE_LV_BUTTON != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_CONT == 0
|
||||
@ -35,29 +35,34 @@ extern "C" {
|
||||
/*Button states*/
|
||||
typedef enum
|
||||
{
|
||||
LV_BTN_STATE_REL,
|
||||
LV_BTN_STATE_PR,
|
||||
LV_BTN_STATE_TREL,
|
||||
LV_BTN_STATE_TPR,
|
||||
LV_BTN_STATE_INA,
|
||||
LV_BTN_STATE_OFF_RELEASED,
|
||||
LV_BTN_STATE_OFF_PRESSED,
|
||||
LV_BTN_STATE_ON_RELEASED,
|
||||
LV_BTN_STATE_ON_PRESSED,
|
||||
LV_BTN_STATE_INACTIVE,
|
||||
LV_BTN_STATE_NUM,
|
||||
}lv_btn_state_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_BTN_ACTION_RELEASE,
|
||||
LV_BTN_ACTION_PRESS,
|
||||
LV_BTN_ACTION_LONG_PRESS,
|
||||
LV_BTN_ACTION_LONG_PRESS_REPEATE,
|
||||
LV_BTN_ACTION_NUM,
|
||||
}lv_btn_action_t;
|
||||
|
||||
/*Data of button*/
|
||||
typedef struct
|
||||
{
|
||||
lv_cont_ext_t cont; /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_action_t pr_action; /*A function to call when the button is pressed (NULL if unused)*/
|
||||
lv_action_t rel_action; /*A function to call when the button is released (NULL if unused)*/
|
||||
lv_action_t lpr_action; /*A function to call when the button is long pressed (NULL if unused)*/
|
||||
lv_action_t lpr_rep_action; /*A function to call periodically after long press (NULL if unused)*/
|
||||
lv_action_t actions[LV_BTN_ACTION_NUM];
|
||||
lv_style_t * styles[LV_BTN_STATE_NUM]; /*Styles in each state*/
|
||||
|
||||
lv_style_t * styles[LV_BTN_STATE_NUM]; /*Styles in each state*/
|
||||
|
||||
lv_btn_state_t state; /*Current state of the button from 'lv_btn_state_t' enum*/
|
||||
uint8_t tgl :1; /*1: Toggle enabled*/
|
||||
uint8_t lpr_exec :1; /*1: Long press action executed (Handled by the library)*/
|
||||
lv_btn_state_t state; /*Current state of the button from 'lv_btn_state_t' enum*/
|
||||
uint8_t toggle :1; /*1: Toggle enabled*/
|
||||
uint8_t long_press_action_executed :1; /*1: Long press action executed (Handled by the library)*/
|
||||
}lv_btn_ext_t;
|
||||
|
||||
|
||||
@ -86,7 +91,7 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
|
||||
* @param btn pointer to a button object
|
||||
* @param tgl true: enable toggled states, false: disable
|
||||
*/
|
||||
void lv_btn_set_tgl(lv_obj_t * btn, bool tgl);
|
||||
void lv_btn_set_toggle(lv_obj_t * btn, bool tgl);
|
||||
|
||||
/**
|
||||
* Set the state of the button
|
||||
@ -100,28 +105,7 @@ void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state);
|
||||
* @param btn pointer to a button object
|
||||
* @param pr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_pr_action(lv_obj_t * btn, lv_action_t pr_action);
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is released
|
||||
* @param btn pointer to a button object
|
||||
* @param rel_action pointer to functionREL
|
||||
*/
|
||||
void lv_btn_set_rel_action(lv_obj_t * btn, lv_action_t rel_action);
|
||||
|
||||
/**
|
||||
* Set a function to call when the button is long pressed
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_action(lv_obj_t * btn, lv_action_t lpr_action);
|
||||
|
||||
/**
|
||||
* Set a function to called periodically after long press.
|
||||
* @param btn pointer to a button object
|
||||
* @param lpr_rep_action pointer to function
|
||||
*/
|
||||
void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_t lpr_rep_action);
|
||||
void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action);
|
||||
|
||||
/**
|
||||
* Set styles of a button is each state
|
||||
@ -132,8 +116,9 @@ void lv_btn_set_lpr_rep_action(lv_obj_t * btn, lv_action_t lpr_rep_action);
|
||||
* @param tpr pointer to a style for toggled pressed state
|
||||
* @param ina pointer to a style for inactive state
|
||||
*/
|
||||
void lv_btn_set_styles(lv_obj_t * btn, lv_style_t * rel, lv_style_t * pr, lv_style_t * trel, lv_style_t * tpr, lv_style_t * ina);
|
||||
void lv_btn_set_style(lv_obj_t * btn, lv_btn_state_t state, lv_style_t * style);
|
||||
|
||||
void lv_btn_set_style_all(lv_obj_t * btn, lv_style_t ** style_array);
|
||||
/**
|
||||
* Get the current state of the button
|
||||
* @param btn pointer to a button object
|
||||
@ -146,14 +131,14 @@ lv_btn_state_t lv_btn_get_state(lv_obj_t * btn);
|
||||
* @param btn pointer to a button object
|
||||
* @return ture: toggle enabled, false: disabled
|
||||
*/
|
||||
bool lv_btn_get_tgl(lv_obj_t * btn);
|
||||
bool lv_btn_get_toggle(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Get the release action of a button
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the release action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_rel_action(lv_obj_t * btn);
|
||||
lv_action_t lv_btn_get_action(lv_obj_t * btn, lv_btn_action_t type);
|
||||
|
||||
/**
|
||||
* Get the press action of a button
|
||||
@ -162,34 +147,16 @@ lv_action_t lv_btn_get_rel_action(lv_obj_t * btn);
|
||||
*/
|
||||
lv_action_t lv_btn_get_pr_action(lv_obj_t * btn);
|
||||
|
||||
/**
|
||||
* Get the long press action of a button
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the release action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_lpr_action(lv_obj_t * btn);
|
||||
/**
|
||||
* Get the long press repeat action of a button
|
||||
* @param btn pointer to a button object
|
||||
* @return pointer to the long press repeat action function
|
||||
*/
|
||||
lv_action_t lv_btn_get_lpr_rep_action(lv_obj_t * btn);
|
||||
/**
|
||||
* Get the style of a button in a given state
|
||||
* @param btn pointer to a button object
|
||||
* @param state a state from 'lv_btn_state_t' in which style should be get
|
||||
* @return pointer to the style in the given state
|
||||
*/
|
||||
lv_style_t * lv_btn_get_style(lv_obj_t * btn, lv_btn_state_t state);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_BTN*/
|
||||
#endif /*USE_LV_BUTTON*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_BTN_H*/
|
||||
#endif /*lv_btn_H*/
|
||||
|
@ -39,7 +39,7 @@ static void lv_btnm_create_btns(lv_obj_t * btnm, const char ** map);
|
||||
static const char * lv_btnm_def_map[] = {"Btn1","Btn2", "Btn3","\n",
|
||||
"\002Btn4","Btn5", ""};
|
||||
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -66,7 +66,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_btnm);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_btnm_ext_t * ext = lv_obj_alloc_ext(new_btnm, sizeof(lv_btnm_ext_t));
|
||||
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->btn_cnt = 0;
|
||||
ext->btn_pr = LV_BTNM_PR_NONE;
|
||||
@ -74,26 +74,26 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->btn_areas = NULL;
|
||||
ext->cb = NULL;
|
||||
ext->map_p = NULL;
|
||||
ext->style_btn_rel = lv_style_get(LV_STYLE_BUTTON_OFF_RELEASED, NULL);
|
||||
ext->style_btn_pr = lv_style_get(LV_STYLE_BUTTON_OFF_PRESSED, NULL);
|
||||
ext->style_btn_trel = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED, NULL);
|
||||
ext->style_btn_tpr = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED, NULL);
|
||||
ext->style_btn_rel = lv_style_get(LV_STYLE_BUTTON_OFF_RELEASED);
|
||||
ext->style_btn_pr = lv_style_get(LV_STYLE_BUTTON_OFF_PRESSED);
|
||||
ext->style_btn_trel = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED);
|
||||
ext->style_btn_tpr = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED);
|
||||
ext->tgl = 0;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_btnm);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_btnm);
|
||||
|
||||
lv_obj_set_signal_f(new_btnm, lv_btnm_signal);
|
||||
lv_obj_set_design_f(new_btnm, lv_btnm_design);
|
||||
lv_obj_set_signal_func(new_btnm, lv_btnm_signal);
|
||||
lv_obj_set_design_func(new_btnm, lv_btnm_design);
|
||||
|
||||
/*Init the new button matrix object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_btnm, LV_HOR_RES, LV_VER_RES / 2);
|
||||
lv_obj_set_style(new_btnm, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_btnm, lv_style_get(LV_STYLE_PRETTY));
|
||||
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_btnm_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_btnm_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->style_btn_rel = copy_ext->style_btn_rel;
|
||||
ext->style_btn_pr = copy_ext->style_btn_pr;
|
||||
lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy));
|
||||
@ -120,7 +120,7 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
area_t btnm_area;
|
||||
area_t btn_area;
|
||||
point_t p;
|
||||
@ -136,7 +136,7 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
lv_indev_get_point(param, &p);
|
||||
btn_pr = lv_btnm_get_btn_from_point(btnm, &p);
|
||||
/*Invalidate to old and the new areas*/;
|
||||
lv_obj_get_cords(btnm, &btnm_area);
|
||||
lv_obj_get_coords(btnm, &btnm_area);
|
||||
if(btn_pr != ext->btn_pr) {
|
||||
lv_indev_reset_lpr(param);
|
||||
if(ext->btn_pr != LV_BTNM_PR_NONE) {
|
||||
@ -182,7 +182,7 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
}
|
||||
|
||||
/*Invalidate to old pressed area*/;
|
||||
lv_obj_get_cords(btnm, &btnm_area);
|
||||
lv_obj_get_coords(btnm, &btnm_area);
|
||||
area_cpy(&btn_area, &ext->btn_areas[ext->btn_pr]);
|
||||
btn_area.x1 += btnm_area.x1;
|
||||
btn_area.y1 += btnm_area.y1;
|
||||
@ -206,22 +206,22 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
|
||||
ext->btn_pr = LV_BTNM_PR_NONE;
|
||||
lv_obj_inv(btnm);
|
||||
lv_obj_invalidate(btnm);
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
ext->btn_pr = 0;
|
||||
lv_obj_inv(btnm);
|
||||
lv_obj_invalidate(btnm);
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
char c = *((char*)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
if(ext->btn_pr == LV_BTNM_PR_NONE) ext->btn_pr = 0;
|
||||
else ext->btn_pr++;
|
||||
if(ext->btn_pr >= ext->btn_cnt - 1) ext->btn_pr = ext->btn_cnt - 1;
|
||||
lv_obj_inv(btnm);
|
||||
lv_obj_invalidate(btnm);
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
|
||||
if(ext->btn_pr == LV_BTNM_PR_NONE) ext->btn_pr = 0;
|
||||
if(ext->btn_pr > 0) ext->btn_pr--;
|
||||
lv_obj_inv(btnm);
|
||||
lv_obj_invalidate(btnm);
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
if(ext->cb != NULL) {
|
||||
uint16_t txt_i = lv_btnm_get_btn_txt(btnm, ext->btn_pr);
|
||||
@ -256,7 +256,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
{
|
||||
if(map == NULL) return;
|
||||
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
ext->map_p = map;
|
||||
|
||||
/*Analyze the map and create the required number of buttons*/
|
||||
@ -334,7 +334,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
i_tot ++; /*Skip the '\n'*/
|
||||
}
|
||||
|
||||
lv_obj_inv(btnm);
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,7 +344,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
|
||||
*/
|
||||
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
ext->cb = cb;
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb)
|
||||
*/
|
||||
void lv_btnm_set_tgl(lv_obj_t * btnm, bool en, uint16_t id)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
ext->tgl = en == false ? 0 : 1;
|
||||
if(ext->tgl != 0) {
|
||||
@ -366,7 +366,7 @@ void lv_btnm_set_tgl(lv_obj_t * btnm, bool en, uint16_t id)
|
||||
ext->btn_tgl = LV_BTNM_PR_NONE;
|
||||
}
|
||||
|
||||
lv_obj_inv(btnm);
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -381,14 +381,14 @@ void lv_btnm_set_tgl(lv_obj_t * btnm, bool en, uint16_t id)
|
||||
void lv_btnm_set_styles_btn(lv_obj_t *btnm, lv_style_t *rel, lv_style_t *pr,
|
||||
lv_style_t *trel, lv_style_t *tpr, lv_style_t *ina)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
if(rel != NULL) ext->style_btn_rel = rel;
|
||||
if(pr != NULL) ext->style_btn_pr = pr;
|
||||
if(trel != NULL) ext->style_btn_trel = trel;
|
||||
if(tpr != NULL) ext->style_btn_tpr = tpr;
|
||||
if(ina != NULL) ext->style_btn_ina = ina;
|
||||
|
||||
lv_obj_inv(btnm);
|
||||
lv_obj_invalidate(btnm);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -402,7 +402,7 @@ void lv_btnm_set_styles_btn(lv_obj_t *btnm, lv_style_t *rel, lv_style_t *pr,
|
||||
*/
|
||||
const char ** lv_btnm_get_map(lv_obj_t * btnm)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
return ext->map_p;
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ const char ** lv_btnm_get_map(lv_obj_t * btnm)
|
||||
*/
|
||||
lv_btnm_callback_t lv_btnm_get_action(lv_obj_t * btnm)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
return ext->cb;
|
||||
}
|
||||
|
||||
@ -426,19 +426,19 @@ lv_btnm_callback_t lv_btnm_get_action(lv_obj_t * btnm)
|
||||
lv_style_t * lv_btnm_get_style_btn(lv_obj_t * btnm, lv_btn_state_t state)
|
||||
{
|
||||
lv_style_t * style;
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
switch(state) {
|
||||
case LV_BTN_STATE_PR:
|
||||
case LV_BTN_STATE_OFF_PRESSED:
|
||||
style = ext->style_btn_pr;
|
||||
break;
|
||||
case LV_BTN_STATE_REL:
|
||||
case LV_BTN_STATE_OFF_RELEASED:
|
||||
style = ext->style_btn_rel;
|
||||
break;
|
||||
case LV_BTN_STATE_TPR:
|
||||
case LV_BTN_STATE_ON_PRESSED:
|
||||
style = ext->style_btn_tpr;
|
||||
break;
|
||||
case LV_BTN_STATE_TREL:
|
||||
case LV_BTN_STATE_ON_RELEASED:
|
||||
style = ext->style_btn_trel;
|
||||
break;
|
||||
default:
|
||||
@ -474,7 +474,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
|
||||
else if (mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design_f(btnm, mask, mode);
|
||||
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
lv_style_t * btn_style;
|
||||
|
||||
area_t area_btnm;
|
||||
@ -495,7 +495,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
|
||||
continue;
|
||||
}
|
||||
|
||||
lv_obj_get_cords(btnm, &area_btnm);
|
||||
lv_obj_get_coords(btnm, &area_btnm);
|
||||
|
||||
area_cpy(&area_tmp, &ext->btn_areas[btn_i]);
|
||||
area_tmp.x1 += area_btnm.x1;
|
||||
@ -507,10 +507,10 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
|
||||
btn_h = area_get_height(&area_tmp);
|
||||
|
||||
/*Load the style*/
|
||||
if(btn_i != ext->btn_pr && btn_i != ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_REL);
|
||||
else if(btn_i == ext->btn_pr && btn_i != ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_PR);
|
||||
else if(btn_i != ext->btn_pr && btn_i == ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_TREL);
|
||||
else if(btn_i == ext->btn_pr && btn_i == ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_TPR);
|
||||
if(btn_i != ext->btn_pr && btn_i != ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_OFF_RELEASED);
|
||||
else if(btn_i == ext->btn_pr && btn_i != ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_OFF_PRESSED);
|
||||
else if(btn_i != ext->btn_pr && btn_i == ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_ON_RELEASED);
|
||||
else if(btn_i == ext->btn_pr && btn_i == ext->btn_tgl) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_ON_PRESSED);
|
||||
|
||||
lv_draw_rect(&area_tmp, mask, btn_style);
|
||||
|
||||
@ -549,7 +549,7 @@ static void lv_btnm_create_btns(lv_obj_t * btnm, const char ** map)
|
||||
i++;
|
||||
}
|
||||
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
|
||||
if(ext->btn_areas != NULL) {
|
||||
dm_free(ext->btn_areas);
|
||||
@ -584,9 +584,9 @@ static uint16_t lv_btnm_get_btn_from_point(lv_obj_t * btnm, point_t * p)
|
||||
{
|
||||
area_t btnm_cords;
|
||||
area_t btn_area;
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
uint16_t i;
|
||||
lv_obj_get_cords(btnm, &btnm_cords);
|
||||
lv_obj_get_coords(btnm, &btnm_cords);
|
||||
|
||||
for(i = 0; i < ext->btn_cnt; i++) {
|
||||
area_cpy(&btn_area, &ext->btn_areas[i]);
|
||||
@ -612,7 +612,7 @@ static uint16_t lv_btnm_get_btn_from_point(lv_obj_t * btnm, point_t * p)
|
||||
*/
|
||||
static uint16_t lv_btnm_get_btn_txt(lv_obj_t * btnm, uint16_t btn_id)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
|
||||
if(btn_id > ext->btn_cnt) return LV_BTNM_PR_NONE;
|
||||
|
||||
uint16_t txt_i = 0;
|
||||
|
@ -29,8 +29,8 @@ static bool lv_bullet_design(lv_obj_t * bullet, const area_t * mask, lv_design_m
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_bg_design_f;
|
||||
static lv_design_f_t ancestor_bullet_design_f;
|
||||
static lv_design_func_t ancestor_bg_design_f;
|
||||
static lv_design_func_t ancestor_bullet_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -56,45 +56,49 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_t * new_cb = lv_btn_create(par, copy);
|
||||
dm_assert(new_cb);
|
||||
|
||||
lv_cb_ext_t * ext = lv_obj_alloc_ext(new_cb, sizeof(lv_cb_ext_t));
|
||||
lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(new_cb, sizeof(lv_cb_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->bullet = NULL;
|
||||
ext->label = NULL;
|
||||
|
||||
if(ancestor_bg_design_f == NULL) ancestor_bg_design_f = lv_obj_get_design_f(new_cb);
|
||||
if(ancestor_bg_design_f == NULL) ancestor_bg_design_f = lv_obj_get_design_func(new_cb);
|
||||
|
||||
lv_obj_set_signal_f(new_cb, lv_cb_signal);
|
||||
lv_obj_set_design_f(new_cb, lv_cb_design);
|
||||
lv_obj_set_signal_func(new_cb, lv_cb_signal);
|
||||
lv_obj_set_design_func(new_cb, lv_cb_design);
|
||||
|
||||
/*Init the new checkbox object*/
|
||||
if(copy == NULL) {
|
||||
ext->bullet = lv_btn_create(new_cb, NULL);
|
||||
if(ancestor_bullet_design_f == NULL) ancestor_bullet_design_f = lv_obj_get_design_f(ext->bullet);
|
||||
lv_btn_set_styles(new_cb, lv_style_get(LV_STYLE_TRANSPARENT, NULL), lv_style_get(LV_STYLE_TRANSPARENT, NULL),
|
||||
lv_style_get(LV_STYLE_TRANSPARENT, NULL), lv_style_get(LV_STYLE_TRANSPARENT, NULL),
|
||||
lv_style_get(LV_STYLE_TRANSPARENT, NULL));
|
||||
if(ancestor_bullet_design_f == NULL) ancestor_bullet_design_f = lv_obj_get_design_func(ext->bullet);
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_OFF_RELEASED, lv_style_get(LV_STYLE_TRANSPARENT));
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_OFF_PRESSED, lv_style_get(LV_STYLE_TRANSPARENT));
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_ON_RELEASED, lv_style_get(LV_STYLE_TRANSPARENT));
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_ON_PRESSED, lv_style_get(LV_STYLE_TRANSPARENT));
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_INACTIVE, lv_style_get(LV_STYLE_TRANSPARENT));
|
||||
|
||||
lv_cont_set_layout(new_cb, LV_CONT_LAYOUT_ROW_M);
|
||||
lv_cont_set_fit(new_cb, true, true);
|
||||
lv_btn_set_tgl(new_cb, true);
|
||||
lv_btn_set_toggle(new_cb, true);
|
||||
|
||||
lv_obj_set_click(ext->bullet, false);
|
||||
lv_btn_set_styles(ext->bullet, lv_style_get(LV_STYLE_PRETTY, NULL), lv_style_get(LV_STYLE_PRETTY_COLOR, NULL),
|
||||
lv_style_get(LV_STYLE_BUTTON_ON_RELEASED, NULL), lv_style_get(LV_STYLE_BUTTON_ON_PRESSED, NULL),
|
||||
lv_style_get(LV_STYLE_BUTTON_INACTIVE, NULL));
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_OFF_RELEASED, lv_style_get(LV_STYLE_PRETTY));
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_OFF_PRESSED, lv_style_get(LV_STYLE_PRETTY_COLOR));
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_ON_RELEASED, lv_style_get(LV_STYLE_BUTTON_ON_RELEASED));
|
||||
lv_btn_set_style(new_cb, LV_BTN_STATE_ON_PRESSED, lv_style_get(LV_STYLE_BUTTON_ON_PRESSED));
|
||||
|
||||
ext->label = lv_label_create(new_cb, NULL);
|
||||
lv_obj_set_style(ext->label, NULL); /*Inherit the style of the parent*/
|
||||
lv_label_set_text(ext->label, "Check box");
|
||||
} else {
|
||||
lv_cb_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_cb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->bullet = lv_btn_create(new_cb, copy_ext->bullet);
|
||||
ext->label = lv_label_create(new_cb, copy_ext->label);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_cb);
|
||||
lv_obj_refresh_style(new_cb);
|
||||
}
|
||||
|
||||
lv_obj_set_design_f(ext->bullet, lv_bullet_design);
|
||||
lv_obj_set_design_func(ext->bullet, lv_bullet_design);
|
||||
|
||||
return new_cb;
|
||||
}
|
||||
@ -113,7 +117,7 @@ bool lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
||||
/* Include the ancient signal function */
|
||||
valid = lv_btn_signal(cb, sign, param);
|
||||
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext(cb);
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
lv_style_t * style = lv_obj_get_style(cb);
|
||||
|
||||
/* The object can be deleted so check its validity and then
|
||||
@ -150,7 +154,7 @@ bool lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext(cb);
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
}
|
||||
|
||||
@ -166,7 +170,7 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt)
|
||||
*/
|
||||
const char * lv_cb_get_text(lv_obj_t * cb)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext(cb);
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
return lv_label_get_text(ext->label);
|
||||
}
|
||||
|
||||
@ -177,7 +181,7 @@ const char * lv_cb_get_text(lv_obj_t * cb)
|
||||
*/
|
||||
lv_obj_t * lv_cb_get_bullet(lv_obj_t * cb)
|
||||
{
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext(cb);
|
||||
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
|
||||
return ext->bullet;
|
||||
}
|
||||
|
||||
@ -201,8 +205,8 @@ static bool lv_cb_design(lv_obj_t * cb, const area_t * mask, lv_design_mode_t mo
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return ancestor_bg_design_f(cb, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN || mode == LV_DESIGN_DRAW_POST) {
|
||||
lv_cb_ext_t * cb_ext = lv_obj_get_ext(cb);
|
||||
lv_btn_ext_t * bullet_ext = lv_obj_get_ext(cb_ext->bullet);
|
||||
lv_cb_ext_t * cb_ext = lv_obj_get_ext_attr(cb);
|
||||
lv_btn_ext_t * bullet_ext = lv_obj_get_ext_attr(cb_ext->bullet);
|
||||
|
||||
/*Be sure the state of the bullet is the same as the parent button*/
|
||||
bullet_ext->state = cb_ext->bg_btn.state;
|
||||
|
@ -17,7 +17,7 @@ extern "C" {
|
||||
#if USE_LV_CB != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_BTN == 0
|
||||
#if USE_LV_BUTTON == 0
|
||||
#error "lv_cb: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
||||
#endif
|
||||
|
||||
|
@ -38,7 +38,7 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -65,7 +65,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_chart);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_chart_ext_t * ext = lv_obj_alloc_ext(new_chart, sizeof(lv_chart_ext_t));
|
||||
lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(new_chart, sizeof(lv_chart_ext_t));
|
||||
dm_assert(ext);
|
||||
ll_init(&ext->dl_ll, sizeof(lv_chart_dl_t));
|
||||
ext->dl_num = 0;
|
||||
@ -77,18 +77,18 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->type = LV_CHART_LINE;
|
||||
ext->dl_opa = OPA_COVER;
|
||||
ext->dl_dark = OPA_50;
|
||||
ext->dl_width = 2 * LV_DOWNSCALE;
|
||||
ext->dl_width = 2 << LV_ANTIALIAS;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_chart);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_chart);
|
||||
|
||||
lv_obj_set_signal_f(new_chart, lv_chart_signal);
|
||||
lv_obj_set_design_f(new_chart, lv_chart_design);
|
||||
lv_obj_set_signal_func(new_chart, lv_chart_signal);
|
||||
lv_obj_set_design_func(new_chart, lv_chart_design);
|
||||
|
||||
/*Init the new chart background object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_chart, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_chart, lv_style_get(LV_STYLE_PRETTY));
|
||||
} else {
|
||||
lv_chart_ext_t * ext_copy = lv_obj_get_ext(copy);
|
||||
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
|
||||
ext->type = ext_copy->type;
|
||||
ext->ymin = ext_copy->ymin;
|
||||
ext->ymax = ext_copy->ymax;
|
||||
@ -98,7 +98,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->dl_opa = ext_copy->dl_opa;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_chart);
|
||||
lv_obj_refresh_style(new_chart);
|
||||
}
|
||||
|
||||
return new_chart;
|
||||
@ -121,7 +121,7 @@ bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param)
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
cord_t ** datal;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
LL_READ(ext->dl_ll, datal) {
|
||||
dm_free(*datal);
|
||||
@ -141,7 +141,7 @@ bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param)
|
||||
*/
|
||||
lv_chart_dl_t * lv_chart_add_data_line(lv_obj_t * chart, color_t color)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_dl_t * dl = ll_ins_head(&ext->dl_ll);
|
||||
cord_t def = (ext->ymin + ext->ymax) >> 1; /*half range as default value*/
|
||||
|
||||
@ -169,7 +169,7 @@ lv_chart_dl_t * lv_chart_add_data_line(lv_obj_t * chart, color_t color)
|
||||
*/
|
||||
void lv_chart_refr(lv_obj_t * chart)
|
||||
{
|
||||
lv_obj_inv(chart);
|
||||
lv_obj_invalidate(chart);
|
||||
}
|
||||
/*=====================
|
||||
* Setter functions
|
||||
@ -183,12 +183,12 @@ void lv_chart_refr(lv_obj_t * chart)
|
||||
*/
|
||||
void lv_chart_set_hvdiv(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
ext->hdiv_num = hdiv;
|
||||
ext->vdiv_num = vdiv;
|
||||
|
||||
lv_obj_inv(chart);
|
||||
lv_obj_invalidate(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,7 +201,7 @@ void lv_chart_set_hvdiv(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
||||
*/
|
||||
void lv_chart_set_range(lv_obj_t * chart, cord_t ymin, cord_t ymax)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
ext->ymin = ymin;
|
||||
ext->ymax = ymax;
|
||||
@ -216,7 +216,7 @@ void lv_chart_set_range(lv_obj_t * chart, cord_t ymin, cord_t ymax)
|
||||
*/
|
||||
void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
ext->type = type;
|
||||
|
||||
lv_chart_refr(chart);
|
||||
@ -229,7 +229,7 @@ void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type)
|
||||
*/
|
||||
void lv_chart_set_pnum(lv_obj_t * chart, uint16_t pnum)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_chart_dl_t * dl;
|
||||
|
||||
if(pnum < 1) pnum = 1;
|
||||
@ -249,9 +249,9 @@ void lv_chart_set_pnum(lv_obj_t * chart, uint16_t pnum)
|
||||
*/
|
||||
void lv_chart_set_dl_opa(lv_obj_t * chart, opa_t opa)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
ext->dl_opa = opa;
|
||||
lv_obj_inv(chart);
|
||||
lv_obj_invalidate(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,9 +261,9 @@ void lv_chart_set_dl_opa(lv_obj_t * chart, opa_t opa)
|
||||
*/
|
||||
void lv_chart_set_dl_width(lv_obj_t * chart, cord_t width)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
ext->dl_width = width;
|
||||
lv_obj_inv(chart);
|
||||
lv_obj_invalidate(chart);
|
||||
}
|
||||
/**
|
||||
* Set the dark effect on the bottom of the points or columns
|
||||
@ -272,7 +272,7 @@ void lv_chart_set_dl_width(lv_obj_t * chart, cord_t width)
|
||||
*/
|
||||
void lv_chart_set_dl_dark(lv_obj_t * chart, opa_t dark_eff)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
ext->dl_dark = dark_eff;
|
||||
}
|
||||
/**
|
||||
@ -283,7 +283,7 @@ void lv_chart_set_dl_dark(lv_obj_t * chart, opa_t dark_eff)
|
||||
*/
|
||||
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < ext->pnum - 1; i++) {
|
||||
@ -307,7 +307,7 @@ void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y)
|
||||
*/
|
||||
lv_chart_type_t lv_chart_get_type(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
return ext->type;
|
||||
}
|
||||
@ -319,7 +319,7 @@ lv_chart_type_t lv_chart_get_type(lv_obj_t * chart)
|
||||
*/
|
||||
uint16_t lv_chart_get_pnum(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
return ext->pnum;
|
||||
}
|
||||
@ -331,7 +331,7 @@ uint16_t lv_chart_get_pnum(lv_obj_t * chart)
|
||||
*/
|
||||
opa_t lv_chart_get_dl_opa(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
return ext->dl_opa;
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ opa_t lv_chart_get_dl_opa(lv_obj_t * chart)
|
||||
*/
|
||||
cord_t lv_chart_get_dl_width(lv_obj_t * chart)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
return ext->dl_width;
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ cord_t lv_chart_get_dl_width(lv_obj_t * chart)
|
||||
*/
|
||||
opa_t lv_chart_get_dl_dark(lv_obj_t * chart, opa_t dark_eff)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
return ext->dl_dark;
|
||||
}
|
||||
/**********************
|
||||
@ -378,9 +378,9 @@ static bool lv_chart_design(lv_obj_t * chart, const area_t * mask, lv_design_mod
|
||||
return ancestor_design_f(chart, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Draw the background*/
|
||||
lv_draw_rect(&chart->cords, mask, lv_obj_get_style(chart));
|
||||
lv_draw_rect(&chart->coords, mask, lv_obj_get_style(chart));
|
||||
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
|
||||
lv_chart_draw_div(chart, mask);
|
||||
|
||||
@ -398,7 +398,7 @@ static bool lv_chart_design(lv_obj_t * chart, const area_t * mask, lv_design_mod
|
||||
*/
|
||||
static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t div_i;
|
||||
@ -408,12 +408,12 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask)
|
||||
point_t p2;
|
||||
cord_t w = lv_obj_get_width(chart);
|
||||
cord_t h = lv_obj_get_height(chart);
|
||||
cord_t x_ofs = chart->cords.x1;
|
||||
cord_t y_ofs = chart->cords.y1;
|
||||
cord_t x_ofs = chart->coords.x1;
|
||||
cord_t y_ofs = chart->coords.y1;
|
||||
|
||||
if(ext->hdiv_num != 0) {
|
||||
/*Draw slide lines if no border*/
|
||||
if(style->border.width != 0) {
|
||||
if(style->body.border.width != 0) {
|
||||
div_i_start = 1;
|
||||
div_i_end = ext->hdiv_num;
|
||||
} else {
|
||||
@ -436,7 +436,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask)
|
||||
|
||||
if(ext->vdiv_num != 0) {
|
||||
/*Draw slide lines if no border*/
|
||||
if(style->border.width != 0) {
|
||||
if(style->body.border.width != 0) {
|
||||
div_i_start = 1;
|
||||
div_i_end = ext->vdiv_num;
|
||||
} else {
|
||||
@ -463,7 +463,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask)
|
||||
*/
|
||||
static void lv_chart_draw_lines(lv_obj_t * chart, const area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t i;
|
||||
@ -471,12 +471,12 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const area_t * mask)
|
||||
point_t p2;
|
||||
cord_t w = lv_obj_get_width(chart);
|
||||
cord_t h = lv_obj_get_height(chart);
|
||||
cord_t x_ofs = chart->cords.x1;
|
||||
cord_t y_ofs = chart->cords.y1;
|
||||
cord_t x_ofs = chart->coords.x1;
|
||||
cord_t y_ofs = chart->coords.y1;
|
||||
int32_t y_tmp;
|
||||
lv_chart_dl_t * dl;
|
||||
lv_style_t lines;
|
||||
lv_style_get(LV_STYLE_PLAIN, &lines);
|
||||
lv_style_copy(&lines, lv_style_get(LV_STYLE_PLAIN));
|
||||
lines.opacity = (uint16_t)((uint16_t)style->opacity * ext->dl_opa) >> 8;
|
||||
lines.line.width = ext->dl_width;
|
||||
|
||||
@ -512,22 +512,22 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const area_t * mask)
|
||||
*/
|
||||
static void lv_chart_draw_points(lv_obj_t * chart, const area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t i;
|
||||
area_t cir_a;
|
||||
cord_t w = lv_obj_get_width(chart);
|
||||
cord_t h = lv_obj_get_height(chart);
|
||||
cord_t x_ofs = chart->cords.x1;
|
||||
cord_t y_ofs = chart->cords.y1;
|
||||
cord_t x_ofs = chart->coords.x1;
|
||||
cord_t y_ofs = chart->coords.y1;
|
||||
int32_t y_tmp;
|
||||
lv_chart_dl_t * dl;
|
||||
uint8_t dl_cnt = 0;
|
||||
lv_style_t style_point;
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_point);
|
||||
lv_style_copy(&style_point, lv_style_get(LV_STYLE_PLAIN));
|
||||
|
||||
style_point.border.width = 0;
|
||||
style_point.body.border.width = 0;
|
||||
style_point.body.empty = 0;
|
||||
style_point.body.radius = LV_RADIUS_CIRCLE;
|
||||
style_point.opacity = (uint16_t)((uint16_t)style->opacity * ext->dl_opa) >> 8;
|
||||
@ -562,7 +562,7 @@ static void lv_chart_draw_points(lv_obj_t * chart, const area_t * mask)
|
||||
*/
|
||||
static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_style_t * style = lv_obj_get_style(chart);
|
||||
|
||||
uint8_t i;
|
||||
@ -577,20 +577,20 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask)
|
||||
cord_t col_w = w / ((ext->dl_num + 1) * ext->pnum); /* Suppose + 1 dl as separator*/
|
||||
cord_t x_ofs = col_w / 2; /*Shift with a half col.*/
|
||||
|
||||
lv_style_get(LV_STYLE_PLAIN, &rects);
|
||||
rects.border.width = 0;
|
||||
lv_style_copy(&rects, lv_style_get(LV_STYLE_PLAIN));
|
||||
rects.body.border.width = 0;
|
||||
rects.body.empty = 0;
|
||||
rects.body.radius = 0;
|
||||
rects.opacity = (uint16_t)((uint16_t)style->opacity * ext->dl_opa) >> 8;
|
||||
|
||||
col_a.y2 = chart->cords.y2;
|
||||
col_a.y2 = chart->coords.y2;
|
||||
|
||||
cord_t x_act;
|
||||
|
||||
/*Go through all points*/
|
||||
for(i = 0; i < ext->pnum; i ++) {
|
||||
x_act = (int32_t)((int32_t) w * i) / ext->pnum;
|
||||
x_act += chart->cords.x1 + x_ofs;
|
||||
x_act += chart->coords.x1 + x_ofs;
|
||||
|
||||
/*Draw the current point of all data line*/
|
||||
LL_READ_BACK(ext->dl_ll, dl) {
|
||||
@ -602,11 +602,11 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask)
|
||||
|
||||
y_tmp = (int32_t)((int32_t) dl->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
col_a.y1 = h - y_tmp + chart->cords.y1;
|
||||
col_a.y1 = h - y_tmp + chart->coords.y1;
|
||||
|
||||
mask_ret = area_union(&col_mask, mask, &col_a);
|
||||
if(mask_ret != false) {
|
||||
lv_draw_rect(&chart->cords, &col_mask, &rects);
|
||||
lv_draw_rect(&chart->coords, &col_mask, &rects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,28 +72,28 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Create a basic object*/
|
||||
lv_obj_t * new_rect = lv_obj_create(par, copy);
|
||||
dm_assert(new_rect);
|
||||
lv_obj_alloc_ext(new_rect, sizeof(lv_cont_ext_t));
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(new_rect);
|
||||
lv_obj_allocate_ext_attr(new_rect, sizeof(lv_cont_ext_t));
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(new_rect);
|
||||
dm_assert(ext);
|
||||
ext->hfit_en = 0;
|
||||
ext->vfit_en = 0;
|
||||
ext->layout = LV_CONT_LAYOUT_OFF;
|
||||
|
||||
lv_obj_set_signal_f(new_rect, lv_cont_signal);
|
||||
lv_obj_set_signal_func(new_rect, lv_cont_signal);
|
||||
|
||||
/*Init the new container*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_rect, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_obj_set_style(new_rect, lv_style_get(LV_STYLE_PLAIN));
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_cont_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_cont_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->hfit_en = copy_ext->hfit_en;
|
||||
ext->vfit_en = copy_ext->vfit_en;
|
||||
ext->layout = copy_ext->layout;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_rect);
|
||||
lv_obj_refresh_style(new_rect);
|
||||
|
||||
}
|
||||
|
||||
@ -145,11 +145,11 @@ bool lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
ext->layout = layout;
|
||||
|
||||
/*Send a signal to refresh the layout*/
|
||||
cont->signal_f(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -162,13 +162,13 @@ void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout)
|
||||
*/
|
||||
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
|
||||
{
|
||||
lv_obj_inv(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
lv_obj_invalidate(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
ext->hfit_en = hor_en == false ? 0 : 1;
|
||||
ext->vfit_en = ver_en == false ? 0 : 1;
|
||||
|
||||
/*Send a signal to set a new size*/
|
||||
cont->signal_f(cont, LV_SIGNAL_CORD_CHG, cont);
|
||||
cont->signal_func(cont, LV_SIGNAL_CORD_CHG, cont);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -182,7 +182,7 @@ void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
|
||||
*/
|
||||
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->layout;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont)
|
||||
*/
|
||||
bool lv_cont_get_hfit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->hfit_en == 0 ? false : true;
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ bool lv_cont_get_hfit(lv_obj_t * cont)
|
||||
*/
|
||||
bool lv_cont_get_vfit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->vfit_en == 0 ? false : true;
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ static void lv_cont_layout_col(lv_obj_t * cont)
|
||||
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -361,7 +361,7 @@ static void lv_cont_layout_row(lv_obj_t * cont)
|
||||
last_cord += lv_obj_get_width(child) + style->body.padding.inner;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,7 +400,7 @@ static void lv_cont_layout_center(lv_obj_t * cont)
|
||||
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -495,7 +495,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
|
||||
child_rs = ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
|
||||
child_rc = child_rs;
|
||||
}
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -545,7 +545,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -554,7 +554,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
*/
|
||||
static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
|
||||
if(ext->hfit_en == 0 &&
|
||||
ext->vfit_en == 0) {
|
||||
@ -569,8 +569,8 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
cord_t vpad = style->body.padding.vertical;
|
||||
|
||||
/*Search the side coordinates of the children*/
|
||||
lv_obj_get_cords(cont, &ori);
|
||||
lv_obj_get_cords(cont, &new_cords);
|
||||
lv_obj_get_coords(cont, &ori);
|
||||
lv_obj_get_coords(cont, &new_cords);
|
||||
|
||||
new_cords.x1 = CORD_MAX;
|
||||
new_cords.y1 = CORD_MAX;
|
||||
@ -579,10 +579,10 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
|
||||
LL_READ(cont->child_ll, i) {
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
new_cords.x1 = MATH_MIN(new_cords.x1, i->cords.x1);
|
||||
new_cords.y1 = MATH_MIN(new_cords.y1, i->cords.y1);
|
||||
new_cords.x2 = MATH_MAX(new_cords.x2, i->cords.x2);
|
||||
new_cords.y2 = MATH_MAX(new_cords.y2, i->cords.y2);
|
||||
new_cords.x1 = MATH_MIN(new_cords.x1, i->coords.x1);
|
||||
new_cords.y1 = MATH_MIN(new_cords.y1, i->coords.y1);
|
||||
new_cords.x2 = MATH_MAX(new_cords.x2, i->coords.x2);
|
||||
new_cords.y2 = MATH_MAX(new_cords.y2, i->coords.y2);
|
||||
}
|
||||
|
||||
/*If the value is not the init value then the page has >=1 child.*/
|
||||
@ -591,33 +591,33 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
new_cords.x1 -= hpad;
|
||||
new_cords.x2 += hpad;
|
||||
} else {
|
||||
new_cords.x1 = cont->cords.x1;
|
||||
new_cords.x2 = cont->cords.x2;
|
||||
new_cords.x1 = cont->coords.x1;
|
||||
new_cords.x2 = cont->coords.x2;
|
||||
}
|
||||
if(ext->vfit_en != 0) {
|
||||
new_cords.y1 -= vpad;
|
||||
new_cords.y2 += vpad;
|
||||
} else {
|
||||
new_cords.y1 = cont->cords.y1;
|
||||
new_cords.y2 = cont->cords.y2;
|
||||
new_cords.y1 = cont->coords.y1;
|
||||
new_cords.y2 = cont->coords.y2;
|
||||
}
|
||||
|
||||
/*Do nothing if the coordinates are not changed*/
|
||||
if(cont->cords.x1 != new_cords.x1 ||
|
||||
cont->cords.y1 != new_cords.y1 ||
|
||||
cont->cords.x2 != new_cords.x2 ||
|
||||
cont->cords.y2 != new_cords.y2) {
|
||||
if(cont->coords.x1 != new_cords.x1 ||
|
||||
cont->coords.y1 != new_cords.y1 ||
|
||||
cont->coords.x2 != new_cords.x2 ||
|
||||
cont->coords.y2 != new_cords.y2) {
|
||||
|
||||
lv_obj_inv(cont);
|
||||
area_cpy(&cont->cords, &new_cords);
|
||||
lv_obj_inv(cont);
|
||||
lv_obj_invalidate(cont);
|
||||
area_cpy(&cont->coords, &new_cords);
|
||||
lv_obj_invalidate(cont);
|
||||
|
||||
/*Notify the object about its new coordinates*/
|
||||
cont->signal_f(cont, LV_SIGNAL_CORD_CHG, &ori);
|
||||
cont->signal_func(cont, LV_SIGNAL_CORD_CHG, &ori);
|
||||
|
||||
/*Inform the parent about the new coordinates*/
|
||||
lv_obj_t * par = lv_obj_get_parent(cont);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ static void lv_ddlist_pos_act_option(lv_obj_t * ddlist);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
static const char * def_options[] = {"Option 1", "Option 2", "Option 3", ""};
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -63,7 +63,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_ddlist);
|
||||
|
||||
/*Allocate the drop down list type specific extended data*/
|
||||
lv_ddlist_ext_t * ext = lv_obj_alloc_ext(new_ddlist, sizeof(lv_ddlist_ext_t));
|
||||
lv_ddlist_ext_t * ext = lv_obj_allocate_ext_attr(new_ddlist, sizeof(lv_ddlist_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
@ -74,31 +74,31 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->sel_opt = 0;
|
||||
ext->num_opt = 0;
|
||||
ext->anim_time = LV_DDLIST_DEF_ANIM_TIME;
|
||||
ext->style_sel = lv_style_get(LV_STYLE_PLAIN_COLOR, NULL);
|
||||
ext->style_sel = lv_style_get(LV_STYLE_PLAIN_COLOR);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_ddlist);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_ddlist);
|
||||
|
||||
lv_obj_set_signal_f(new_ddlist, lv_ddlist_signal);
|
||||
lv_obj_set_design_f(new_ddlist, lv_ddlist_design);
|
||||
lv_obj_set_signal_func(new_ddlist, lv_ddlist_signal);
|
||||
lv_obj_set_design_func(new_ddlist, lv_ddlist_design);
|
||||
|
||||
/*Init the new drop down list drop down list*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_t * scrl = lv_page_get_scrl(new_ddlist);
|
||||
lv_obj_set_drag(scrl, false);
|
||||
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSPARENT, NULL));
|
||||
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSPARENT));
|
||||
lv_cont_set_fit(scrl, true, true);
|
||||
|
||||
ext->opt_label = lv_label_create(new_ddlist, NULL);
|
||||
lv_cont_set_fit(new_ddlist, true, false);
|
||||
lv_page_set_rel_action(new_ddlist, lv_ddlist_rel_action);
|
||||
lv_page_set_sb_mode(new_ddlist, LV_PAGE_SB_MODE_DRAG);
|
||||
lv_obj_set_style(new_ddlist, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_ddlist, lv_style_get(LV_STYLE_PRETTY));
|
||||
lv_ddlist_set_options(new_ddlist, def_options);
|
||||
}
|
||||
/*Copy an existing drop down list*/
|
||||
else {
|
||||
lv_ddlist_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_ddlist_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->opt_label = lv_label_create(new_ddlist, copy_ext->opt_label);
|
||||
lv_label_set_text(ext->opt_label, lv_label_get_text(copy_ext->opt_label));
|
||||
ext->sel_opt = copy_ext->sel_opt;
|
||||
@ -107,7 +107,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->num_opt = copy_ext->num_opt;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_ddlist);
|
||||
lv_obj_refresh_style(new_ddlist);
|
||||
}
|
||||
|
||||
return new_ddlist;
|
||||
@ -133,24 +133,24 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_ddlist_refr_size(ddlist, 0);
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
if(ext->opened == false) {
|
||||
ext->opened = true;
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
if(ext->opened != false) {
|
||||
ext->opened = false;
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
char c = *((char*)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
|
||||
if(ext->sel_opt +1 < ext->num_opt) {
|
||||
ext->sel_opt ++;
|
||||
lv_obj_inv(ddlist);
|
||||
lv_obj_invalidate(ddlist);
|
||||
if(ext->cb != NULL) {
|
||||
ext->cb(ddlist);
|
||||
}
|
||||
@ -158,7 +158,7 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
|
||||
if(ext->sel_opt > 0) {
|
||||
ext->sel_opt --;
|
||||
lv_obj_inv(ddlist);
|
||||
lv_obj_invalidate(ddlist);
|
||||
if(ext->cb != NULL) {
|
||||
ext->cb(ddlist);
|
||||
}
|
||||
@ -188,7 +188,7 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
lv_label_set_text(ext->opt_label, "");
|
||||
uint16_t i = 0;
|
||||
@ -210,7 +210,7 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options)
|
||||
*/
|
||||
void lv_ddlist_set_options_str(lv_obj_t * ddlist, const char * options)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
/*Count the '\n'-s to determine the number of options*/
|
||||
ext->num_opt = 0;
|
||||
@ -231,7 +231,7 @@ void lv_ddlist_set_options_str(lv_obj_t * ddlist, const char * options)
|
||||
*/
|
||||
void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
ext->sel_opt = sel_opt < ext->num_opt ? sel_opt : ext->num_opt - 1;
|
||||
|
||||
@ -239,7 +239,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
||||
if(ext->opened == 0) {
|
||||
lv_ddlist_pos_act_option(ddlist);
|
||||
} else {
|
||||
lv_obj_inv(ddlist);
|
||||
lv_obj_invalidate(ddlist);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
|
||||
*/
|
||||
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t cb)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
ext->cb = cb;
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t cb)
|
||||
*/
|
||||
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
ext->fix_height = h;
|
||||
lv_ddlist_refr_size(ddlist, 0);
|
||||
}
|
||||
@ -274,7 +274,7 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h)
|
||||
*/
|
||||
void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
ext->anim_time = anim_time;
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
|
||||
*/
|
||||
void lv_ddlist_set_style_select(lv_obj_t * ddlist, lv_style_t * style)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
ext->style_sel = style;
|
||||
|
||||
}
|
||||
@ -298,7 +298,7 @@ void lv_ddlist_set_style_select(lv_obj_t * ddlist, lv_style_t * style)
|
||||
*/
|
||||
void lv_ddlist_open(lv_obj_t * ddlist, bool state, bool anim)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
ext->opened = state ? 1 : 0;
|
||||
lv_ddlist_refr_size(ddlist, anim ? ext->anim_time : 0);
|
||||
|
||||
@ -314,7 +314,7 @@ void lv_ddlist_open(lv_obj_t * ddlist, bool state, bool anim)
|
||||
*/
|
||||
const char * lv_ddlist_get_options(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
return lv_label_get_text(ext->opt_label);
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ const char * lv_ddlist_get_options(lv_obj_t * ddlist)
|
||||
*/
|
||||
uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
return ext->sel_opt;
|
||||
}
|
||||
@ -337,7 +337,7 @@ uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist)
|
||||
*/
|
||||
void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
uint16_t i;
|
||||
uint16_t line = 0;
|
||||
@ -362,7 +362,7 @@ void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf)
|
||||
*/
|
||||
cord_t lv_ddlist_get_fix_height(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
return ext->fix_height;
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ cord_t lv_ddlist_get_fix_height(lv_obj_t * ddlist)
|
||||
*/
|
||||
lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
if(ext->style_sel == NULL) return lv_obj_get_style(ddlist);
|
||||
|
||||
return ext->style_sel;
|
||||
@ -385,7 +385,7 @@ lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist)
|
||||
*/
|
||||
uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
return ext->anim_time;
|
||||
}
|
||||
|
||||
@ -414,18 +414,18 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
|
||||
ancestor_design_f(ddlist, mask, mode);
|
||||
|
||||
/*If the list is opened draw a rectangle below the selected item*/
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
if(ext->opened != 0) {
|
||||
lv_style_t * style = lv_obj_get_style(ddlist);
|
||||
const font_t * font = style->text.font;
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
area_t rect_area;
|
||||
rect_area.y1 = ext->opt_label->cords.y1;
|
||||
rect_area.y1 = ext->opt_label->coords.y1;
|
||||
rect_area.y1 += ext->sel_opt * (font_h + style->text.space_line);
|
||||
rect_area.y1 -= style->text.space_line / 2;
|
||||
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->text.space_line;
|
||||
rect_area.x1 = ext->opt_label->cords.x1 - style->body.padding.horizontal;
|
||||
rect_area.x1 = ext->opt_label->coords.x1 - style->body.padding.horizontal;
|
||||
rect_area.x2 = rect_area.x1 + lv_obj_get_width(lv_page_get_scrl(ddlist));
|
||||
|
||||
lv_draw_rect(&rect_area, mask, ext->style_sel);
|
||||
@ -446,7 +446,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
|
||||
*/
|
||||
static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
if(ext->opened == 0) { /*Open the list*/
|
||||
ext->opened = 1;
|
||||
@ -459,8 +459,8 @@ static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist)
|
||||
lv_indev_t *indev = lv_indev_get_act();
|
||||
point_t p;
|
||||
lv_indev_get_point(indev, &p);
|
||||
p.x -= ext->opt_label->cords.x1;
|
||||
p.y -= ext->opt_label->cords.y1;
|
||||
p.x -= ext->opt_label->coords.x1;
|
||||
p.y -= ext->opt_label->coords.y1;
|
||||
uint16_t letter_i;
|
||||
letter_i = lv_label_get_letter_on(ext->opt_label, &p);
|
||||
|
||||
@ -490,7 +490,7 @@ static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist)
|
||||
*/
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
lv_style_t * style = lv_obj_get_style(ddlist);
|
||||
cord_t new_height;
|
||||
if(ext->opened) { /*Open the list*/
|
||||
@ -530,7 +530,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time)
|
||||
*/
|
||||
static void lv_ddlist_pos_act_option(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
lv_style_t * style = lv_obj_get_style(ddlist);
|
||||
const font_t * font = style->text.font;
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
@ -538,7 +538,7 @@ static void lv_ddlist_pos_act_option(lv_obj_t * ddlist)
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ddlist);
|
||||
|
||||
cord_t h = lv_obj_get_height(ddlist);
|
||||
cord_t line_y1 = ext->sel_opt * (font_h + label_style->text.space_line) + ext->opt_label->cords.y1 - scrl->cords.y1;
|
||||
cord_t line_y1 = ext->sel_opt * (font_h + label_style->text.space_line) + ext->opt_label->coords.y1 - scrl->coords.y1;
|
||||
|
||||
lv_obj_set_y(scrl, - line_y1 + (h - font_h) / 2);
|
||||
|
||||
|
@ -41,7 +41,7 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f = NULL;
|
||||
static lv_design_func_t ancestor_design_f = NULL;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -68,7 +68,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_gauge);
|
||||
|
||||
/*Allocate the gauge type specific extended data*/
|
||||
lv_gauge_ext_t * ext = lv_obj_alloc_ext(new_gauge, sizeof(lv_gauge_ext_t));
|
||||
lv_gauge_ext_t * ext = lv_obj_allocate_ext_attr(new_gauge, sizeof(lv_gauge_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
@ -76,24 +76,24 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->values = NULL;
|
||||
ext->needle_colors = NULL;
|
||||
ext->low_critical = 0;
|
||||
ext->style_critical = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
ext->style_critical = lv_style_get(LV_STYLE_PRETTY_COLOR);
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_gauge);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_gauge);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_gauge, lv_gauge_signal);
|
||||
lv_obj_set_design_f(new_gauge, lv_gauge_design);
|
||||
lv_obj_set_signal_func(new_gauge, lv_gauge_signal);
|
||||
lv_obj_set_design_func(new_gauge, lv_gauge_design);
|
||||
|
||||
/*Init the new gauge gauge*/
|
||||
if(copy == NULL) {
|
||||
lv_lmeter_set_scale(new_gauge, 220, 6);
|
||||
lv_gauge_set_needle_num(new_gauge, 1, NULL);
|
||||
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
|
||||
lv_obj_set_style(new_gauge, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_gauge, lv_style_get(LV_STYLE_PRETTY));
|
||||
}
|
||||
/*Copy an existing gauge*/
|
||||
else {
|
||||
lv_gauge_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_gauge_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->low_critical = copy_ext->low_critical;
|
||||
lv_gauge_set_style_critical(new_gauge, lv_gauge_get_style_critical(copy));
|
||||
lv_gauge_set_needle_num(new_gauge, copy_ext->needle_num, copy_ext->needle_colors);
|
||||
@ -104,7 +104,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_gauge);
|
||||
lv_obj_refresh_style(new_gauge);
|
||||
}
|
||||
|
||||
return new_gauge;
|
||||
@ -127,14 +127,14 @@ bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
dm_free(ext->values);
|
||||
ext->values = NULL;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
lv_style_t * style_crit = lv_gauge_get_style_critical(gauge);
|
||||
if(style_crit->shadow.width > gauge->ext_size) gauge->ext_size = style_crit->shadow.width;
|
||||
if(style_crit->body.shadow.width > gauge->ext_size) gauge->ext_size = style_crit->body.shadow.width;
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
if(ext->values != NULL) {
|
||||
dm_free(ext->values);
|
||||
ext->values = NULL;
|
||||
@ -169,7 +169,7 @@ void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors)
|
||||
|
||||
ext->needle_num = num;
|
||||
ext->needle_colors = colors;
|
||||
lv_obj_inv(gauge);
|
||||
lv_obj_invalidate(gauge);
|
||||
}
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ void lv_gauge_set_needle_num(lv_obj_t * gauge, uint8_t num, color_t * colors)
|
||||
*/
|
||||
void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
if(needle >= ext->needle_num) return;
|
||||
|
||||
@ -196,7 +196,7 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value)
|
||||
/*To be consistent with bar set the first needle's value for the bar*/
|
||||
if(needle == 0) lv_bar_set_value(gauge, value);
|
||||
|
||||
lv_obj_inv(gauge);
|
||||
lv_obj_invalidate(gauge);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,11 +206,11 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value)
|
||||
*/
|
||||
void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
ext->low_critical = low == false ? 0 : 1;
|
||||
|
||||
lv_obj_inv(gauge);
|
||||
lv_obj_invalidate(gauge);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,10 +220,10 @@ void lv_gauge_set_low_critical(lv_obj_t * gauge, bool low)
|
||||
*/
|
||||
void lv_gauge_set_style_critical(lv_obj_t * gauge, lv_style_t * style)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
ext->style_critical = style;
|
||||
gauge->signal_f(gauge, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
lv_obj_inv(gauge);
|
||||
gauge->signal_func(gauge, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
lv_obj_invalidate(gauge);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@ -237,7 +237,7 @@ void lv_gauge_set_style_critical(lv_obj_t * gauge, lv_style_t * style)
|
||||
*/
|
||||
uint8_t lv_gauge_get_needle_num(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
return ext->needle_num;
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ uint8_t lv_gauge_get_needle_num(lv_obj_t * gauge)
|
||||
*/
|
||||
int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
int16_t min = lv_bar_get_min_value(gauge);
|
||||
|
||||
if(needle >= ext->needle_num) return min;
|
||||
@ -264,7 +264,7 @@ int16_t lv_gauge_get_value(lv_obj_t * gauge, uint8_t needle)
|
||||
*/
|
||||
bool lv_gauge_get_low_critical(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
return ext->low_critical == 0 ? false : true;
|
||||
}
|
||||
@ -276,7 +276,7 @@ bool lv_gauge_get_low_critical(lv_obj_t * gauge)
|
||||
*/
|
||||
lv_style_t * lv_gauge_get_style_critical(lv_obj_t * gauge)
|
||||
{
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
if(ext->style_critical == NULL) return lv_obj_get_style(gauge);
|
||||
|
||||
@ -308,7 +308,7 @@ static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mod
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_style_t * style_base = lv_obj_get_style(gauge);
|
||||
lv_style_t * style_critical = lv_gauge_get_style_critical(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
/* Draw the background
|
||||
* Re-color the gauge according to the critical value*/
|
||||
@ -337,12 +337,12 @@ static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mod
|
||||
style_bg.text.color = color_mix(style_critical->text.color, style_base->text.color, ratio);
|
||||
style_bg.body.color_main= color_mix(style_critical->body.color_main, style_base->body.color_main, ratio);
|
||||
style_bg.body.color_gradient = color_mix(style_critical->body.color_gradient, style_base->body.color_gradient, ratio);
|
||||
style_bg.border.color = color_mix(style_critical->border.color, style_base->border.color, ratio);
|
||||
style_bg.shadow.color = color_mix(style_critical->shadow.color, style_base->shadow.color, ratio);
|
||||
style_bg.shadow.width = (cord_t)(((cord_t)style_critical->shadow.width * ratio) + ((cord_t)style_base->shadow.width * (OPA_COVER - ratio))) >> 8;
|
||||
style_bg.body.border.color = color_mix(style_critical->body.border.color, style_base->body.border.color, ratio);
|
||||
style_bg.body.shadow.color = color_mix(style_critical->body.shadow.color, style_base->body.shadow.color, ratio);
|
||||
style_bg.body.shadow.width = (cord_t)(((cord_t)style_critical->body.shadow.width * ratio) + ((cord_t)style_base->body.shadow.width * (OPA_COVER - ratio))) >> 8;
|
||||
style_bg.opacity = (cord_t)(((uint16_t)style_critical->opacity * ratio) + ((uint16_t)style_base->opacity * (OPA_COVER - ratio))) >> 8;
|
||||
|
||||
lv_draw_rect(&gauge->cords, mask, &style_bg);
|
||||
lv_draw_rect(&gauge->coords, mask, &style_bg);
|
||||
|
||||
lv_gauge_draw_scale(gauge, mask, &style_bg);
|
||||
|
||||
@ -366,8 +366,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_
|
||||
char scale_txt[16];
|
||||
|
||||
cord_t r = lv_obj_get_width(gauge) / 2 - style->body.padding.horizontal;
|
||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1;
|
||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1;
|
||||
int16_t scale_angle = lv_lmeter_get_scale_angle(gauge);
|
||||
uint16_t scale_num = lv_lmeter_get_scale_num(gauge);
|
||||
int16_t angle_ofs = 90 + (360 - scale_angle) / 2;
|
||||
@ -412,11 +412,11 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_
|
||||
static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style_t * style)
|
||||
{
|
||||
lv_style_t style_needle;
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext(gauge);
|
||||
lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge);
|
||||
|
||||
cord_t r = lv_obj_get_width(gauge) / 2 - style->body.padding.inner;
|
||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1;
|
||||
cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1;
|
||||
uint16_t angle = lv_lmeter_get_scale_angle(gauge);
|
||||
int16_t angle_ofs = 90 + (360 - angle) / 2;
|
||||
int16_t min = lv_bar_get_min_value(gauge);
|
||||
@ -444,9 +444,9 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style
|
||||
|
||||
/*Draw the needle middle area*/
|
||||
lv_style_t style_neddle_mid;
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_neddle_mid);
|
||||
style_neddle_mid.body.color_main = style->border.color;
|
||||
style_neddle_mid.body.color_gradient = style->border.color;
|
||||
lv_style_copy(&style_neddle_mid, lv_style_get(LV_STYLE_PLAIN));
|
||||
style_neddle_mid.body.color_main = style->body.border.color;
|
||||
style_neddle_mid.body.color_gradient = style->body.border.color;
|
||||
style_neddle_mid.body.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
area_t nm_cord;
|
||||
|
@ -61,7 +61,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_img);
|
||||
|
||||
/*Extend the basic object to image object*/
|
||||
lv_img_ext_t * ext = lv_obj_alloc_ext(new_img, sizeof(lv_img_ext_t));
|
||||
lv_img_ext_t * ext = lv_obj_allocate_ext_attr(new_img, sizeof(lv_img_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->fn = NULL;
|
||||
ext->w = lv_obj_get_width(new_img);
|
||||
@ -71,8 +71,8 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->auto_size = 1;
|
||||
|
||||
/*Init the new object*/
|
||||
lv_obj_set_signal_f(new_img, lv_img_signal);
|
||||
lv_obj_set_design_f(new_img, lv_img_design);
|
||||
lv_obj_set_signal_func(new_img, lv_img_signal);
|
||||
lv_obj_set_design_func(new_img, lv_img_design);
|
||||
|
||||
if(copy == NULL) {
|
||||
/* Enable auto size for non screens
|
||||
@ -80,16 +80,16 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
* and must be screen sized*/
|
||||
if(par != NULL) ext->auto_size = 1;
|
||||
else ext->auto_size = 0;
|
||||
if(par != NULL) lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
|
||||
else lv_obj_set_style(new_img, lv_style_get(LV_STYLE_PLAIN, NULL)); /*Set style for screens*/
|
||||
if(par != NULL) lv_obj_set_style(new_img, NULL); /*Inherit the style by default*/
|
||||
else lv_obj_set_style(new_img, lv_style_get(LV_STYLE_PLAIN)); /*Set style for screens*/
|
||||
} else {
|
||||
lv_img_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->auto_size = copy_ext->auto_size;
|
||||
ext->upscale = copy_ext->upscale;
|
||||
lv_img_set_file(new_img, copy_ext->fn);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_img);
|
||||
lv_obj_refresh_style(new_img);
|
||||
}
|
||||
|
||||
return new_img;
|
||||
@ -111,7 +111,7 @@ bool lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
dm_free(ext->fn);
|
||||
}
|
||||
@ -156,7 +156,7 @@ fs_res_t lv_img_create_file(const char * fn, const color_int_t * data)
|
||||
*/
|
||||
void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
/*Handle normal images*/
|
||||
if(lv_img_is_symbol(fn) == false) {
|
||||
@ -220,7 +220,7 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
lv_obj_set_size(img, ext->w, ext->h);
|
||||
}
|
||||
|
||||
lv_obj_inv(img);
|
||||
lv_obj_invalidate(img);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,7 +231,7 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
*/
|
||||
void lv_img_set_auto_size(lv_obj_t * img, bool en)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
ext->auto_size = (en == false ? 0 : 1);
|
||||
}
|
||||
@ -245,7 +245,7 @@ void lv_img_set_auto_size(lv_obj_t * img, bool en)
|
||||
*/
|
||||
void lv_img_set_upscale(lv_obj_t * img, bool en)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
/*Upscale works only if antialiassing is enabled*/
|
||||
#if LV_ANTIALIAS == 0
|
||||
@ -268,7 +268,7 @@ void lv_img_set_upscale(lv_obj_t * img, bool en)
|
||||
*/
|
||||
bool lv_img_get_auto_size(lv_obj_t * img)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
return ext->auto_size == 0 ? false : true;
|
||||
}
|
||||
@ -280,7 +280,7 @@ bool lv_img_get_auto_size(lv_obj_t * img)
|
||||
*/
|
||||
bool lv_img_get_upscale(lv_obj_t * img)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
return ext->upscale == 0 ? false : true;
|
||||
}
|
||||
@ -301,11 +301,11 @@ bool lv_img_get_upscale(lv_obj_t * img)
|
||||
static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
lv_style_t * style = lv_obj_get_style(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext(img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
bool cover = false;
|
||||
if(ext->transp == 0) cover = area_is_in(mask, &img->cords);
|
||||
if(ext->transp == 0) cover = area_is_in(mask, &img->coords);
|
||||
return cover;
|
||||
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
@ -316,7 +316,7 @@ static bool lv_img_design(lv_obj_t * img, const area_t * mask, lv_design_mode_t
|
||||
bool sym = lv_img_is_symbol(ext->fn);
|
||||
#endif
|
||||
|
||||
lv_obj_get_cords(img, &cords);
|
||||
lv_obj_get_coords(img, &cords);
|
||||
|
||||
area_t cords_tmp;
|
||||
cords_tmp.y1 = cords.y1;
|
||||
|
@ -84,7 +84,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_kb);
|
||||
|
||||
/*Allocate the keyboard type specific extended data*/
|
||||
lv_kb_ext_t * ext = lv_obj_alloc_ext(new_kb, sizeof(lv_kb_ext_t));
|
||||
lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
@ -96,7 +96,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->ok_action = NULL;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_kb, lv_kb_signal);
|
||||
lv_obj_set_signal_func(new_kb, lv_kb_signal);
|
||||
|
||||
/*Init the new keyboard keyboard*/
|
||||
if(copy == NULL) {
|
||||
@ -107,7 +107,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing keyboard*/
|
||||
else {
|
||||
lv_kb_ext_t * copy_ext = lv_obj_get_ext(copy);ext->ta = NULL;
|
||||
lv_kb_ext_t * copy_ext = lv_obj_get_ext_attr(copy);ext->ta = NULL;
|
||||
ext->ta = copy_ext->ta;
|
||||
ext->mode = copy_ext->mode;
|
||||
ext->cur_mng = copy_ext->cur_mng;
|
||||
@ -115,7 +115,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->ok_action = copy_ext->ok_action;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_kb);
|
||||
lv_obj_refresh_style(new_kb);
|
||||
}
|
||||
|
||||
return new_kb;
|
||||
@ -157,7 +157,7 @@ bool lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
|
||||
if(ext->ta != NULL && ext->cur_mng != 0) lv_ta_set_cursor_show(ext->ta, false);
|
||||
ext->ta = ta;
|
||||
@ -171,7 +171,7 @@ void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta)
|
||||
*/
|
||||
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
ext->mode = mode;
|
||||
if(mode == LV_KB_MODE_TXT) lv_btnm_set_map(kb, kb_map_lc);
|
||||
else if(mode == LV_KB_MODE_NUM) lv_btnm_set_map(kb, kb_map_num);
|
||||
@ -185,7 +185,7 @@ void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode)
|
||||
*/
|
||||
void lv_kb_set_cur_mng(lv_obj_t * kb, bool en)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
ext->cur_mng = en == false? 0 : 1;
|
||||
|
||||
if(ext->ta != NULL) lv_ta_set_cursor_show(ext->ta, true);
|
||||
@ -198,7 +198,7 @@ void lv_kb_set_cur_mng(lv_obj_t * kb, bool en)
|
||||
*/
|
||||
void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
ext->ok_action = action;
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action)
|
||||
*/
|
||||
void lv_kb_set_close_action(lv_obj_t * kb, lv_action_t action)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
ext->close_action = action;
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ void lv_kb_set_close_action(lv_obj_t * kb, lv_action_t action)
|
||||
*/
|
||||
lv_obj_t * lv_kb_get_ta(lv_obj_t * kb)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
return ext->ta;
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ lv_obj_t * lv_kb_get_ta(lv_obj_t * kb)
|
||||
*/
|
||||
lv_kb_mode_t lv_kb_get_mode(lv_obj_t * kb)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
return ext->mode;
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ lv_kb_mode_t lv_kb_get_mode(lv_obj_t * kb)
|
||||
*/
|
||||
bool lv_kb_get_cur_mng(lv_obj_t * kb, bool en)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
return ext->cur_mng == 0 ? false : true;
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ bool lv_kb_get_cur_mng(lv_obj_t * kb, bool en)
|
||||
*/
|
||||
lv_action_t lv_kb_get_ok_action(lv_obj_t * kb, lv_action_t action)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
return ext->ok_action;
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ lv_action_t lv_kb_get_ok_action(lv_obj_t * kb, lv_action_t action)
|
||||
*/
|
||||
lv_action_t lv_kb_get_close_action(lv_obj_t * kb, lv_action_t action)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
return ext->close_action;
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ static bool lv_kb_design(lv_obj_t * kb, const area_t * mask, lv_design_mode_t mo
|
||||
*/
|
||||
static lv_action_res_t lv_app_kb_action(lv_obj_t * kb, uint16_t i)
|
||||
{
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext(kb);
|
||||
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
|
||||
if(ext->ta == NULL) return LV_ACTION_RES_OK;
|
||||
|
||||
const char ** map = lv_btnm_get_map(kb);
|
||||
|
@ -24,11 +24,11 @@
|
||||
*********************/
|
||||
/*Test configurations*/
|
||||
#ifndef LV_LABEL_SCROLL_SPEED
|
||||
#define LV_LABEL_SCROLL_SPEED (25 * LV_DOWNSCALE) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL' mode*/
|
||||
#define LV_LABEL_SCROLL_SPEED (25 << LV_ANTIALIAS) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL' mode*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_LABEL_SCROLL_SPEED_VER
|
||||
#define LV_LABEL_SCROLL_SPEED_VER (10 * LV_DOWNSCALE) /*Ver. scroll speed if hor. scroll is applied too*/
|
||||
#define LV_LABEL_SCROLL_SPEED_VER (10 << LV_ANTIALIAS) /*Ver. scroll speed if hor. scroll is applied too*/
|
||||
#endif
|
||||
|
||||
#ifndef LV_LABEL_SCROLL_PLAYBACK_PAUSE
|
||||
@ -78,9 +78,9 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_label);
|
||||
|
||||
/*Extend the basic object to a label object*/
|
||||
lv_obj_alloc_ext(new_label, sizeof(lv_label_ext_t));
|
||||
lv_obj_allocate_ext_attr(new_label, sizeof(lv_label_ext_t));
|
||||
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(new_label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(new_label);
|
||||
dm_assert(ext);
|
||||
ext->txt = NULL;
|
||||
ext->static_txt = 0;
|
||||
@ -90,8 +90,8 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->long_mode = LV_LABEL_LONG_EXPAND;
|
||||
ext->offset.x = 0;
|
||||
ext->offset.y = 0;
|
||||
lv_obj_set_design_f(new_label, lv_label_design);
|
||||
lv_obj_set_signal_f(new_label, lv_label_signal);
|
||||
lv_obj_set_design_func(new_label, lv_label_design);
|
||||
lv_obj_set_signal_func(new_label, lv_label_signal);
|
||||
|
||||
/*Init the new label*/
|
||||
if(copy == NULL) {
|
||||
@ -102,14 +102,14 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy 'copy' if not NULL*/
|
||||
else {
|
||||
lv_label_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_label_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
lv_label_set_long_mode(new_label, lv_label_get_long_mode(copy));
|
||||
lv_label_set_recolor(new_label, lv_label_get_recolor(copy));
|
||||
if(copy_ext->static_txt == 0) lv_label_set_text(new_label, lv_label_get_text(copy));
|
||||
else lv_label_set_text_static(new_label, lv_label_get_text(copy));
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_label);
|
||||
lv_obj_refresh_style(new_label);
|
||||
}
|
||||
return new_label;
|
||||
}
|
||||
@ -131,7 +131,7 @@ bool lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
if(ext->static_txt == 0) {
|
||||
dm_free(ext->txt);
|
||||
@ -142,8 +142,8 @@ bool lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param)
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
else if (sign == LV_SIGNAL_CORD_CHG) {
|
||||
if(area_get_width(&label->cords) != area_get_width(param)
|
||||
|| area_get_height(&label->cords) != area_get_height(param))
|
||||
if(area_get_width(&label->coords) != area_get_width(param)
|
||||
|| area_get_height(&label->coords) != area_get_height(param))
|
||||
{
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
@ -165,9 +165,9 @@ bool lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_label_set_text(lv_obj_t * label, const char * text)
|
||||
{
|
||||
lv_obj_inv(label);
|
||||
lv_obj_invalidate(label);
|
||||
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
|
||||
/*If text is NULL then refresh */
|
||||
if(text == NULL) {
|
||||
@ -202,9 +202,9 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
|
||||
*/
|
||||
void lv_label_set_text_array(lv_obj_t * label, const char * array, uint16_t size)
|
||||
{
|
||||
lv_obj_inv(label);
|
||||
lv_obj_invalidate(label);
|
||||
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
|
||||
/*If trying to set its own text or the array is NULL then refresh */
|
||||
if(array == ext->txt || array == NULL) {
|
||||
@ -233,7 +233,7 @@ void lv_label_set_text_array(lv_obj_t * label, const char * array, uint16_t size
|
||||
*/
|
||||
void lv_label_set_text_static(lv_obj_t * label, const char * text)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
if(ext->static_txt == 0 && ext->txt != NULL) {
|
||||
dm_free(ext->txt);
|
||||
ext->txt = NULL;
|
||||
@ -257,12 +257,12 @@ void lv_label_set_text_static(lv_obj_t * label, const char * text)
|
||||
*/
|
||||
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
|
||||
/*Can not append to static text*/
|
||||
if(ext->static_txt != 0) return;
|
||||
|
||||
lv_obj_inv(label);
|
||||
lv_obj_invalidate(label);
|
||||
|
||||
/*Allocate space for the new text*/
|
||||
uint32_t old_len = strlen(ext->txt);
|
||||
@ -290,7 +290,7 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
||||
*/
|
||||
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
|
||||
/*Delete the old animation (if exists)*/
|
||||
anim_del(label, (anim_fp_t) lv_obj_set_x);
|
||||
@ -314,7 +314,7 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
|
||||
*/
|
||||
void lv_label_set_recolor(lv_obj_t * label, bool recolor)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
|
||||
ext->recolor = recolor == false ? 0 : 1;
|
||||
|
||||
@ -328,7 +328,7 @@ void lv_label_set_recolor(lv_obj_t * label, bool recolor)
|
||||
*/
|
||||
void lv_label_set_no_break(lv_obj_t * label, bool en)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
ext->no_break = en == false ? 0 : 1;
|
||||
|
||||
lv_label_refr_text(label);
|
||||
@ -345,7 +345,7 @@ void lv_label_set_no_break(lv_obj_t * label, bool en)
|
||||
*/
|
||||
char * lv_label_get_text(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
|
||||
return ext->txt;
|
||||
}
|
||||
@ -357,7 +357,7 @@ char * lv_label_get_text(lv_obj_t * label)
|
||||
*/
|
||||
lv_label_long_mode_t lv_label_get_long_mode(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
return ext->long_mode;
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ lv_label_long_mode_t lv_label_get_long_mode(lv_obj_t * label)
|
||||
*/
|
||||
bool lv_label_get_recolor(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
return ext->recolor == 0 ? false : true;
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ bool lv_label_get_recolor(lv_obj_t * label)
|
||||
void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
|
||||
{
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
cord_t max_w = lv_obj_get_width(label);
|
||||
@ -456,7 +456,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
|
||||
uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
|
||||
{
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
cord_t max_w = lv_obj_get_width(label);
|
||||
@ -533,7 +533,7 @@ static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mod
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
area_t cords;
|
||||
lv_style_t * style = lv_obj_get_style(label);
|
||||
lv_obj_get_cords(label, &cords);
|
||||
lv_obj_get_coords(label, &cords);
|
||||
|
||||
#if LV_OBJ_GROUP != 0
|
||||
lv_group_t * g = lv_obj_get_group(label);
|
||||
@ -550,7 +550,7 @@ static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mod
|
||||
/*TEST: draw a background for the label*/
|
||||
//lv_vfill(&label->cords, mask, COLOR_LIME, OPA_COVER);
|
||||
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
txt_flag_t flag = TXT_FLAG_NONE;
|
||||
if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR;
|
||||
if(ext->expand != 0) flag |= TXT_FLAG_EXPAND;
|
||||
@ -567,7 +567,7 @@ static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mod
|
||||
*/
|
||||
static void lv_label_refr_text(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
|
||||
if(ext->txt == NULL) return;
|
||||
|
||||
@ -683,21 +683,21 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
}
|
||||
|
||||
|
||||
lv_obj_inv(label);
|
||||
lv_obj_invalidate(label);
|
||||
}
|
||||
|
||||
|
||||
static void lv_label_set_offset_x(lv_obj_t * label, cord_t x)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
ext->offset.x = x;
|
||||
lv_obj_inv(label);
|
||||
lv_obj_invalidate(label);
|
||||
}
|
||||
|
||||
static void lv_label_set_offset_y(lv_obj_t * label, cord_t y)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext(label);
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
ext->offset.y = y;
|
||||
lv_obj_inv(label);
|
||||
lv_obj_invalidate(label);
|
||||
}
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@ static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -59,27 +59,27 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_led);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_led_ext_t * ext = lv_obj_alloc_ext(new_led, sizeof(lv_led_ext_t));
|
||||
lv_led_ext_t * ext = lv_obj_allocate_ext_attr(new_led, sizeof(lv_led_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->bright = LV_LED_BRIGHT_ON;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_led);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_led);
|
||||
|
||||
lv_obj_set_signal_f(new_led, lv_led_signal);
|
||||
lv_obj_set_design_f(new_led, lv_led_design);
|
||||
lv_obj_set_signal_func(new_led, lv_led_signal);
|
||||
lv_obj_set_design_func(new_led, lv_led_design);
|
||||
|
||||
/*Init the new led object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_led, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL));
|
||||
lv_obj_set_style(new_led, lv_style_get(LV_STYLE_PRETTY_COLOR));
|
||||
lv_obj_set_size(new_led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_led_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_led_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->bright = copy_ext->bright;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_led);
|
||||
lv_obj_refresh_style(new_led);
|
||||
}
|
||||
|
||||
return new_led;
|
||||
@ -120,11 +120,11 @@ bool lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param)
|
||||
void lv_led_set_bright(lv_obj_t * led, uint8_t bright)
|
||||
{
|
||||
/*Set the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext(led);
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
ext->bright = bright;
|
||||
|
||||
/*Invalidate the object there fore it will be redrawn*/
|
||||
lv_obj_inv(led);
|
||||
lv_obj_invalidate(led);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +168,7 @@ void lv_led_tgl(lv_obj_t * led)
|
||||
*/
|
||||
uint8_t lv_led_get_bright(lv_obj_t * led)
|
||||
{
|
||||
lv_led_ext_t * ext = lv_obj_get_ext(led);
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
return ext->bright;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t
|
||||
return ancestor_design_f(led, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/*Make darker colors in a temporary style according to the brightness*/
|
||||
lv_led_ext_t * ext = lv_obj_get_ext(led);
|
||||
lv_led_ext_t * ext = lv_obj_get_ext_attr(led);
|
||||
lv_style_t * style = lv_obj_get_style(led);
|
||||
|
||||
/*Create a temporal style*/
|
||||
@ -203,11 +203,11 @@ static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t
|
||||
/*Mix. the color with black proportionally with brightness*/
|
||||
leds_tmp.body.color_main = color_mix(leds_tmp.body.color_main, COLOR_BLACK, ext->bright);
|
||||
leds_tmp.body.color_gradient = color_mix(leds_tmp.body.color_gradient, COLOR_BLACK, ext->bright);
|
||||
leds_tmp.border.color = color_mix(leds_tmp.border.color, COLOR_BLACK, ext->bright);
|
||||
leds_tmp.body.border.color = color_mix(leds_tmp.body.border.color, COLOR_BLACK, ext->bright);
|
||||
|
||||
/*Set the current swidth according to brightness proportionally between LV_LED_BRIGHT_OFF and LV_LED_BRIGHT_ON*/
|
||||
uint16_t bright_tmp = ext->bright;
|
||||
leds_tmp.shadow.width = ((bright_tmp - LV_LED_BRIGHT_OFF) * style->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);
|
||||
|
@ -54,7 +54,7 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_line);
|
||||
|
||||
/*Extend the basic object to line object*/
|
||||
lv_line_ext_t * ext = lv_obj_alloc_ext(new_line, sizeof(lv_line_ext_t));
|
||||
lv_line_ext_t * ext = lv_obj_allocate_ext_attr(new_line, sizeof(lv_line_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->point_num = 0;
|
||||
ext->point_array = NULL;
|
||||
@ -62,23 +62,23 @@ lv_obj_t * lv_line_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->y_inv = 0;
|
||||
ext->upscale = 0;
|
||||
|
||||
lv_obj_set_design_f(new_line, lv_line_design);
|
||||
lv_obj_set_signal_f(new_line, lv_line_signal);
|
||||
lv_obj_set_design_func(new_line, lv_line_design);
|
||||
lv_obj_set_signal_func(new_line, lv_line_signal);
|
||||
|
||||
/*Init the new line*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_style(new_line, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_obj_set_style(new_line, lv_style_get(LV_STYLE_PLAIN));
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_line_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_line_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
lv_line_set_auto_size(new_line,lv_line_get_auto_size(copy));
|
||||
lv_line_set_y_inv(new_line,lv_line_get_y_inv(copy));
|
||||
lv_line_set_auto_size(new_line,lv_line_get_auto_size(copy));
|
||||
lv_line_set_upscale(new_line,lv_line_get_upscale(copy));
|
||||
lv_line_set_points(new_line, copy_ext->point_array, copy_ext->point_num);
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_line);
|
||||
lv_obj_refresh_style(new_line);
|
||||
}
|
||||
|
||||
return new_line;
|
||||
@ -122,13 +122,13 @@ bool lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_line_set_points(lv_obj_t * line, const point_t * point_a, uint16_t point_num)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
ext->point_array = point_a;
|
||||
ext->point_num = point_num;
|
||||
|
||||
uint8_t us = 1;
|
||||
if(ext->upscale != 0) {
|
||||
us = LV_DOWNSCALE;
|
||||
us = 1 << LV_ANTIALIAS;
|
||||
}
|
||||
|
||||
if(point_num > 0 && ext->auto_size != 0) {
|
||||
@ -153,7 +153,7 @@ void lv_line_set_points(lv_obj_t * line, const point_t * point_a, uint16_t point
|
||||
*/
|
||||
void lv_line_set_auto_size(lv_obj_t * line, bool autosize)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
ext->auto_size = autosize == false ? 0 : 1;
|
||||
|
||||
@ -172,11 +172,11 @@ void lv_line_set_auto_size(lv_obj_t * line, bool autosize)
|
||||
*/
|
||||
void lv_line_set_y_inv(lv_obj_t * line, bool yinv)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
ext->y_inv = yinv == false ? 0 : 1;
|
||||
|
||||
lv_obj_inv(line);
|
||||
lv_obj_invalidate(line);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,7 +186,7 @@ void lv_line_set_y_inv(lv_obj_t * line, bool yinv)
|
||||
*/
|
||||
void lv_line_set_upscale(lv_obj_t * line, bool unscale)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
ext->upscale = unscale == false ? 0 : 1;
|
||||
|
||||
@ -205,7 +205,7 @@ void lv_line_set_upscale(lv_obj_t * line, bool unscale)
|
||||
*/
|
||||
bool lv_line_get_auto_size(lv_obj_t * line)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
return ext->auto_size == 0 ? false : true;
|
||||
}
|
||||
@ -217,7 +217,7 @@ bool lv_line_get_auto_size(lv_obj_t * line)
|
||||
*/
|
||||
bool lv_line_get_y_inv(lv_obj_t * line)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
return ext->y_inv == 0 ? false : true;
|
||||
}
|
||||
@ -229,7 +229,7 @@ bool lv_line_get_y_inv(lv_obj_t * line)
|
||||
*/
|
||||
bool lv_line_get_upscale(lv_obj_t * line)
|
||||
{
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
return ext->upscale == 0 ? false : true;
|
||||
}
|
||||
@ -253,13 +253,13 @@ static bool lv_line_design(lv_obj_t * line, const area_t * mask, lv_design_mode_
|
||||
/*A line never covers an area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) return false;
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_line_ext_t * ext = lv_obj_get_ext(line);
|
||||
lv_line_ext_t * ext = lv_obj_get_ext_attr(line);
|
||||
|
||||
if(ext->point_num == 0 || ext->point_array == NULL) return false;
|
||||
|
||||
lv_style_t * style = lv_obj_get_style(line);
|
||||
area_t area;
|
||||
lv_obj_get_cords(line, &area);
|
||||
lv_obj_get_coords(line, &area);
|
||||
cord_t x_ofs = area.x1;
|
||||
cord_t y_ofs = area.y1;
|
||||
point_t p1;
|
||||
@ -268,7 +268,7 @@ static bool lv_line_design(lv_obj_t * line, const area_t * mask, lv_design_mode_
|
||||
uint16_t i;
|
||||
uint8_t us = 1;
|
||||
if(ext->upscale != 0) {
|
||||
us = LV_DOWNSCALE;
|
||||
us = 1 << LV_ANTIALIAS;
|
||||
}
|
||||
|
||||
/*Read all pints and draw the lines*/
|
||||
|
@ -63,40 +63,40 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_list = lv_page_create(par, copy);
|
||||
dm_assert(new_list);
|
||||
lv_list_ext_t * ext = lv_obj_alloc_ext(new_list, sizeof(lv_list_ext_t));
|
||||
lv_list_ext_t * ext = lv_obj_allocate_ext_attr(new_list, sizeof(lv_list_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
ext->sb_out = 0;
|
||||
ext->style_img = NULL;
|
||||
ext->styles_btn[LV_BTN_STATE_REL] = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_TREL] = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_INA] = lv_style_get(LV_STYLE_BUTTON_INACTIVE, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_OFF_RELEASED] = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED);
|
||||
ext->styles_btn[LV_BTN_STATE_OFF_PRESSED] = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED);
|
||||
ext->styles_btn[LV_BTN_STATE_ON_RELEASED] = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED);
|
||||
ext->styles_btn[LV_BTN_STATE_OFF_PRESSED] = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED);
|
||||
ext->styles_btn[LV_BTN_STATE_INACTIVE] = lv_style_get(LV_STYLE_BUTTON_INACTIVE);
|
||||
|
||||
lv_obj_set_signal_f(new_list, lv_list_signal);
|
||||
lv_obj_set_signal_func(new_list, lv_list_signal);
|
||||
|
||||
/*Init the new list object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
|
||||
lv_cont_set_layout(ext->page.scrl, LV_LIST_LAYOUT_DEF);
|
||||
lv_obj_set_style(new_list, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT, NULL));
|
||||
lv_obj_set_style(lv_page_get_scrl(new_list), lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_list, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT));
|
||||
lv_obj_set_style(lv_page_get_scrl(new_list), lv_style_get(LV_STYLE_PRETTY));
|
||||
lv_page_set_sb_mode(new_list, LV_PAGE_SB_MODE_AUTO);
|
||||
} else {
|
||||
lv_list_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_list_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
|
||||
lv_list_set_styles_btn(new_list, copy_ext->styles_btn[LV_BTN_STATE_REL],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_PR],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_TREL],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_TPR],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_INA]);
|
||||
lv_list_set_styles_btn(new_list, copy_ext->styles_btn[LV_BTN_STATE_OFF_RELEASED],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_OFF_PRESSED],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_ON_RELEASED],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_ON_PRESSED],
|
||||
copy_ext->styles_btn[LV_BTN_STATE_INACTIVE]);
|
||||
lv_list_set_style_img(new_list, copy_ext->style_img);
|
||||
|
||||
lv_list_set_sb_out(new_list, copy_ext->sb_out);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_list);
|
||||
lv_obj_refresh_style(new_list);
|
||||
}
|
||||
|
||||
return new_list;
|
||||
@ -128,19 +128,19 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
}
|
||||
if(btn_prev != NULL) {
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_OFF_PRESSED);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
/*Get the 'pressed' button*/
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_OFF_PRESSED) break;
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
}
|
||||
|
||||
if(btn != NULL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char*)param);
|
||||
@ -150,14 +150,14 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_obj_t * btn_prev = NULL;
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_OFF_PRESSED) break;
|
||||
btn_prev = btn;
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
}
|
||||
|
||||
if(btn_prev != NULL && btn != NULL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_OFF_PRESSED);
|
||||
lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME);
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
|
||||
@ -165,15 +165,15 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_OFF_PRESSED) break;
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
}
|
||||
|
||||
if(btn != NULL) {
|
||||
lv_obj_t * btn_prev = lv_list_get_next_btn(list, btn);
|
||||
if(btn_prev != NULL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_OFF_PRESSED);
|
||||
lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME);
|
||||
}
|
||||
}
|
||||
@ -182,13 +182,13 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_OFF_PRESSED) break;
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
}
|
||||
|
||||
if(btn != NULL) {
|
||||
lv_action_t rel_action;
|
||||
rel_action = lv_btn_get_rel_action(btn);
|
||||
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_RELEASE);
|
||||
if(rel_action != NULL) rel_action(btn);
|
||||
}
|
||||
}
|
||||
@ -208,16 +208,14 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action)
|
||||
{
|
||||
lv_style_t * style = lv_obj_get_style(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
/*Create a list element with the image an the text*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_btn_create(list, NULL);
|
||||
lv_btn_set_styles(liste, ext->styles_btn[LV_BTN_STATE_REL], ext->styles_btn[LV_BTN_STATE_PR],
|
||||
ext->styles_btn[LV_BTN_STATE_TREL], ext->styles_btn[LV_BTN_STATE_TPR],
|
||||
ext->styles_btn[LV_BTN_STATE_INA]);
|
||||
lv_btn_set_style_all(liste, ext->styles_btn);
|
||||
|
||||
lv_btn_set_rel_action(liste, rel_action);
|
||||
lv_btn_set_action(liste, LV_BTN_ACTION_RELEASE, rel_action);
|
||||
lv_page_glue_obj(liste, true);
|
||||
lv_cont_set_layout(liste, LV_CONT_LAYOUT_ROW_M);
|
||||
lv_cont_set_fit(liste, false, true);
|
||||
@ -245,7 +243,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l
|
||||
lv_obj_t * label = lv_label_create(liste, NULL);
|
||||
lv_label_set_text(label, txt);
|
||||
lv_obj_set_click(label, false);
|
||||
lv_obj_set_width(label, liste->cords.x2 - label->cords.x1);
|
||||
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_ROLL);
|
||||
}
|
||||
|
||||
@ -265,7 +263,7 @@ void lv_list_up(lv_obj_t * list)
|
||||
lv_obj_t * e_prev = NULL;
|
||||
e = lv_list_get_next_btn(list, NULL);
|
||||
while(e != NULL) {
|
||||
if(e->cords.y2 <= list->cords.y2) {
|
||||
if(e->coords.y2 <= list->coords.y2) {
|
||||
if(e_prev != NULL) {
|
||||
cord_t new_y = lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev));
|
||||
#if LV_LIST_FOCUS_TIME == 0
|
||||
@ -306,7 +304,7 @@ void lv_list_down(lv_obj_t * list)
|
||||
lv_obj_t * e;
|
||||
e = lv_list_get_next_btn(list, NULL);
|
||||
while(e != NULL) {
|
||||
if(e->cords.y1 < list->cords.y1) {
|
||||
if(e->coords.y1 < list->coords.y1) {
|
||||
cord_t new_y = -lv_obj_get_y(e);
|
||||
#if LV_LIST_FOCUS_TIME == 0
|
||||
lv_obj_set_y(scrl, new_y);
|
||||
@ -344,7 +342,7 @@ void lv_list_down(lv_obj_t * list)
|
||||
*/
|
||||
void lv_list_set_sb_out(lv_obj_t * list, bool out)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
ext->sb_out = out == false ? 0 : 1;
|
||||
}
|
||||
@ -363,18 +361,22 @@ void lv_list_set_styles_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
|
||||
lv_style_t * trel, lv_style_t * tpr,
|
||||
lv_style_t * ina)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
ext->styles_btn[LV_BTN_STATE_REL] = rel;
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = pr;
|
||||
ext->styles_btn[LV_BTN_STATE_TREL] = trel;
|
||||
ext->styles_btn[LV_BTN_STATE_TPR] = tpr;
|
||||
ext->styles_btn[LV_BTN_STATE_INA] = ina;
|
||||
ext->styles_btn[LV_BTN_STATE_OFF_RELEASED] = rel;
|
||||
ext->styles_btn[LV_BTN_STATE_OFF_PRESSED] = pr;
|
||||
ext->styles_btn[LV_BTN_STATE_ON_RELEASED] = trel;
|
||||
ext->styles_btn[LV_BTN_STATE_ON_PRESSED] = tpr;
|
||||
ext->styles_btn[LV_BTN_STATE_INACTIVE] = ina;
|
||||
|
||||
lv_obj_t * liste = lv_list_get_next_btn(list, NULL);
|
||||
while(liste != NULL)
|
||||
{
|
||||
lv_btn_set_styles(liste, rel, pr, trel, tpr, ina);
|
||||
lv_btn_set_style(liste, LV_BTN_STATE_OFF_RELEASED, rel);
|
||||
lv_btn_set_style(liste, LV_BTN_STATE_OFF_PRESSED, pr);
|
||||
lv_btn_set_style(liste, LV_BTN_STATE_ON_RELEASED, trel);
|
||||
lv_btn_set_style(liste, LV_BTN_STATE_ON_PRESSED, tpr);
|
||||
lv_btn_set_style(liste, LV_BTN_STATE_INACTIVE, ina);
|
||||
liste = lv_list_get_next_btn(list, liste);
|
||||
}
|
||||
}
|
||||
@ -387,7 +389,7 @@ void lv_list_set_styles_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
|
||||
*/
|
||||
void lv_list_set_style_img(lv_obj_t * list, lv_style_t * style)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
ext->style_img = style;
|
||||
|
||||
@ -428,7 +430,7 @@ lv_obj_t * lv_list_get_element_label(lv_obj_t * liste)
|
||||
lv_obj_t * label = lv_obj_get_child(liste, NULL);
|
||||
if(label == NULL) return NULL;
|
||||
|
||||
while(label->signal_f != lv_label_signal) {
|
||||
while(label->signal_func != lv_label_signal) {
|
||||
label = lv_obj_get_child(liste, NULL);
|
||||
if(label == NULL) break;
|
||||
}
|
||||
@ -447,7 +449,7 @@ lv_obj_t * lv_list_get_element_img(lv_obj_t * liste)
|
||||
lv_obj_t * img = lv_obj_get_child(liste, NULL);
|
||||
if(img == NULL) return NULL;
|
||||
|
||||
while(img->signal_f != lv_img_signal) {
|
||||
while(img->signal_func != lv_img_signal) {
|
||||
img = lv_obj_get_child(liste, NULL);
|
||||
if(img == NULL) break;
|
||||
}
|
||||
@ -465,7 +467,7 @@ lv_obj_t * lv_list_get_element_img(lv_obj_t * liste)
|
||||
*/
|
||||
bool lv_list_get_sb_out(lv_obj_t * list, bool en)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
return ext->sb_out == 0 ? false : true;
|
||||
}
|
||||
|
||||
@ -477,7 +479,7 @@ bool lv_list_get_sb_out(lv_obj_t * list, bool en)
|
||||
*/
|
||||
lv_style_t * lv_list_get_style_liste(lv_obj_t * list, lv_btn_state_t state)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
if(ext->styles_btn[state] == NULL) return lv_obj_get_style(list);
|
||||
|
||||
@ -492,9 +494,9 @@ lv_style_t * lv_list_get_style_liste(lv_obj_t * list, lv_btn_state_t state)
|
||||
*/
|
||||
lv_style_t * lv_list_get_style_img(lv_obj_t * list, lv_btn_state_t state)
|
||||
{
|
||||
lv_list_ext_t * ext = lv_obj_get_ext(list);
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
if(ext->style_img == NULL) return lv_list_get_style_liste(list, LV_BTN_STATE_REL);
|
||||
if(ext->style_img == NULL) return lv_list_get_style_liste(list, LV_BTN_STATE_OFF_RELEASED);
|
||||
|
||||
return ext->style_img;
|
||||
}
|
||||
@ -544,7 +546,7 @@ static lv_obj_t * lv_list_get_next_btn(lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
btn = lv_obj_get_child(scrl, prev_btn);
|
||||
if(btn == NULL) return NULL;
|
||||
|
||||
while(btn->signal_f != lv_btn_signal) {
|
||||
while(btn->signal_func != lv_btn_signal) {
|
||||
btn = lv_obj_get_child(scrl, prev_btn);
|
||||
if(btn == NULL) break;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ extern "C" {
|
||||
#error "lv_list: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_BTN == 0
|
||||
#if USE_LV_BUTTON == 0
|
||||
#error "lv_list: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
||||
#endif
|
||||
|
||||
|
@ -55,7 +55,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_lmeter);
|
||||
|
||||
/*Allocate the line meter type specific extended data*/
|
||||
lv_lmeter_ext_t * ext = lv_obj_alloc_ext(new_lmeter, sizeof(lv_lmeter_ext_t));
|
||||
lv_lmeter_ext_t * ext = lv_obj_allocate_ext_attr(new_lmeter, sizeof(lv_lmeter_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
@ -63,23 +63,23 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->scale_angle = 240; /*(scale_num - 1) * N looks better */
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_lmeter, lv_lmeter_signal);
|
||||
lv_obj_set_design_f(new_lmeter, lv_lmeter_design);
|
||||
lv_obj_set_signal_func(new_lmeter, lv_lmeter_signal);
|
||||
lv_obj_set_design_func(new_lmeter, lv_lmeter_design);
|
||||
|
||||
/*Init the new line meter line meter*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_lmeter, 1 * LV_DPI, 1 * LV_DPI);
|
||||
lv_obj_set_style(new_lmeter, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL));
|
||||
lv_obj_set_style(new_lmeter, lv_style_get(LV_STYLE_PRETTY_COLOR));
|
||||
}
|
||||
/*Copy an existing line meter*/
|
||||
else {
|
||||
lv_lmeter_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_lmeter_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->scale_angle = copy_ext->scale_angle;
|
||||
ext->scale_num = copy_ext->scale_num;
|
||||
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_lmeter);
|
||||
lv_obj_refresh_style(new_lmeter);
|
||||
}
|
||||
|
||||
return new_lmeter;
|
||||
@ -122,11 +122,11 @@ bool lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t num)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
ext->scale_angle = angle;
|
||||
ext->scale_num = num;
|
||||
|
||||
lv_obj_inv(lmeter);
|
||||
lv_obj_invalidate(lmeter);
|
||||
}
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t num)
|
||||
*/
|
||||
uint8_t lv_lmeter_get_scale_num(lv_obj_t * lmeter)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
return ext->scale_num ;
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ uint8_t lv_lmeter_get_scale_num(lv_obj_t * lmeter)
|
||||
*/
|
||||
uint16_t lv_lmeter_get_scale_angle(lv_obj_t * lmeter)
|
||||
{
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
return ext->scale_angle;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext(lmeter);
|
||||
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||
lv_style_t * style = lv_obj_get_style(lmeter);
|
||||
|
||||
lv_style_t style_tmp;
|
||||
@ -187,8 +187,8 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m
|
||||
|
||||
cord_t r_out = lv_obj_get_width(lmeter) / 2;
|
||||
cord_t r_in =r_out - style->body.padding.horizontal;
|
||||
cord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->cords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->cords.y1;
|
||||
cord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1;
|
||||
cord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1;
|
||||
int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2;
|
||||
int16_t min = lv_bar_get_min_value(lmeter);
|
||||
int16_t max = lv_bar_get_max_value(lmeter);
|
||||
|
@ -61,16 +61,16 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_mbox);
|
||||
|
||||
/*Allocate the message box type specific extended data*/
|
||||
lv_mbox_ext_t * ext = lv_obj_alloc_ext(new_mbox, sizeof(lv_mbox_ext_t));
|
||||
lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(new_mbox, sizeof(lv_mbox_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->txt = NULL;
|
||||
ext->btnh = NULL;
|
||||
ext->style_btn_rel = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED, NULL);
|
||||
ext->style_btn_pr = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED, NULL);
|
||||
ext->style_btn_rel = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED);
|
||||
ext->style_btn_pr = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED);
|
||||
ext->anim_close_time = LV_MBOX_CLOSE_ANIM_TIME;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_mbox, lv_mbox_signal);
|
||||
lv_obj_set_signal_func(new_mbox, lv_mbox_signal);
|
||||
|
||||
/*Init the new message box message box*/
|
||||
if(copy == NULL) {
|
||||
@ -80,11 +80,11 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->txt = lv_label_create(new_mbox, NULL);
|
||||
lv_label_set_text(ext->txt, "Text of the message box");
|
||||
|
||||
lv_obj_set_style(new_mbox, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_mbox, lv_style_get(LV_STYLE_PRETTY));
|
||||
}
|
||||
/*Copy an existing message box*/
|
||||
else {
|
||||
lv_mbox_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_mbox_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
|
||||
ext->txt = lv_label_create(new_mbox, copy_ext->txt);
|
||||
|
||||
@ -92,15 +92,13 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
if(copy_ext->btnh != NULL) {
|
||||
lv_obj_t * btn_copy;
|
||||
const char * btn_txt_copy;
|
||||
lv_btn_ext_t * btn_ext_copy;
|
||||
LL_READ_BACK(copy_ext->btnh->child_ll, btn_copy) {
|
||||
btn_txt_copy = lv_label_get_text(lv_obj_get_child(btn_copy, NULL));
|
||||
btn_ext_copy = lv_obj_get_ext(btn_copy);
|
||||
lv_mbox_add_btn(new_mbox, btn_txt_copy, btn_ext_copy->rel_action);
|
||||
lv_mbox_add_btn(new_mbox, btn_txt_copy, lv_btn_get_action(btn_copy, LV_BTN_ACTION_RELEASE));
|
||||
}
|
||||
}
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_mbox);
|
||||
lv_obj_refresh_style(new_mbox);
|
||||
}
|
||||
|
||||
lv_mbox_realign(new_mbox);
|
||||
@ -125,7 +123,7 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/*If the size is changed refresh the message box*/
|
||||
@ -144,8 +142,8 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
btn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(btn != NULL) {
|
||||
/*Refresh the next button's style*/
|
||||
lv_btn_set_styles(btn, ext->style_btn_rel, ext->style_btn_pr, NULL, NULL, NULL);
|
||||
|
||||
lv_btn_set_style(btn, LV_BTN_STATE_OFF_RELEASED, ext->style_btn_rel);
|
||||
lv_btn_set_style(btn, LV_BTN_STATE_OFF_PRESSED, ext->style_btn_pr);
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
}
|
||||
@ -160,7 +158,7 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
if(btn_prev != NULL) {
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_OFF_PRESSED);
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
@ -169,16 +167,16 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_OFF_PRESSED) break;
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
|
||||
if(btn != NULL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
char c = *((char*)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
/*Get the last pressed button*/
|
||||
@ -187,14 +185,14 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
lv_obj_t * btn_prev = NULL;
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_OFF_PRESSED) break;
|
||||
btn_prev = btn;
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
|
||||
if(btn_prev != NULL && btn != NULL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_OFF_PRESSED);
|
||||
}
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
|
||||
@ -203,15 +201,15 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_OFF_PRESSED) break;
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
|
||||
if(btn != NULL) {
|
||||
lv_obj_t * btn_prev = lv_obj_get_child(ext->btnh, btn);
|
||||
if(btn_prev != NULL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_OFF_RELEASED);
|
||||
lv_btn_set_state(btn_prev, LV_BTN_STATE_OFF_PRESSED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,13 +220,13 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_OFF_PRESSED) break;
|
||||
btn = lv_obj_get_child(ext->btnh, btn);
|
||||
}
|
||||
|
||||
if(btn != NULL) {
|
||||
lv_action_t rel_action;
|
||||
rel_action = lv_btn_get_rel_action(btn);
|
||||
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_RELEASE);
|
||||
if(rel_action != NULL) rel_action(btn);
|
||||
}
|
||||
}
|
||||
@ -262,12 +260,12 @@ lv_action_res_t lv_mbox_close_action(lv_obj_t * btn)
|
||||
*/
|
||||
lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t rel_action)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
/*Create a button if it is not existed yet*/
|
||||
if(ext->btnh == NULL) {
|
||||
ext->btnh = lv_cont_create(mbox, NULL);
|
||||
lv_obj_set_style(ext->btnh, lv_style_get(LV_STYLE_TRANSPARENT, NULL));
|
||||
lv_obj_set_style(ext->btnh, lv_style_get(LV_STYLE_TRANSPARENT));
|
||||
lv_obj_set_click(ext->btnh, false);
|
||||
lv_cont_set_fit(ext->btnh, false, true);
|
||||
lv_cont_set_layout(ext->btnh, LV_CONT_LAYOUT_PRETTY);
|
||||
@ -275,8 +273,9 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
|
||||
|
||||
lv_obj_t * btn;
|
||||
btn = lv_btn_create(ext->btnh, NULL);
|
||||
lv_btn_set_rel_action(btn, rel_action);
|
||||
lv_btn_set_styles(btn, ext->style_btn_rel, ext->style_btn_pr, NULL, NULL, NULL);
|
||||
lv_btn_set_action(btn, LV_BTN_ACTION_RELEASE, rel_action);
|
||||
lv_btn_set_style(btn, LV_BTN_STATE_OFF_RELEASED, ext->style_btn_rel);
|
||||
lv_btn_set_style(btn, LV_BTN_STATE_OFF_PRESSED, ext->style_btn_pr);
|
||||
lv_cont_set_fit(btn, true, true);
|
||||
|
||||
lv_obj_t * label;
|
||||
@ -299,7 +298,7 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
|
||||
*/
|
||||
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
lv_label_set_text(ext->txt, txt);
|
||||
lv_mbox_realign(mbox);
|
||||
@ -316,7 +315,7 @@ void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
|
||||
*/
|
||||
void lv_mbox_set_styles_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
ext->style_btn_rel = rel;
|
||||
ext->style_btn_pr = pr;
|
||||
@ -325,7 +324,8 @@ void lv_mbox_set_styles_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr)
|
||||
lv_obj_t * btn = lv_obj_get_child(ext->btnh, NULL);
|
||||
|
||||
while(btn != NULL) {
|
||||
lv_btn_set_styles(btn, rel, pr, NULL, NULL, NULL);
|
||||
lv_btn_set_style(btn, LV_BTN_STATE_OFF_RELEASED, rel);
|
||||
lv_btn_set_style(btn, LV_BTN_STATE_OFF_PRESSED, pr);
|
||||
btn = lv_obj_get_child(mbox, btn);
|
||||
}
|
||||
}
|
||||
@ -338,7 +338,7 @@ void lv_mbox_set_styles_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr)
|
||||
*/
|
||||
void lv_mbox_set_anim_close_time(lv_obj_t * mbox, uint16_t time)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
ext->anim_close_time = time;
|
||||
}
|
||||
|
||||
@ -349,17 +349,17 @@ void lv_mbox_set_anim_close_time(lv_obj_t * mbox, uint16_t time)
|
||||
*/
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
if(ext->anim_close_time != 0) {
|
||||
/*Add shrinking animations*/
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_H| ANIM_OUT, ext->anim_close_time, tout, NULL);
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_V| ANIM_OUT, ext->anim_close_time, tout, lv_obj_del);
|
||||
lv_obj_animate(mbox, LV_ANIM_GROW_H| ANIM_OUT, ext->anim_close_time, tout, NULL);
|
||||
lv_obj_animate(mbox, LV_ANIM_GROW_V| ANIM_OUT, ext->anim_close_time, tout, lv_obj_del);
|
||||
|
||||
/*When the animations start disable fit to let shrinking work*/
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, 1, tout, lv_mbox_disable_fit);
|
||||
lv_obj_animate(mbox, LV_ANIM_NONE, 1, tout, lv_mbox_disable_fit);
|
||||
} else {
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, ext->anim_close_time, tout, lv_obj_del);
|
||||
lv_obj_animate(mbox, LV_ANIM_NONE, ext->anim_close_time, tout, lv_obj_del);
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,7 +383,7 @@ void lv_mbox_stop_auto_close(lv_obj_t * mbox)
|
||||
*/
|
||||
const char * lv_mbox_get_txt(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
return lv_label_get_text(ext->txt);
|
||||
}
|
||||
@ -409,7 +409,7 @@ lv_obj_t * lv_mbox_get_from_btn(lv_obj_t * btn)
|
||||
*/
|
||||
uint16_t lv_mbox_get_anim_close_time(lv_obj_t * mbox )
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
return ext->anim_close_time;
|
||||
}
|
||||
/**
|
||||
@ -420,7 +420,7 @@ uint16_t lv_mbox_get_anim_close_time(lv_obj_t * mbox )
|
||||
*/
|
||||
lv_style_t * lv_mbox_get_style_btn(lv_obj_t * mbox, lv_btn_state_t state)
|
||||
{
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
if(ext->styles[state] == NULL) return lv_obj_get_style(mbox);
|
||||
|
||||
@ -462,7 +462,7 @@ static bool lv_mbox_design(lv_obj_t * mbox, const area_t * mask, lv_design_mode_
|
||||
*/
|
||||
static void lv_mbox_realign(lv_obj_t * mbox)
|
||||
{
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
|
||||
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
|
||||
|
||||
if(ext->txt == NULL) return;
|
||||
|
||||
|
@ -21,7 +21,7 @@ extern "C" {
|
||||
#error "lv_mbox: lv_cont is required. Enable it in lv_conf.h (USE_LV_CONT 1) "
|
||||
#endif
|
||||
|
||||
#if USE_LV_BTN == 0
|
||||
#if USE_LV_BUTTON == 0
|
||||
#error "lv_mbox: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
||||
#endif
|
||||
|
||||
|
@ -35,8 +35,8 @@ static bool lv_scrl_design(lv_obj_t * scrl, const area_t * mask, lv_design_mode_
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_page_design_f;
|
||||
static lv_design_f_t ancestor_scrl_design_f;
|
||||
static lv_design_func_t ancestor_page_design_f;
|
||||
static lv_design_func_t ancestor_scrl_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -63,31 +63,31 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_page);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_page_ext_t * ext = lv_obj_alloc_ext(new_page, sizeof(lv_page_ext_t));
|
||||
lv_page_ext_t * ext = lv_obj_allocate_ext_attr(new_page, sizeof(lv_page_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->scrl = NULL;
|
||||
ext->pr_action = NULL;
|
||||
ext->rel_action = NULL;
|
||||
ext->sbh_draw = 0;
|
||||
ext->sbv_draw = 0;
|
||||
ext->style_sb = lv_style_get(LV_STYLE_PRETTY, NULL);
|
||||
ext->style_sb = lv_style_get(LV_STYLE_PRETTY);
|
||||
ext->sb_width = LV_DPI / 8; /*Will be modified later*/
|
||||
ext->sb_mode = LV_PAGE_SB_MODE_ON;
|
||||
|
||||
if(ancestor_page_design_f == NULL) ancestor_page_design_f = lv_obj_get_design_f(new_page);
|
||||
if(ancestor_page_design_f == NULL) ancestor_page_design_f = lv_obj_get_design_func(new_page);
|
||||
|
||||
/*Init the new page object*/
|
||||
if(copy == NULL) {
|
||||
lv_style_t * style = lv_style_get(LV_STYLE_PRETTY_COLOR, NULL);
|
||||
lv_style_t * style = lv_style_get(LV_STYLE_PRETTY_COLOR);
|
||||
ext->scrl = lv_cont_create(new_page, NULL);
|
||||
if(ancestor_scrl_design_f == NULL) ancestor_scrl_design_f = lv_obj_get_design_f(ext->scrl);
|
||||
lv_obj_set_signal_f(ext->scrl, lv_page_scrl_signal);
|
||||
if(ancestor_scrl_design_f == NULL) ancestor_scrl_design_f = lv_obj_get_design_func(ext->scrl);
|
||||
lv_obj_set_signal_func(ext->scrl, lv_page_scrl_signal);
|
||||
lv_obj_set_drag(ext->scrl, true);
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT);
|
||||
lv_cont_set_fit(ext->scrl, false, true);
|
||||
lv_obj_set_style(ext->scrl, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_design_f(ext->scrl, lv_scrl_design);
|
||||
lv_obj_set_style(ext->scrl, lv_style_get(LV_STYLE_PRETTY));
|
||||
lv_obj_set_design_func(ext->scrl, lv_scrl_design);
|
||||
|
||||
lv_page_set_sb_width(new_page, style->body.padding.horizontal);
|
||||
lv_page_set_sb_mode(new_page, ext->sb_mode);
|
||||
@ -95,13 +95,13 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_f(new_page, lv_page_signal);
|
||||
lv_obj_set_design_f(new_page, lv_page_design);
|
||||
lv_obj_set_signal_func(new_page, lv_page_signal);
|
||||
lv_obj_set_design_func(new_page, lv_page_design);
|
||||
lv_obj_set_style(new_page, style);
|
||||
} else {
|
||||
lv_page_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
|
||||
lv_obj_set_signal_f(ext->scrl, lv_page_scrl_signal);
|
||||
lv_obj_set_signal_func(ext->scrl, lv_page_scrl_signal);
|
||||
|
||||
lv_page_set_pr_action(new_page, copy_ext->pr_action);
|
||||
lv_page_set_rel_action(new_page, copy_ext->rel_action);
|
||||
@ -111,11 +111,11 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_f(new_page, lv_page_signal);
|
||||
lv_obj_set_design_f(new_page, lv_page_design);
|
||||
lv_obj_set_signal_func(new_page, lv_page_signal);
|
||||
lv_obj_set_design_func(new_page, lv_page_design);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_page);
|
||||
lv_obj_refresh_style(new_page);
|
||||
}
|
||||
|
||||
lv_page_sb_refresh(new_page);
|
||||
@ -140,7 +140,7 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(obj_valid != false) {
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
lv_obj_t * child;
|
||||
if(sign == LV_SIGNAL_CHILD_CHG) { /*Move children to the scrollable object*/
|
||||
child = lv_obj_get_child(page, NULL);
|
||||
@ -158,7 +158,7 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
if(lv_cont_get_hfit(ext->scrl) == false) {
|
||||
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.horizontal);
|
||||
} else {
|
||||
ext->scrl->signal_f(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->cords);
|
||||
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||
}
|
||||
|
||||
if(ext->sb_mode == LV_PAGE_SB_MODE_ON) {
|
||||
@ -181,7 +181,7 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.horizontal);
|
||||
}
|
||||
|
||||
ext->scrl->signal_f(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->cords);
|
||||
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||
|
||||
/*The scrollbars are important only if they are visible now*/
|
||||
if(ext->sbh_draw != 0 || ext->sbv_draw != 0)
|
||||
@ -223,7 +223,7 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
||||
|
||||
lv_obj_t * page = lv_obj_get_parent(scrl);
|
||||
lv_style_t * page_style = lv_obj_get_style(page);
|
||||
lv_page_ext_t * page_ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
|
||||
|
||||
if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
|
||||
@ -243,8 +243,8 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
||||
|
||||
new_x = lv_obj_get_x(scrl);
|
||||
new_y = lv_obj_get_y(scrl);
|
||||
lv_obj_get_cords(scrl, &scrl_cords);
|
||||
lv_obj_get_cords(page, &page_cords);
|
||||
lv_obj_get_coords(scrl, &scrl_cords);
|
||||
lv_obj_get_coords(page, &page_cords);
|
||||
|
||||
/*scrollable width smaller then page width? -> align to left*/
|
||||
if(area_get_width(&scrl_cords) + 2 * hpad < area_get_width(&page_cords)) {
|
||||
@ -302,19 +302,19 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
||||
area_t sb_area_tmp;
|
||||
if(page_ext->sbh_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &page_ext->sbh);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
sb_area_tmp.x1 += page->coords.x1;
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x2;
|
||||
sb_area_tmp.y2 += page->coords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
page_ext->sbh_draw = 0;
|
||||
}
|
||||
if(page_ext->sbv_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &page_ext->sbv);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
sb_area_tmp.x1 += page->coords.x1;
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x2;
|
||||
sb_area_tmp.y2 += page->coords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
page_ext->sbv_draw = 0;
|
||||
}
|
||||
@ -346,7 +346,7 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->rel_action = rel_action;
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action)
|
||||
*/
|
||||
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->pr_action = pr_action;
|
||||
}
|
||||
|
||||
@ -368,12 +368,12 @@ void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action)
|
||||
*/
|
||||
void lv_page_set_sb_width(lv_obj_t * page, cord_t sb_width)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->sb_width = sb_width;
|
||||
area_set_height(&ext->sbh, ext->sb_width);
|
||||
area_set_width(&ext->sbv, ext->sb_width);
|
||||
lv_page_sb_refresh(page);
|
||||
lv_obj_inv(page);
|
||||
lv_obj_invalidate(page);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -383,10 +383,10 @@ void lv_page_set_sb_width(lv_obj_t * page, cord_t sb_width)
|
||||
*/
|
||||
void lv_page_set_sb_mode(lv_obj_t * page, lv_page_sb_mode_t sb_mode)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->sb_mode = sb_mode;
|
||||
page->signal_f(page, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_inv(page);
|
||||
page->signal_func(page, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_invalidate(page);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -396,9 +396,9 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_page_sb_mode_t sb_mode)
|
||||
*/
|
||||
void lv_page_set_style_sb(lv_obj_t * page, lv_style_t * style)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
ext->style_sb = style;
|
||||
lv_obj_inv(page);
|
||||
lv_obj_invalidate(page);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -420,12 +420,12 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue)
|
||||
*/
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
lv_style_t * style = lv_obj_get_style(page);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(page);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
|
||||
cord_t obj_y = obj->cords.y1 - ext->scrl->cords.y1;
|
||||
cord_t obj_y = obj->coords.y1 - ext->scrl->coords.y1;
|
||||
cord_t obj_h = lv_obj_get_height(obj);
|
||||
cord_t scrlable_y = lv_obj_get_y(ext->scrl);
|
||||
cord_t page_h = lv_obj_get_height(page);
|
||||
@ -483,7 +483,7 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
*/
|
||||
lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
|
||||
return ext->scrl;
|
||||
}
|
||||
@ -494,7 +494,7 @@ lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
|
||||
*/
|
||||
cord_t lv_page_get_sb_width(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
return ext->sb_width;
|
||||
}
|
||||
|
||||
@ -505,7 +505,7 @@ cord_t lv_page_get_sb_width(lv_obj_t * page)
|
||||
*/
|
||||
lv_page_sb_mode_t lv_page_get_sb_mode(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
return ext->sb_mode;
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ lv_page_sb_mode_t lv_page_get_sb_mode(lv_obj_t * page)
|
||||
*/
|
||||
lv_style_t * lv_page_get_style_sb(lv_obj_t * page)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
if(ext->style_sb == NULL) return lv_obj_get_style(page);
|
||||
|
||||
else return ext->style_sb;
|
||||
@ -544,27 +544,27 @@ static bool lv_page_design(lv_obj_t * scrl, const area_t * mask, lv_design_mode_
|
||||
ancestor_page_design_f(scrl, mask, mode);
|
||||
} else if(mode == LV_DESIGN_DRAW_POST) { /*Draw the scroll bars finally*/
|
||||
ancestor_page_design_f(scrl, mask, mode);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(scrl);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(scrl);
|
||||
|
||||
/*Draw the scrollbars*/
|
||||
area_t sb_area;
|
||||
if(ext->sbh_draw != 0) {
|
||||
/*Convert the relative coordinates to absolute*/
|
||||
area_cpy(&sb_area, &ext->sbh);
|
||||
sb_area.x1 += scrl->cords.x1;
|
||||
sb_area.y1 += scrl->cords.y1;
|
||||
sb_area.x2 += scrl->cords.x1;
|
||||
sb_area.y2 += scrl->cords.y1;
|
||||
sb_area.x1 += scrl->coords.x1;
|
||||
sb_area.y1 += scrl->coords.y1;
|
||||
sb_area.x2 += scrl->coords.x1;
|
||||
sb_area.y2 += scrl->coords.y1;
|
||||
lv_draw_rect(&sb_area, mask, ext->style_sb);
|
||||
}
|
||||
|
||||
if(ext->sbv_draw != 0) {
|
||||
/*Convert the relative coordinates to absolute*/
|
||||
area_cpy(&sb_area, &ext->sbv);
|
||||
sb_area.x1 += scrl->cords.x1;
|
||||
sb_area.y1 += scrl->cords.y1;
|
||||
sb_area.x2 += scrl->cords.x1;
|
||||
sb_area.y2 += scrl->cords.y1;
|
||||
sb_area.x1 += scrl->coords.x1;
|
||||
sb_area.y1 += scrl->coords.y1;
|
||||
sb_area.x2 += scrl->coords.x1;
|
||||
sb_area.y2 += scrl->coords.y1;
|
||||
lv_draw_rect(&sb_area, mask, ext->style_sb);
|
||||
}
|
||||
}
|
||||
@ -627,7 +627,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
* - horizontal and vertical scrollbars can overlap on the corners
|
||||
* - if the page has radius the scrollbar can be out of the radius */
|
||||
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
lv_style_t * style = lv_obj_get_style(page);
|
||||
lv_obj_t * scrl = ext->scrl;
|
||||
cord_t size_tmp;
|
||||
@ -651,18 +651,18 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
area_t sb_area_tmp;
|
||||
if(ext->sbh_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &ext->sbh);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
sb_area_tmp.x1 += page->coords.x1;
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x2;
|
||||
sb_area_tmp.y2 += page->coords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
}
|
||||
if(ext->sbv_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &ext->sbv);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
sb_area_tmp.x1 += page->coords.x1;
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x2;
|
||||
sb_area_tmp.y2 += page->coords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
}
|
||||
|
||||
@ -702,18 +702,18 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
/*Invalidate the new scrollbar areas*/
|
||||
if(ext->sbh_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &ext->sbh);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
sb_area_tmp.x1 += page->coords.x1;
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x2;
|
||||
sb_area_tmp.y2 += page->coords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
}
|
||||
if(ext->sbv_draw != 0) {
|
||||
area_cpy(&sb_area_tmp, &ext->sbv);
|
||||
sb_area_tmp.x1 += page->cords.x1;
|
||||
sb_area_tmp.y1 += page->cords.y1;
|
||||
sb_area_tmp.x2 += page->cords.x2;
|
||||
sb_area_tmp.y2 += page->cords.y2;
|
||||
sb_area_tmp.x1 += page->coords.x1;
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x2;
|
||||
sb_area_tmp.y2 += page->coords.y2;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void *
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_f_t ancestor_scr_signal_f;
|
||||
static lv_signal_func_t ancestor_scr_signal_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -56,16 +56,16 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_roller);
|
||||
|
||||
/*Allocate the roller type specific extended data*/
|
||||
lv_roller_ext_t * ext = lv_obj_alloc_ext(new_roller, sizeof(lv_roller_ext_t));
|
||||
lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_roller, lv_roller_signal);
|
||||
lv_obj_set_design_f(new_roller, lv_roller_design);
|
||||
lv_obj_set_signal_func(new_roller, lv_roller_signal);
|
||||
lv_obj_set_design_func(new_roller, lv_roller_design);
|
||||
|
||||
if(ancestor_scr_signal_f == NULL) ancestor_scr_signal_f = lv_obj_get_signal_f(lv_page_get_scrl(new_roller));
|
||||
if(ancestor_scr_signal_f == NULL) ancestor_scr_signal_f = lv_obj_get_signal_func(lv_page_get_scrl(new_roller));
|
||||
|
||||
/*Init the new roller roller*/
|
||||
if(copy == NULL) {
|
||||
@ -73,20 +73,20 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_obj_set_drag(scrl, true); /*In ddlist is might be disabled*/
|
||||
lv_page_set_rel_action(new_roller, NULL); /*Handle roller specific actions*/
|
||||
lv_cont_set_fit(lv_page_get_scrl(new_roller), true, false); /*Height is specified directly*/
|
||||
lv_obj_set_signal_f(scrl, roller_scrl_signal);
|
||||
lv_obj_set_signal_func(scrl, roller_scrl_signal);
|
||||
lv_ddlist_open(new_roller, true, 0);
|
||||
|
||||
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.opt_label);
|
||||
lv_ddlist_set_fix_height(new_roller, (font_get_height(style_label->text.font) >> FONT_ANTIALIAS) * 3
|
||||
+ style_label->text.space_line * 4);
|
||||
lv_obj_refr_style(new_roller); /*To set scrollable size automatically*/
|
||||
lv_obj_refresh_style(new_roller); /*To set scrollable size automatically*/
|
||||
}
|
||||
/*Copy an existing roller*/
|
||||
else {
|
||||
lv_roller_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_roller_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_roller);
|
||||
lv_obj_refresh_style(new_roller);
|
||||
}
|
||||
|
||||
return new_roller;
|
||||
@ -109,7 +109,7 @@ bool lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext(roller);
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_obj_set_height(lv_page_get_scrl(roller),
|
||||
lv_obj_get_height(ext->ddlist.opt_label) + lv_obj_get_height(roller));
|
||||
@ -185,15 +185,15 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_style_t * style = lv_obj_get_style(roller);
|
||||
lv_draw_rect(&roller->cords, mask, style);
|
||||
lv_draw_rect(&roller->coords, mask, style);
|
||||
|
||||
const font_t * font = style->text.font;
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext(roller);
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
area_t rect_area;
|
||||
rect_area.y1 = roller->cords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.space_line - 2;
|
||||
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.space_line - 2;
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->text.space_line;
|
||||
rect_area.x1 = ext->ddlist.opt_label->cords.x1 - style->body.padding.horizontal;
|
||||
rect_area.x1 = ext->ddlist.opt_label->coords.x1 - style->body.padding.horizontal;
|
||||
rect_area.x2 = rect_area.x1 + lv_obj_get_width(lv_page_get_scrl(roller));
|
||||
|
||||
lv_draw_rect(&rect_area, mask, ext->ddlist.style_sel);
|
||||
@ -226,15 +226,15 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void *
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
int32_t id = -1;
|
||||
lv_obj_t * roller = lv_obj_get_parent(roller_scrl);
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext(roller);
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.opt_label);
|
||||
const font_t * font = style_label->text.font;
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
if(sign == LV_SIGNAL_DRAG_END) {
|
||||
/*If dragged then align the list to there be an element in the middle*/
|
||||
cord_t label_y1 = ext->ddlist.opt_label->cords.y1 - roller->cords.y1;
|
||||
cord_t label_y1 = ext->ddlist.opt_label->coords.y1 - roller->coords.y1;
|
||||
cord_t label_unit = (font_get_height(style_label->text.font) >> FONT_ANTIALIAS) + style_label->text.space_line / 2;
|
||||
cord_t mid = (roller->cords.y2 - roller->cords.y1) / 2;
|
||||
cord_t mid = (roller->coords.y2 - roller->coords.y1) / 2;
|
||||
id = (mid - label_y1) / label_unit;
|
||||
if(id < 0) id = 0;
|
||||
if(id >= ext->ddlist.num_opt) id = ext->ddlist.num_opt - 1;
|
||||
@ -245,7 +245,7 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void *
|
||||
if(!lv_indev_is_dragging(indev)) {
|
||||
point_t p;
|
||||
lv_indev_get_point(indev, &p);
|
||||
p.y = p.y - ext->ddlist.opt_label->cords.y1;
|
||||
p.y = p.y - ext->ddlist.opt_label->coords.y1;
|
||||
id = p.y / (font_h + style_label->text.space_line);
|
||||
if(id < 0) id = 0;
|
||||
if(id >= ext->ddlist.num_opt) id = ext->ddlist.num_opt - 1;
|
||||
@ -256,7 +256,7 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void *
|
||||
/*Position the scrollable according to the new selected option*/
|
||||
if(id != -1) {
|
||||
cord_t h = lv_obj_get_height(roller);
|
||||
cord_t line_y1 = id * (font_h + style_label->text.space_line) + ext->ddlist.opt_label->cords.y1 - roller_scrl->cords.y1;
|
||||
cord_t line_y1 = id * (font_h + style_label->text.space_line) + ext->ddlist.opt_label->coords.y1 - roller_scrl->coords.y1;
|
||||
cord_t new_y = - line_y1 + (h - font_h) / 2;
|
||||
|
||||
if(ext->ddlist.anim_time == 0) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_SLIDER_SIZE_MIN (2 * LV_DOWNSCALE) /*hpad and vpad cannot make the bar or indicator smaller then this [px]*/
|
||||
#define LV_SLIDER_SIZE_MIN (2 << LV_ANTIALIAS) /*hpad and vpad cannot make the bar or indicator smaller then this [px]*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -31,7 +31,7 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
static lv_design_func_t ancestor_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -58,22 +58,22 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_slider);
|
||||
|
||||
/*Allocate the slider type specific extended data*/
|
||||
lv_slider_ext_t * ext = lv_obj_alloc_ext(new_slider, sizeof(lv_slider_ext_t));
|
||||
lv_slider_ext_t * ext = lv_obj_allocate_ext_attr(new_slider, sizeof(lv_slider_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->cb = NULL;
|
||||
ext->tmp_value = ext->bar.min_value;
|
||||
ext->style_knob = lv_style_get(LV_STYLE_PRETTY, NULL);
|
||||
ext->style_knob = lv_style_get(LV_STYLE_PRETTY);
|
||||
ext->knob_in = 0;
|
||||
|
||||
/* Save the bar design function.
|
||||
* It will be used in the sllider design function*/
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_slider);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_slider);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_slider, lv_slider_signal);
|
||||
lv_obj_set_design_f(new_slider, lv_slider_design);
|
||||
lv_obj_set_signal_func(new_slider, lv_slider_signal);
|
||||
lv_obj_set_design_func(new_slider, lv_slider_design);
|
||||
|
||||
/*Init the new slider slider*/
|
||||
if(copy == NULL) {
|
||||
@ -82,12 +82,12 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing slider*/
|
||||
else {
|
||||
lv_slider_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_slider_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->style_knob = copy_ext->style_knob;
|
||||
ext->cb = copy_ext->cb;
|
||||
ext->knob_in = copy_ext->knob_in;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_slider);
|
||||
lv_obj_refresh_style(new_slider);
|
||||
}
|
||||
|
||||
return new_slider;
|
||||
@ -110,7 +110,7 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
point_t p;
|
||||
cord_t w = lv_obj_get_width(slider);
|
||||
cord_t h = lv_obj_get_height(slider);
|
||||
@ -123,11 +123,11 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
|
||||
lv_indev_get_point(param, &p);
|
||||
if(w > h) {
|
||||
cord_t knob_w = h;
|
||||
p.x -= slider->cords.x1 + h / 2; /*Modify the point to shift with half knob (important on the start and end)*/
|
||||
p.x -= slider->coords.x1 + h / 2; /*Modify the point to shift with half knob (important on the start and end)*/
|
||||
tmp = (int32_t) ((int32_t) p.x * (ext->bar.max_value - ext->bar.min_value + 1)) / (w - knob_w);
|
||||
} else {
|
||||
cord_t knob_h = w;
|
||||
p.y -= slider->cords.y1 + w / 2; /*Modify the point to shift with half knob (important on the start and end)*/
|
||||
p.y -= slider->coords.y1 + w / 2; /*Modify the point to shift with half knob (important on the start and end)*/
|
||||
tmp = (int32_t) ((int32_t) p.y * (ext->bar.max_value - ext->bar.min_value + 1)) / (h - knob_h);
|
||||
tmp = ext->bar.max_value - tmp; /*Invert he value: small value means higher y*/
|
||||
}
|
||||
@ -147,7 +147,7 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
|
||||
* During the drawing method the ext. size is used by the knob so refresh the ext. size.*/
|
||||
if(lv_obj_get_width(slider) != area_get_width(param) ||
|
||||
lv_obj_get_height(slider) != area_get_height(param)) {
|
||||
slider->signal_f(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
slider->signal_func(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
if(ext->knob_in == 0) {
|
||||
@ -163,7 +163,7 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
|
||||
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
char c = *((char*)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
lv_bar_set_value(slider, lv_bar_get_value(slider) + 1);
|
||||
@ -189,7 +189,7 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_slider_set_action(lv_obj_t * slider, lv_action_t cb)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
ext->cb = cb;
|
||||
}
|
||||
|
||||
@ -200,12 +200,12 @@ void lv_slider_set_action(lv_obj_t * slider, lv_action_t cb)
|
||||
*/
|
||||
void lv_slider_set_style_knob(lv_obj_t * slider, lv_style_t * style)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
ext->style_knob = style;
|
||||
|
||||
slider->signal_f(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
slider->signal_func(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
|
||||
|
||||
lv_obj_inv(slider);
|
||||
lv_obj_invalidate(slider);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,7 +216,7 @@ void lv_slider_set_style_knob(lv_obj_t * slider, lv_style_t * style)
|
||||
*/
|
||||
void lv_slider_set_knob_in(lv_obj_t * slider, bool in)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
ext->knob_in = in == false ? 0 : 1;
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ void lv_slider_set_knob_in(lv_obj_t * slider, bool in)
|
||||
*/
|
||||
lv_action_t lv_slider_get_action(lv_obj_t * slider)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
return ext->cb;
|
||||
}
|
||||
/**
|
||||
@ -241,7 +241,7 @@ lv_action_t lv_slider_get_action(lv_obj_t * slider)
|
||||
*/
|
||||
lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
return ext->style_knob;
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider)
|
||||
*/
|
||||
bool lv_slider_get_knob_in(lv_obj_t * slider)
|
||||
{
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
return ext->knob_in == 0 ? false : true;
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
|
||||
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
|
||||
|
||||
lv_style_t * style_slider = lv_obj_get_style(slider);
|
||||
lv_style_t * style_knob = lv_slider_get_style_knob(slider);
|
||||
@ -288,7 +288,7 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
|
||||
|
||||
/*Draw the bar*/
|
||||
area_t area_bar;
|
||||
area_cpy(&area_bar, &slider->cords);
|
||||
area_cpy(&area_bar, &slider->coords);
|
||||
/*Be sure at least vpad/hpad width bar will remain*/
|
||||
cord_t pad_ver_bar = style_slider->body.padding.vertical;
|
||||
cord_t pad_hor_bar = style_slider->body.padding.horizontal;
|
||||
@ -324,8 +324,8 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
|
||||
area_indic.y1 += pad_ver_indic;
|
||||
area_indic.y2 -= pad_ver_indic;
|
||||
|
||||
cord_t slider_w = area_get_width(&slider->cords);
|
||||
cord_t slider_h = area_get_height(&slider->cords);
|
||||
cord_t slider_w = area_get_width(&slider->coords);
|
||||
cord_t slider_h = area_get_height(&slider->coords);
|
||||
|
||||
cord_t act_value = lv_bar_get_value(slider);
|
||||
cord_t min_value = lv_bar_get_min_value(slider);
|
||||
@ -344,7 +344,7 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
|
||||
if(act_value != min_value) lv_draw_rect(&area_indic, mask, style_indic);
|
||||
|
||||
area_t knob_area;
|
||||
area_cpy(&knob_area, &slider->cords);
|
||||
area_cpy(&knob_area, &slider->coords);
|
||||
|
||||
if(slider_w >= slider_h) {
|
||||
if(ext->knob_in == 0) {
|
||||
@ -352,23 +352,23 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
|
||||
knob_area.x2 = knob_area.x1 + slider_h;
|
||||
} else {
|
||||
knob_area.x1 = (int32_t) ((int32_t)(slider_w - slider_h) * act_value) / (max_value - min_value);
|
||||
knob_area.x1 += slider->cords.x1;
|
||||
knob_area.x1 += slider->coords.x1;
|
||||
knob_area.x2 = knob_area.x1 + slider_h;
|
||||
}
|
||||
|
||||
knob_area.y1 = slider->cords.y1;
|
||||
knob_area.y2 = slider->cords.y2;
|
||||
knob_area.y1 = slider->coords.y1;
|
||||
knob_area.y2 = slider->coords.y2;
|
||||
} else {
|
||||
if(ext->knob_in == 0) {
|
||||
knob_area.y1 = area_indic.y1 - slider_w / 2;
|
||||
knob_area.y2 = knob_area.y1 + slider_w;
|
||||
} else {
|
||||
knob_area.y2 = (int32_t) ((int32_t)(slider_h - slider_w) * act_value) / (max_value - min_value);
|
||||
knob_area.y2 = slider->cords.y2 - knob_area.y2;
|
||||
knob_area.y2 = slider->coords.y2 - knob_area.y2;
|
||||
knob_area.y1 = knob_area.y2 - slider_w;
|
||||
}
|
||||
knob_area.x1 = slider->cords.x1;
|
||||
knob_area.x2 = slider->cords.x2;
|
||||
knob_area.x1 = slider->coords.x1;
|
||||
knob_area.x2 = slider->coords.x2;
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,14 +54,14 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_sw);
|
||||
|
||||
/*Allocate the switch type specific extended data*/
|
||||
lv_sw_ext_t * ext = lv_obj_alloc_ext(new_sw, sizeof(lv_sw_ext_t));
|
||||
lv_sw_ext_t * ext = lv_obj_allocate_ext_attr(new_sw, sizeof(lv_sw_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->changed = 0;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_sw, lv_sw_signal);
|
||||
lv_obj_set_signal_func(new_sw, lv_sw_signal);
|
||||
|
||||
/*Init the new switch switch*/
|
||||
if(copy == NULL) {
|
||||
@ -74,7 +74,7 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Nothing to copy*/
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_sw);
|
||||
lv_obj_refresh_style(new_sw);
|
||||
}
|
||||
|
||||
return new_sw;
|
||||
@ -91,7 +91,7 @@ bool lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid;
|
||||
|
||||
lv_sw_ext_t * ext = lv_obj_get_ext(sw);
|
||||
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
|
||||
int16_t old_val = lv_bar_get_value(sw);
|
||||
|
||||
lv_action_t slider_cb = ext->slider.cb;
|
||||
|
149
lv_objx/lv_ta.c
149
lv_objx/lv_ta.c
@ -53,8 +53,8 @@ static void lv_ta_save_valid_cursor_x(lv_obj_t * ta);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
lv_design_f_t ancestor_design_f;
|
||||
lv_design_f_t scrl_design_f;
|
||||
lv_design_func_t ancestor_design_f;
|
||||
lv_design_func_t scrl_design_f;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -81,7 +81,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_ta);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_ta_ext_t * ext = lv_obj_alloc_ext(new_ta, sizeof(lv_ta_ext_t));
|
||||
lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(new_ta, sizeof(lv_ta_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->cursor_show = 1;
|
||||
ext->cursor_state = 0;
|
||||
@ -93,31 +93,31 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->cursor_valid_x = 0;
|
||||
ext->label = NULL;
|
||||
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_f(new_ta);
|
||||
if(scrl_design_f == NULL) scrl_design_f = lv_obj_get_design_f(ext->page.scrl);
|
||||
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_ta);
|
||||
if(scrl_design_f == NULL) scrl_design_f = lv_obj_get_design_func(ext->page.scrl);
|
||||
|
||||
lv_obj_set_signal_f(new_ta, lv_ta_signal);
|
||||
lv_obj_set_signal_f(lv_page_get_scrl(new_ta), lv_ta_scrl_signal);
|
||||
lv_obj_set_design_f(new_ta, lv_ta_design);
|
||||
lv_obj_set_signal_func(new_ta, lv_ta_signal);
|
||||
lv_obj_set_signal_func(lv_page_get_scrl(new_ta), lv_ta_scrl_signal);
|
||||
lv_obj_set_design_func(new_ta, lv_ta_design);
|
||||
|
||||
/*Init the new text area object*/
|
||||
if(copy == NULL) {
|
||||
ext->label = lv_label_create(new_ta, NULL);
|
||||
|
||||
lv_obj_set_design_f(ext->page.scrl, lv_ta_scrling_design);
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrling_design);
|
||||
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
|
||||
lv_label_set_text(ext->label, "Text.area");
|
||||
lv_page_glue_obj(ext->label, true);
|
||||
lv_obj_set_click(ext->label, false);
|
||||
lv_obj_set_style(new_ta, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_ta, lv_style_get(LV_STYLE_PRETTY));
|
||||
lv_page_set_sb_mode(new_ta, LV_PAGE_SB_MODE_AUTO);
|
||||
lv_obj_set_style(lv_page_get_scrl(new_ta), lv_style_get(LV_STYLE_TRANSPARENT_TIGHT, NULL));
|
||||
lv_obj_set_style(lv_page_get_scrl(new_ta), lv_style_get(LV_STYLE_TRANSPARENT_TIGHT));
|
||||
lv_obj_set_size(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_obj_set_design_f(ext->page.scrl, lv_ta_scrling_design);
|
||||
lv_ta_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrling_design);
|
||||
lv_ta_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->label = lv_label_create(new_ta, copy_ext->label);
|
||||
ext->cursor_show = copy_ext->cursor_show;
|
||||
ext->pwd_mode = copy_ext->pwd_mode;
|
||||
@ -125,7 +125,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
if(copy_ext->one_line) lv_ta_set_one_line(new_ta, true);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_ta);
|
||||
lv_obj_refresh_style(new_ta);
|
||||
}
|
||||
|
||||
/*Create a cursor blinker animation*/
|
||||
@ -164,7 +164,7 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
if(ext->pwd_tmp != NULL) dm_free(ext->pwd_tmp);
|
||||
|
||||
@ -184,7 +184,7 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
}
|
||||
lv_label_set_text(ext->label, NULL);
|
||||
|
||||
lv_obj_refr_ext_size(lv_page_get_scrl(ta));
|
||||
lv_obj_refresh_ext_size(lv_page_get_scrl(ta));
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/*Set the label width according to the text area width*/
|
||||
@ -235,7 +235,7 @@ bool lv_ta_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
||||
if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
||||
/*Set ext. size because the cursor might be out of this object*/
|
||||
lv_obj_t * ta = lv_obj_get_parent(scrl);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_style_t * style_label = lv_obj_get_style(ext->label);
|
||||
|
||||
scrl->ext_size = MATH_MAX(scrl->ext_size, style_label->text.space_line + font_get_height(style_label->text.font));
|
||||
@ -254,7 +254,7 @@ bool lv_ta_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
||||
*/
|
||||
void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
|
||||
if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/
|
||||
#if TXT_UTF8 == 0
|
||||
@ -315,9 +315,8 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
|
||||
*/
|
||||
void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
const char * label_txt = lv_label_get_text(ext->label);
|
||||
uint16_t label_len = strlen(label_txt);
|
||||
uint16_t txt_len = strlen(txt);
|
||||
|
||||
if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/
|
||||
@ -360,7 +359,7 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
|
||||
*/
|
||||
void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_label_set_text(ext->label, txt);
|
||||
lv_ta_set_cursor_pos(ta, LV_TA_CUR_LAST);
|
||||
|
||||
@ -400,7 +399,7 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||
*/
|
||||
void lv_ta_del(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
uint16_t cur_pos = ext->cursor_pos;
|
||||
|
||||
if(cur_pos == 0) return;
|
||||
@ -450,7 +449,7 @@ void lv_ta_del(lv_obj_t * ta)
|
||||
*/
|
||||
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ta);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
uint16_t len = txt_len(lv_label_get_text(ext->label));
|
||||
@ -469,8 +468,8 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
area_t label_cords;
|
||||
area_t ta_cords;
|
||||
lv_label_get_letter_pos(ext->label, pos, &cur_pos);
|
||||
lv_obj_get_cords(ta, &ta_cords);
|
||||
lv_obj_get_cords(ext->label, &label_cords);
|
||||
lv_obj_get_coords(ta, &ta_cords);
|
||||
lv_obj_get_coords(ext->label, &label_cords);
|
||||
|
||||
/*Check the top*/
|
||||
if(lv_obj_get_y(label_par) + cur_pos.y < 0) {
|
||||
@ -510,7 +509,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
a.path = anim_get_path(ANIM_PATH_STEP);
|
||||
anim_create(&a);
|
||||
|
||||
lv_obj_inv(ta);
|
||||
lv_obj_invalidate(ta);
|
||||
}
|
||||
|
||||
|
||||
@ -550,7 +549,7 @@ void lv_ta_cursor_left(lv_obj_t * ta)
|
||||
*/
|
||||
void lv_ta_cursor_down(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
point_t pos;
|
||||
|
||||
/*Get the position of the current letter*/
|
||||
@ -577,7 +576,7 @@ void lv_ta_cursor_down(lv_obj_t * ta)
|
||||
*/
|
||||
void lv_ta_cursor_up(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
point_t pos;
|
||||
|
||||
/*Get the position of the current letter*/
|
||||
@ -602,10 +601,10 @@ void lv_ta_cursor_up(lv_obj_t * ta)
|
||||
*/
|
||||
void lv_ta_set_cursor_show(lv_obj_t * ta, bool show)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
ext->cursor_show = show == false ? 0 : 1;
|
||||
ext->cursor_state = 0;
|
||||
lv_obj_inv(ta);
|
||||
lv_obj_invalidate(ta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -615,9 +614,9 @@ void lv_ta_set_cursor_show(lv_obj_t * ta, bool show)
|
||||
*/
|
||||
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_ta_cursor_type_t cur_type)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
ext->cursor_type = cur_type;
|
||||
lv_obj_inv(ta);
|
||||
lv_obj_invalidate(ta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -627,9 +626,9 @@ void lv_ta_set_cursor_type(lv_obj_t * ta, lv_ta_cursor_type_t cur_type)
|
||||
*/
|
||||
void lv_ta_set_cursor_style(lv_obj_t * ta, lv_style_t * style)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
ext->cursor_style = style;
|
||||
lv_obj_inv(ta);
|
||||
lv_obj_invalidate(ta);
|
||||
}
|
||||
|
||||
|
||||
@ -640,7 +639,7 @@ void lv_ta_set_cursor_style(lv_obj_t * ta, lv_style_t * style)
|
||||
*/
|
||||
void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
|
||||
/*Pwd mode is now enabled*/
|
||||
if(ext->pwd_mode == 0 && en != false) {
|
||||
@ -675,7 +674,7 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
|
||||
void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
||||
{
|
||||
if(en != false) {
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_style_t * style_ta = lv_obj_get_style(ta);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(ta));
|
||||
lv_style_t * style_label = lv_obj_get_style(ext->label);
|
||||
@ -688,7 +687,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
||||
lv_label_set_no_break(ext->label, true);
|
||||
lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->body.padding.horizontal, style_ta->body.padding.vertical);
|
||||
} else {
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_style_t * style_ta = lv_obj_get_style(ta);
|
||||
|
||||
ext->one_line = 0;
|
||||
@ -711,7 +710,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
||||
*/
|
||||
const char * lv_ta_get_txt(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
|
||||
const char * txt;
|
||||
if(ext->pwd_mode == 0) {
|
||||
@ -731,7 +730,7 @@ const char * lv_ta_get_txt(lv_obj_t * ta)
|
||||
*/
|
||||
lv_obj_t * lv_ta_get_label(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
return ext->label;
|
||||
}
|
||||
|
||||
@ -743,7 +742,7 @@ lv_obj_t * lv_ta_get_label(lv_obj_t * ta)
|
||||
*/
|
||||
uint16_t lv_ta_get_cursor_pos(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
return ext->cursor_pos;
|
||||
}
|
||||
|
||||
@ -754,7 +753,7 @@ uint16_t lv_ta_get_cursor_pos(lv_obj_t * ta)
|
||||
*/
|
||||
bool lv_ta_get_cursor_show(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
return ext->cursor_show;
|
||||
}
|
||||
|
||||
@ -765,7 +764,7 @@ bool lv_ta_get_cursor_show(lv_obj_t * ta)
|
||||
*/
|
||||
lv_ta_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
return ext->cursor_type;
|
||||
}
|
||||
|
||||
@ -776,7 +775,7 @@ lv_ta_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta)
|
||||
*/
|
||||
lv_style_t * lv_ta_get_cursor_style(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
return ext->cursor_style;
|
||||
}
|
||||
|
||||
@ -787,7 +786,7 @@ lv_style_t * lv_ta_get_cursor_style(lv_obj_t * ta)
|
||||
*/
|
||||
bool lv_ta_get_pwd_mode(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
return ext->pwd_mode;
|
||||
}
|
||||
|
||||
@ -847,32 +846,32 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design
|
||||
|
||||
/*Draw the cursor too*/
|
||||
lv_obj_t * ta = lv_obj_get_parent(scrl);
|
||||
lv_ta_ext_t * ta_ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ta_ext = lv_obj_get_ext_attr(ta);
|
||||
if(ta_ext->cursor_show == 0 || ta_ext->cursor_state == 0) return true; /*The cursor is not visible now*/
|
||||
|
||||
lv_style_t * label_style = lv_obj_get_style(ta_ext->label);
|
||||
|
||||
lv_style_t cur_style;
|
||||
if(ta_ext->cursor_style != NULL) {
|
||||
lv_style_cpy(&cur_style, ta_ext->cursor_style);
|
||||
lv_style_copy(&cur_style, ta_ext->cursor_style);
|
||||
}
|
||||
else {
|
||||
/*If cursor style is not specified then use the modified label style */
|
||||
lv_style_cpy(&cur_style, label_style);
|
||||
lv_style_copy(&cur_style, label_style);
|
||||
color_t ccolor_tmp = cur_style.text.color; /*Make letter color to cursor color*/
|
||||
cur_style.text.color = cur_style.body.color_main; /*In block mode the letter color will be current background color*/
|
||||
cur_style.body.color_main = ccolor_tmp;
|
||||
cur_style.body.color_gradient = ccolor_tmp;
|
||||
cur_style.border.color = ccolor_tmp;
|
||||
cur_style.border.opa = OPA_COVER;
|
||||
cur_style.border.width = 1 * LV_DOWNSCALE;
|
||||
cur_style.line.width = 1 * LV_DOWNSCALE;
|
||||
cur_style.shadow.width = 0;
|
||||
cur_style.body.border.color = ccolor_tmp;
|
||||
cur_style.body.border.opa = OPA_COVER;
|
||||
cur_style.body.border.width = 1 << LV_ANTIALIAS;
|
||||
cur_style.body.shadow.width = 0;
|
||||
cur_style.body.radius = 0;
|
||||
cur_style.body.empty = 0;
|
||||
cur_style.opacity = OPA_COVER;
|
||||
cur_style.body.padding.horizontal = 0;
|
||||
cur_style.body.padding.vertical = 0;
|
||||
cur_style.line.width = 1 << LV_ANTIALIAS;
|
||||
cur_style.opacity = OPA_COVER;
|
||||
}
|
||||
|
||||
uint16_t cur_pos = lv_ta_get_cursor_pos(ta);
|
||||
@ -898,7 +897,7 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design
|
||||
lv_label_get_letter_pos(ta_ext->label, byte_pos, &letter_pos);
|
||||
|
||||
/*If the cursor is out of the text (most right) draw it to the next line*/
|
||||
if(letter_pos.x + ta_ext->label->cords.x1 + letter_w > ta_ext->label->cords.x2 && ta_ext->one_line == 0) {
|
||||
if(letter_pos.x + ta_ext->label->coords.x1 + letter_w > ta_ext->label->coords.x2 && ta_ext->one_line == 0) {
|
||||
letter_pos.x = 0;
|
||||
letter_pos.y += letter_h + label_style->text.space_line;
|
||||
|
||||
@ -917,16 +916,16 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design
|
||||
/*Draw he cursor according to the type*/
|
||||
area_t cur_area;
|
||||
if(ta_ext->cursor_type == LV_TA_CURSOR_LINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.padding.horizontal - (cur_style.line.width >> 1) - (cur_style.line.width & 0x1);
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.padding.vertical;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.padding.horizontal + (cur_style.line.width >> 1);
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.padding.vertical + letter_h;
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.horizontal - (cur_style.line.width >> 1) - (cur_style.line.width & 0x1);
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.vertical;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.horizontal + (cur_style.line.width >> 1);
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.vertical + letter_h;
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
} else if(ta_ext->cursor_type == LV_TA_CURSOR_BLOCK) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 - cur_style.body.padding.horizontal;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.body.padding.vertical;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.padding.horizontal + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.padding.vertical + letter_h;
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.horizontal;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.vertical;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.horizontal + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.vertical + letter_h;
|
||||
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
|
||||
@ -944,19 +943,19 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design
|
||||
lv_draw_label(&cur_area, mask, &cur_style, letter_buf, TXT_FLAG_NONE, 0);
|
||||
|
||||
} else if(ta_ext->cursor_type == LV_TA_CURSOR_OUTLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 - cur_style.body.padding.horizontal;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.body.padding.vertical;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.padding.horizontal + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.body.padding.vertical+ letter_h;
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.horizontal;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.vertical;
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.horizontal + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.vertical+ letter_h;
|
||||
|
||||
cur_style.body.empty = 1;
|
||||
if(cur_style.border.width == 0) cur_style.border.width = 1 * LV_DOWNSCALE; /*Be sure the border will be drawn*/
|
||||
if(cur_style.body.border.width == 0) cur_style.body.border.width = 1 << LV_ANTIALIAS; /*Be sure the border will be drawn*/
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
} else if(ta_ext->cursor_type == LV_TA_CURSOR_UNDERLINE) {
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.padding.horizontal;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.padding.vertical + letter_h - (cur_style.line.width >> 1);
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.padding.horizontal + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.padding.vertical + letter_h + (cur_style.line.width >> 1) + (cur_style.line.width & 0x1);
|
||||
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.horizontal;
|
||||
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.vertical + letter_h - (cur_style.line.width >> 1);
|
||||
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.horizontal + letter_w;
|
||||
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.vertical + letter_h + (cur_style.line.width >> 1) + (cur_style.line.width & 0x1);
|
||||
|
||||
lv_draw_rect(&cur_area, mask, &cur_style);
|
||||
}
|
||||
@ -974,10 +973,10 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design
|
||||
*/
|
||||
static void cursor_blink_anim(lv_obj_t * ta, uint8_t show)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(show != ext->cursor_state) {
|
||||
ext->cursor_state = show == 0 ? 0 : 1;
|
||||
if(ext->cursor_show != 0) lv_obj_inv(ta);
|
||||
if(ext->cursor_show != 0) lv_obj_invalidate(ta);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1000,7 +999,7 @@ static void pwd_char_hider_anim(lv_obj_t * ta, int32_t x)
|
||||
*/
|
||||
static void pwd_char_hider(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(ext->pwd_mode != 0) {
|
||||
char * txt = lv_label_get_text(ext->label);
|
||||
int16_t len = txt_len(txt);
|
||||
@ -1020,7 +1019,7 @@ static void pwd_char_hider(lv_obj_t * ta)
|
||||
*/
|
||||
static void lv_ta_save_valid_cursor_x(lv_obj_t * ta)
|
||||
{
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
point_t cur_pos;
|
||||
lv_label_get_letter_pos(ext->label, ext->cursor_pos, &cur_pos);
|
||||
ext->cursor_valid_x = cur_pos.x;
|
||||
|
@ -39,7 +39,7 @@ static lv_action_res_t tab_btnm_action(lv_obj_t * tab_btnm, uint16_t id);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_f_t page_scrl_signal;
|
||||
static lv_signal_func_t page_scrl_signal;
|
||||
static const char * tab_def[] = {""};
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -66,7 +66,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_tabview);
|
||||
|
||||
/*Allocate the tab type specific extended data*/
|
||||
lv_tabview_ext_t * ext = lv_obj_alloc_ext(new_tabview, sizeof(lv_tabview_ext_t));
|
||||
lv_tabview_ext_t * ext = lv_obj_allocate_ext_attr(new_tabview, sizeof(lv_tabview_ext_t));
|
||||
dm_assert(ext);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
@ -82,12 +82,12 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->tab_name_ptr[0] = "";
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_tabview, lv_tabview_signal);
|
||||
lv_obj_set_signal_func(new_tabview, lv_tabview_signal);
|
||||
|
||||
/*Init the new tab tab*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_tabview, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_style(new_tabview, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_obj_set_style(new_tabview, lv_style_get(LV_STYLE_PRETTY));
|
||||
|
||||
ext->tabs = lv_btnm_create(new_tabview, NULL);
|
||||
lv_btnm_set_map(ext->tabs, tab_def);
|
||||
@ -105,12 +105,12 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_cont_set_fit(ext->content, true, false);
|
||||
lv_cont_set_layout(ext->content, LV_CONT_LAYOUT_ROW_T);
|
||||
lv_obj_set_height(ext->content, LV_VER_RES);
|
||||
lv_obj_set_style(ext->content, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT, NULL));
|
||||
lv_obj_set_style(ext->content, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT));
|
||||
lv_obj_align(ext->content, ext->tabs, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
}
|
||||
/*Copy an existing tab*/
|
||||
else {
|
||||
lv_tabview_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_tabview_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->point_last.x = 0;
|
||||
ext->point_last.y = 0;
|
||||
ext->tabs = lv_btnm_create(new_tabview, copy_ext->tabs);
|
||||
@ -128,7 +128,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_tabview);
|
||||
lv_obj_refresh_style(new_tabview);
|
||||
}
|
||||
|
||||
return new_tabview;
|
||||
@ -151,7 +151,7 @@ bool lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * param)
|
||||
/* The object can be deleted so check its validity and then
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
dm_free(ext->tab_name_ptr);
|
||||
ext->tab_name_ptr = NULL;
|
||||
@ -180,16 +180,16 @@ bool lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * param)
|
||||
*/
|
||||
lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
|
||||
/*Create the container page*/
|
||||
lv_obj_t * h = lv_page_create(ext->content, NULL);
|
||||
lv_obj_set_size(h, lv_obj_get_width(tabview), lv_obj_get_height(tabview));
|
||||
lv_obj_set_style(h, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL));
|
||||
lv_obj_set_signal_f(h, tabpage_signal);
|
||||
lv_obj_set_style(h, lv_style_get(LV_STYLE_PRETTY_COLOR));
|
||||
lv_obj_set_signal_func(h, tabpage_signal);
|
||||
lv_page_set_sb_mode(h, LV_PAGE_SB_MODE_AUTO);
|
||||
if(page_scrl_signal == NULL) page_scrl_signal = lv_obj_get_signal_f(lv_page_get_scrl(h));
|
||||
lv_obj_set_signal_f(lv_page_get_scrl(h), tabscrl_signal);
|
||||
if(page_scrl_signal == NULL) page_scrl_signal = lv_obj_get_signal_func(lv_page_get_scrl(h));
|
||||
lv_obj_set_signal_func(lv_page_get_scrl(h), tabscrl_signal);
|
||||
|
||||
/*Extend the button matrix map with the new name*/
|
||||
ext->tab_cnt++;
|
||||
@ -226,7 +226,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||
*/
|
||||
void lv_tabview_set_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
lv_style_t * style = lv_obj_get_style(ext->content);
|
||||
|
||||
ext->tab_act = id >= ext->tab_cnt ? ext->tab_cnt - 1 : id;
|
||||
@ -293,7 +293,7 @@ void lv_tabview_set_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
|
||||
*/
|
||||
uint16_t lv_tabview_get_tab_act(lv_obj_t * tabview)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
return ext->tab_act;
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ uint16_t lv_tabview_get_tab_act(lv_obj_t * tabview)
|
||||
*/
|
||||
uint16_t lv_tabview_get_tab_cnt(lv_obj_t * tabview)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
return ext->tab_cnt;
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ uint16_t lv_tabview_get_tab_cnt(lv_obj_t * tabview)
|
||||
*/
|
||||
lv_obj_t * lv_tabview_get_tab_page(lv_obj_t * tabview, uint16_t id)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
uint16_t i = 0;
|
||||
lv_obj_t * page = lv_obj_get_child(ext->content, NULL);
|
||||
|
||||
@ -337,7 +337,7 @@ lv_obj_t * lv_tabview_get_tab_page(lv_obj_t * tabview, uint16_t id)
|
||||
*/
|
||||
lv_obj_t * lv_tabview_get_tabs(lv_obj_t * tabview)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
return ext->tabs;
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ lv_obj_t * lv_tabview_get_tabs(lv_obj_t * tabview)
|
||||
*/
|
||||
lv_obj_t * lv_tabview_get_indic(lv_obj_t * tabview)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
return ext->indic;
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ lv_obj_t * lv_tabview_get_indic(lv_obj_t * tabview)
|
||||
*/
|
||||
void lv_tabview_realign(lv_obj_t * tabview)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
|
||||
lv_obj_set_width(ext->tabs, lv_obj_get_width(tabview));
|
||||
lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->tabs));
|
||||
@ -494,7 +494,7 @@ static bool tabscrl_signal(lv_obj_t * tab_scrl, lv_signal_t sign, void * param)
|
||||
*/
|
||||
static void tabpage_pressed_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_indev_get_point(indev, &ext->point_last);
|
||||
}
|
||||
@ -506,7 +506,7 @@ static void tabpage_pressed_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
*/
|
||||
static void tabpage_pressing_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
point_t point_act;
|
||||
lv_indev_get_point(indev, &point_act);
|
||||
@ -532,7 +532,7 @@ static void tabpage_pressing_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
cord_t indic_width = lv_obj_get_width(ext->indic);
|
||||
lv_style_t * tabs_style = lv_obj_get_style(ext->tabs);
|
||||
lv_style_t * indic_style = lv_obj_get_style(ext->indic);
|
||||
cord_t p = ((tabpage->cords.x1 - tabview->cords.x1) * (indic_width + tabs_style->body.padding.inner)) / lv_obj_get_width(tabview);
|
||||
cord_t p = ((tabpage->coords.x1 - tabview->coords.x1) * (indic_width + tabs_style->body.padding.inner)) / lv_obj_get_width(tabview);
|
||||
|
||||
lv_obj_set_x(ext->indic, indic_width * ext->tab_act + tabs_style->body.padding.inner * ext->tab_act + indic_style->body.padding.horizontal - p);
|
||||
}
|
||||
@ -545,7 +545,7 @@ static void tabpage_pressing_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
*/
|
||||
static void tabpage_press_lost_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
{
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tabview);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
ext->drag_h = 0;
|
||||
ext->draging = 0;
|
||||
|
||||
@ -563,12 +563,12 @@ static void tabpage_press_lost_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
}
|
||||
|
||||
|
||||
cord_t page_x1 = tabpage->cords.x1 + x_predict;
|
||||
cord_t page_x2 = tabpage->cords.x2 + x_predict;
|
||||
cord_t page_x1 = tabpage->coords.x1 + x_predict;
|
||||
cord_t page_x2 = tabpage->coords.x2 + x_predict;
|
||||
|
||||
if(page_x1 > (tabview->cords.x2 - tabview->cords.x1) / 2) {
|
||||
if(page_x1 > (tabview->coords.x2 - tabview->coords.x1) / 2) {
|
||||
if(ext->tab_act != 0) ext->tab_act--;
|
||||
} else if(page_x2 < (tabview->cords.x2 - tabview->cords.x1) / 2) {
|
||||
} else if(page_x2 < (tabview->coords.x2 - tabview->coords.x1) / 2) {
|
||||
if(ext->tab_act < ext->tab_cnt - 1) ext->tab_act++;
|
||||
}
|
||||
|
||||
@ -584,7 +584,7 @@ static void tabpage_press_lost_hadler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
static lv_action_res_t tab_btnm_action(lv_obj_t * tab_btnm, uint16_t id)
|
||||
{
|
||||
lv_obj_t * tab = lv_obj_get_parent(tab_btnm);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext(tab);
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tab);
|
||||
ext->tab_act = id;
|
||||
lv_tabview_set_act(tab, id, true);
|
||||
|
||||
|
@ -56,31 +56,31 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
dm_assert(new_win);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_win_ext_t * ext = lv_obj_alloc_ext(new_win, sizeof(lv_win_ext_t));
|
||||
lv_win_ext_t * ext = lv_obj_allocate_ext_attr(new_win, sizeof(lv_win_ext_t));
|
||||
dm_assert(ext);
|
||||
ext->page = NULL;
|
||||
ext->btnh = NULL;
|
||||
ext->header = NULL;
|
||||
ext->title = NULL;
|
||||
ext->style_header = lv_style_get(LV_STYLE_PLAIN_COLOR, NULL);
|
||||
ext->style_cbtn_rel = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED, NULL);
|
||||
ext->style_cbtn_pr = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED, NULL);
|
||||
ext->style_header = lv_style_get(LV_STYLE_PLAIN_COLOR);
|
||||
ext->style_cbtn_rel = lv_style_get(LV_STYLE_BUTTON_ON_RELEASED);
|
||||
ext->style_cbtn_pr = lv_style_get(LV_STYLE_BUTTON_ON_PRESSED);
|
||||
ext->cbtn_size = ( LV_DPI) / 2;
|
||||
|
||||
/*Init the new window object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_pos(new_win, 0, 0);
|
||||
lv_obj_set_style(new_win, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_obj_set_style(new_win, lv_style_get(LV_STYLE_PLAIN));
|
||||
|
||||
ext->page = lv_page_create(new_win, NULL);
|
||||
lv_obj_set_protect(ext->page, LV_PROTECT_PARENT);
|
||||
lv_obj_set_style(ext->page, lv_style_get(LV_STYLE_PLAIN, NULL));
|
||||
lv_obj_set_style(ext->page, lv_style_get(LV_STYLE_PLAIN));
|
||||
lv_page_set_sb_mode(ext->page, LV_PAGE_SB_MODE_AUTO);
|
||||
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
||||
lv_cont_set_fit(scrl, false, true);
|
||||
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSPARENT, NULL));
|
||||
lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSPARENT));
|
||||
|
||||
/*Create a holder for the header*/
|
||||
ext->header = lv_cont_create(new_win, NULL);
|
||||
@ -88,7 +88,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Move back the header because it is automatically moved to the scrollable */
|
||||
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
|
||||
lv_obj_set_parent(ext->header, new_win);
|
||||
lv_obj_set_style(ext->header, lv_style_get(LV_STYLE_PLAIN_COLOR, NULL));
|
||||
lv_obj_set_style(ext->header, lv_style_get(LV_STYLE_PLAIN_COLOR));
|
||||
|
||||
/*Create a title on the header*/
|
||||
ext->title = lv_label_create(ext->header, NULL);
|
||||
@ -97,15 +97,15 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*Create a holder for the control buttons*/
|
||||
ext->btnh = lv_cont_create(ext->header, NULL);
|
||||
lv_cont_set_fit(ext->btnh, true, false);
|
||||
lv_obj_set_style(ext->btnh, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT, NULL));
|
||||
lv_obj_set_style(ext->btnh, lv_style_get(LV_STYLE_TRANSPARENT_TIGHT));
|
||||
lv_cont_set_layout(ext->btnh, LV_CONT_LAYOUT_ROW_M);
|
||||
|
||||
lv_obj_set_signal_f(new_win, lv_win_signal);
|
||||
lv_obj_set_signal_func(new_win, lv_win_signal);
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_win_ext_t * copy_ext = lv_obj_get_ext(copy);
|
||||
lv_win_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
/*Create the objects*/
|
||||
ext->header = lv_cont_create(new_win, copy_ext->header);
|
||||
ext->title = lv_label_create(ext->header, copy_ext->title);
|
||||
@ -121,9 +121,9 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
child = lv_obj_get_child(copy_ext->btnh, child);
|
||||
}
|
||||
|
||||
lv_obj_set_signal_f(new_win, lv_win_signal);
|
||||
lv_obj_set_signal_func(new_win, lv_win_signal);
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refr_style(new_win);
|
||||
lv_obj_refresh_style(new_win);
|
||||
}
|
||||
|
||||
lv_win_realign(new_win);
|
||||
@ -206,13 +206,13 @@ bool lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
|
||||
*/
|
||||
lv_obj_t * lv_win_add_cbtn(lv_obj_t * win, const char * img_path, lv_action_t rel_action)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(ext->btnh, NULL);
|
||||
lv_btn_set_styles(btn, ext->style_cbtn_rel, ext->style_cbtn_pr,
|
||||
NULL, NULL, NULL);
|
||||
lv_btn_set_style(btn, LV_BTN_STATE_OFF_RELEASED, ext->style_cbtn_rel);
|
||||
lv_btn_set_style(btn, LV_BTN_STATE_OFF_PRESSED, ext->style_cbtn_pr);
|
||||
lv_obj_set_size(btn, ext->cbtn_size, ext->cbtn_size);
|
||||
lv_btn_set_rel_action(btn, rel_action);
|
||||
lv_btn_set_action(btn, LV_BTN_ACTION_RELEASE, rel_action);
|
||||
|
||||
lv_obj_t * img = lv_img_create(btn, NULL);
|
||||
lv_obj_set_click(img, false);
|
||||
@ -244,7 +244,7 @@ lv_action_res_t lv_win_close_action(lv_obj_t * btn)
|
||||
*/
|
||||
void lv_win_set_title(lv_obj_t * win, const char * title)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
lv_label_set_text(ext->title, title);
|
||||
lv_win_realign(win);
|
||||
@ -257,7 +257,7 @@ void lv_win_set_title(lv_obj_t * win, const char * title)
|
||||
*/
|
||||
void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
ext->cbtn_size = size;
|
||||
|
||||
lv_win_realign(win);
|
||||
@ -271,13 +271,15 @@ void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size)
|
||||
*/
|
||||
void lv_win_set_styles_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
ext->style_cbtn_rel = rel;
|
||||
ext->style_cbtn_pr = pr;
|
||||
lv_obj_t * cbtn;
|
||||
cbtn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(cbtn != NULL) {
|
||||
lv_btn_set_styles(cbtn, ext->style_cbtn_rel, ext->style_cbtn_pr, NULL, NULL, NULL);
|
||||
lv_btn_set_style(cbtn, LV_BTN_STATE_OFF_RELEASED, ext->style_cbtn_rel);
|
||||
lv_btn_set_style(cbtn, LV_BTN_STATE_OFF_PRESSED, ext->style_cbtn_pr);
|
||||
|
||||
cbtn = lv_obj_get_child(ext->btnh, cbtn);
|
||||
}
|
||||
}
|
||||
@ -293,7 +295,7 @@ void lv_win_set_styles_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr)
|
||||
*/
|
||||
const char * lv_win_get_title(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return lv_label_get_text(ext->title);
|
||||
}
|
||||
|
||||
@ -304,7 +306,7 @@ const char * lv_win_get_title(lv_obj_t * win)
|
||||
*/
|
||||
lv_obj_t * lv_win_get_page(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return ext->page;
|
||||
}
|
||||
|
||||
@ -315,7 +317,7 @@ lv_obj_t * lv_win_get_page(lv_obj_t * win)
|
||||
*/
|
||||
lv_obj_t * lv_win_get_header(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return ext->header;
|
||||
}
|
||||
|
||||
@ -326,7 +328,7 @@ lv_obj_t * lv_win_get_header(lv_obj_t * win)
|
||||
*/
|
||||
cord_t lv_win_get_cbtn_size(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return ext->cbtn_size;
|
||||
}
|
||||
|
||||
@ -337,7 +339,7 @@ cord_t lv_win_get_cbtn_size(lv_obj_t * win)
|
||||
*/
|
||||
cord_t lv_win_get_width(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
|
||||
@ -399,7 +401,7 @@ static bool lv_win_design(lv_obj_t * win, const area_t * mask, lv_design_mode_t
|
||||
*/
|
||||
static void lv_win_realign(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
|
||||
if(ext->page == NULL || ext->btnh == NULL || ext->header == NULL || ext->title == NULL) return;
|
||||
|
||||
@ -424,7 +426,7 @@ static void lv_win_realign(lv_obj_t * win)
|
||||
lv_obj_align(ext->title, NULL, LV_ALIGN_IN_LEFT_MID, ext->style_header->body.padding.horizontal, 0);
|
||||
}
|
||||
|
||||
lv_obj_set_pos_us(ext->header, 0, 0);
|
||||
lv_obj_set_pos_scale(ext->header, 0, 0);
|
||||
|
||||
lv_obj_t * page = lv_win_get_page(win);
|
||||
lv_obj_set_size(page, lv_obj_get_width(win), lv_obj_get_height(win) - lv_obj_get_height(ext->header));
|
||||
|
@ -17,7 +17,7 @@ extern "C" {
|
||||
#if USE_LV_WIN != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if USE_LV_BTN == 0
|
||||
#if USE_LV_BUTTON == 0
|
||||
#error "lv_win: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user