BigW Consortium Gitlab

Commit a676590e by Gabor Kiss-Vamosi

add group focus callback and invalid area rounding callback option

parent 7310a2c6
......@@ -158,6 +158,8 @@ void lv_group_focus_next(lv_group_t * group)
if(group->obj_focus){
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
lv_obj_invalidate(*group->obj_focus);
if(group->focus_cb) group->focus_cb(group);
}
}
......@@ -184,6 +186,8 @@ void lv_group_focus_prev(lv_group_t * group)
if(group->obj_focus != NULL){
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
lv_obj_invalidate(*group->obj_focus);
if(group->focus_cb) group->focus_cb(group);
}
}
......@@ -212,18 +216,28 @@ void lv_group_send_data(lv_group_t * group, uint32_t c)
act->signal_func(act, LV_SIGNAL_CONTROLL, &c);
}
/**
* Set a function for a group which will modify the object's style if it is in focus
* @param group pointer to a group
* @param style_cb the style modifier function pointer
* @param style_mod_func the style modifier function pointer
*/
void lv_group_set_style_mod_cb(lv_group_t * group, void (*style_cb)(lv_style_t * style))
void lv_group_set_style_mod_cb(lv_group_t * group,lv_group_style_mod_func_t style_mod_func)
{
group->style_mod = style_cb;
group->style_mod = style_mod_func;
if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus);
}
/**
* Set a function for a group which will be called when a new object is focused
* @param group pointer to a group
* @param focus_cb the call back function or NULL if unused
*/
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
{
group->focus_cb = focus_cb;
}
/**
* Modify a style with the set 'style_mod' function. The input style remains unchanged.
* @param group pointer to group
......@@ -253,6 +267,26 @@ lv_obj_t * lv_group_get_focused(lv_group_t * group)
return *group->obj_focus;
}
/**
* Get a the style modifier function of a group
* @param group pointer to a group
* @return pointer to the style modifier function
*/
lv_group_style_mod_func_t lv_group_get_style_mod_cb(lv_group_t * group)
{
return group->style_mod ;
}
/**
* Get the focus callback function of a group
* @param group pointer to a group
* @return the call back function or NULL if not set
*/
lv_group_focus_cb_t lv_group_get_focus_cb(lv_group_t * group)
{
return group->focus_cb;
}
/**********************
* STATIC FUNCTIONS
**********************/
......
......@@ -34,13 +34,19 @@ extern "C" {
/**********************
* TYPEDEFS
**********************/
struct _lv_group_t;
typedef void (*lv_group_style_mod_func_t)(lv_style_t *);
typedef void (*lv_group_focus_cb_t)(struct _lv_group_t *);
typedef struct _lv_group_t
{
lv_ll_t obj_ll;
lv_obj_t ** obj_focus;
void (*style_mod)(lv_style_t * style);
lv_style_t style_tmp;
uint8_t frozen:1;
lv_ll_t obj_ll; /*Linked list to store the objects in the group */
lv_obj_t ** obj_focus; /*The object in focus*/
lv_group_style_mod_func_t style_mod; /*A function which modifies the style of the focused object*/
lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/
lv_style_t style_tmp; /*Stores the modified style of the focused object */
uint8_t frozen:1; /*1: can't focus to new object*/
}lv_group_t;
/**********************
......@@ -98,13 +104,19 @@ void lv_group_focus_freeze(lv_group_t * group, bool en);
*/
void lv_group_send_data(lv_group_t * group, uint32_t c);
/**
* Set a function for a group which will modify the object's style if it is in focus
* @param group pointer to a group
* @param style_cb the style modifier function pointer
* @param style_mod_func the style modifier function pointer
*/
void lv_group_set_style_mod_cb(lv_group_t * group,lv_group_style_mod_func_t style_mod_func);
/**
* Set a function for a group which will be called when a new object is focused
* @param group pointer to a group
* @param focus_cb the call back function or NULL if unused
*/
void lv_group_set_style_mod_cb(lv_group_t * group, void (*style_cb)(lv_style_t * style));
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb);
/**
* Modify a style with the set 'style_mod' function. The input style remains unchanged.
......@@ -121,6 +133,20 @@ lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style);
*/
lv_obj_t * lv_group_get_focused(lv_group_t * group);
/**
* Get a the style modifier function of a group
* @param group pointer to a group
* @return pointer to the style modifier function
*/
lv_group_style_mod_func_t lv_group_get_style_mod_cb(lv_group_t * group);
/**
* Get the focus callback function of a group
* @param group pointer to a group
* @return the call back function or NULL if not set
*/
lv_group_focus_cb_t lv_group_get_focus_cb(lv_group_t * group);
/**********************
* MACROS
**********************/
......
......@@ -48,7 +48,8 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p);
**********************/
static lv_join_t inv_buf[LV_INV_FIFO_SIZE];
static uint16_t inv_buf_p;
static void (*monitor_cb)(uint32_t, uint32_t);
static void (*monitor_cb)(uint32_t, uint32_t); /*Monitor the rendering time*/
static void (*round_cb)(lv_area_t*); /*If set then called to modify invalidated areas for special display controllers*/
static uint32_t px_num;
/**********************
......@@ -97,18 +98,8 @@ void lv_inv_area(const lv_area_t * area_p)
/*The area is truncated to the screen*/
if(suc != false) {
#if LV_INV_FULL_ROW == 1
/*Extend invalid area to be as wide as the screen*/
com_area.x1 = 0;
com_area.x2 = LV_HOR_RES-1;
#endif
if(round_cb) round_cb(&com_area);
#if LV_INV_FULL_COL == 1
/*Extend invalid area to be as tall as the screen*/
com_area.y1 = 0;
com_area.y2 = LV_VER_RES-1;
#endif
/*Save only if this area is not in one of the saved areas*/
uint16_t i;
for(i = 0; i < inv_buf_p; i++) {
......@@ -138,6 +129,16 @@ void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t))
monitor_cb = cb;
}
/**
* Called when an area is invalidated to modify the coordinates of the area.
* Special display controllers may require special coordinate rounding
* @param cb pointer to the a function which will modify the area
*/
void lv_refr_set_round_cd(void(*cb)(lv_area_t*))
{
round_cb = cb;
}
/**********************
* STATIC FUNCTIONS
**********************/
......
......@@ -58,6 +58,13 @@ void lv_inv_area(const lv_area_t * area_p);
*/
void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t));
/**
* Called when an area is invalidated to modify the coordinates of the area.
* Special display controllers may require special coordinate rounding
* @param cb pointer to the a function which will modify the area
*/
void lv_refr_set_round_cd(void(*cb)(lv_area_t*));
/**********************
* STATIC FUNCTIONS
**********************/
......
......@@ -231,8 +231,9 @@ lv_img_src_t lv_img_get_src_type(const void * src)
/*The first byte shows the type of the image source*/
if(u8_p[0] >= 'A' && u8_p[0] <= 'Z') return LV_IMG_SRC_FILE; /*It's a driver letter*/
else if(u8_p[0] >= 127) return LV_IMG_SRC_SYMBOL; /*After ASCII letteres only symbols (even UTF-8) can be*/
else if(((u8_p[0] & 0xFC) >> 2) == LV_IMG_FORMAT_INTERNAL_RAW) return LV_IMG_SRC_VARIABLE; /*Mask the file format part og of lv_img_t header. IT should be 0 which means C array */
else if(u8_p[0] >= ' ') return LV_IMG_SRC_SYMBOL; /*Other printable characters are considered symbols*/
else return LV_IMG_SRC_UNKNOWN;
}
......@@ -315,8 +316,6 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
lv_draw_img(&img->coords, mask, style, NULL);
}
}
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment