Merge beta to release v4.0
This commit is contained in:
@@ -177,6 +177,7 @@ static void dispi_proc_point(lv_dispi_t * dispi_p, cord_t x, cord_t y)
|
||||
if(lv_dispi_reset_now != false) {
|
||||
dispi_p->act_obj = NULL;
|
||||
dispi_p->last_obj = NULL;
|
||||
dispi_p->drag_range_out = 0;
|
||||
dispi_p->drag_in_prog = 0;
|
||||
dispi_p->long_press_sent = 0;
|
||||
dispi_p->press_time_stamp = 0;
|
||||
@@ -188,10 +189,10 @@ static void dispi_proc_point(lv_dispi_t * dispi_p, cord_t x, cord_t y)
|
||||
if(dispi_p->pressed != false){
|
||||
#if LV_DISPI_TP_MARKER != 0
|
||||
area_t area;
|
||||
area.x1 = x;
|
||||
area.y1 = y;
|
||||
area.x2 = x + 1;
|
||||
area.y2 = y + 1;
|
||||
area.x1 = x - (LV_DISPI_TP_MARKER >> 1);
|
||||
area.y1 = y - (LV_DISPI_TP_MARKER >> 1);
|
||||
area.x2 = x + ((LV_DISPI_TP_MARKER >> 1) | 0x1);
|
||||
area.y2 = y + ((LV_DISPI_TP_MARKER >> 1) | 0x1);
|
||||
lv_rfill(&area, NULL, COLOR_MAKE(0xFF, 0, 0), OPA_COVER);
|
||||
#endif
|
||||
dispi_proc_press(dispi_p);
|
||||
@@ -218,8 +219,8 @@ static void dispi_proc_press(lv_dispi_t * dispi_p)
|
||||
if(dispi_p->act_obj == NULL) {
|
||||
pr_obj = dispi_search_obj(dispi_p, lv_scr_act());
|
||||
}
|
||||
/*If there is last object but it can not be dragged also search*/
|
||||
else if(lv_obj_get_drag(dispi_p->act_obj) == false) {/*Now act_obj != NULL*/
|
||||
/*If there is last object but it is not dragged also search*/
|
||||
else if(dispi_p->drag_in_prog == 0) {/*Now act_obj != NULL*/
|
||||
pr_obj = dispi_search_obj(dispi_p, lv_scr_act());
|
||||
}
|
||||
/*If a dragable object was the last then keep it*/
|
||||
@@ -244,6 +245,7 @@ static void dispi_proc_press(lv_dispi_t * dispi_p)
|
||||
* It is necessary to count the long press time.*/
|
||||
dispi_p->press_time_stamp = systick_get();
|
||||
dispi_p->long_press_sent = 0;
|
||||
dispi_p->drag_range_out = 0;
|
||||
dispi_p->drag_in_prog = 0;
|
||||
dispi_p->vect_sum.x = 0;
|
||||
dispi_p->vect_sum.y = 0;
|
||||
@@ -402,7 +404,7 @@ static void dispi_drag(lv_dispi_t * dispi_p)
|
||||
if(lv_obj_get_drag(drag_obj) == false) return;
|
||||
|
||||
/*If still there is no drag then count the movement*/
|
||||
if(dispi_p->drag_in_prog == 0) {
|
||||
if(dispi_p->drag_range_out == 0) {
|
||||
dispi_p->vect_sum.x += dispi_p->vect.x;
|
||||
dispi_p->vect_sum.y += dispi_p->vect.y;
|
||||
|
||||
@@ -410,21 +412,29 @@ static void dispi_drag(lv_dispi_t * dispi_p)
|
||||
if(MATH_ABS(dispi_p->vect_sum.x) >= LV_DISPI_DRAG_LIMIT ||
|
||||
MATH_ABS(dispi_p->vect_sum.y) >= LV_DISPI_DRAG_LIMIT)
|
||||
{
|
||||
dispi_p->drag_in_prog = 1;
|
||||
drag_obj->signal_f(drag_obj,
|
||||
LV_SIGNAL_DRAG_BEGIN, dispi_p);
|
||||
dispi_p->drag_range_out = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*If the drag limit is stepped over then handle the dragging*/
|
||||
if(dispi_p->drag_in_prog != 0) {
|
||||
if(dispi_p->drag_range_out != 0) {
|
||||
/*Set new position if the vector is not zero*/
|
||||
if(dispi_p->vect.x != 0 ||
|
||||
dispi_p->vect.y != 0) {
|
||||
/*Get the coordinates of the object end modify them*/
|
||||
cord_t act_x = lv_obj_get_x(drag_obj) + dispi_p->vect.x;
|
||||
cord_t act_y = lv_obj_get_y(drag_obj) + dispi_p->vect.y;
|
||||
lv_obj_set_pos(drag_obj, act_x, act_y);
|
||||
cord_t act_x = lv_obj_get_x(drag_obj);
|
||||
cord_t act_y = lv_obj_get_y(drag_obj);
|
||||
|
||||
lv_obj_set_pos(drag_obj, act_x + dispi_p->vect.x, act_y + dispi_p->vect.y);
|
||||
|
||||
/*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(dispi_p->drag_range_out != 0) { /*Send the drag begin signal on first move*/
|
||||
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_BEGIN, dispi_p);
|
||||
}
|
||||
dispi_p->drag_in_prog = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ typedef struct
|
||||
uint32_t lpr_rep_time_stamp;
|
||||
|
||||
/*Flags*/
|
||||
uint8_t drag_range_out :1;
|
||||
uint8_t drag_in_prog :1;
|
||||
uint8_t long_press_sent :1;
|
||||
uint8_t wait_release :1;
|
||||
@@ -39,8 +40,8 @@ typedef struct
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_ACTION_RES_INV = 0,
|
||||
LV_ACTION_RES_OK,
|
||||
LV_ACTION_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action function*/
|
||||
LV_ACTION_RES_OK, /*The object is valid (no deleted) after the action*/
|
||||
}lv_action_res_t;
|
||||
|
||||
typedef lv_action_res_t ( * lv_action_t) (struct __LV_OBJ_T * obj, lv_dispi_t * dispi);
|
||||
|
||||
299
lv_obj/lv_obj.c
299
lv_obj/lv_obj.c
@@ -7,13 +7,14 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include <lv_conf.h>
|
||||
#include <lvgl/lv_draw/lv_draw_rbasic.h>
|
||||
#include <lvgl/lv_draw/lv_draw_vbasic.h>
|
||||
#include <lvgl/lv_misc/anim.h>
|
||||
#include <lvgl/lv_obj/lv_dispi.h>
|
||||
#include <lvgl/lv_obj/lv_obj.h>
|
||||
#include <lvgl/lv_obj/lv_refr.h>
|
||||
#include "lv_conf.h"
|
||||
#include "lvgl/lv_draw/lv_draw.h"
|
||||
#include "lvgl/lv_obj/lv_dispi.h"
|
||||
#include "lvgl/lv_obj/lv_obj.h"
|
||||
#include "lvgl/lv_obj/lv_refr.h"
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
#include "lvgl/lv_draw/lv_draw_rbasic.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -34,6 +35,7 @@
|
||||
**********************/
|
||||
static void lv_obj_pos_child_refr(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 bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode_t mode);
|
||||
|
||||
@@ -44,11 +46,6 @@ static lv_obj_t * def_scr = NULL;
|
||||
static lv_obj_t * act_scr = NULL;
|
||||
static ll_dsc_t scr_ll;
|
||||
|
||||
static lv_objs_t lv_objs_def = {.color = COLOR_MAKE(0xa0, 0xc0, 0xe0), .transp = 0};
|
||||
static lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR, .transp = 0};
|
||||
static lv_objs_t lv_objs_transp = {.transp = 1};
|
||||
|
||||
|
||||
#ifdef LV_IMG_DEF_WALLPAPER
|
||||
LV_IMG_DECLARE(LV_IMG_DEF_WALLPAPER);
|
||||
#endif
|
||||
@@ -70,12 +67,12 @@ void lv_init(void)
|
||||
area_t scr_area;
|
||||
area_set(&scr_area, 0, 0, LV_HOR_RES, LV_VER_RES);
|
||||
lv_rfill(&scr_area, NULL, COLOR_BLACK, OPA_COVER);
|
||||
|
||||
/*Init. the sstyles*/
|
||||
lv_style_init();
|
||||
|
||||
/*Init. the screen refresh system*/
|
||||
lv_refr_init();
|
||||
|
||||
/*Init. the animations*/
|
||||
anim_init();
|
||||
|
||||
/*Create the default screen*/
|
||||
ll_init(&scr_ll, sizeof(lv_obj_t));
|
||||
@@ -84,6 +81,7 @@ void lv_init(void)
|
||||
def_scr = lv_img_create(NULL, NULL);
|
||||
lv_img_set_auto_size(def_scr, false);
|
||||
lv_img_set_file(def_scr, "U:/def_wp");
|
||||
lv_img_set_upscale(def_scr, true);
|
||||
#else
|
||||
def_scr = lv_obj_create(NULL, NULL);
|
||||
#endif
|
||||
@@ -133,15 +131,16 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Set appearance*/
|
||||
new_obj->style_p = lv_objs_get(LV_OBJS_SCR, NULL);
|
||||
new_obj->opa = OPA_COVER;
|
||||
new_obj->style_p = lv_style_get(LV_STYLE_SCR, NULL);
|
||||
|
||||
/*Set virtual functions*/
|
||||
lv_obj_set_signal_f(new_obj, lv_obj_signal);
|
||||
lv_obj_set_design_f(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;
|
||||
#endif
|
||||
@@ -151,7 +150,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->drag_en = 0;
|
||||
new_obj->drag_throw_en = 0;
|
||||
new_obj->drag_parent = 0;
|
||||
new_obj->style_iso = 0;
|
||||
new_obj->hidden = 0;
|
||||
new_obj->top_en = 0;
|
||||
new_obj->protect = LV_PROTECT_NONE;
|
||||
@@ -176,15 +174,16 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Set appearance*/
|
||||
new_obj->style_p = lv_objs_get(LV_OBJS_DEF, NULL);
|
||||
new_obj->opa = OPA_COVER;
|
||||
new_obj->style_p = lv_style_get(LV_STYLE_PLAIN, NULL);
|
||||
|
||||
/*Set virtual functions*/
|
||||
lv_obj_set_signal_f(new_obj, lv_obj_signal);
|
||||
lv_obj_set_design_f(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;
|
||||
#endif
|
||||
@@ -194,7 +193,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
new_obj->drag_en = 0;
|
||||
new_obj->drag_throw_en = 0;
|
||||
new_obj->drag_parent = 0;
|
||||
new_obj->style_iso = 0;
|
||||
new_obj->hidden = 0;
|
||||
new_obj->top_en = 0;
|
||||
new_obj->protect = LV_PROTECT_NONE;
|
||||
@@ -207,10 +205,10 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
area_cpy(&new_obj->cords, ©->cords);
|
||||
new_obj->ext_size = copy->ext_size;
|
||||
|
||||
new_obj->opa = copy->opa;
|
||||
|
||||
/*Set free data*/
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
new_obj->free_num = copy->free_num;
|
||||
#endif
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
new_obj->free_p = copy->free_p;
|
||||
#endif
|
||||
@@ -225,10 +223,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
|
||||
new_obj->style_p = copy->style_p;
|
||||
|
||||
if(copy->style_iso != 0) {
|
||||
lv_obj_iso_style(new_obj, dm_get_size(copy->style_p));
|
||||
}
|
||||
|
||||
lv_obj_set_pos(new_obj, lv_obj_get_x(copy), lv_obj_get_y(copy));
|
||||
}
|
||||
|
||||
@@ -246,7 +240,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
|
||||
|
||||
/**
|
||||
* Delete 'obj' and all of its children
|
||||
* @param obj
|
||||
* @param obj pointer to an object to delete
|
||||
*/
|
||||
void lv_obj_del(lv_obj_t * obj)
|
||||
{
|
||||
@@ -284,7 +278,6 @@ void lv_obj_del(lv_obj_t * obj)
|
||||
|
||||
/*Delete the base objects*/
|
||||
if(obj->ext != NULL) dm_free(obj->ext);
|
||||
if(obj->style_iso != 0) dm_free(obj->style_p);
|
||||
dm_free(obj); /*Free the object itself*/
|
||||
|
||||
/* Reset all display input (dispi) because
|
||||
@@ -308,50 +301,25 @@ bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
{
|
||||
bool valid = true;
|
||||
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CHILD_CHG:
|
||||
/*Return 'invalid' if the child change signal is not enabled*/
|
||||
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) valid = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case LV_SIGNAL_CHILD_CHG:
|
||||
/*Return 'invalid' if the child change signal is not enabled*/
|
||||
if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) valid = false;
|
||||
break;
|
||||
case LV_SIGNAL_REFR_EXT_SIZE:
|
||||
if(style->swidth > obj->ext_size) obj->ext_size = style->swidth;
|
||||
break;
|
||||
case LV_SIGNAL_STYLE_CHG:
|
||||
lv_obj_refr_ext_size(obj);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with a pointer to built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_objs_builtin_t enum
|
||||
* @param copy_p copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_objs_t style
|
||||
*/
|
||||
lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p)
|
||||
{
|
||||
lv_objs_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
case LV_OBJS_DEF:
|
||||
style_p = &lv_objs_def;
|
||||
break;
|
||||
case LV_OBJS_SCR:
|
||||
style_p = &lv_objs_scr;
|
||||
break;
|
||||
case LV_OBJS_TRANSP:
|
||||
style_p = &lv_objs_transp;
|
||||
break;
|
||||
default:
|
||||
style_p = NULL;
|
||||
}
|
||||
|
||||
if(copy_p != NULL) {
|
||||
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_objs_t));
|
||||
else memcpy(copy_p, &lv_objs_def, sizeof(lv_objs_t));
|
||||
}
|
||||
|
||||
return style_p;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
@@ -489,7 +457,7 @@ void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y)
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent).
|
||||
* The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @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)
|
||||
@@ -511,7 +479,7 @@ void lv_obj_set_x(lv_obj_t * obj, cord_t x)
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object.
|
||||
* The coordinate will be upscaled to compensate LV_DOWNSCALE.
|
||||
* The coordinate will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
@@ -532,7 +500,7 @@ void lv_obj_set_y(lv_obj_t * obj, cord_t y)
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object.
|
||||
* The coordinate will be upscaled to compensate LV_DOWNSCALE.
|
||||
* The coordinate will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
@@ -581,7 +549,7 @@ void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of an object. The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* Set the size of an object. The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
@@ -602,7 +570,7 @@ void lv_obj_set_width(lv_obj_t * obj, cord_t w)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of an object. The width will be upscaled to compensate LV_DOWNSCALE
|
||||
* Set the width of an object. The width will be upscaled with LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
@@ -622,7 +590,7 @@ void lv_obj_set_height(lv_obj_t * obj, cord_t h)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of an object. The height will be upscaled to compensate LV_DOWNSCALE
|
||||
* Set the height of an object. The height will be upscaled with LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
@@ -770,7 +738,7 @@ void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod
|
||||
|
||||
|
||||
/**
|
||||
* Align an object to an other object. The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* Align an object to an other object. The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
@@ -803,76 +771,15 @@ void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size)
|
||||
* @param obj pointer to an object
|
||||
* @param style_p pointer to the new style
|
||||
*/
|
||||
void lv_obj_set_style(lv_obj_t * obj, void * style)
|
||||
void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style)
|
||||
{
|
||||
lv_obj_inv(obj);
|
||||
|
||||
if(obj->style_iso != 0) {
|
||||
dm_free(obj->style_p);
|
||||
obj->style_iso = 0;
|
||||
}
|
||||
obj->style_p = style;
|
||||
|
||||
/*Send a style change signal to the object*/
|
||||
lv_obj_refr_style(obj);
|
||||
/*Send a signal about style change to every children with NULL style*/
|
||||
lv_child_refr_style(obj);
|
||||
|
||||
lv_obj_inv(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Isolate the style of an object. In other words a unique style will be created
|
||||
* for this object which can be freely modified independently from the style of the
|
||||
* other objects.
|
||||
*/
|
||||
void * lv_obj_iso_style(lv_obj_t * obj, uint32_t style_size)
|
||||
{
|
||||
if(obj->style_iso != 0) return obj->style_p;
|
||||
|
||||
void * ori_style_p = lv_obj_get_style(obj);
|
||||
void * iso_style = dm_alloc(style_size);
|
||||
dm_assert(iso_style);
|
||||
memcpy(iso_style, ori_style_p, style_size);
|
||||
|
||||
obj->style_iso = 1;
|
||||
obj->style_p = iso_style;
|
||||
|
||||
lv_obj_refr_style(obj);
|
||||
|
||||
return obj->style_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opacity of an object
|
||||
* @param obj pointer to an object
|
||||
* @param opa 0 (transparent) .. 255(fully cover)
|
||||
*/
|
||||
void lv_obj_set_opa(lv_obj_t * obj, uint8_t opa)
|
||||
{
|
||||
obj->opa = opa;
|
||||
|
||||
lv_obj_inv(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opacity of an object and all of its children
|
||||
* @param obj pointer to an object
|
||||
* @param opa 0 (transparent) .. 255(fully cover)
|
||||
*/
|
||||
void lv_obj_set_opar(lv_obj_t * obj, uint8_t opa)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
|
||||
LL_READ(obj->child_ll, i) {
|
||||
lv_obj_set_opar(i, opa);
|
||||
}
|
||||
|
||||
/*Set the opacity is the object is not protected*/
|
||||
if(lv_obj_is_protected(obj, LV_PROTECT_OPA) == false) obj->opa = opa;
|
||||
|
||||
lv_obj_inv(obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
@@ -887,10 +794,10 @@ void lv_obj_refr_style(lv_obj_t * obj)
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pinter to a style. Only objects with this style will be notified
|
||||
* @param style pointer to a style. Only the objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_style_refr_all(void * style)
|
||||
void lv_style_refr_objs(void * style)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LL_READ(scr_ll, i) {
|
||||
@@ -1042,6 +949,7 @@ void lv_obj_refr_ext_size(lv_obj_t * obj)
|
||||
lv_obj_inv(obj);
|
||||
}
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
/**
|
||||
* Set an application specific number for an object.
|
||||
* It can help to identify objects in the application.
|
||||
@@ -1052,6 +960,7 @@ void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num)
|
||||
{
|
||||
obj->free_num = free_num;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
/**
|
||||
@@ -1115,11 +1024,6 @@ void lv_obj_anim(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t
|
||||
a.start = lv_obj_get_height(par);
|
||||
a.end = lv_obj_get_y(obj);
|
||||
break;
|
||||
case LV_ANIM_FADE:
|
||||
a.fp = (void(*)(void * , int32_t))lv_obj_set_opar;
|
||||
a.start = OPA_TRANSP;
|
||||
a.end = OPA_COVER;
|
||||
break;
|
||||
case LV_ANIM_GROW_H:
|
||||
a.fp = (void(*)(void * , int32_t))lv_obj_set_width;
|
||||
a.start = 0;
|
||||
@@ -1300,7 +1204,7 @@ cord_t lv_obj_get_height(lv_obj_t * obj)
|
||||
* @param obj pointer to an object
|
||||
* @return the extended size attribute
|
||||
*/
|
||||
cord_t lv_obj_getext_size(lv_obj_t * obj)
|
||||
cord_t lv_obj_get_ext_size(lv_obj_t * obj)
|
||||
{
|
||||
return obj->ext_size;
|
||||
}
|
||||
@@ -1310,23 +1214,26 @@ cord_t lv_obj_getext_size(lv_obj_t * obj)
|
||||
*---------------*/
|
||||
|
||||
/**
|
||||
* Get the style pointer of an object
|
||||
* Get the style pointer of an object (if NULL get style of the parent)
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a style
|
||||
*/
|
||||
void * lv_obj_get_style(lv_obj_t * obj)
|
||||
lv_style_t * lv_obj_get_style(lv_obj_t * obj)
|
||||
{
|
||||
return obj->style_p;
|
||||
}
|
||||
if(obj->style_p != NULL) return obj->style_p;
|
||||
else {
|
||||
lv_obj_t * par = obj->par;
|
||||
|
||||
/**
|
||||
* Get the opacity of an object
|
||||
* @param obj pointer to an object
|
||||
* @return 0 (transparent) .. 255 (fully cover)
|
||||
*/
|
||||
opa_t lv_obj_get_opa(lv_obj_t * obj)
|
||||
{
|
||||
return obj->opa;
|
||||
while(par != NULL) {
|
||||
if(par->style_p != NULL) {
|
||||
if(par->style_p->glass == 0) return par->style_p;
|
||||
}
|
||||
par = par->par;
|
||||
}
|
||||
}
|
||||
|
||||
/*Never reach this, at least the screen has to be a style*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*-----------------
|
||||
@@ -1393,16 +1300,6 @@ bool lv_obj_get_drag_parent(lv_obj_t * obj)
|
||||
return obj->drag_parent == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style isolation attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a style
|
||||
*/
|
||||
bool lv_obj_get_style_iso(lv_obj_t * obj)
|
||||
{
|
||||
return obj->style_iso == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the protect field of an object
|
||||
* @param obj pointer to an object
|
||||
@@ -1460,7 +1357,7 @@ void * lv_obj_get_ext(lv_obj_t * obj)
|
||||
return obj->ext;
|
||||
}
|
||||
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
/**
|
||||
* Get the free number
|
||||
* @param obj pointer to an object
|
||||
@@ -1470,6 +1367,7 @@ uint8_t lv_obj_get_free_num(lv_obj_t * obj)
|
||||
{
|
||||
return obj->free_num;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
/**
|
||||
@@ -1499,21 +1397,33 @@ void * lv_obj_get_free_p(lv_obj_t * obj)
|
||||
static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
bool cover;
|
||||
cover = area_is_in(mask_p, &obj->cords);
|
||||
return cover;
|
||||
|
||||
/* Because of the radius it is not sure the area is covered
|
||||
* Check the areas where there is no radius*/
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->empty != 0) return false;
|
||||
|
||||
uint16_t r = style->radius;
|
||||
|
||||
if(r == LV_RADIUS_CIRCLE) return false;
|
||||
|
||||
area_t area_tmp;
|
||||
|
||||
/*Check horizontally without radius*/
|
||||
lv_obj_get_cords(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);
|
||||
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_objs_t * objs_p = lv_obj_get_style(obj);
|
||||
|
||||
opa_t opa = lv_obj_get_opa(obj);
|
||||
color_t color = objs_p->color;
|
||||
|
||||
/*Simply draw a rectangle*/
|
||||
#if LV_VDB_SIZE == 0
|
||||
lv_rfill(&obj->cords, mask_p, color, opa);
|
||||
#else
|
||||
lv_vfill(&obj->cords, mask_p, color, opa);
|
||||
#endif
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
lv_draw_rect(&obj->cords, mask_p, style);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1555,6 +1465,26 @@ static void lv_style_refr_core(void * style_p, lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recursively refresh the style of the children. Go deeper until a not NULL style is found
|
||||
* 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)
|
||||
{
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
while(child != NULL) {
|
||||
if(child->style_p == NULL) {
|
||||
lv_child_refr_style(child);
|
||||
}
|
||||
child = lv_obj_get_child(obj, child);
|
||||
}
|
||||
|
||||
/*Send a style change signal to the object*/
|
||||
lv_obj_refr_style(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by 'lv_obj_del' to delete the children objects
|
||||
* @param obj pointer to an object (all of its children will be deleted)
|
||||
@@ -1589,9 +1519,6 @@ static void lv_obj_del_child(lv_obj_t * obj)
|
||||
|
||||
/*Delete the base objects*/
|
||||
if(obj->ext != NULL) dm_free(obj->ext);
|
||||
if(obj->style_iso != 0) dm_free(obj->style_p);
|
||||
dm_free(obj); /*Free the object itself*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
191
lv_obj/lv_obj.h
191
lv_obj/lv_obj.h
@@ -9,16 +9,19 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <lvgl/lv_misc/area.h>
|
||||
#include "lv_conf.h"
|
||||
#include <misc/gfx/area.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "misc/mem/dyn_mem.h"
|
||||
#include "misc/mem/linked_list.h"
|
||||
#include "misc/others/color.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*Error check of lv_conf.h*/
|
||||
#if LV_HOR_RES == 0 || LV_VER_RES == 0
|
||||
#error "LV: LV_HOR_RES and LV_VER_RES must be greater then 0"
|
||||
@@ -76,39 +79,37 @@ typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void
|
||||
|
||||
typedef struct __LV_OBJ_T
|
||||
{
|
||||
struct __LV_OBJ_T * par;
|
||||
ll_dsc_t child_ll;
|
||||
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;
|
||||
area_t cords; /*Coordinates of the object (x1, y1, x2, y2)*/
|
||||
|
||||
lv_signal_f_t signal_f;
|
||||
lv_design_f_t design_f;
|
||||
lv_signal_f_t signal_f; /*Object type specific signal function*/
|
||||
lv_design_f_t design_f; /*Object type specific design function*/
|
||||
|
||||
void * ext; /*The object attributes can be extended here*/
|
||||
void * style_p; /*Object specific style*/
|
||||
void * ext; /*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)*/
|
||||
void * free_p; /*Application specific pointer (set it freely)*/
|
||||
#endif
|
||||
|
||||
/*Attributes and states*/
|
||||
uint8_t click_en :1; /*1: can be pressed by a display input device*/
|
||||
uint8_t drag_en :1; /*1: enable the dragging*/
|
||||
uint8_t click_en :1; /*1: Can be pressed by a display input device*/
|
||||
uint8_t drag_en :1; /*1: Enable the dragging*/
|
||||
uint8_t drag_throw_en:1; /*1: Enable throwing with drag*/
|
||||
uint8_t drag_parent :1; /*1. Parent will be dragged instead*/
|
||||
uint8_t style_iso :1; /*1: The object has got an own style*/
|
||||
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_en :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. Used to draw shadow, shine etc.*/
|
||||
cord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
uint8_t free_num; /*Application specific identifier (set it freely)*/
|
||||
opa_t opa;
|
||||
|
||||
|
||||
#endif
|
||||
}lv_obj_t;
|
||||
|
||||
/*Protect some attributes (max. 8 bit)*/
|
||||
@@ -116,54 +117,45 @@ typedef enum
|
||||
{
|
||||
LV_PROTECT_NONE = 0x00,
|
||||
LV_PROTECT_CHILD_CHG = 0x01, /*Disable the child change signal. Used by the library*/
|
||||
LV_PROTECT_OPA = 0x02, /*Prevent lv_obj_set_opar to modify the opacity*/
|
||||
LV_PROTECT_PARENT = 0x04, /*Prevent automatic parent change (e.g. in lv_page)*/
|
||||
LV_PROTECT_POS = 0x08, /*Prevent automatic positioning (e.g. in lv_rect layout)*/
|
||||
LV_PROTECT_PARENT = 0x02, /*Prevent automatic parent change (e.g. in lv_page)*/
|
||||
LV_PROTECT_POS = 0x04, /*Prevent automatic positioning (e.g. in lv_rect layout)*/
|
||||
}lv_protect_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_ALIGN_CENTER = 0,
|
||||
LV_ALIGN_IN_TOP_LEFT,
|
||||
LV_ALIGN_IN_TOP_MID,
|
||||
LV_ALIGN_IN_TOP_RIGHT,
|
||||
LV_ALIGN_IN_BOTTOM_LEFT,
|
||||
LV_ALIGN_IN_BOTTOM_MID,
|
||||
LV_ALIGN_IN_BOTTOM_RIGHT,
|
||||
LV_ALIGN_IN_LEFT_MID,
|
||||
LV_ALIGN_IN_RIGHT_MID,
|
||||
LV_ALIGN_OUT_TOP_LEFT,
|
||||
LV_ALIGN_OUT_TOP_MID,
|
||||
LV_ALIGN_OUT_TOP_RIGHT,
|
||||
LV_ALIGN_OUT_BOTTOM_LEFT,
|
||||
LV_ALIGN_OUT_BOTTOM_MID,
|
||||
LV_ALIGN_OUT_BOTTOM_RIGHT,
|
||||
LV_ALIGN_OUT_LEFT_TOP,
|
||||
LV_ALIGN_OUT_LEFT_MID,
|
||||
LV_ALIGN_OUT_LEFT_BOTTOM,
|
||||
LV_ALIGN_OUT_RIGHT_TOP,
|
||||
LV_ALIGN_OUT_RIGHT_MID,
|
||||
LV_ALIGN_OUT_RIGHT_BOTTOM,
|
||||
LV_ALIGN_IN_TOP_LEFT,
|
||||
LV_ALIGN_IN_TOP_MID,
|
||||
LV_ALIGN_IN_TOP_RIGHT,
|
||||
LV_ALIGN_IN_BOTTOM_LEFT,
|
||||
LV_ALIGN_IN_BOTTOM_MID,
|
||||
LV_ALIGN_IN_BOTTOM_RIGHT,
|
||||
LV_ALIGN_IN_LEFT_MID,
|
||||
LV_ALIGN_IN_RIGHT_MID,
|
||||
LV_ALIGN_OUT_TOP_LEFT,
|
||||
LV_ALIGN_OUT_TOP_MID,
|
||||
LV_ALIGN_OUT_TOP_RIGHT,
|
||||
LV_ALIGN_OUT_BOTTOM_LEFT,
|
||||
LV_ALIGN_OUT_BOTTOM_MID,
|
||||
LV_ALIGN_OUT_BOTTOM_RIGHT,
|
||||
LV_ALIGN_OUT_LEFT_TOP,
|
||||
LV_ALIGN_OUT_LEFT_MID,
|
||||
LV_ALIGN_OUT_LEFT_BOTTOM,
|
||||
LV_ALIGN_OUT_RIGHT_TOP,
|
||||
LV_ALIGN_OUT_RIGHT_MID,
|
||||
LV_ALIGN_OUT_RIGHT_BOTTOM,
|
||||
}lv_align_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
color_t color;
|
||||
uint8_t transp :1;
|
||||
opa_t opa;
|
||||
}lv_objs_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_OBJS_DEF,
|
||||
LV_OBJS_SCR,
|
||||
LV_OBJS_TRANSP,
|
||||
}lv_objs_builtin_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_ANIM_NONE = 0,
|
||||
LV_ANIM_FADE, /*Animate the opacity*/
|
||||
LV_ANIM_FLOAT_TOP, /*Float from/to the top*/
|
||||
LV_ANIM_FLOAT_LEFT, /*Float from/to the left*/
|
||||
LV_ANIM_FLOAT_BOTTOM, /*Float from/to the bottom*/
|
||||
@@ -181,25 +173,6 @@ typedef enum
|
||||
*/
|
||||
void lv_init(void);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pinter to a style. Only objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_style_refr_all(void * style);
|
||||
|
||||
/**
|
||||
* Create a basic object
|
||||
* @param parent pointer to a parent object.
|
||||
@@ -211,7 +184,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy);
|
||||
|
||||
/**
|
||||
* Delete 'obj' and all of its children
|
||||
* @param obj
|
||||
* @param obj pointer to an object to delete
|
||||
*/
|
||||
void lv_obj_del(lv_obj_t * obj);
|
||||
|
||||
@@ -225,12 +198,10 @@ void lv_obj_del(lv_obj_t * obj);
|
||||
bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
/**
|
||||
* Return with a pointer to built-in style and/or copy it to a variable
|
||||
* @param style a style name from lv_objs_builtin_t enum
|
||||
* @param copy_p copy the style to this variable. (NULL if unused)
|
||||
* @return pointer to an lv_objs_t style
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p);
|
||||
void lv_obj_inv(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Load a new screen
|
||||
@@ -255,7 +226,7 @@ void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent).
|
||||
* The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @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)
|
||||
@@ -271,7 +242,7 @@ void lv_obj_set_x(lv_obj_t * obj, cord_t x);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object.
|
||||
* The coordinate will be upscaled to compensate LV_DOWNSCALE.
|
||||
* The coordinate will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
@@ -286,7 +257,7 @@ void lv_obj_set_y(lv_obj_t * obj, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object.
|
||||
* The coordinate will be upscaled to compensate LV_DOWNSCALE.
|
||||
* The coordinate will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
@@ -301,7 +272,7 @@ void lv_obj_set_y_us(lv_obj_t * obj, cord_t y);
|
||||
void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the size of an object. The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* Set the size of an object. The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
@@ -316,7 +287,7 @@ void lv_obj_set_size_us(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
void lv_obj_set_width(lv_obj_t * obj, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the width of an object. The width will be upscaled to compensate LV_DOWNSCALE
|
||||
* Set the width of an object. The width will be upscaled with LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
@@ -330,7 +301,7 @@ void lv_obj_set_width_us(lv_obj_t * obj, cord_t w);
|
||||
void lv_obj_set_height(lv_obj_t * obj, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the height of an object. The height will be upscaled to compensate LV_DOWNSCALE
|
||||
* Set the height of an object. The height will be upscaled with LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
@@ -347,7 +318,7 @@ void lv_obj_set_height_us(lv_obj_t * obj, cord_t h);
|
||||
void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
|
||||
/**
|
||||
* Align an object to an other object. The coordinates will be upscaled to compensate LV_DOWNSCALE.
|
||||
* Align an object to an other object. The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
@@ -368,28 +339,20 @@ void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size);
|
||||
* @param obj pointer to an object
|
||||
* @param style_p pointer to the new style
|
||||
*/
|
||||
void lv_obj_set_style(lv_obj_t * obj, void * style);
|
||||
void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Isolate the style of an object. In other words a unique style will be created
|
||||
* for this object which can be freely modified independently from the style of the
|
||||
* other objects.
|
||||
*/
|
||||
void * lv_obj_iso_style(lv_obj_t * obj, uint32_t style_size);
|
||||
|
||||
/**
|
||||
* Set the opacity of an object
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
* @param opa 0 (transparent) .. 255(fully cover)
|
||||
*/
|
||||
void lv_obj_set_opa(lv_obj_t * obj, uint8_t opa);
|
||||
void lv_obj_refr_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Set the opacity of an object and all of its children
|
||||
* @param obj pointer to an object
|
||||
* @param opa 0 (transparent) .. 255(fully cover)
|
||||
* Notify all object if a style is modified
|
||||
* @param style pointer to a style. Only the objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_obj_set_opar(lv_obj_t * obj, uint8_t opa);
|
||||
void lv_style_refr_objs(void * style);
|
||||
|
||||
/**
|
||||
* Hide an object. It won't be visible and clickable.
|
||||
@@ -478,6 +441,7 @@ void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size);
|
||||
*/
|
||||
void lv_obj_refr_ext_size(lv_obj_t * obj);
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
/**
|
||||
* Set an application specific number for an object.
|
||||
* It can help to identify objects in the application.
|
||||
@@ -485,7 +449,9 @@ void lv_obj_refr_ext_size(lv_obj_t * obj);
|
||||
* @param free_num the new free number
|
||||
*/
|
||||
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
/**
|
||||
* Set an application specific pointer for an object.
|
||||
* It can help to identify objects in the application.
|
||||
@@ -493,7 +459,7 @@ void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
|
||||
* @param free_p the new free pinter
|
||||
*/
|
||||
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Animate an object
|
||||
* @param obj pointer to an object to animate
|
||||
@@ -580,21 +546,14 @@ cord_t lv_obj_get_height(lv_obj_t * obj);
|
||||
* @param obj pointer to an object
|
||||
* @return the extended size attribute
|
||||
*/
|
||||
cord_t lv_obj_getext_size(lv_obj_t * obj);
|
||||
cord_t lv_obj_get_ext_size(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the style pointer of an object
|
||||
* Get the style pointer of an object (if NULL get style of the parent)
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a style
|
||||
*/
|
||||
void * lv_obj_get_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the opacity of an object
|
||||
* @param obj pointer to an object
|
||||
* @return 0 (transparent) .. 255 (fully cover)
|
||||
*/
|
||||
opa_t lv_obj_get_opa(lv_obj_t * obj);
|
||||
lv_style_t * lv_obj_get_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the hidden attribute of an object
|
||||
@@ -638,13 +597,6 @@ bool lv_obj_get_drag_throw(lv_obj_t * obj);
|
||||
*/
|
||||
bool lv_obj_get_drag_parent(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the style isolation attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a style
|
||||
*/
|
||||
bool lv_obj_get_style_iso(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the protect field of an object
|
||||
* @param obj pointer to an object
|
||||
@@ -682,25 +634,26 @@ lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj);
|
||||
*/
|
||||
void * lv_obj_get_ext(lv_obj_t * obj);
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
/**
|
||||
* Get the free number
|
||||
* @param obj pointer to an object
|
||||
* @return the free number
|
||||
*/
|
||||
uint8_t lv_obj_get_free_num(lv_obj_t * obj);
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 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);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define LV_SA(obj, style_type) ((style_type *) obj->style_p)
|
||||
#define LV_EA(obj, ext_type) ((ext_type *) obj->ext)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,8 +45,8 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
lv_join_t inv_buf[LV_INV_FIFO_SIZE];
|
||||
uint16_t inv_buf_p;
|
||||
static lv_join_t inv_buf[LV_INV_FIFO_SIZE];
|
||||
static uint16_t inv_buf_p;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@@ -76,6 +76,12 @@ void lv_refr_init(void)
|
||||
*/
|
||||
void lv_inv_area(const area_t * area_p)
|
||||
{
|
||||
/*Clear the invalidate buffer if the parameter is NULL*/
|
||||
if(area_p == NULL) {
|
||||
inv_buf_p = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
area_t scr_area;
|
||||
scr_area.x1 = 0;
|
||||
scr_area.y1 = 0;
|
||||
@@ -224,12 +230,12 @@ static void lv_refr_area_with_vdb(const area_t * area_p)
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Always use the full row*/
|
||||
vdb_p->vdb_area.x1 = area_p->x1;
|
||||
vdb_p->vdb_area.y1 = area_p->y1;
|
||||
vdb_p->vdb_area.x2 = area_p->x2;
|
||||
vdb_p->area.x1 = area_p->x1;
|
||||
vdb_p->area.y1 = area_p->y1;
|
||||
vdb_p->area.x2 = area_p->x2;
|
||||
|
||||
/*Calculate the max row num*/
|
||||
uint32_t max_row = (uint32_t) LV_VDB_SIZE / (vdb_p->vdb_area.x2 - vdb_p->vdb_area.x1 + 1);
|
||||
uint32_t max_row = (uint32_t) LV_VDB_SIZE / (vdb_p->area.x2 - vdb_p->area.x1 + 1);
|
||||
if(max_row > area_get_height(area_p)) max_row = area_get_height(area_p);
|
||||
|
||||
/*Round the row number with downscale*/
|
||||
@@ -242,17 +248,17 @@ static void lv_refr_area_with_vdb(const area_t * area_p)
|
||||
|
||||
for(row = area_p->y1; row + max_row - 1 <= area_p->y2; row += max_row) {
|
||||
/*Calc. the next y coordinates of VDB*/
|
||||
vdb_p->vdb_area.y1 = row;
|
||||
vdb_p->vdb_area.y2 = row + max_row - 1;
|
||||
vdb_p->area.y1 = row;
|
||||
vdb_p->area.y2 = row + max_row - 1;
|
||||
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
}
|
||||
|
||||
/*If the last y coordinates are not handled yet ...*/
|
||||
if(area_p->y2 != vdb_p->vdb_area.y2) {
|
||||
if(area_p->y2 != vdb_p->area.y2) {
|
||||
/*Calc. the next y coordinates of VDB*/
|
||||
vdb_p->vdb_area.y1 = row;
|
||||
vdb_p->vdb_area.y2 = area_p->y2;
|
||||
vdb_p->area.y1 = row;
|
||||
vdb_p->area.y2 = area_p->y2;
|
||||
|
||||
/*Refresh this part too*/
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
@@ -271,7 +277,7 @@ static void lv_refr_area_part_vdb(const area_t * area_p)
|
||||
/*Get the new mask from the original area and the act. VDB
|
||||
It will be a part of 'area_p'*/
|
||||
area_t start_mask;
|
||||
area_union(&start_mask, area_p, &vdb_p->vdb_area);
|
||||
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());
|
||||
@@ -310,8 +316,8 @@ static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
|
||||
/*If no better children check this object*/
|
||||
if(found_p == NULL) {
|
||||
if(obj->opa == OPA_COVER &&
|
||||
LV_SA(obj, lv_objs_t)->transp == 0 &&
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->opa == OPA_COVER &&
|
||||
obj->design_f(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
found_p = obj;
|
||||
}
|
||||
@@ -396,10 +402,11 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
/*Draw the parent and its children only if they ore on 'mask_parent'*/
|
||||
if(union_ok != false) {
|
||||
|
||||
/* Redraw the object */
|
||||
if(obj->opa != OPA_TRANSP && LV_SA(obj, lv_objs_t)->transp == 0) {
|
||||
/* Redraw the object */
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->opa != OPA_TRANSP) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||
/* tick_wait_ms(100); */ /*DEBUG: Wait after every object draw to see the order of drawing*/
|
||||
//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*/
|
||||
@@ -430,7 +437,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(obj->opa != OPA_TRANSP && LV_SA(obj, lv_objs_t)->transp == 0) {
|
||||
if(style->opa != OPA_TRANSP) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
}
|
||||
}
|
||||
|
||||
233
lv_obj/lv_style.c
Normal file
233
lv_obj/lv_style.c
Normal file
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* @file lv_style.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
static lv_style_t lv_style_scr;
|
||||
static lv_style_t lv_style_transp;
|
||||
static lv_style_t lv_style_transp_tight;
|
||||
static lv_style_t lv_style_plain;
|
||||
static lv_style_t lv_style_plain_color;
|
||||
static lv_style_t lv_style_pretty;
|
||||
static lv_style_t lv_style_pretty_color;
|
||||
static lv_style_t lv_style_btn_rel;
|
||||
static lv_style_t lv_style_btn_pr;
|
||||
static lv_style_t lv_style_btn_trel;
|
||||
static lv_style_t lv_style_btn_tpr;
|
||||
static lv_style_t lv_style_btn_ina;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the basic styles
|
||||
*/
|
||||
void lv_style_init (void)
|
||||
{
|
||||
/* Not White/Black/Gray colors are created by HSV model with
|
||||
* HUE = 210*/
|
||||
|
||||
/*Screen style*/
|
||||
lv_style_scr.ccolor = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_scr.opa = OPA_COVER;
|
||||
|
||||
lv_style_scr.mcolor = COLOR_MAKE(0xc9, 0xdb, 0xee);
|
||||
lv_style_scr.gcolor = COLOR_MAKE(0x4d, 0x91, 0xd5);
|
||||
lv_style_scr.bcolor = COLOR_BLACK;
|
||||
lv_style_scr.scolor = COLOR_GRAY;
|
||||
lv_style_scr.radius = 0;
|
||||
lv_style_scr.bwidth = 0;
|
||||
lv_style_scr.swidth = 0;
|
||||
lv_style_scr.stype = LV_STYPE_FULL;
|
||||
lv_style_scr.vpad = LV_DPI / 12;
|
||||
lv_style_scr.hpad = LV_DPI / 12;
|
||||
lv_style_scr.opad = LV_DPI / 12;
|
||||
lv_style_scr.bopa = OPA_COVER;
|
||||
lv_style_scr.empty = 0;
|
||||
lv_style_scr.glass = 0;
|
||||
|
||||
lv_style_scr.font = font_get(FONT_DEFAULT);
|
||||
lv_style_scr.letter_space = 1 * LV_DOWNSCALE;
|
||||
lv_style_scr.line_space = 3 * LV_DOWNSCALE;
|
||||
lv_style_scr.txt_align = LV_TXT_ALIGN_LEFT;
|
||||
lv_style_scr.img_recolor = OPA_TRANSP;
|
||||
lv_style_scr.line_width = 1 * LV_DOWNSCALE;
|
||||
|
||||
/*Plain style (by default near the same as the screen style)*/
|
||||
memcpy(&lv_style_plain, &lv_style_scr, sizeof(lv_style_t));
|
||||
lv_style_plain.mcolor = COLOR_WHITE;
|
||||
lv_style_plain.gcolor = COLOR_WHITE;
|
||||
lv_style_plain.bcolor = COLOR_WHITE;
|
||||
|
||||
/*Plain color style*/
|
||||
memcpy(&lv_style_plain_color, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_plain_color.ccolor = COLOR_MAKE(0xf0, 0xf0, 0xf0);
|
||||
lv_style_plain_color.mcolor = COLOR_MAKE(0x55, 0x96, 0xd8);
|
||||
lv_style_plain_color.gcolor = lv_style_plain_color.mcolor;
|
||||
|
||||
/*Pretty style */
|
||||
memcpy(&lv_style_pretty, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_pretty.ccolor = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_pretty.mcolor = COLOR_WHITE;
|
||||
lv_style_pretty.gcolor = COLOR_SILVER;
|
||||
lv_style_pretty.bcolor = COLOR_MAKE(0x40, 0x40, 0x40);
|
||||
lv_style_pretty.radius = LV_DPI / 15;
|
||||
lv_style_pretty.bwidth = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_pretty.bopa = OPA_50;
|
||||
|
||||
/*Pretty color style*/
|
||||
memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t));
|
||||
lv_style_pretty_color.ccolor = COLOR_MAKE(0xe0, 0xe0, 0xe0);
|
||||
lv_style_pretty_color.mcolor = COLOR_MAKE(0x6b, 0x9a, 0xc7);
|
||||
lv_style_pretty_color.gcolor = COLOR_MAKE(0x2b, 0x59, 0x8b);
|
||||
lv_style_pretty_color.bcolor = COLOR_MAKE(0x15, 0x2c, 0x42);
|
||||
|
||||
/*Transparent style*/
|
||||
memcpy(&lv_style_transp, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_transp.empty = 1;
|
||||
lv_style_transp.bwidth = 0;
|
||||
lv_style_transp.glass = 1;
|
||||
|
||||
/*Transparent tight style*/
|
||||
memcpy(&lv_style_transp_tight, &lv_style_transp, sizeof(lv_style_t));
|
||||
lv_style_transp_tight.hpad = 0;
|
||||
lv_style_transp_tight.vpad = 0;
|
||||
|
||||
/*Button released style*/
|
||||
memcpy(&lv_style_btn_rel, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_btn_rel.mcolor = COLOR_MAKE(0x76, 0xa2, 0xd0);
|
||||
lv_style_btn_rel.gcolor = COLOR_MAKE(0x19, 0x3a, 0x5d);
|
||||
lv_style_btn_rel.bcolor = COLOR_MAKE(0x0b, 0x19, 0x28);
|
||||
lv_style_btn_rel.ccolor = COLOR_MAKE(0xff, 0xff, 0xff);
|
||||
lv_style_btn_rel.bwidth = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_btn_rel.radius = LV_DPI / 15;
|
||||
lv_style_btn_rel.bopa = OPA_70;
|
||||
lv_style_btn_rel.scolor = COLOR_GRAY;
|
||||
lv_style_btn_rel.swidth = 0;
|
||||
lv_style_btn_rel.hpad = LV_DPI / 4;
|
||||
lv_style_btn_rel.vpad = LV_DPI / 6;
|
||||
lv_style_btn_rel.opad = LV_DPI / 10;
|
||||
|
||||
/*Button pressed style*/
|
||||
memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_pr.mcolor = COLOR_MAKE(0x33, 0x62, 0x94);
|
||||
lv_style_btn_pr.gcolor = COLOR_MAKE(0x10, 0x26, 0x3c);
|
||||
lv_style_btn_pr.ccolor = COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
|
||||
/*Button toggle released style*/
|
||||
memcpy(&lv_style_btn_trel, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_trel.mcolor = COLOR_MAKE(0x0a, 0x11, 0x22);
|
||||
lv_style_btn_trel.gcolor = COLOR_MAKE(0x37, 0x62, 0x90);
|
||||
lv_style_btn_trel.bcolor = COLOR_MAKE(0x01, 0x07, 0x0d);
|
||||
lv_style_btn_trel.ccolor = COLOR_MAKE(0xc8, 0xdd, 0xf4);
|
||||
|
||||
/*Button toggle pressed style*/
|
||||
memcpy(&lv_style_btn_tpr, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_tpr.mcolor = COLOR_MAKE(0x02, 0x14, 0x27);
|
||||
lv_style_btn_tpr.gcolor = COLOR_MAKE(0x2b, 0x4c, 0x70);
|
||||
lv_style_btn_tpr.ccolor = COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
|
||||
/*Button inactive style*/
|
||||
memcpy(&lv_style_btn_ina, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_ina.mcolor = COLOR_MAKE(0xd8, 0xd8, 0xd8);
|
||||
lv_style_btn_ina.gcolor = COLOR_MAKE(0xd8, 0xd8, 0xd8);
|
||||
lv_style_btn_ina.bcolor = COLOR_MAKE(0x90, 0x90, 0x90);
|
||||
lv_style_btn_ina.ccolor = COLOR_MAKE(0x70, 0x70, 0x70);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get style from its name
|
||||
* @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 * style = &lv_style_plain;
|
||||
|
||||
switch(style_name) {
|
||||
case LV_STYLE_SCR:
|
||||
style = &lv_style_scr;
|
||||
break;
|
||||
case LV_STYLE_PLAIN:
|
||||
style = &lv_style_plain;
|
||||
break;
|
||||
case LV_STYLE_PLAIN_COLOR:
|
||||
style = &lv_style_plain_color;
|
||||
break;
|
||||
case LV_STYLE_PRETTY:
|
||||
style = &lv_style_pretty;
|
||||
break;
|
||||
case LV_STYLE_PRETTY_COLOR:
|
||||
style = &lv_style_pretty_color;
|
||||
break;
|
||||
case LV_STYLE_TRANSP:
|
||||
style = &lv_style_transp;
|
||||
break;
|
||||
case LV_STYLE_TRANSP_TIGHT:
|
||||
style = &lv_style_transp_tight;
|
||||
break;
|
||||
case LV_STYLE_BTN_REL:
|
||||
style = &lv_style_btn_rel;
|
||||
break;
|
||||
case LV_STYLE_BTN_PR:
|
||||
style = &lv_style_btn_pr;
|
||||
break;
|
||||
case LV_STYLE_BTN_TREL:
|
||||
style = &lv_style_btn_trel;
|
||||
break;
|
||||
case LV_STYLE_BTN_TPR:
|
||||
style = &lv_style_btn_tpr;
|
||||
break;
|
||||
case LV_STYLE_BTN_INA:
|
||||
style = &lv_style_btn_ina;
|
||||
break;
|
||||
default:
|
||||
style = &lv_style_plain;
|
||||
}
|
||||
|
||||
if(copy != NULL) memcpy(copy, style, sizeof(lv_style_t));
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a style to an other
|
||||
* @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)
|
||||
{
|
||||
memcpy(dest, src, sizeof(lv_style_t));
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
105
lv_obj/lv_style.h
Normal file
105
lv_obj/lv_style.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @file lv_style.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_STYLE_H
|
||||
#define LV_STYLE_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_RADIUS_CIRCLE (CORD_MAX) /*A very big radius to always draw as circle*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_TXT_ALIGN_LEFT = 0,
|
||||
LV_TXT_ALIGN_MID,
|
||||
}lv_txt_align_t;
|
||||
|
||||
|
||||
/*Shadow types*/
|
||||
typedef enum
|
||||
{
|
||||
LV_STYPE_BOTTOM = 0,
|
||||
LV_STYPE_FULL,
|
||||
}lv_stype_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*Object level styles*/
|
||||
color_t ccolor; /*Content color (e.g. text or image re-color )*/
|
||||
opa_t opa; /*Opacity of the object*/
|
||||
uint8_t glass :1; /*1: Do not inherit this style*/
|
||||
uint8_t empty :1; /*Transparent background (border drawn)*/
|
||||
uint8_t stype :2; /*Shadow type from 'lv_shadow_type_t'*/
|
||||
uint8_t txt_align:2;
|
||||
color_t mcolor; /*Main color of background*/
|
||||
color_t gcolor; /*Gradient color of background*/
|
||||
color_t bcolor; /*Border color of background*/
|
||||
color_t scolor; /*Shadow color of background*/
|
||||
cord_t radius; /*Corner radius of background*/
|
||||
cord_t bwidth; /*Width of the background border*/
|
||||
cord_t swidth; /*Width of the background shadow effect*/
|
||||
cord_t vpad; /*Vertical padding*/
|
||||
cord_t hpad; /*Horizontal padding*/
|
||||
cord_t opad; /*Object padding on the background*/
|
||||
opa_t bopa; /*Opacity of background border*/
|
||||
const font_t * font;
|
||||
cord_t letter_space;
|
||||
cord_t line_space;
|
||||
opa_t img_recolor;
|
||||
cord_t line_width;
|
||||
}lv_style_t;
|
||||
|
||||
typedef enum {
|
||||
LV_STYLE_SCR,
|
||||
LV_STYLE_TRANSP,
|
||||
LV_STYLE_TRANSP_TIGHT,
|
||||
LV_STYLE_PLAIN,
|
||||
LV_STYLE_PLAIN_COLOR,
|
||||
LV_STYLE_PRETTY,
|
||||
LV_STYLE_PRETTY_COLOR,
|
||||
LV_STYLE_BTN_REL,
|
||||
LV_STYLE_BTN_PR,
|
||||
LV_STYLE_BTN_TREL,
|
||||
LV_STYLE_BTN_TPR,
|
||||
LV_STYLE_BTN_INA,
|
||||
}lv_style_name_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the basic styles
|
||||
*/
|
||||
void lv_style_init (void);
|
||||
|
||||
/**
|
||||
* Get style from its name
|
||||
* @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);
|
||||
|
||||
void lv_style_cpy(lv_style_t * dest, const lv_style_t * src);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
@@ -53,8 +53,7 @@ lv_vdb_t * lv_vdb_get(void)
|
||||
void lv_vdb_flush(void)
|
||||
{
|
||||
#if LV_ANTIALIAS == 0
|
||||
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 , vdb.vdb_area.y1, vdb.vdb_area.x2, vdb.vdb_area.y2);
|
||||
disp_map(DISP_ID_ALL, vdb.buf);
|
||||
disp_map(vdb.area.x1, vdb.area.y1, vdb.area.x2, vdb.area.y2, vdb.buf);
|
||||
#else
|
||||
/* Get the average of 2x2 pixels and put the result back to the VDB
|
||||
* The reading goes much faster then the write back
|
||||
@@ -69,25 +68,33 @@ void lv_vdb_flush(void)
|
||||
* */
|
||||
cord_t x;
|
||||
cord_t y;
|
||||
cord_t w = area_get_width(&vdb.vdb_area);
|
||||
cord_t w = area_get_width(&vdb.area);
|
||||
color_t * in1_buf = vdb.buf; /*Pointer to the first row*/
|
||||
color_t * in2_buf = vdb.buf + w; /*Pointer to the second row*/
|
||||
color_t * out_buf = vdb.buf; /*Store the result here*/
|
||||
for(y = vdb.vdb_area.y1; y < vdb.vdb_area.y2; y += 2) {
|
||||
for(x = vdb.vdb_area.x1; x < vdb.vdb_area.x2; x += 2) {
|
||||
/*Get the average of 2x2 red*/
|
||||
out_buf->red = (in1_buf->red + (in1_buf + 1)->red +
|
||||
in2_buf->red + (in2_buf+ 1)->red) >> 2;
|
||||
/*Get the average of 2x2 green*/
|
||||
out_buf->green = (in1_buf->green + (in1_buf + 1)->green +
|
||||
in2_buf->green + (in2_buf + 1)->green) >> 2;
|
||||
/*Get the average of 2x2 blue*/
|
||||
out_buf->blue = (in1_buf->blue + (in1_buf + 1)->blue +
|
||||
in2_buf->blue + (in2_buf + 1)->blue) >> 2;
|
||||
|
||||
in1_buf+=2; /*Skip the next pixel because it is already used above*/
|
||||
in2_buf+=2;
|
||||
out_buf++;
|
||||
for(y = vdb.area.y1; y < vdb.area.y2; y += 2) {
|
||||
for(x = vdb.area.x1; x < vdb.area.x2; x += 2) {
|
||||
|
||||
/*If the pixels are the same do not calculate the average */
|
||||
if(in1_buf->full == (in1_buf + 1)->full &&
|
||||
in1_buf->full == in2_buf->full &&
|
||||
in1_buf->full == (in2_buf + 1)->full) {
|
||||
out_buf->full = in1_buf->full;
|
||||
} else {
|
||||
/*Get the average of 2x2 red*/
|
||||
out_buf->red = (in1_buf->red + (in1_buf + 1)->red +
|
||||
in2_buf->red + (in2_buf+ 1)->red) >> 2;
|
||||
/*Get the average of 2x2 green*/
|
||||
out_buf->green = (in1_buf->green + (in1_buf + 1)->green +
|
||||
in2_buf->green + (in2_buf + 1)->green) >> 2;
|
||||
/*Get the average of 2x2 blue*/
|
||||
out_buf->blue = (in1_buf->blue + (in1_buf + 1)->blue +
|
||||
in2_buf->blue + (in2_buf + 1)->blue) >> 2;
|
||||
}
|
||||
|
||||
in1_buf += 2; /*Skip the next pixel because it is already used above*/
|
||||
in2_buf += 2;
|
||||
out_buf ++;
|
||||
}
|
||||
/*2 row is ready so go the next 2*/
|
||||
in1_buf += w; /*Skip the next row because it is processed from in2_buf*/
|
||||
@@ -96,8 +103,7 @@ void lv_vdb_flush(void)
|
||||
|
||||
/* Now the full the VDB is filtered and the result is stored in the first quarter of it
|
||||
* Write out the filtered map to the display*/
|
||||
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 >> 1, vdb.vdb_area.y1 >> 1, vdb.vdb_area.x2 >> 1, vdb.vdb_area.y2 >> 1);
|
||||
disp_map(DISP_ID_ALL, vdb.buf);
|
||||
disp_map(vdb.area.x1 >> 1, vdb.area.y1 >> 1, vdb.area.x2 >> 1, vdb.area.y2 >> 1, vdb.buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -105,6 +111,4 @@ void lv_vdb_flush(void)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,9 +13,8 @@
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "misc/others/color.h"
|
||||
#include <lvgl/lv_misc/area.h>
|
||||
#include "../lv_misc/font.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -27,7 +26,7 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
area_t vdb_area;
|
||||
area_t area;
|
||||
color_t buf[LV_VDB_SIZE];
|
||||
}lv_vdb_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user