1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

add lv_obj_has/set/clear_flag() instead unique function for click, hidden etc

This commit is contained in:
Gabor Kiss-Vamosi 2020-09-02 11:56:51 +02:00
parent 5852852f8b
commit f09d871e4c
9 changed files with 83 additions and 423 deletions

View File

@ -216,7 +216,7 @@ static void calc_implicit_cols(lv_obj_t * cont, _lv_grid_calc_t * calc)
uint32_t child_cnt = lv_obj_count_children(cont);
uint32_t col_cnt = (child_cnt / grid->row_dsc_len) + 1;
uint32_t col_cnt = ((child_cnt + grid->row_dsc_len - 1) / grid->row_dsc_len) + 1; /*+ grid->row_dsc_len - 1 to round up*/
/* If `col_dsc_buf_used`, nested a call of this func. will release `col_dsc_buf_used` because it think it taken it.
* So mark that if the buffer was taken in this call*/
bool col_dsc_buf_mine = false;
@ -272,7 +272,7 @@ static void calc_implicit_rows(lv_obj_t * cont, _lv_grid_calc_t * calc)
lv_grid_t * grid = cont->grid;
uint32_t child_cnt = lv_obj_count_children(cont);
uint32_t row_cnt = (child_cnt / grid->col_dsc_len) + 1;
uint32_t row_cnt = ((child_cnt + grid->col_dsc_len - 1) / grid->col_dsc_len) + 1; /*+ grid->col_dsc_len - 1 to round up*/
bool row_dsc_buf_mine = false;
/*At worst case all children is gird item prepare place for all of them*/
lv_coord_t * rows_h;

View File

@ -31,7 +31,6 @@
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
void * (*move)(const lv_ll_t *, const void *));
static void lv_group_refocus(lv_group_t * g);
static void obj_to_foreground(lv_obj_t * obj);
/**********************
* STATIC VARIABLES
@ -241,9 +240,6 @@ void lv_group_focus_obj(lv_obj_t * obj)
lv_res_t res = lv_event_send(*g->obj_focus, LV_EVENT_FOCUSED, NULL);
if(res != LV_RES_OK) return;
lv_obj_invalidate(*g->obj_focus);
/*If the object or its parent has `top == true` bring it to the foreground*/
obj_to_foreground(*g->obj_focus);
}
break;
}
@ -490,7 +486,7 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
if(obj_next == NULL) continue;
/*Hidden objects don't receive focus*/
if(!lv_obj_get_hidden(*obj_next)) break;
if(lv_obj_has_flag(*obj_next, LV_OBJ_FLAG_HIDDEN) == false) break;
}
if(obj_next == group->obj_focus) return; /*There's only one visible object and it's already focused*/
@ -508,28 +504,10 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, NULL);
if(res != LV_RES_OK) return;
/*If the object or its parent has `top == true` bring it to the foreground*/
obj_to_foreground(*group->obj_focus);
lv_obj_invalidate(*group->obj_focus);
if(group->focus_cb) group->focus_cb(group);
}
static void obj_to_foreground(lv_obj_t * obj)
{
/*Search for 'top' attribute*/
lv_obj_t * i = obj;
lv_obj_t * last_top = NULL;
while(i != NULL) {
if(i->top != 0) last_top = i;
i = lv_obj_get_parent(i);
}
if(last_top != NULL) {
/*Move the last_top object to the foreground*/
lv_obj_move_foreground(last_top);
}
}
#endif /*LV_USE_GROUP != 0*/

View File

@ -212,7 +212,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
indev->cursor = cur_obj;
lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp));
lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y);
lv_obj_set_click(indev->cursor, false);
lv_obj_add_flag(indev->cursor, LV_OBJ_FLAG_CLICKABLE);
}
#if LV_USE_GROUP
@ -831,7 +831,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
}
/*If there is last object but it is not scrolled and not protected also search*/
else if(proc->types.pointer.scroll_obj == NULL &&
lv_obj_is_protected(indev_obj_act, LV_PROTECT_PRESS_LOST) == false) {
lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_PRESS_LOCK) == false) {
indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_sys(disp), &proc->types.pointer.act_point);
if(indev_obj_act == NULL) indev_obj_act = lv_indev_search_obj(lv_disp_get_layer_top(disp),
&proc->types.pointer.act_point);
@ -884,19 +884,6 @@ static void indev_proc_press(lv_indev_proc_t * proc)
proc->types.pointer.vect.x = 0;
proc->types.pointer.vect.y = 0;
/*Search for 'top' attribute*/
lv_obj_t * i = indev_obj_act;
lv_obj_t * last_top = NULL;
while(i != NULL) {
if(i->top) last_top = i;
i = lv_obj_get_parent(i);
}
if(last_top != NULL) {
/*Move the last_top object to the foreground*/
lv_obj_move_foreground(last_top);
}
/*Send a signal about the press*/
lv_signal_send(indev_obj_act, LV_SIGNAL_PRESSED, indev_act);
if(indev_reset_check(proc)) return;
@ -1079,10 +1066,10 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point)
/*If then the children was not ok, and this obj is clickable
* and it or its parent is not hidden then save this object*/
if(found_p == NULL && lv_obj_get_click(obj) != false) {
if(found_p == NULL && lv_obj_has_flag(obj, LV_OBJ_FLAG_CLICKABLE)) {
lv_obj_t * hidden_i = obj;
while(hidden_i != NULL) {
if(lv_obj_get_hidden(hidden_i) == true) break;
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_HIDDEN) == true) break;
hidden_i = lv_obj_get_parent(hidden_i);
}
/*No parent found with hidden == true*/
@ -1101,7 +1088,7 @@ static void indev_click_focus(lv_indev_proc_t * proc)
{
/*Handle click focus*/
lv_obj_t * obj_to_focus = lv_obj_get_focused_obj(indev_obj_act);
if(lv_obj_is_protected(indev_obj_act, LV_PROTECT_CLICK_FOCUS) == false &&
if(lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_PRESS_LOCK) == false &&
proc->types.pointer.last_pressed != obj_to_focus) {
#if LV_USE_GROUP
lv_group_t * g_act = lv_obj_get_group(indev_obj_act);
@ -1362,7 +1349,7 @@ static void indev_gesture(lv_indev_proc_t * proc)
lv_obj_t * gesture_obj = proc->types.pointer.act_obj;
/*If gesture parent is active check recursively the gesture attribute*/
while(gesture_obj && lv_obj_get_gesture_parent(gesture_obj)) {
while(gesture_obj && lv_obj_has_flag(gesture_obj, LV_OBJ_FLAG_GESTURE_BUBBLE)) {
gesture_obj = lv_obj_get_parent(gesture_obj);
}

View File

@ -329,14 +329,9 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Set attributes*/
new_obj->adv_hittest = 0;
new_obj->click = 1;
new_obj->scroll_mode = LV_SCROLL_MODE_AUTO;
new_obj->hidden = 0;
new_obj->top = 0;
new_obj->protect = LV_PROTECT_NONE;
new_obj->parent_event = 0;
new_obj->gesture_parent = parent ? 1 : 0;
new_obj->focus_parent = 0;
new_obj->flags = LV_OBJ_FLAG_CLICKABLE;
if(parent) new_obj->flags |= LV_OBJ_FLAG_GESTURE_BUBBLE;
new_obj->state = LV_STATE_DEFAULT;
new_obj->scroll.x = 0;
new_obj->scroll.y = 0;
@ -374,14 +369,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Copy attributes*/
new_obj->adv_hittest = copy->adv_hittest;
new_obj->click = copy->click;
new_obj->flags = copy->flags;
new_obj->scroll_mode = copy->scroll_mode;
new_obj->hidden = copy->hidden;
new_obj->top = copy->top;
new_obj->parent_event = copy->parent_event;
new_obj->protect = copy->protect;
new_obj->gesture_parent = copy->gesture_parent;
#if LV_USE_GROUP
/*Add to the same group*/
@ -533,7 +522,7 @@ void lv_obj_invalidate(const lv_obj_t * obj)
*/
bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area)
{
if(lv_obj_get_hidden(obj)) return false;
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_HIDDEN)) return false;
/*Invalidate the object only if it belongs to the curent or previous'*/
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
@ -562,7 +551,7 @@ bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area)
while(par != NULL) {
is_common = _lv_area_intersect(area, area, &par->coords);
if(is_common == false) return false; /*If no common parts with parent break;*/
if(lv_obj_get_hidden(par)) return false; /*If the parent is hidden then the child is hidden and won't be drawn*/
if(lv_obj_has_flag(par, LV_OBJ_FLAG_HIDDEN)) return false; /*If the parent is hidden then the child is hidden and won't be drawn*/
par = lv_obj_get_parent(par);
}
@ -794,12 +783,6 @@ static bool refr_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
lv_obj_t * par = lv_obj_get_parent(obj);
if(par != NULL) par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
/*Tell the children the parent's size has changed*/
lv_obj_t * i;
_LV_LL_READ(obj->child_ll, i) {
i->signal_cb(i, LV_SIGNAL_PARENT_SIZE_CHG, &ori);
}
/*Invalidate the new area*/
lv_obj_invalidate(obj);
return true;
@ -1763,25 +1746,6 @@ void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis)
* Attribute set
*----------------*/
/**
* Hide an object. It won't be visible and clickable.
* @param obj pointer to an object
* @param en true: hide the object
*/
void lv_obj_set_hidden(lv_obj_t * obj, bool en)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
obj->hidden = en == false ? 0 : 1;
if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */
lv_obj_t * par = lv_obj_get_parent(obj);
if(par) par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
}
/**
* Set whether advanced hit-testing is enabled on an object
* @param obj pointer to an object
@ -1794,31 +1758,6 @@ void lv_obj_set_adv_hittest(lv_obj_t * obj, bool en)
obj->adv_hittest = en == false ? 0 : 1;
}
/**
* Enable or disable the clicking of an object
* @param obj pointer to an object
* @param en true: make the object clickable
*/
void lv_obj_set_click(lv_obj_t * obj, bool en)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->click = (en == true ? 1 : 0);
}
/**
* Enable to bring this object to the foreground if it
* or any of its children is clicked
* @param obj pointer to an object
* @param en true: enable the auto top feature
*/
void lv_obj_set_top(lv_obj_t * obj, bool en)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->top = (en == true ? 1 : 0);
}
/**
* Set how the scrollbars should behave.
* @param obj pointer to an object
@ -1833,54 +1772,6 @@ void lv_obj_set_scroll_mode(lv_obj_t * obj, lv_scroll_mode_t mode)
lv_obj_invalidate(obj);
}
/**
* Enable to use parent for gesture related operations.
* If trying to gesture the object the parent will be moved instead
* @param obj pointer to an object
* @param en true: enable the 'gesture parent' for the object
*/
void lv_obj_set_gesture_parent(lv_obj_t * obj, bool en)
{
obj->gesture_parent = (en == true ? 1 : 0);
}
/**
* Enable to use parent for focus state.
* When object is focused the parent will get the state instead (visual only)
* @param obj pointer to an object
* @param en true: enable the 'focus parent' for the object
*/
void lv_obj_set_focus_parent(lv_obj_t * obj, bool en)
{
if(lv_obj_is_focused(obj)) {
if(en) {
obj->focus_parent = 1;
lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED);
lv_obj_set_state(lv_obj_get_focused_obj(obj), LV_STATE_FOCUSED);
}
else {
lv_obj_clear_state(lv_obj_get_focused_obj(obj), LV_STATE_FOCUSED | LV_STATE_EDITED);
lv_obj_set_state(obj, LV_STATE_FOCUSED);
obj->focus_parent = 0;
}
}
else {
obj->focus_parent = (en == true ? 1 : 0);
}
}
/**
* Propagate the events to the parent too
* @param obj pointer to an object
* @param en true: enable the event propagation
*/
void lv_obj_set_parent_event(lv_obj_t * obj, bool en)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->parent_event = (en == true ? 1 : 0);
}
/**
* Set the base direction of the object
* @param obj pointer to an object
@ -1903,31 +1794,24 @@ void lv_obj_set_base_dir(lv_obj_t * obj, lv_bidi_dir_t dir)
base_dir_refr_children(obj);
}
/**
* Set a bit or bits in the protect filed
* @param obj pointer to an object
* @param prot 'OR'-ed values from `lv_protect_t`
*/
void lv_obj_add_protect(lv_obj_t * obj, uint8_t prot)
void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->protect |= prot;
obj->flags |= f;
}
/**
* Clear a bit or bits in the protect filed
* @param obj pointer to an object
* @param prot 'OR'-ed values from `lv_protect_t`
*/
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot)
void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
prot = (~prot) & 0xFF;
obj->protect &= prot;
obj->flags &= (~f);
}
/**
* Set the state (fully overwrite) of an object.
* If specified in the styles a transition animation will be started
@ -2001,6 +1885,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
}
/**
* Add a given state or states to the object. The other state bits will remain unchanged.
* If specified in the styles a transition animation will be started
@ -2185,7 +2070,7 @@ lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t
}
if(obj) {
if(obj->parent_event && obj->parent) {
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) && obj->parent) {
lv_res_t res = lv_event_send(obj->parent, event, data);
if(res != LV_RES_OK) {
return LV_RES_INV;
@ -3124,16 +3009,11 @@ lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint8_t part)
* Attribute get
*----------------*/
/**
* Get the hidden attribute of an object
* @param obj pointer to an object
* @return true: the object is hidden
*/
bool lv_obj_get_hidden(const lv_obj_t * obj)
bool lv_obj_has_flag(lv_obj_t * obj, lv_obj_flag_t f)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return obj->hidden == 0 ? false : true;
return obj->flags & f ? true : false;
}
/**
@ -3148,29 +3028,6 @@ bool lv_obj_get_adv_hittest(const lv_obj_t * obj)
return obj->adv_hittest == 0 ? false : true;
}
/**
* Get the click enable attribute of an object
* @param obj pointer to an object
* @return true: the object is clickable
*/
bool lv_obj_get_click(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return obj->click == 0 ? false : true;
}
/**
* Get the top enable attribute of an object
* @param obj pointer to an object
* @return true: the auto top feature is enabled
*/
bool lv_obj_get_top(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return obj->top == 0 ? false : true;
}
/**
* Get how the scrollbars should behave.
@ -3184,39 +3041,6 @@ lv_scroll_mode_t lv_obj_get_scroll_mode(lv_obj_t * obj)
return obj->scroll_mode;
}
/**
* Get the gesture parent attribute of an object
* @param obj pointer to an object
* @return true: gesture parent is enabled
*/
bool lv_obj_get_gesture_parent(const lv_obj_t * obj)
{
return obj->gesture_parent == 0 ? false : true;
}
/**
* Get the focus parent attribute of an object
* @param obj pointer to an object
* @return true: focus parent is enabled
*/
bool lv_obj_get_focus_parent(const lv_obj_t * obj)
{
return obj->focus_parent == 0 ? false : true;
}
/**
* Get the parent event attribute of an object
* @param obj pointer to an object
* @return true: parent event is enabled
*/
bool lv_obj_get_parent_event(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return obj->parent_event == 0 ? false : true;
}
lv_bidi_dir_t lv_obj_get_base_dir(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
@ -3237,31 +3061,6 @@ lv_bidi_dir_t lv_obj_get_base_dir(const lv_obj_t * obj)
#endif
}
/**
* Get the protect field of an object
* @param obj pointer to an object
* @return protect field ('OR'ed values of `lv_protect_t`)
*/
uint8_t lv_obj_get_protect(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return obj->protect;
}
/**
* Check at least one bit of a given protect bitfield is set
* @param obj pointer to an object
* @param prot protect bits to test ('OR'ed values of `lv_protect_t`)
* @return false: none of the given bits are set, true: at least one bit is set
*/
bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return (obj->protect & prot) == 0 ? false : true;
}
lv_state_t lv_obj_get_state(const lv_obj_t * obj, uint8_t part)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
@ -4159,7 +3958,7 @@ lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj)
{
if(obj == NULL) return NULL;
const lv_obj_t * focus_obj = obj;
while(lv_obj_get_focus_parent(focus_obj) != false && focus_obj != NULL) {
while(lv_obj_has_flag(focus_obj, LV_OBJ_FLAG_FOCUS_BUBBLE) != false && focus_obj != NULL) {
focus_obj = lv_obj_get_parent(focus_obj);
}
@ -4193,9 +3992,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
}
}
else if(sign == 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) res = LV_RES_INV;
if(obj->w_set == LV_SIZE_AUTO || obj->h_set == LV_SIZE_AUTO) {
lv_obj_set_size(obj, obj->w_set, obj->h_set);
}
@ -4208,11 +4004,6 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
lv_grid_full_refr(obj);
}
}
// else if(lv_obj_is_content_sensitive(obj)) {
// lv_grid_full_refr(lv_obj_get_parent(obj));
// }
}
else if(sign == LV_SIGNAL_SCROLL) {
@ -4252,11 +4043,13 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
obj->ext_draw_pad = LV_MATH_MAX(obj->ext_draw_pad, d);
}
else if(sign == LV_SIGNAL_STYLE_CHG) {
lv_obj_t * child = lv_obj_get_child(obj, NULL);
while(child) {
lv_obj_set_pos(child, child->x_set, child->y_set);
child = lv_obj_get_child(obj, child);
}
if(lv_obj_is_grid_item(obj)) lv_grid_full_refr(obj);
// lv_obj_t * child = lv_obj_get_child(obj, NULL);
// while(child) {
// lv_obj_set_pos(child, child->x_set, child->y_set);
// child = lv_obj_get_child(obj, child);
// }
if(obj->w_set == LV_SIZE_AUTO || obj->h_set == LV_SIZE_AUTO) {

View File

@ -126,7 +126,6 @@ enum {
LV_SIGNAL_CLEANUP, /**< Object is being deleted */
LV_SIGNAL_CHILD_CHG, /**< Child was removed/added */
LV_SIGNAL_COORD_CHG, /**< Object coordinates/size have changed */
LV_SIGNAL_PARENT_SIZE_CHG, /**< Parent's size has changed */
LV_SIGNAL_STYLE_CHG, /**< Object's style has changed */
LV_SIGNAL_BASE_DIR_CHG, /**<The base dir has changed*/
LV_SIGNAL_REFR_EXT_DRAW_PAD, /**< Object's extra padding has changed */
@ -159,19 +158,6 @@ typedef uint8_t lv_signal_t;
typedef lv_res_t (*lv_signal_cb_t)(struct _lv_obj_t * obj, lv_signal_t sign, void * param);
/*Protect some attributes (max. 8 bit)*/
enum {
LV_PROTECT_NONE = 0x00,
LV_PROTECT_CHILD_CHG = 0x01, /**< Disable the child change signal. Used by the library*/
LV_PROTECT_PARENT = 0x02, /**< Prevent automatic parent change (e.g. in lv_page)*/
LV_PROTECT_POS = 0x04, /**< Prevent automatic positioning (e.g. in lv_cont layout)*/
LV_PROTECT_FOLLOW = 0x08, /**< Prevent the object be followed in automatic ordering (e.g. in
lv_cont PRETTY layout)*/
LV_PROTECT_PRESS_LOST = 0x10, /**< If the `indev` was pressing this object but swiped out while
pressing do not search other object.*/
LV_PROTECT_CLICK_FOCUS = 0x20, /**< Prevent focusing the object by clicking on it*/
};
typedef uint8_t lv_protect_t;
enum {
LV_STATE_DEFAULT = 0x00,
@ -185,6 +171,35 @@ enum {
typedef uint8_t lv_state_t;
enum {
LV_SCROLL_SNAP_OFF,
LV_SCROLL_SNAP_NORMAL,
LV_SCROLL_SNAP_ALWAYS,
};
typedef uint8_t lv_scroll_snap_t;
enum {
LV_SCROLL_SNAP_ALIGN_START,
LV_SCROLL_SNAP_ALIGN_END,
LV_SCROLL_SNAP_ALIGN_CENTER
};
typedef uint8_t lv_scroll_snap_align_t;
enum {
LV_OBJ_FLAG_HIDDEN,
LV_OBJ_FLAG_CLICKABLE,
LV_OBJ_FLAG_SCROLLABLE,
LV_OBJ_FLAG_SCROLL_ELASTIC,
LV_OBJ_FLAG_SCROLL_MOMENTUM,
LV_OBJ_FLAG_PRESS_LOCK,
LV_OBJ_FLAG_EVENT_BUBBLE,
LV_OBJ_FLAG_GESTURE_BUBBLE,
LV_OBJ_FLAG_FOCUS_BUBBLE,
};
typedef uint16_t lv_obj_flag_t;
/** Scrollbar modes: shows when should the scrollbars be visible*/
enum {
LV_SCROLL_MODE_OFF = 0x0, /**< Never show scroll bars*/
@ -218,15 +233,16 @@ typedef struct _lv_obj_t {
lv_coord_t ext_draw_pad; /**< EXTend the size in every direction for drawing. */
/*Attributes and states*/
uint8_t click : 1; /**< 1: Can be pressed by an input device*/
uint8_t hidden : 1; /**< 1: Object is hidden*/
uint8_t top : 1; /**< 1: If the object or its children is clicked it goes to the foreground*/
uint8_t parent_event : 1; /**< 1: Send the object's events to the parent too. */
uint8_t adv_hittest : 1; /**< 1: Use advanced hit-testing (slower) */
uint8_t gesture_parent : 1; /**< 1: Parent will be gesture instead*/
uint8_t focus_parent : 1; /**< 1: Parent will be focused instead*/
lv_obj_flag_t flags : 9;
lv_scroll_mode_t scroll_mode :2; /**< How to display scrollbars*/
lv_scroll_snap_t snap_x : 2;
lv_scroll_snap_t snap_y : 2;
lv_scroll_snap_align_t snap_align_x : 2;
lv_scroll_snap_align_t snap_align_y : 2;
lv_bidi_dir_t base_dir : 2; /**< Base direction of texts related to this object */
uint8_t adv_hittest : 1; /**< 1: Use advanced hit-testing (slower) */
lv_state_t state;
lv_coord_t x_set;
lv_coord_t y_set;
lv_coord_t w_set;
@ -236,9 +252,6 @@ typedef struct _lv_obj_t {
void * group_p;
#endif
uint8_t protect; /**< Automatically happening actions can be prevented.
'OR'ed values from `lv_protect_t`*/
lv_state_t state;
#if LV_USE_USER_DATA
lv_obj_user_data_t user_data; /**< Custom user data for object. */
@ -711,13 +724,6 @@ void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis);
* Attribute set
*----------------*/
/**
* Hide an object. It won't be visible and clickable.
* @param obj pointer to an object
* @param en true: hide the object
*/
void lv_obj_set_hidden(lv_obj_t * obj, bool en);
/**
* Set whether advanced hit-testing is enabled on an object
* @param obj pointer to an object
@ -725,28 +731,6 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool en);
*/
void lv_obj_set_adv_hittest(lv_obj_t * obj, bool en);
/**
* Enable or disable the clicking of an object
* @param obj pointer to an object
* @param en true: make the object clickable
*/
void lv_obj_set_click(lv_obj_t * obj, bool en);
/**
* Enable to bring this object to the foreground if it
* or any of its children is clicked
* @param obj pointer to an object
* @param en true: enable the auto top feature
*/
void lv_obj_set_top(lv_obj_t * obj, bool en);
/**
* Enable to use parent for focus state.
* When object is focused the parent will get the state instead (visual only)
* @param obj pointer to an object
* @param en true: enable the 'focus parent' for the object
*/
void lv_obj_set_focus_parent(lv_obj_t * obj, bool en);
/**
* Set how the scrollbars should behave.
@ -755,21 +739,6 @@ void lv_obj_set_focus_parent(lv_obj_t * obj, bool en);
*/
void lv_obj_set_scroll_mode(lv_obj_t * obj, lv_scroll_mode_t mode);
/**
* Enable to use parent for gesture related operations.
* If trying to gesture the object the parent will be moved instead
* @param obj pointer to an object
* @param en true: enable the 'gesture parent' for the object
*/
void lv_obj_set_gesture_parent(lv_obj_t * obj, bool en);
/**
* Propagate the events to the parent too
* @param obj pointer to an object
* @param en true: enable the event propagation
*/
void lv_obj_set_parent_event(lv_obj_t * obj, bool en);
/**
* Set the base direction of the object
* @param obj pointer to an object
@ -777,19 +746,8 @@ void lv_obj_set_parent_event(lv_obj_t * obj, bool en);
*/
void lv_obj_set_base_dir(lv_obj_t * obj, lv_bidi_dir_t dir);
/**
* Set a bit or bits in the protect filed
* @param obj pointer to an object
* @param prot 'OR'-ed values from `lv_protect_t`
*/
void lv_obj_add_protect(lv_obj_t * obj, uint8_t prot);
/**
* Clear a bit or bits in the protect filed
* @param obj pointer to an object
* @param prot 'OR'-ed values from `lv_protect_t`
*/
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot);
void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f);
void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f);
/**
* Set the state (fully overwrite) of an object.
@ -1208,12 +1166,8 @@ lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint8_t part);
* Attribute get
*----------------*/
/**
* Get the hidden attribute of an object
* @param obj pointer to an object
* @return true: the object is hidden
*/
bool lv_obj_get_hidden(const lv_obj_t * obj);
bool lv_obj_has_flag(lv_obj_t * obj, lv_obj_flag_t f);
/**
* Get whether advanced hit-testing is enabled on an object
@ -1222,59 +1176,8 @@ bool lv_obj_get_hidden(const lv_obj_t * obj);
*/
bool lv_obj_get_adv_hittest(const lv_obj_t * obj);
/**
* Get the click enable attribute of an object
* @param obj pointer to an object
* @return true: the object is clickable
*/
bool lv_obj_get_click(const lv_obj_t * obj);
/**
* Get the top enable attribute of an object
* @param obj pointer to an object
* @return true: the auto top feature is enabled
*/
bool lv_obj_get_top(const lv_obj_t * obj);
/**
* Get the focus parent attribute of an object
* @param obj pointer to an object
* @return true: focus parent is enabled
*/
bool lv_obj_get_focus_parent(const lv_obj_t * obj);
/**
* Get the parent event attribute of an object
* @param obj pointer to an object
* @return true: parent event is enabled
*/
bool lv_obj_get_parent_event(const lv_obj_t * obj);
/**
* Get the gesture parent attribute of an object
* @param obj pointer to an object
* @return true: gesture parent is enabled
*/
bool lv_obj_get_gesture_parent(const lv_obj_t * obj);
lv_bidi_dir_t lv_obj_get_base_dir(const lv_obj_t * obj);
/**
* Get the protect field of an object
* @param obj pointer to an object
* @return protect field ('OR'ed values of `lv_protect_t`)
*/
uint8_t lv_obj_get_protect(const lv_obj_t * obj);
/**
* Check at least one bit of a given protect bitfield is set
* @param obj pointer to an object
* @param prot protect bits to test ('OR'ed values of `lv_protect_t`)
* @return false: none of the given bits are set, true: at least one bit is set
*/
bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot);
lv_state_t lv_obj_get_state(const lv_obj_t * obj, uint8_t part);
/**

View File

@ -571,7 +571,7 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
lv_obj_t * found_p = NULL;
/*If this object is fully cover the draw area check the children too */
if(_lv_area_is_in(area_p, &obj->coords, 0) && obj->hidden == 0) {
if(_lv_area_is_in(area_p, &obj->coords, 0) && (obj->flags & LV_OBJ_FLAG_HIDDEN) == 0) {
lv_design_res_t design_res = obj->design_cb ? obj->design_cb(obj, area_p,
LV_DESIGN_COVER_CHK) : LV_DESIGN_RES_NOT_COVER;
if(design_res == LV_DESIGN_RES_MASKED) return NULL;
@ -649,7 +649,7 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
{
/*Do not refresh hidden objects*/
if(obj->hidden != 0) return;
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_HIDDEN)) return;
bool union_ok; /* Store the return value of area_union */
/* Truncate the original mask to the coordinates of the parent

View File

@ -158,8 +158,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/
lv_obj_reset_style_list(disp->top_layer, LV_OBJ_PART_MAIN);
lv_obj_reset_style_list(disp->sys_layer, LV_OBJ_PART_MAIN);
lv_obj_set_click(disp->top_layer, false);
lv_obj_set_click(disp->sys_layer, false);
lv_obj_clear_flag(disp->top_layer, LV_OBJ_FLAG_CLICKABLE);
lv_obj_clear_flag(disp->sys_layer, LV_OBJ_FLAG_CLICKABLE);
lv_obj_set_scroll_mode(disp->top_layer, LV_SCROLL_MODE_OFF);
lv_obj_set_scroll_mode(disp->sys_layer, LV_SCROLL_MODE_OFF);

View File

@ -50,11 +50,10 @@ typedef uint8_t lv_indev_type_t;
enum { LV_INDEV_STATE_REL = 0, LV_INDEV_STATE_PR };
typedef uint8_t lv_indev_state_t;
enum {
LV_SCROLL_DIR_NONE = 0x0, /**< Object can't be dragged to any directions. */
LV_SCROLL_DIR_HOR = 0x1, /**< Object can be dragged horizontally. */
LV_SCROLL_DIR_VER = 0x2, /**< Object can be dragged vertically. */
LV_SCROLL_DIR_NONE,
LV_SCROLL_DIR_HOR,
LV_SCROLL_DIR_VER,
};
typedef uint8_t lv_scroll_dir_t;

View File

@ -127,7 +127,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new label*/
if(copy == NULL) {
lv_theme_apply(new_label, LV_THEME_LABEL);
lv_obj_set_click(new_label, false);
lv_obj_clear_flag(new_label, LV_OBJ_FLAG_CLICKABLE);
lv_label_set_long_mode(new_label, LV_LABEL_LONG_EXPAND);
lv_label_set_text(new_label, "Text");
}