mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
style improvments + integrate arc, canvas, objmask
This commit is contained in:
parent
42e6984a75
commit
02f4dd764f
@ -53,7 +53,8 @@ typedef struct _lv_event_temp_data
|
||||
**********************/
|
||||
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff);
|
||||
static void report_style_mod_core(void * style_p, lv_obj_t * obj);
|
||||
static void refresh_children_style(lv_obj_t * obj, uint8_t part);
|
||||
static void refresh_children_style_cache(lv_obj_t * obj);
|
||||
static void refresh_children_style(lv_obj_t * obj);
|
||||
static lv_res_t style_cache_update_core(lv_obj_t * obj, uint8_t part);
|
||||
static void delete_children(lv_obj_t * obj);
|
||||
static void base_dir_refr_children(lv_obj_t * obj);
|
||||
@ -1168,28 +1169,28 @@ void lv_obj_set_style_color(lv_obj_t * obj, uint8_t part, lv_style_property_t pr
|
||||
{
|
||||
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, part);
|
||||
lv_style_set_color(&style_dsc->local, prop, color);
|
||||
lv_obj_refresh_style(obj, part);
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_value(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_int_t value)
|
||||
{
|
||||
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, part);
|
||||
lv_style_set_int(&style_dsc->local, prop, value);
|
||||
lv_obj_refresh_style(obj, part);
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_opa_t opa)
|
||||
{
|
||||
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, part);
|
||||
lv_style_set_opa(&style_dsc->local, prop, opa);
|
||||
lv_obj_refresh_style(obj, part);
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, void * p)
|
||||
{
|
||||
lv_style_dsc_t * style_dsc = lv_obj_get_style(obj, part);
|
||||
lv_style_set_ptr(&style_dsc->local, prop, p);
|
||||
lv_obj_refresh_style(obj, part);
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
|
||||
void lv_obj_add_style_class(lv_obj_t * obj, uint8_t part, lv_style_t * style)
|
||||
@ -1204,7 +1205,7 @@ void lv_obj_add_style_class(lv_obj_t * obj, uint8_t part, lv_style_t * style)
|
||||
|
||||
lv_style_dsc_add_class(style_dsc, style);
|
||||
|
||||
lv_obj_refresh_style(obj, part);
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
|
||||
void lv_obj_reset_style(lv_obj_t * obj, uint8_t part)
|
||||
@ -1217,7 +1218,7 @@ void lv_obj_reset_style(lv_obj_t * obj, uint8_t part)
|
||||
|
||||
lv_style_dsc_reset(style_dsc);
|
||||
|
||||
lv_obj_refresh_style(obj, part);
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
|
||||
|
||||
@ -1225,17 +1226,15 @@ void lv_obj_reset_style(lv_obj_t * obj, uint8_t part)
|
||||
* Notify an object (and its children) about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refresh_style(lv_obj_t * obj, uint8_t part)
|
||||
void lv_obj_refresh_style(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_obj_update_style_cache(obj, part);
|
||||
/*Re-cache all children's styles first*/
|
||||
refresh_children_style_cache(obj);
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, &part);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
refresh_children_style(obj, part);
|
||||
/*Send style change signals*/
|
||||
refresh_children_style(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1429,7 +1428,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_obj_state_t state)
|
||||
lv_obj_state_t new_state = obj->state | state;
|
||||
if(obj->state != new_state) {
|
||||
obj->state = new_state;
|
||||
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL);
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1441,7 +1440,7 @@ void lv_obj_clear_state(lv_obj_t * obj, lv_obj_state_t state)
|
||||
lv_obj_state_t new_state = obj->state & state;
|
||||
if(obj->state != new_state) {
|
||||
obj->state = new_state;
|
||||
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL);
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2018,14 +2017,16 @@ lv_style_dsc_t * lv_obj_get_style(const lv_obj_t * obj, uint8_t part)
|
||||
{
|
||||
if(part == LV_OBJ_PART_MAIN) return &obj->style_dsc;
|
||||
|
||||
void * p = ∂
|
||||
lv_get_style_info_t info;
|
||||
info.part = part;
|
||||
info.result = NULL;
|
||||
|
||||
lv_res_t res;
|
||||
res = lv_signal_send((lv_obj_t*)obj, LV_SIGNAL_GET_STYLE, &p);
|
||||
res = lv_signal_send((lv_obj_t*)obj, LV_SIGNAL_GET_STYLE, &info);
|
||||
|
||||
if(res != LV_RES_OK) return NULL;
|
||||
|
||||
return p;
|
||||
return info.result;
|
||||
}
|
||||
|
||||
|
||||
@ -2132,7 +2133,6 @@ lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t state;
|
||||
lv_style_property_t prop_ori = prop;
|
||||
|
||||
lv_style_attr_t attr;
|
||||
@ -2155,7 +2155,7 @@ lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style
|
||||
weight_act = lv_style_get_int(&dsc->local, prop, &value_act);
|
||||
|
||||
/*On perfect match return the value immediately*/
|
||||
if(weight_act == weight_goal) {
|
||||
if(weight_act == weight_goal && weight_act > weight) {
|
||||
return value_act;
|
||||
}
|
||||
/*If the found ID is better the current candidate then use it*/
|
||||
@ -2169,7 +2169,7 @@ lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style
|
||||
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
|
||||
weight_act = lv_style_get_int(class, prop, &value_act);
|
||||
/*On perfect match return the value immediately*/
|
||||
if(weight_act == weight_goal) {
|
||||
if(weight_act == weight_goal && weight_act > weight) {
|
||||
return value_act;
|
||||
}
|
||||
/*If the found ID is better the current candidate then use it*/
|
||||
@ -2209,7 +2209,6 @@ lv_style_int_t lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_style
|
||||
|
||||
lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
|
||||
{
|
||||
uint8_t state;
|
||||
lv_style_property_t prop_ori = prop;
|
||||
|
||||
lv_style_attr_t attr;
|
||||
@ -2232,7 +2231,7 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_p
|
||||
weight_act = lv_style_get_color(&dsc->local, prop, &value_act);
|
||||
|
||||
/*On perfect match return the value immediately*/
|
||||
if(weight_act == weight_goal) {
|
||||
if(weight_act == weight_goal && weight_act > weight) {
|
||||
return value_act;
|
||||
}
|
||||
/*If the found ID is better the current candidate then use it*/
|
||||
@ -2246,7 +2245,7 @@ lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_p
|
||||
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
|
||||
weight_act = lv_style_get_color(class, prop, &value_act);
|
||||
/*On perfect match return the value immediately*/
|
||||
if(weight_act == weight_goal) {
|
||||
if(weight_act == weight_goal && weight_act > weight) {
|
||||
return value_act;
|
||||
}
|
||||
/*If the found ID is better the current candidate then use it*/
|
||||
@ -2348,7 +2347,7 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prope
|
||||
weight_act = lv_style_get_opa(&dsc->local, prop, &value_act);
|
||||
|
||||
/*On perfect match return the value immediately*/
|
||||
if(weight_act == weight_goal) {
|
||||
if(weight_act == weight_goal && weight_act > weight) {
|
||||
return value_act;
|
||||
}
|
||||
/*If the found ID is better the current candidate then use it*/
|
||||
@ -2362,7 +2361,7 @@ lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prope
|
||||
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
|
||||
weight_act = lv_style_get_opa(class, prop, &value_act);
|
||||
/*On perfect match return the value immediately*/
|
||||
if(weight_act == weight_goal) {
|
||||
if(weight_act == weight_goal && weight_act > weight) {
|
||||
return value_act;
|
||||
}
|
||||
/*If the found ID is better the current candidate then use it*/
|
||||
@ -2409,7 +2408,6 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_propert
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint8_t state;
|
||||
lv_style_property_t prop_ori = prop;
|
||||
|
||||
lv_style_attr_t attr;
|
||||
@ -2432,7 +2430,7 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_propert
|
||||
weight_act = lv_style_get_ptr(&dsc->local, prop, &value_act);
|
||||
|
||||
/*On perfect match return the value immediately*/
|
||||
if(weight_act == weight_goal) {
|
||||
if(weight_act == weight_goal && weight_act > weight) {
|
||||
return value_act;
|
||||
}
|
||||
/*If the found ID is better the current candidate then use it*/
|
||||
@ -2446,7 +2444,7 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_propert
|
||||
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
|
||||
weight_act = lv_style_get_ptr(class, prop, &value_act);
|
||||
/*On perfect match return the value immediately*/
|
||||
if(weight_act == weight_goal) {
|
||||
if(weight_act == weight_goal && weight_act > weight) {
|
||||
return value_act;
|
||||
}
|
||||
/*If the found ID is better the current candidate then use it*/
|
||||
@ -2480,17 +2478,14 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_propert
|
||||
}
|
||||
|
||||
|
||||
void lv_obj_update_style_cache(lv_obj_t * obj, uint8_t part)
|
||||
void lv_obj_update_style_cache(lv_obj_t * obj)
|
||||
{
|
||||
if(part != LV_OBJ_PART_ALL) {
|
||||
style_cache_update_core(obj, part);
|
||||
} else {
|
||||
uint8_t part_sub;
|
||||
for(part_sub = 0; part_sub != LV_OBJ_PART_ALL; part_sub++) {
|
||||
lv_res_t res;
|
||||
res = style_cache_update_core(obj, part_sub);
|
||||
if(res == LV_RES_INV) break;
|
||||
}
|
||||
uint8_t part_sub;
|
||||
|
||||
for(part_sub = 0; part_sub != _LV_OBJ_PART_ALL; part_sub++) {
|
||||
lv_res_t res;
|
||||
res = style_cache_update_core(obj, part_sub);
|
||||
if(res == LV_RES_INV) break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2652,7 +2647,7 @@ lv_obj_state_t lv_obj_get_state(const lv_obj_t * obj, uint8_t part)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(part < _LV_OBJ_PART_REAL_START) return obj->state;
|
||||
if(part < _LV_OBJ_PART_REAL_LAST) return obj->state;
|
||||
|
||||
/*If a real part is asked, then use the object's signal to get its state.
|
||||
* A real object can be in different state then the main part
|
||||
@ -2980,18 +2975,25 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
|
||||
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_t * draw_dsc)
|
||||
{
|
||||
draw_dsc->color = lv_obj_get_style_color(obj, part, LV_STYLE_TEXT_COLOR);
|
||||
draw_dsc->letter_space = lv_obj_get_style_int(obj, part, LV_STYLE_LETTER_SPACE);
|
||||
draw_dsc->line_space = lv_obj_get_style_int(obj, part, LV_STYLE_LETTER_SPACE);
|
||||
draw_dsc->opa = lv_obj_get_style_opa(obj, part, LV_STYLE_TEXT_OPA);
|
||||
|
||||
draw_dsc->font = lv_obj_get_style_ptr(obj, part, LV_STYLE_FONT);
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
lv_opa_t opa_scale = lv_obj_get_style_opa(obj, part, LV_STYLE_OPA_SCALE);
|
||||
|
||||
if(opa_scale < LV_OPA_MAX) {
|
||||
draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8;
|
||||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_color(obj, part, LV_STYLE_TEXT_COLOR);
|
||||
draw_dsc->letter_space = lv_obj_get_style_int(obj, part, LV_STYLE_LETTER_SPACE);
|
||||
draw_dsc->line_space = lv_obj_get_style_int(obj, part, LV_STYLE_LETTER_SPACE);
|
||||
|
||||
draw_dsc->font = lv_obj_get_style_ptr(obj, part, LV_STYLE_FONT);
|
||||
|
||||
if(draw_dsc->sel_start != LV_DRAW_LABEL_NO_TXT_SEL && draw_dsc->sel_end != LV_DRAW_LABEL_NO_TXT_SEL) {
|
||||
draw_dsc->color = lv_obj_get_style_color(obj, part, LV_STYLE_TEXT_SEL_COLOR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc)
|
||||
@ -3099,10 +3101,9 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
{
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** type_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
if((**type_p) == LV_OBJ_PART_MAIN) *style_dsc_p = &obj->style_dsc;
|
||||
else *style_dsc_p = NULL;
|
||||
lv_get_style_info_t * info = param;
|
||||
if(info->part == LV_OBJ_PART_MAIN) info->result = &obj->style_dsc;
|
||||
else info->result = NULL;
|
||||
return LV_RES_OK;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||
@ -3167,12 +3168,12 @@ static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coor
|
||||
static void report_style_mod_core(void * style, lv_obj_t * obj)
|
||||
{
|
||||
uint8_t part_sub;
|
||||
for(part_sub = 0; part_sub != LV_OBJ_PART_ALL; part_sub++) {
|
||||
for(part_sub = 0; part_sub != _LV_OBJ_PART_ALL; part_sub++) {
|
||||
lv_style_dsc_t * dsc = lv_obj_get_style(obj, part_sub);
|
||||
if(dsc == NULL) break;
|
||||
|
||||
if(&dsc->local == style) {
|
||||
lv_obj_refresh_style(obj, part_sub);
|
||||
lv_obj_refresh_style(obj);
|
||||
/* Two local style can't have the same pointer
|
||||
* so there won't be an other match*/
|
||||
return;
|
||||
@ -3182,7 +3183,7 @@ static void report_style_mod_core(void * style, lv_obj_t * obj)
|
||||
for(ci = 0; ci < dsc->class_cnt; ci++) {
|
||||
lv_style_t * class = lv_style_dsc_get_class(dsc, ci);
|
||||
if(class == style) {
|
||||
lv_obj_refresh_style(obj, part_sub);
|
||||
lv_obj_refresh_style(obj);
|
||||
/*It's enough to handle once (if duplicated)*/
|
||||
break;
|
||||
}
|
||||
@ -3197,22 +3198,40 @@ static void report_style_mod_core(void * style, lv_obj_t * obj)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void refresh_children_style_cache(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_update_style_cache(obj);
|
||||
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
while(child != NULL) {
|
||||
lv_obj_update_style_cache(child);
|
||||
child = lv_obj_get_child(obj, child);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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 refresh_children_style(lv_obj_t * obj, uint8_t part)
|
||||
static void refresh_children_style(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_invalidate(obj);
|
||||
obj->signal_cb(obj, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
while(child != NULL) {
|
||||
refresh_children_style(child, part); /*Check children too*/
|
||||
lv_obj_invalidate(child);
|
||||
child->signal_cb(child, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
lv_obj_invalidate(child);
|
||||
|
||||
lv_obj_update_style_cache(child, part);
|
||||
lv_obj_invalidate(child);
|
||||
child->signal_cb(child, LV_SIGNAL_STYLE_CHG, &part);
|
||||
lv_obj_invalidate(child);
|
||||
refresh_children_style(child); /*Check children too*/
|
||||
child = lv_obj_get_child(obj, child);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,6 @@ extern "C" {
|
||||
#define LV_EXT_CLICK_AREA_TINY 1
|
||||
#define LV_EXT_CLICK_AREA_FULL 2
|
||||
|
||||
#define _LV_OBJ_PART_MAIN_VALUE 0x00
|
||||
#define _LV_OBJ_PART_VIRTUAL_START 0x01
|
||||
#define _LV_OBJ_PART_REAL_START 0x40
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -272,7 +268,9 @@ typedef struct _lv_obj_t
|
||||
|
||||
enum {
|
||||
LV_OBJ_PART_MAIN,
|
||||
LV_OBJ_PART_ALL = 0xFF,
|
||||
_LV_OBJ_PART_VIRTUAL_LAST = 0x01,
|
||||
_LV_OBJ_PART_REAL_LAST = 0x40,
|
||||
_LV_OBJ_PART_ALL = 0xFF,
|
||||
};
|
||||
|
||||
typedef uint8_t lv_obj_part_t;
|
||||
@ -290,6 +288,13 @@ typedef struct
|
||||
bool result;
|
||||
} lv_hit_test_info_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t part;
|
||||
lv_style_dsc_t * result;
|
||||
} lv_get_style_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t part;
|
||||
@ -501,7 +506,7 @@ void lv_obj_reset_style(lv_obj_t * obj, uint8_t type);
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refresh_style(lv_obj_t * obj, uint8_t type);
|
||||
void lv_obj_refresh_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
@ -875,7 +880,7 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_propert
|
||||
//const lv_style_t * lv_obj_get_style(const lv_obj_t * obj);
|
||||
|
||||
|
||||
void lv_obj_update_style_cache(lv_obj_t * obj, uint8_t part);
|
||||
void lv_obj_update_style_cache(lv_obj_t * obj);
|
||||
|
||||
/*-----------------
|
||||
* Attribute get
|
||||
|
@ -116,6 +116,7 @@ enum {
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_LINE_SPACE, 0x6, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x6, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_COLOR, 0x6, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_COLOR, 0x6, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_INHERIT),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_OPA, 0x6, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_FONT, 0x6, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_INHERIT),
|
||||
|
||||
|
@ -1,150 +1,154 @@
|
||||
///**
|
||||
// * @file lv_draw_arc.c
|
||||
// *
|
||||
// */
|
||||
//
|
||||
///*********************
|
||||
// * INCLUDES
|
||||
// *********************/
|
||||
//#include "lv_draw_arc.h"
|
||||
//#include "lv_draw_mask.h"
|
||||
//#include "../lv_misc/lv_math.h"
|
||||
//
|
||||
///*********************
|
||||
// * DEFINES
|
||||
// *********************/
|
||||
//
|
||||
///**********************
|
||||
// * TYPEDEFS
|
||||
// **********************/
|
||||
//
|
||||
///**********************
|
||||
// * STATIC PROTOTYPES
|
||||
// **********************/
|
||||
//static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, lv_area_t * res_area);
|
||||
//
|
||||
///**********************
|
||||
// * STATIC VARIABLES
|
||||
// **********************/
|
||||
//
|
||||
///**********************
|
||||
// * MACROS
|
||||
// **********************/
|
||||
//
|
||||
///**********************
|
||||
// * GLOBAL FUNCTIONS
|
||||
// **********************/
|
||||
//
|
||||
///**
|
||||
// * Draw an arc. (Can draw pie too with great thickness.)
|
||||
// * @param center_x the x coordinate of the center of the arc
|
||||
// * @param center_y the y coordinate of the center of the arc
|
||||
// * @param radius the radius of the arc
|
||||
// * @param mask the arc will be drawn only in this mask
|
||||
// * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
|
||||
// * @param end_angle the end angle of the arc
|
||||
// * @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
|
||||
// * @param opa_scale scale down all opacities by the factor
|
||||
// */
|
||||
//void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * clip_area,
|
||||
// uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
//{
|
||||
// lv_style_t circle_style;
|
||||
// lv_style_copy(&circle_style, style);
|
||||
// circle_style.body.radius = LV_RADIUS_CIRCLE;
|
||||
// circle_style.body.opa = LV_OPA_TRANSP;
|
||||
// circle_style.body.border.width = style->line.width;
|
||||
// circle_style.body.border.color = style->line.color;
|
||||
// circle_style.body.border.opa = style->line.opa;
|
||||
//
|
||||
// lv_draw_mask_angle_param_t mask_angle_param;
|
||||
// lv_draw_mask_angle_init(&mask_angle_param, center_x, center_y, start_angle, end_angle);
|
||||
//
|
||||
// int16_t mask_angle_id = lv_draw_mask_add(&mask_angle_param, NULL);
|
||||
//
|
||||
// lv_area_t area;
|
||||
// area.x1 = center_x - radius;
|
||||
// area.y1 = center_y - radius;
|
||||
// area.x2 = center_x + radius - 1; /*-1 because the center already belongs to the left/bottom part*/
|
||||
// area.y2 = center_y + radius - 1;
|
||||
//
|
||||
// lv_draw_rect(&area, clip_area, &circle_style, LV_OPA_COVER);
|
||||
//
|
||||
// lv_draw_mask_remove_id(mask_angle_id);
|
||||
//
|
||||
// if(style->line.rounded) {
|
||||
// circle_style.body.main_color = style->line.color;
|
||||
// circle_style.body.grad_color = style->line.color;
|
||||
// circle_style.body.opa = LV_OPA_COVER;
|
||||
// circle_style.body.border.width = 0;
|
||||
//
|
||||
// lv_area_t round_area;
|
||||
// get_rounded_area(start_angle, radius, style->line.width, &round_area);
|
||||
// round_area.x1 += center_x;
|
||||
// round_area.x2 += center_x;
|
||||
// round_area.y1 += center_y;
|
||||
// round_area.y2 += center_y;
|
||||
//
|
||||
// lv_draw_rect(&round_area, clip_area, &circle_style, opa_scale);
|
||||
//
|
||||
// get_rounded_area(end_angle, radius, style->line.width, &round_area);
|
||||
// round_area.x1 += center_x;
|
||||
// round_area.x2 += center_x;
|
||||
// round_area.y1 += center_y;
|
||||
// round_area.y2 += center_y;
|
||||
//
|
||||
// lv_draw_rect(&round_area, clip_area, &circle_style, opa_scale);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//
|
||||
///**********************
|
||||
// * STATIC FUNCTIONS
|
||||
// **********************/
|
||||
//
|
||||
//static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, lv_area_t * res_area)
|
||||
//{
|
||||
// const uint8_t ps = 8;
|
||||
// const uint8_t pa = 127;
|
||||
//
|
||||
// lv_coord_t thick_half = tickness / 2;
|
||||
// lv_coord_t thick_corr = tickness & 0x01 ? 0 : 1;
|
||||
//
|
||||
// lv_coord_t rx_corr;
|
||||
// lv_coord_t ry_corr;
|
||||
//
|
||||
// if(angle > 90 && angle < 270) rx_corr = 0;
|
||||
// else rx_corr = 0;
|
||||
//
|
||||
// if(angle > 0 && angle < 180) ry_corr = 0;
|
||||
// else ry_corr = 0;
|
||||
//
|
||||
// lv_coord_t cir_x;
|
||||
// lv_coord_t cir_y;
|
||||
//
|
||||
// cir_x = ((radius - rx_corr - thick_half) * lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps);
|
||||
// cir_y = ((radius - ry_corr - thick_half) * lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps);
|
||||
//
|
||||
// /* Actually the center of the pixel need to be calculated so apply 1/2 px offset*/
|
||||
// if(cir_x > 0) {
|
||||
// cir_x = (cir_x - pa) >> ps;
|
||||
// res_area->x1 = cir_x - thick_half + thick_corr;
|
||||
// res_area->x2 = cir_x + thick_half;
|
||||
// }
|
||||
// else {
|
||||
// cir_x = (cir_x + pa) >> ps;
|
||||
// res_area->x1 = cir_x - thick_half;
|
||||
// res_area->x2 = cir_x + thick_half - thick_corr;
|
||||
// }
|
||||
//
|
||||
// if(cir_y > 0) {
|
||||
// cir_y = (cir_y - pa) >> ps;
|
||||
// res_area->y1 = cir_y - thick_half + thick_corr;
|
||||
// res_area->y2 = cir_y + thick_half;
|
||||
// }
|
||||
// else {
|
||||
// cir_y = (cir_y + pa) >> ps;
|
||||
// res_area->y1 = cir_y - thick_half;
|
||||
// res_area->y2 = cir_y + thick_half - thick_corr;
|
||||
// }
|
||||
//}
|
||||
/**
|
||||
* @file lv_draw_arc.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_arc.h"
|
||||
#include "lv_draw_mask.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, lv_area_t * res_area);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Draw an arc. (Can draw pie too with great thickness.)
|
||||
* @param center_x the x coordinate of the center of the arc
|
||||
* @param center_y the y coordinate of the center of the arc
|
||||
* @param radius the radius of the arc
|
||||
* @param mask the arc will be drawn only in this mask
|
||||
* @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
|
||||
* @param end_angle the end angle of the arc
|
||||
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
lv_draw_rect_dsc_t cir_dsc;
|
||||
lv_draw_rect_dsc_init(&cir_dsc);
|
||||
cir_dsc.radius = LV_RADIUS_CIRCLE;
|
||||
cir_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
cir_dsc.border_opa = dsc->opa;
|
||||
cir_dsc.border_color = dsc->color;
|
||||
cir_dsc.border_width = dsc->width;
|
||||
cir_dsc.border_blend_mode = dsc->blend_mode;
|
||||
|
||||
lv_draw_mask_angle_param_t mask_angle_param;
|
||||
lv_draw_mask_angle_init(&mask_angle_param, center_x, center_y, start_angle, end_angle);
|
||||
|
||||
int16_t mask_angle_id = lv_draw_mask_add(&mask_angle_param, NULL);
|
||||
|
||||
lv_area_t area;
|
||||
area.x1 = center_x - radius;
|
||||
area.y1 = center_y - radius;
|
||||
area.x2 = center_x + radius - 1; /*-1 because the center already belongs to the left/bottom part*/
|
||||
area.y2 = center_y + radius - 1;
|
||||
|
||||
lv_draw_rect(&area, clip_area, &cir_dsc);
|
||||
|
||||
lv_draw_mask_remove_id(mask_angle_id);
|
||||
|
||||
if(dsc->round_start || dsc->round_end) {
|
||||
cir_dsc.bg_color = dsc->color;
|
||||
cir_dsc.bg_opa = dsc->opa;
|
||||
cir_dsc.bg_blend_mode = dsc->blend_mode;
|
||||
cir_dsc.border_width = 0;
|
||||
|
||||
lv_area_t round_area;
|
||||
if(dsc->round_start) {
|
||||
get_rounded_area(start_angle, radius, dsc->width, &round_area);
|
||||
round_area.x1 += center_x;
|
||||
round_area.x2 += center_x;
|
||||
round_area.y1 += center_y;
|
||||
round_area.y2 += center_y;
|
||||
|
||||
lv_draw_rect(&round_area, clip_area, &cir_dsc);
|
||||
}
|
||||
|
||||
if(dsc->round_end) {
|
||||
get_rounded_area(end_angle, radius, dsc->width, &round_area);
|
||||
round_area.x1 += center_x;
|
||||
round_area.x2 += center_x;
|
||||
round_area.y1 += center_y;
|
||||
round_area.y2 += center_y;
|
||||
|
||||
lv_draw_rect(&round_area, clip_area, &cir_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, lv_area_t * res_area)
|
||||
{
|
||||
const uint8_t ps = 8;
|
||||
const uint8_t pa = 127;
|
||||
|
||||
lv_coord_t thick_half = tickness / 2;
|
||||
lv_coord_t thick_corr = tickness & 0x01 ? 0 : 1;
|
||||
|
||||
lv_coord_t rx_corr;
|
||||
lv_coord_t ry_corr;
|
||||
|
||||
if(angle > 90 && angle < 270) rx_corr = 0;
|
||||
else rx_corr = 0;
|
||||
|
||||
if(angle > 0 && angle < 180) ry_corr = 0;
|
||||
else ry_corr = 0;
|
||||
|
||||
lv_coord_t cir_x;
|
||||
lv_coord_t cir_y;
|
||||
|
||||
cir_x = ((radius - rx_corr - thick_half) * lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps);
|
||||
cir_y = ((radius - ry_corr - thick_half) * lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps);
|
||||
|
||||
/* Actually the center of the pixel need to be calculated so apply 1/2 px offset*/
|
||||
if(cir_x > 0) {
|
||||
cir_x = (cir_x - pa) >> ps;
|
||||
res_area->x1 = cir_x - thick_half + thick_corr;
|
||||
res_area->x2 = cir_x + thick_half;
|
||||
}
|
||||
else {
|
||||
cir_x = (cir_x + pa) >> ps;
|
||||
res_area->x1 = cir_x - thick_half;
|
||||
res_area->x2 = cir_x + thick_half - thick_corr;
|
||||
}
|
||||
|
||||
if(cir_y > 0) {
|
||||
cir_y = (cir_y - pa) >> ps;
|
||||
res_area->y1 = cir_y - thick_half + thick_corr;
|
||||
res_area->y2 = cir_y + thick_half;
|
||||
}
|
||||
else {
|
||||
cir_y = (cir_y + pa) >> ps;
|
||||
res_area->y1 = cir_y - thick_half;
|
||||
res_area->y2 = cir_y + thick_half - thick_corr;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw.h"
|
||||
#include "lv_draw_line.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -38,8 +39,7 @@ extern "C" {
|
||||
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask,
|
||||
uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -80,13 +80,8 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new arc arc*/
|
||||
if(copy == NULL) {
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->style.arc);
|
||||
} else {
|
||||
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color);
|
||||
}
|
||||
lv_style_dsc_reset(&new_arc->style_dsc);
|
||||
_ot(new_arc, LV_ARC_PART_MAIN, ARC);
|
||||
|
||||
}
|
||||
/*Copy an existing arc*/
|
||||
@ -154,21 +149,6 @@ void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end)
|
||||
lv_obj_invalidate(arc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a style of a arc.
|
||||
* @param arc pointer to arc object
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
* */
|
||||
void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, const lv_style_t * style)
|
||||
{
|
||||
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||
|
||||
switch(type) {
|
||||
case LV_ARC_STYLE_MAIN: lv_obj_set_style(arc, style); break;
|
||||
}
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -201,26 +181,6 @@ uint16_t lv_arc_get_angle_end(lv_obj_t * arc)
|
||||
return ext->angle_end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get style of a arc.
|
||||
* @param arc pointer to arc object
|
||||
* @param type which style should be get
|
||||
* @return style pointer to the style
|
||||
* */
|
||||
const lv_style_t * lv_arc_get_style(const lv_obj_t * arc, lv_arc_style_t type)
|
||||
{
|
||||
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||
|
||||
const lv_style_t * style = NULL;
|
||||
|
||||
switch(type) {
|
||||
case LV_ARC_STYLE_MAIN: style = lv_obj_get_style(arc); break;
|
||||
default: style = NULL; break;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
@ -252,13 +212,14 @@ static lv_design_res_t lv_arc_design(lv_obj_t * arc, const lv_area_t * clip_area
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
const lv_style_t * style = lv_arc_get_style(arc, LV_ARC_STYLE_MAIN);
|
||||
lv_draw_line_dsc_t arc_dsc;
|
||||
lv_draw_line_dsc_init(&arc_dsc);
|
||||
lv_obj_init_draw_line_dsc(arc, LV_ARC_PART_MAIN, &arc_dsc);
|
||||
|
||||
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(arc), lv_obj_get_height(arc))) / 2;
|
||||
lv_coord_t x = arc->coords.x1 + lv_obj_get_width(arc) / 2;
|
||||
lv_coord_t y = arc->coords.y1 + lv_obj_get_height(arc) / 2;
|
||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(arc);
|
||||
lv_draw_arc(x, y, r, clip_area, ext->angle_start, ext->angle_end, style, opa_scale);
|
||||
lv_draw_arc(x, y, r, ext->angle_start, ext->angle_end, clip_area, &arc_dsc);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
|
@ -34,11 +34,11 @@ typedef struct
|
||||
lv_coord_t angle_end;
|
||||
} lv_arc_ext_t;
|
||||
|
||||
/*Styles*/
|
||||
/*Parts of the arc*/
|
||||
enum {
|
||||
LV_ARC_STYLE_MAIN,
|
||||
LV_ARC_PART_MAIN,
|
||||
};
|
||||
typedef uint8_t lv_arc_style_t;
|
||||
typedef uint8_t lv_arc_part_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -74,14 +74,6 @@ void lv_arc_set_start_angle(lv_obj_t * arc, int16_t start);
|
||||
*/
|
||||
void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end);
|
||||
|
||||
/**
|
||||
* Set a style of a arc.
|
||||
* @param arc pointer to arc object
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
* */
|
||||
void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, const lv_style_t * style);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -100,14 +92,6 @@ uint16_t lv_arc_get_angle_start(lv_obj_t * arc);
|
||||
*/
|
||||
uint16_t lv_arc_get_angle_end(lv_obj_t * arc);
|
||||
|
||||
/**
|
||||
* Get style of a arc.
|
||||
* @param arc pointer to arc object
|
||||
* @param type which style should be get
|
||||
* @return style pointer to the style
|
||||
* */
|
||||
const lv_style_t * lv_arc_get_style(const lv_obj_t * arc, lv_arc_style_t type);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
@ -126,7 +126,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->style_indic = ext_copy->style_indic;
|
||||
ext->type = ext_copy->type;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_bar, LV_OBJ_PART_ALL);
|
||||
lv_obj_refresh_style(new_bar);
|
||||
|
||||
lv_bar_set_value(new_bar, ext->cur_value, false);
|
||||
}
|
||||
@ -564,9 +564,10 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
||||
lv_res_t res;
|
||||
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** type_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_bar_get_style(bar, **type_p);
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_bar_get_style(bar, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(bar, sign, param);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
// memcpy((void*) ext->styles, copy_ext->styles, sizeof(ext->styles));
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_btn,LV_BTN_PART_MAIN);
|
||||
lv_obj_refresh_style(new_btn);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("button created");
|
||||
|
@ -757,10 +757,10 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
{
|
||||
lv_res_t res;
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** type_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_btnm_get_style(btnm, **type_p);
|
||||
return LV_RES_OK;
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_btnm_get_style(btnm, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(btnm, sign, param);
|
||||
}
|
||||
|
||||
/* Include the ancient signal function */
|
||||
@ -773,8 +773,12 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_mem_free(ext->button_areas);
|
||||
lv_mem_free(ext->ctrl_bits);
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_COORD_CHG) {
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_btnm_set_map(btnm, ext->map_p);
|
||||
} else if(sign == LV_SIGNAL_COORD_CHG) {
|
||||
if(lv_obj_get_width(btnm) != lv_area_get_width(param) || lv_obj_get_height(btnm) != lv_area_get_height(param)) {
|
||||
lv_btnm_set_map(btnm, ext->map_p);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_PRESSED) {
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
|
||||
|
@ -142,7 +142,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_style_dsc_add_class(&ext->style_today_box, lv_theme_get_style(LV_THEME_CALENDAR_TODAY_BOX));
|
||||
lv_style_dsc_add_class(&ext->style_week_box, lv_theme_get_style(LV_THEME_CALENDAR_WEEK_BOX));
|
||||
|
||||
lv_obj_refresh_style(new_calendar, LV_OBJ_PART_ALL);
|
||||
lv_obj_refresh_style(new_calendar);
|
||||
|
||||
lv_obj_set_size(new_calendar, LV_DPI * 2, LV_DPI * 2);
|
||||
|
||||
@ -430,9 +430,10 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
|
||||
{
|
||||
lv_res_t res;
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** part_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_calendar_get_style(calendar, **part_p);
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_calendar_get_style(calendar, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(calendar, sign, param);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
@ -842,8 +843,6 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
|
||||
calendar->state = LV_OBJ_STATE_PRESSED;
|
||||
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DATE_NUMS, &pr_label_dsc);
|
||||
pr_label_dsc.color = LV_COLOR_RED;
|
||||
|
||||
|
||||
calendar->state = state_ori;
|
||||
calendar->style_dsc.cache.enabled = 1;
|
||||
|
@ -187,21 +187,6 @@ void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c)
|
||||
lv_obj_invalidate(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a style of a canvas.
|
||||
* @param canvas pointer to canvas object
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, const lv_style_t * style)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
|
||||
switch(type) {
|
||||
case LV_CANVAS_STYLE_MAIN: lv_img_set_style(canvas, LV_IMG_STYLE_MAIN, style); break;
|
||||
}
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -726,8 +711,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
/*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
|
||||
lv_color_t ctransp = LV_COLOR_TRANSP;
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
|
||||
rect_dsc->bg_color.full == ctransp.full &&
|
||||
rect_dsc->bg_grad_color.full == ctransp.full)
|
||||
rect_dsc->bg_color.full == ctransp.full)
|
||||
{
|
||||
disp.driver.antialiasing = 0;
|
||||
}
|
||||
@ -751,11 +735,10 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
* @param txt text to display
|
||||
* @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`)
|
||||
*/
|
||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style,
|
||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, lv_draw_label_dsc_t * label_draw_dsc,
|
||||
const char * txt, lv_label_align_t align)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(style);
|
||||
|
||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||
|
||||
@ -804,7 +787,9 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
default: flag = LV_TXT_FLAG_NONE; break;
|
||||
}
|
||||
|
||||
lv_draw_label(&coords, &mask, style, LV_OPA_COVER, txt, flag, NULL, NULL, NULL, lv_obj_get_base_dir(canvas));
|
||||
label_draw_dsc->flag = flag;
|
||||
|
||||
lv_draw_label(&coords, &mask, label_draw_dsc, txt, NULL);
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
}
|
||||
@ -818,7 +803,6 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, lv_draw_img_dsc_t * img_draw_dsc)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(style);
|
||||
|
||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||
|
||||
@ -915,7 +899,7 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
|
||||
/*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
|
||||
lv_color_t ctransp = LV_COLOR_TRANSP;
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
|
||||
line_draw_dsc->color == ctransp.full)
|
||||
line_draw_dsc->color.full == ctransp.full)
|
||||
{
|
||||
disp.driver.antialiasing = 0;
|
||||
}
|
||||
@ -939,10 +923,9 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
|
||||
* @param point_cnt number of points
|
||||
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
|
||||
*/
|
||||
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, const lv_style_t * style)
|
||||
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, lv_draw_rect_dsc_t * poly_draw_dsc)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(style);
|
||||
|
||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||
|
||||
@ -978,8 +961,7 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32
|
||||
/*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
|
||||
lv_color_t ctransp = LV_COLOR_TRANSP;
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
|
||||
style->body.main_color.full == ctransp.full &&
|
||||
style->body.grad_color.full == ctransp.full)
|
||||
poly_draw_dsc->bg_color.full == ctransp.full)
|
||||
{
|
||||
disp.driver.antialiasing = 0;
|
||||
}
|
||||
@ -988,7 +970,7 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32
|
||||
lv_disp_t * refr_ori = lv_refr_get_disp_refreshing();
|
||||
lv_refr_set_disp_refreshing(&disp);
|
||||
|
||||
lv_draw_polygon(points, point_cnt, &mask, style, LV_OPA_COVER);
|
||||
// lv_draw_polygon(points, point_cnt, &mask, poly_draw_dsc);
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
}
|
||||
@ -1004,10 +986,9 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32
|
||||
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
|
||||
*/
|
||||
void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle,
|
||||
int32_t end_angle, const lv_style_t * style)
|
||||
int32_t end_angle, lv_draw_line_dsc_t * arc_draw_dsc)
|
||||
{
|
||||
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(style);
|
||||
|
||||
lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);
|
||||
|
||||
@ -1043,8 +1024,7 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_
|
||||
/*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
|
||||
lv_color_t ctransp = LV_COLOR_TRANSP;
|
||||
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
|
||||
style->body.main_color.full == ctransp.full &&
|
||||
style->body.grad_color.full == ctransp.full)
|
||||
arc_draw_dsc->color.full == ctransp.full)
|
||||
{
|
||||
disp.driver.antialiasing = 0;
|
||||
}
|
||||
@ -1053,7 +1033,7 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_
|
||||
lv_disp_t * refr_ori = lv_refr_get_disp_refreshing();
|
||||
lv_refr_set_disp_refreshing(&disp);
|
||||
|
||||
lv_draw_arc(x, y, r, &mask, start_angle, end_angle, style, LV_OPA_COVER);
|
||||
lv_draw_arc(x, y, r, start_angle, end_angle, &mask, arc_draw_dsc);
|
||||
|
||||
lv_refr_set_disp_refreshing(refr_ori);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa);
|
||||
* @param style style of the rectangle (`body` properties are used except `padding`)
|
||||
*/
|
||||
void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h,
|
||||
const lv_style_t * style);
|
||||
lv_draw_rect_dsc_t * rect_dsc);
|
||||
|
||||
/**
|
||||
* Draw a text on the canvas.
|
||||
@ -194,7 +194,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
* @param txt text to display
|
||||
* @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`)
|
||||
*/
|
||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style,
|
||||
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, lv_draw_label_dsc_t * label_draw_dsc,
|
||||
const char * txt, lv_label_align_t align);
|
||||
|
||||
/**
|
||||
@ -203,7 +203,7 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
|
||||
* @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image.
|
||||
* @param style style of the image (`image` properties are used)
|
||||
*/
|
||||
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, const lv_style_t * style);
|
||||
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, lv_draw_img_dsc_t * img_draw_dsc);
|
||||
|
||||
/**
|
||||
* Draw a line on the canvas
|
||||
@ -212,7 +212,7 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi
|
||||
* @param point_cnt number of points
|
||||
* @param style style of the line (`line` properties are used)
|
||||
*/
|
||||
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, const lv_style_t * style);
|
||||
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, lv_draw_line_dsc_t * line_draw_dsc);
|
||||
|
||||
/**
|
||||
* Draw a polygon on the canvas
|
||||
@ -221,7 +221,7 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t
|
||||
* @param point_cnt number of points
|
||||
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
|
||||
*/
|
||||
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, const lv_style_t * style);
|
||||
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, lv_draw_rect_dsc_t * poly_draw_dsc);
|
||||
|
||||
/**
|
||||
* Draw an arc on the canvas
|
||||
@ -234,7 +234,7 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32
|
||||
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
|
||||
*/
|
||||
void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle,
|
||||
int32_t end_angle, const lv_style_t * style);
|
||||
int32_t end_angle, lv_draw_line_dsc_t * arc_draw_dsc);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -168,9 +168,10 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
||||
{
|
||||
lv_res_t res;
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** type_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_cb_get_style(cb, **type_p);
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_cb_get_style(cb, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(cb, sign, param);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
@ -186,7 +187,7 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
||||
lv_coord_t line_height = lv_font_get_line_height(font);
|
||||
lv_obj_set_size(ext->bullet, line_height, line_height);
|
||||
ext->bullet->state = cb->state;
|
||||
lv_obj_refresh_style(ext->bullet, LV_OBJ_PART_ALL);
|
||||
lv_obj_refresh_style(ext->bullet);
|
||||
} else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
|
||||
} else if(sign == LV_SIGNAL_CONTROL) {
|
||||
|
@ -112,7 +112,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->layout = copy_ext->layout;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_cont, LV_CONT_PART_MAIN);
|
||||
lv_obj_refresh_style(new_cont);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("container created");
|
||||
@ -253,9 +253,10 @@ lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont)
|
||||
static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
||||
{
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** type_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_cont_get_style(cont, **type_p);
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_cont_get_style(cont, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(cont, sign, param);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,9 @@ typedef struct
|
||||
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_CONT_PART_MAIN,
|
||||
LV_CONT_PART_MAIN = LV_OBJ_PART_MAIN,
|
||||
_LV_CONT_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_LAST,
|
||||
_LV_CONT_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_cont_part_t;
|
||||
|
||||
|
@ -1151,10 +1151,10 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
|
||||
lv_res_t res;
|
||||
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** type_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_label_get_style(label, **type_p);
|
||||
return LV_RES_OK;
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_label_get_style(label, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(label, sign, param);
|
||||
}
|
||||
|
||||
/* Include the ancient signal function */
|
||||
|
@ -63,11 +63,12 @@ typedef struct
|
||||
|
||||
/** List styles. */
|
||||
enum {
|
||||
LV_LIST_PART_BG = _LV_OBJ_PART_MAIN_VALUE, /**< List background style */
|
||||
LV_LIST_PART_SCRLBAR = _LV_OBJ_PART_VIRTUAL_START, /**< List scrollbar style. */
|
||||
LV_LIST_PART_EDGE_FLASH, /**< List edge flash style. */
|
||||
|
||||
LV_LIST_PART_SCRL = _LV_OBJ_PART_REAL_START, /**< List scrollable area style. */
|
||||
LV_LIST_PART_BG = LV_PAGE_PART_BG, /**< List background style */
|
||||
LV_LIST_PART_SCRLBAR = LV_PAGE_PART_SCRLBAR, /**< List scrollbar style. */
|
||||
LV_LIST_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, /**< List edge flash style. */
|
||||
_LV_LIST_PART_VIRTUAL_LAST = _LV_PAGE_PART_VIRTUAL_LAST,
|
||||
LV_LIST_PART_SCRL = LV_PAGE_PART_SCRL, /**< List scrollable area style. */
|
||||
_LV_LIST_PART_REAL_LAST = _LV_PAGE_PART_REAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_list_style_t;
|
||||
|
||||
|
@ -77,7 +77,8 @@ lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new object mask object mask*/
|
||||
if(copy == NULL) {
|
||||
lv_objmask_set_style(new_objmask, LV_OBJMASK_STYLE_BG, &lv_style_transp);
|
||||
lv_style_dsc_reset(&new_objmask->style_dsc);
|
||||
lv_obj_add_style_class(new_objmask, LV_OBJMASK_PART_MAIN, &lv_style_transp_tight);
|
||||
|
||||
}
|
||||
/*TODO: Copy an existing object mask*/
|
||||
|
@ -41,11 +41,11 @@ typedef struct
|
||||
|
||||
} lv_objmask_ext_t;
|
||||
|
||||
/*Styles*/
|
||||
/*Parts of the object*/
|
||||
enum {
|
||||
LV_OBJMASK_STYLE_BG,
|
||||
LV_OBJMASK_PART_MAIN,
|
||||
};
|
||||
typedef uint8_t lv_objmask_style_t;
|
||||
typedef uint8_t lv_objmask_part_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -91,30 +91,9 @@ void lv_objmask_remove_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask);
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the style of a object mask
|
||||
* @param objmask pointer to a container object
|
||||
* @param type which style should be set (can be only `LV_CONT_STYLE_MAIN`)
|
||||
* @param style pointer to the new style
|
||||
*/
|
||||
static inline void lv_objmask_set_style(lv_obj_t * objmask, lv_cont_style_t type, const lv_style_t * style)
|
||||
{
|
||||
lv_cont_set_style(objmask, type, style);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
/**
|
||||
* Get the style of an object mask
|
||||
* @param objmask pointer to a container object
|
||||
* @param type which style should be get (can be only `LV_CONT_STYLE_MAIN`)
|
||||
* @return pointer to the container's style
|
||||
*/
|
||||
static inline const lv_style_t * lv_objmask_get_style(const lv_obj_t * objmask, lv_cont_style_t type)
|
||||
{
|
||||
return lv_cont_get_style(objmask, type);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
|
@ -132,7 +132,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_page_set_sb_mode(new_page, ext->sb.mode);
|
||||
|
||||
lv_obj_refresh_style(new_page, LV_OBJ_PART_ALL);
|
||||
lv_obj_refresh_style(new_page);
|
||||
|
||||
} else {
|
||||
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
@ -758,10 +758,10 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
{
|
||||
lv_res_t res;
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** part_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_page_get_style(page, **part_p);
|
||||
return LV_RES_OK;
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_page_get_style(page, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(page, sign, param);
|
||||
} else if(sign == LV_SIGNAL_GET_STATE) {
|
||||
lv_get_state_info_t * info = param;
|
||||
if(info->part == LV_PAGE_PART_SCRL) info->result = lv_obj_get_state(lv_page_get_scrl(page), LV_CONT_PART_MAIN);
|
||||
|
@ -87,11 +87,13 @@ typedef struct
|
||||
} lv_page_ext_t;
|
||||
|
||||
enum {
|
||||
LV_PAGE_PART_BG = _LV_OBJ_PART_MAIN_VALUE,
|
||||
LV_PAGE_PART_SCRLBAR = _LV_OBJ_PART_VIRTUAL_START,
|
||||
LV_PAGE_PART_BG = LV_CONT_PART_MAIN,
|
||||
LV_PAGE_PART_SCRLBAR = _LV_OBJ_PART_VIRTUAL_LAST,
|
||||
LV_PAGE_PART_EDGE_FLASH,
|
||||
_LV_PAGE_PART_VIRTUAL_LAST,
|
||||
|
||||
LV_PAGE_PART_SCRL = _LV_OBJ_PART_REAL_START,
|
||||
LV_PAGE_PART_SCRL = _LV_OBJ_PART_REAL_LAST,
|
||||
_LV_PAGE_PART_REAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_part_style_t;
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * param);
|
||||
static lv_style_dsc_t * lv_spinbox_get_style(lv_obj_t * ta, uint8_t part);
|
||||
static void lv_spinbox_updatevalue(lv_obj_t * spinbox);
|
||||
|
||||
/**********************
|
||||
@ -88,13 +89,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new spinbox spinbox*/
|
||||
if(copy == NULL) {
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_BG, th->style.spinbox.bg);
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_CURSOR, th->style.spinbox.cursor);
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_SB, th->style.spinbox.sb);
|
||||
}
|
||||
|
||||
}
|
||||
/*Copy an existing spinbox*/
|
||||
else {
|
||||
@ -106,7 +101,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_spinbox_set_step(new_spinbox, copy_ext->step);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_spinbox);
|
||||
// lv_obj_refresh_style(new_spinbox);
|
||||
}
|
||||
|
||||
lv_spinbox_updatevalue(new_spinbox);
|
||||
@ -335,6 +330,12 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
{
|
||||
|
||||
lv_res_t res = LV_RES_OK;
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_spinbox_get_style(spinbox, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(spinbox, sign, param);
|
||||
}
|
||||
|
||||
/* Include the ancient signal function */
|
||||
if(sign != LV_SIGNAL_CONTROL) {
|
||||
@ -402,6 +403,35 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style descriptor of a part of the object
|
||||
* @param page pointer the object
|
||||
* @param part the part from `lv_spinbox_part_t`. (LV_SPINBOX_PART_...)
|
||||
* @return pointer to the style descriptor of the specified part
|
||||
*/
|
||||
static lv_style_dsc_t * lv_spinbox_get_style(lv_obj_t * ta, uint8_t part)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_style_dsc_t * style_dsc_p;
|
||||
|
||||
switch(part) {
|
||||
case LV_SPINBOX_PART_BG:
|
||||
style_dsc_p = &ta->style_dsc;
|
||||
break;
|
||||
case LV_SPINBOX_PART_SCRLBAR:
|
||||
style_dsc_p = &ext->ta.page.sb.style;
|
||||
break;
|
||||
case LV_SPINBOX_PART_CURSOR:
|
||||
style_dsc_p = &ext->ta.cursor.style;
|
||||
break;
|
||||
default:
|
||||
style_dsc_p = NULL;
|
||||
}
|
||||
|
||||
return style_dsc_p;
|
||||
}
|
||||
static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
@ -50,11 +50,13 @@ typedef struct
|
||||
|
||||
/*Styles*/
|
||||
enum {
|
||||
LV_SPINBOX_STYLE_BG,
|
||||
LV_SPINBOX_STYLE_SB,
|
||||
LV_SPINBOX_STYLE_CURSOR,
|
||||
LV_SPINBOX_PART_BG = LV_TA_PART_BG,
|
||||
LV_SPINBOX_PART_SCRLBAR = LV_TA_PART_SCRLBAR,
|
||||
LV_SPINBOX_PART_CURSOR = LV_TA_PART_CURSOR,
|
||||
_LV_SPINBOX_PART_VIRTUAL_LAST = _LV_TA_PART_VIRTUAL_LAST,
|
||||
_LV_SPINBOX_PART_REAL_LAST = _LV_TA_PART_REAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_spinbox_style_t;
|
||||
typedef uint8_t lv_spinbox_part_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -72,17 +74,6 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set a style of a spinbox.
|
||||
* @param templ pointer to template object
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
*/
|
||||
static inline void lv_spinbox_set_style(lv_obj_t * spinbox, lv_spinbox_style_t type, lv_style_t * style)
|
||||
{
|
||||
lv_ta_set_style(spinbox, type, style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set spinbox value
|
||||
* @param spinbox pointer to spinbox
|
||||
@ -125,17 +116,6 @@ void lv_spinbox_set_padding_left(lv_obj_t * spinbox, uint8_t padding);
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get style of a spinbox.
|
||||
* @param templ pointer to template object
|
||||
* @param type which style should be get
|
||||
* @return style pointer to the style
|
||||
*/
|
||||
static inline const lv_style_t * lv_spinbox_get_style(lv_obj_t * spinbox, lv_spinbox_style_t type)
|
||||
{
|
||||
return lv_ta_get_style(spinbox, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the spinbox numeral value (user has to convert to float according to its digit format)
|
||||
* @param spinbox pointer to spinbox
|
||||
|
@ -109,7 +109,6 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->pwd_show_time = LV_TA_DEF_PWD_SHOW_TIME;
|
||||
ext->accapted_chars = NULL;
|
||||
ext->max_length = 0;
|
||||
ext->cursor.style = NULL;
|
||||
ext->cursor.blink_time = LV_TA_DEF_CURSOR_BLINK_TIME;
|
||||
ext->cursor.pos = 0;
|
||||
ext->cursor.click_pos = 1;
|
||||
@ -122,6 +121,8 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->label = NULL;
|
||||
ext->placeholder = NULL;
|
||||
|
||||
lv_style_dsc_init(&ext->cursor.style);
|
||||
|
||||
#if LV_USE_ANIMATION == 0
|
||||
ext->pwd_show_time = 0;
|
||||
ext->cursor.blink_time = 0;
|
||||
@ -1375,9 +1376,15 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
{
|
||||
lv_res_t res;
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** type_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_ta_get_style(ta, **type_p);
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_ta_get_style(ta, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(ta, sign, param);
|
||||
}else if(sign == LV_SIGNAL_GET_STATE) {
|
||||
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
lv_get_state_info_t * info = param;
|
||||
if(info->part == LV_TA_PART_PLACEHOLDER) info->result = ext->placeholder ? lv_obj_get_state(ext->placeholder, LV_LABEL_PART_MAIN) : 0;
|
||||
else info->result = lv_obj_get_state(ta, info->part);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
@ -1549,20 +1556,23 @@ static lv_style_dsc_t * lv_ta_get_style(lv_obj_t * ta, uint8_t part)
|
||||
lv_style_dsc_t * style_dsc_p;
|
||||
|
||||
switch(part) {
|
||||
case LV_PAGE_PART_BG:
|
||||
case LV_TA_PART_BG:
|
||||
style_dsc_p = &ta->style_dsc;
|
||||
break;
|
||||
case LV_PAGE_PART_SCRL:
|
||||
style_dsc_p = lv_obj_get_style(ext->page.scrl, LV_CONT_PART_MAIN);
|
||||
break;
|
||||
case LV_PAGE_PART_SCRLBAR:
|
||||
case LV_TA_PART_SCRLBAR:
|
||||
style_dsc_p = &ext->page.sb.style;
|
||||
break;
|
||||
case LV_TA_PART_CURSOR:
|
||||
style_dsc_p = &ext->cursor.style;
|
||||
break;
|
||||
#if LV_USE_ANIMATION
|
||||
case LV_PAGE_PART_EDGE_FLASH:
|
||||
case LV_TA_PART_EDGE_FLASH:
|
||||
style_dsc_p = &ext->page.edge_flash.style;
|
||||
break;
|
||||
#endif
|
||||
case LV_TA_PART_PLACEHOLDER:
|
||||
style_dsc_p = ext->placeholder ? lv_obj_get_style(ext->placeholder, LV_LABEL_PART_MAIN) : NULL;
|
||||
break;
|
||||
default:
|
||||
style_dsc_p = NULL;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ typedef struct
|
||||
uint16_t pwd_show_time; /*Time to show characters in password mode before change them to '*' */
|
||||
struct
|
||||
{
|
||||
const lv_style_t * style; /* Style of the cursor (NULL to use label's style)*/
|
||||
lv_style_dsc_t style; /* Style of the cursor (NULL to use label's style)*/
|
||||
lv_coord_t valid_x; /* Used when stepping up/down to a shorter line.
|
||||
* (Used by the library)*/
|
||||
uint16_t pos; /* The current cursor position
|
||||
@ -89,11 +89,14 @@ typedef struct
|
||||
|
||||
/** Possible text areas tyles. */
|
||||
enum {
|
||||
LV_TA_PART_BG, /**< Text area background style */
|
||||
LV_TA_PART_SB, /**< Scrollbar style */
|
||||
LV_TA_PART_CURSOR, /**< Cursor style */
|
||||
LV_TA_PART_EDGE_FLASH, /**< Edge flash style */
|
||||
LV_TA_PART_PLACEHOLDER, /**< Placeholder style */
|
||||
LV_TA_PART_BG = LV_PAGE_PART_BG, /**< Text area background style */
|
||||
LV_TA_PART_SCRLBAR = LV_PAGE_PART_SCRLBAR, /**< Scrollbar style */
|
||||
LV_TA_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, /**< Edge flash style */
|
||||
LV_TA_PART_CURSOR = _LV_PAGE_PART_VIRTUAL_LAST, /**< Cursor style */
|
||||
_LV_TA_PART_VIRTUAL_LAST,
|
||||
|
||||
LV_TA_PART_PLACEHOLDER = _LV_PAGE_PART_REAL_LAST, /**< Placeholder style */
|
||||
_LV_TA_PART_REAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_ta_style_t;
|
||||
|
||||
|
@ -584,10 +584,10 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
{
|
||||
lv_res_t res;
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
uint8_t ** type_p = param;
|
||||
lv_style_dsc_t ** style_dsc_p = param;
|
||||
*style_dsc_p = lv_tabview_get_style(tabview, **type_p);
|
||||
return LV_RES_OK;
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_tabview_get_style(tabview, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(tabview, sign, param);
|
||||
}
|
||||
|
||||
/* Include the ancient signal function */
|
||||
@ -605,6 +605,9 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
ext->btns = NULL; /*These objects were children so they are already invalid*/
|
||||
ext->content = NULL;
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Be sure the buttons are updated because correct button size is required in `tabview_realign`*/
|
||||
lv_signal_send(ext->btns, LV_SIGNAL_STYLE_CHG, NULL);
|
||||
|
||||
tabview_realign(tabview);
|
||||
} else if(sign == LV_SIGNAL_COORD_CHG) {
|
||||
if(ext->content != NULL && (lv_obj_get_width(tabview) != lv_area_get_width(param) ||
|
||||
|
@ -67,11 +67,14 @@ typedef struct
|
||||
} lv_tabview_ext_t;
|
||||
|
||||
enum {
|
||||
LV_TABVIEW_PART_BG,
|
||||
LV_TABVIEW_PART_BG_SCRL,
|
||||
LV_TABVIEW_PART_BG = LV_OBJ_PART_MAIN,
|
||||
_LV_TABVIEW_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_LAST,
|
||||
|
||||
LV_TABVIEW_PART_BG_SCRL = _LV_OBJ_PART_REAL_LAST,
|
||||
LV_TABVIEW_PART_BTNS,
|
||||
LV_TABVIEW_PART_BTNS_BG,
|
||||
LV_TABVIEW_PART_INDIC,
|
||||
_LV_TABVIEW_PART_REAL_LAST,
|
||||
};
|
||||
typedef uint8_t lv_tabview_part_t;
|
||||
|
||||
|
@ -111,6 +111,8 @@ typedef enum {
|
||||
LV_THEME_CALENDAR_DATE_NUMS,
|
||||
LV_THEME_CALENDAR_TODAY_BOX,
|
||||
LV_THEME_CALENDAR_WEEK_BOX,
|
||||
|
||||
LV_THEME_ARC,
|
||||
}lv_theme_style_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -61,6 +61,14 @@ static lv_style_t ddlist_bg, ddlist_sel;
|
||||
static lv_style_t ta_cursor;
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
static lv_style_t arc;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
static lv_style_t calendar_date_nums;
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -325,22 +333,9 @@ static void gauge_init(void)
|
||||
static void arc_init(void)
|
||||
{
|
||||
#if LV_USE_ARC != 0
|
||||
|
||||
static lv_style_t arc;
|
||||
lv_style_copy(&arc, &def);
|
||||
arc.line.width = 8;
|
||||
arc.line.color = lv_color_hsv_to_rgb(_hue, 70, 90);
|
||||
arc.line.rounded = 1;
|
||||
|
||||
/*For preloader*/
|
||||
arc.body.border.width = 2;
|
||||
arc.body.border.color = lv_color_hex3(0x555);
|
||||
arc.body.padding.left = 3;
|
||||
arc.body.padding.right = 3;
|
||||
arc.body.padding.top = 3;
|
||||
arc.body.padding.bottom = 3;
|
||||
|
||||
theme.style.arc = &arc;
|
||||
lv_style_init(&arc);
|
||||
lv_style_set_color(&arc, LV_STYLE_LINE_COLOR, LV_COLOR_AQUA);
|
||||
lv_style_set_int(&arc, LV_STYLE_LINE_WIDTH, 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -362,7 +357,11 @@ static void chart_init(void)
|
||||
static void calendar_init(void)
|
||||
{
|
||||
#if LV_USE_CALENDAR
|
||||
|
||||
lv_style_init(&calendar_date_nums);
|
||||
lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR, LV_COLOR_RED);
|
||||
lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_DISABLED, LV_COLOR_GRAY);
|
||||
lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_WHITE);
|
||||
lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_CHECKED, LV_COLOR_NAVY);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -455,9 +454,6 @@ static void ta_init(void)
|
||||
static void spinbox_init(void)
|
||||
{
|
||||
#if LV_USE_SPINBOX
|
||||
theme.style.spinbox.bg = &panel;
|
||||
theme.style.spinbox.cursor = theme.style.ta.cursor;
|
||||
theme.style.spinbox.sb = theme.style.ta.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -660,6 +656,10 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name)
|
||||
case LV_THEME_CALENDAR_TODAY_BOX:
|
||||
case LV_THEME_CALENDAR_WEEK_BOX:
|
||||
return &btn;
|
||||
case LV_THEME_CALENDAR_DATE_NUMS:
|
||||
return &calendar_date_nums;
|
||||
case LV_THEME_ARC:
|
||||
return &arc;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user