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

refactor(event): adjust events names

This commit is contained in:
Gabor Kiss-Vamosi 2021-03-18 17:18:11 +01:00
parent 03f74ce186
commit 0ef2e08d02
20 changed files with 72 additions and 78 deletions

View File

@ -456,7 +456,7 @@ void lv_obj_set_base_dir(lv_obj_t * obj, lv_bidi_dir_t dir)
lv_obj_allocate_spec_attr(obj);
obj->spec_attr->base_dir = dir;
lv_event_send(obj, LV_EVENT_BASE_DIR_CHG, NULL);
lv_event_send(obj, LV_EVENT_BASE_DIR_CHANGED, NULL);
/* Notify the children about the parent base dir has changed.
* (The children might have `LV_BIDI_DIR_INHERIT`)*/
@ -977,7 +977,7 @@ static void lv_obj_event_cb(lv_obj_t * obj, lv_event_t e)
lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY);
}
else if(e == LV_EVENT_COORD_CHG) {
else if(e == LV_EVENT_COORD_CHANGED) {
bool w_new = true;
bool h_new = true;
void * param = lv_event_get_param();
@ -1028,14 +1028,14 @@ static void lv_obj_event_cb(lv_obj_t * obj, lv_event_t e)
}
}
}
else if(e == LV_EVENT_CHILD_CHG) {
else if(e == LV_EVENT_CHILD_CHANGED) {
lv_obj_mark_layout_as_dirty(obj);
if(obj->w_set == LV_SIZE_CONTENT || obj->h_set == LV_SIZE_CONTENT) {
lv_obj_set_size(obj, obj->w_set, obj->h_set);
}
}
else if(e == LV_EVENT_BASE_DIR_CHG) {
else if(e == LV_EVENT_BASE_DIR_CHANGED) {
/* The layout might depend on the base dir.
* E.g. the first is element is on the left or right*/
lv_obj_mark_layout_as_dirty(obj);
@ -1050,7 +1050,7 @@ static void lv_obj_event_cb(lv_obj_t * obj, lv_event_t e)
lv_coord_t d = lv_obj_calculate_ext_draw_size(obj, LV_PART_MAIN);
*s = LV_MAX(*s, d);
}
else if(e == LV_EVENT_STYLE_CHG) {
else if(e == LV_EVENT_STYLE_CHANGED) {
/* Padding might have changed so the layout should be recalculated*/
lv_obj_mark_layout_as_dirty(obj);
@ -1149,7 +1149,7 @@ static void base_dir_refr_children(lv_obj_t * obj)
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
if(lv_obj_get_base_dir(child) == LV_BIDI_DIR_INHERIT) {
lv_event_send(child, LV_EVENT_BASE_DIR_CHG, NULL);
lv_event_send(child, LV_EVENT_BASE_DIR_CHANGED, NULL);
base_dir_refr_children(child);
}
}

View File

@ -42,53 +42,50 @@ struct _lv_obj_t;
* Type of event being sent to the object.
*/
typedef enum {
/** Input device events*/
LV_EVENT_PRESSED, /**< The object has been pressed*/
LV_EVENT_PRESSING, /**< The object is being pressed (called continuously while pressing)*/
LV_EVENT_PRESS_LOST, /**< User is still pressing but slid cursor/finger off of the object */
LV_EVENT_PRESS_LOST, /**< User is still being pressed but slid cursor/finger off of the object */
LV_EVENT_SHORT_CLICKED, /**< User pressed object for a short period of time, then released it. Not called if scrolled. */
LV_EVENT_LONG_PRESSED, /**< Object has been pressed for at least `LV_INDEV_LONG_PRESS_TIME`. Not called if scrolled.*/
LV_EVENT_LONG_PRESSED_REPEAT, /**< Called after `LV_INDEV_LONG_PRESS_TIME` in every
`LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if scrolled.*/
LV_EVENT_LONG_PRESSED_REPEAT, /**< Called after `LV_INDEV_LONG_PRESS_TIME` in every `LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if scrolled.*/
LV_EVENT_CLICKED, /**< Called on release if not scrolled (regardless to long press)*/
LV_EVENT_RELEASED, /**< Called in every cases when the object has been released*/
LV_EVENT_SCROLL_BEGIN,
LV_EVENT_SCROLL_END,
LV_EVENT_SCROLL,
LV_EVENT_GESTURE, /**< The object has been gesture*/
LV_EVENT_KEY,
LV_EVENT_FOCUSED,
LV_EVENT_DEFOCUSED,
LV_EVENT_LEAVE,
LV_EVENT_SCROLL_BEGIN, /**< Scrolling begins*/
LV_EVENT_SCROLL_END, /**< Scrolling ends*/
LV_EVENT_SCROLL, /**< Scrolling*/
LV_EVENT_GESTURE, /**< Gesture detected*/
LV_EVENT_KEY, /**< A key is sent to the object */
LV_EVENT_FOCUSED, /**< Focused */
LV_EVENT_DEFOCUSED, /**< Defocused*/
LV_EVENT_LEAVE, /**< Defocused but still selected*/
LV_EVENT_HIT_TEST, /**< Perform advanced hit-testing */
/** Drawing events*/
LV_EVENT_COVER_CHECK, /**< Check if the object fully covers an area */
LV_EVENT_REFR_EXT_DRAW_SIZE, /**< Get the required extra draw area around the object (e.g. for shadow) */
LV_EVENT_DRAW_MAIN_BEGIN, /**< Starting the main drawing phase*/
LV_EVENT_DRAW_MAIN, /**< Perform the main drawing*/
LV_EVENT_DRAW_MAIN_END, /**< Finishing the main drawing phase*/
LV_EVENT_DRAW_POST_BEGIN, /**< Starting the post draw phase (when all children are drawn)*/
LV_EVENT_DRAW_POST, /**< Perform the post draw phase (when all children are drawn)*/
LV_EVENT_DRAW_POST_END, /**< Finishing the post draw phase (when all children are drawn)*/
LV_EVENT_DRAW_PART_BEGIN, /**< Starting to draw a part. */
LV_EVENT_DRAW_PART_END, /**< Finishing to draw a part. */
/** General events*/
LV_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved) */
LV_EVENT_INSERT,
LV_EVENT_REFRESH,
LV_EVENT_INSERT, /**< A text is inserted to the object */
LV_EVENT_REFRESH, /**< Notify the object to refresh something on it (for the user)*/
LV_EVENT_DELETE, /**< Object is being deleted */
LV_EVENT_COVER_CHECK, /**< Check if the object fully covers the 'mask_p' area */
LV_EVENT_REFR_EXT_DRAW_SIZE, /**< Draw extras on the object */
LV_EVENT_DRAW_MAIN_BEGIN,
LV_EVENT_DRAW_MAIN,
LV_EVENT_DRAW_MAIN_END,
LV_EVENT_DRAW_POST_BEGIN,
LV_EVENT_DRAW_POST,
LV_EVENT_DRAW_POST_END,
LV_EVENT_DRAW_PART_BEGIN,
LV_EVENT_DRAW_PART_END,
LV_EVENT_READY, /**< A process has finished */
LV_EVENT_CANCEL, /**< A process has been cancelled */
/*General signals*/
LV_EVENT_CHILD_CHG, /**< Child was removed/added */
LV_EVENT_COORD_CHG, /**< Object coordinates/size have changed */
LV_EVENT_STYLE_CHG, /**< Object's style has changed */
LV_EVENT_BASE_DIR_CHG, /**< The base dir has changed*/
LV_EVENT_CHILD_CHANGED, /**< Child was removed/added */
LV_EVENT_COORD_CHANGED, /**< Object coordinates/size have changed */
LV_EVENT_STYLE_CHANGED, /**< Object's style has changed */
LV_EVENT_BASE_DIR_CHANGED, /**< The base dir has changed*/
LV_EVENT_GET_SELF_SIZE, /**< Get the internal size of a widget*/
/*Input device related*/
LV_EVENT_HIT_TEST, /**< Advanced hit-testing */
_LV_EVENT_LAST /** Number of default events*/
}lv_event_t;

View File

@ -57,7 +57,7 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p
if(parent) {
/* Send a signal to the parent to notify it about the new child.
* Also triggers layout update*/
lv_event_send(parent, LV_EVENT_CHILD_CHG, obj);
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
/*Invalidate the area if not screen created*/
lv_obj_invalidate(obj);

View File

@ -504,10 +504,10 @@ void lv_obj_move_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, bool notify)
lv_obj_move_children_by(obj, diff.x, diff.y, false);
/*Inform the object about its new coordinates*/
lv_event_send(obj, LV_EVENT_COORD_CHG, &ori);
lv_event_send(obj, LV_EVENT_COORD_CHANGED, &ori);
/*Send a signal to the parent too*/
if(parent && notify) lv_event_send(parent, LV_EVENT_CHILD_CHG, obj);
if(parent && notify) lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
/*Invalidate the new area*/
lv_obj_invalidate(obj);
@ -714,10 +714,10 @@ static bool refr_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
}
/*Send a signal to the object with its new coordinates*/
lv_event_send(obj, LV_EVENT_COORD_CHG, &ori);
lv_event_send(obj, LV_EVENT_COORD_CHANGED, &ori);
/*Send a signal to the parent too*/
if(parent != NULL) lv_event_send(parent, LV_EVENT_CHILD_CHG, obj);
if(parent != NULL) lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
/*Invalidate the new area*/
lv_obj_invalidate(obj);

View File

@ -171,7 +171,7 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop)
lv_obj_invalidate(obj);
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_PROP_LAYOUT_REFR))) {
lv_event_send(obj, LV_EVENT_STYLE_CHG, NULL); /*To update layout*/
lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL); /*To update layout*/
} else if(prop & LV_STYLE_PROP_EXT_DRAW) {
lv_obj_refresh_ext_draw_size(obj);
}
@ -569,7 +569,7 @@ static void refresh_children_style(lv_obj_t * obj)
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
lv_obj_invalidate(child);
lv_event_send(child, LV_EVENT_STYLE_CHG, NULL);
lv_event_send(child, LV_EVENT_STYLE_CHANGED, NULL);
lv_obj_invalidate(child);
refresh_children_style(child); /*Check children too*/

View File

@ -72,7 +72,7 @@ void lv_obj_del(lv_obj_t * obj)
par->spec_attr->scroll.x = 0;
par->spec_attr->scroll.y = 0;
}
lv_event_send(par, LV_EVENT_CHILD_CHG, NULL);
lv_event_send(par, LV_EVENT_CHILD_CHANGED, NULL);
}
/*Handle if the active screen was deleted*/
@ -178,10 +178,10 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
}
/*Notify the original parent because one of its children is lost*/
lv_event_send(old_parent, LV_EVENT_CHILD_CHG, obj);
lv_event_send(old_parent, LV_EVENT_CHILD_CHANGED, obj);
/*Notify the new parent about the child*/
lv_event_send(parent, LV_EVENT_CHILD_CHG, obj);
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
lv_obj_invalidate(obj);
}
@ -201,7 +201,7 @@ void lv_obj_move_foreground(lv_obj_t * obj)
parent->spec_attr->children[lv_obj_get_child_cnt(parent) - 1] = obj;
/*Notify the new parent about the child*/
lv_event_send(parent, LV_EVENT_CHILD_CHG, obj);
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
lv_obj_invalidate(parent);
}
@ -221,7 +221,7 @@ void lv_obj_move_background(lv_obj_t * obj)
parent->spec_attr->children[0] = obj;
/*Notify the new parent about the child*/
lv_event_send(parent, LV_EVENT_CHILD_CHG, obj);
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
lv_obj_invalidate(parent);
}

View File

@ -349,7 +349,7 @@ static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_
if(lv_area_get_height(&old_coords) != area_get_main_size(&item->coords)) {
lv_obj_invalidate(item);
lv_event_send(item, LV_EVENT_COORD_CHG, &old_coords);
lv_event_send(item, LV_EVENT_COORD_CHANGED, &old_coords);
lv_obj_invalidate(item);
}
}

View File

@ -421,7 +421,7 @@ static void item_repos(lv_obj_t * item, _lv_grid_calc_t * c, item_repos_hint_t *
lv_area_set_width(&item->coords, item_w);
lv_area_set_height(&item->coords, item_h);
lv_obj_invalidate(item);
lv_event_send(item, LV_EVENT_COORD_CHG, &old_coords);
lv_event_send(item, LV_EVENT_COORD_CHANGED, &old_coords);
}
bool moved = true;

View File

@ -354,7 +354,7 @@ static void lv_colorwheel_event(lv_obj_t * obj, lv_event_t e)
lv_coord_t * s = lv_event_get_param();
*s = LV_MAX(*s, knob_pad);
}
else if(e == LV_EVENT_COORD_CHG) {
else if(e == LV_EVENT_COORD_CHANGED) {
void * param = lv_event_get_param();
/*Refresh extended draw area to make knob visible*/
if(lv_obj_get_width(obj) != lv_area_get_width(param) ||
@ -362,7 +362,7 @@ static void lv_colorwheel_event(lv_obj_t * obj, lv_event_t e)
refr_knob_pos(obj);
}
}
else if(e == LV_EVENT_STYLE_CHG) {
else if(e == LV_EVENT_STYLE_CHANGED) {
/*Refresh extended draw area to make knob visible*/
refr_knob_pos(obj);
}

View File

@ -169,7 +169,7 @@ void lv_disp_drv_update(lv_disp_t * disp, lv_disp_drv_t * new_drv)
lv_obj_get_coords(disp->screens[i], &prev_coords);
lv_area_set_width(&disp->screens[i]->coords, w);
lv_area_set_height(&disp->screens[i]->coords, h);
lv_event_send(disp->screens[i], LV_EVENT_COORD_CHG, &prev_coords);
lv_event_send(disp->screens[i], LV_EVENT_COORD_CHANGED, &prev_coords);
}
/*

View File

@ -686,7 +686,6 @@ static void lv_arc_event(lv_obj_t * obj, lv_event_t e)
lv_coord_t * s = lv_event_get_param();
*s = LV_MAX(*s, knob_pad - bg_pad);
} else if(e == LV_EVENT_DRAW_MAIN) {
const lv_area_t * clip_area = lv_event_get_param();
lv_arc_draw(obj);
}
}

View File

@ -400,10 +400,10 @@ static void lv_btnmatrix_event(lv_obj_t * obj, lv_event_t e)
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
lv_point_t p;
if(e == LV_EVENT_STYLE_CHG) {
if(e == LV_EVENT_STYLE_CHANGED) {
lv_btnmatrix_set_map(obj, btnm->map_p);
}
else if(e == LV_EVENT_COORD_CHG) {
else if(e == LV_EVENT_COORD_CHANGED) {
void * param = lv_event_get_param();
if(param &&
(lv_obj_get_width(obj) != lv_area_get_width(param) || lv_obj_get_height(obj) != lv_area_get_height(param)))

View File

@ -650,7 +650,6 @@ static void lv_chart_event(lv_obj_t * obj, lv_event_t e)
draw_div_lines(obj, clip_area);
draw_axes(obj, clip_area);
lv_chart_t * chart = (lv_chart_t *)obj;
if(chart->type & LV_CHART_TYPE_LINE) draw_series_line(obj, clip_area);
else if(chart->type & LV_CHART_TYPE_BAR) draw_series_bar(obj, clip_area);

View File

@ -662,7 +662,7 @@ static void lv_dropdown_event(lv_obj_t * obj, lv_event_t e)
lv_obj_invalidate(obj);
}
}
else if(e == LV_EVENT_COORD_CHG) {
else if(e == LV_EVENT_COORD_CHANGED) {
if(dropdown->list) lv_dropdown_close(obj);
}
else if(e == LV_EVENT_GET_SELF_SIZE) {

View File

@ -420,7 +420,7 @@ static void lv_img_event(lv_obj_t * obj, lv_event_t e)
lv_img_t * img = (lv_img_t *)obj;
if(e == LV_EVENT_STYLE_CHG) {
if(e == LV_EVENT_STYLE_CHANGED) {
/*Refresh the file name to refresh the symbol text size*/
if(img->src_type == LV_IMG_SRC_SYMBOL) {
lv_img_set_src(obj, img->src);

View File

@ -745,12 +745,12 @@ static void lv_label_event_cb(lv_obj_t * obj, lv_event_t e)
res = lv_obj_event_base(MY_CLASS, obj, e);
if(res != LV_RES_OK) return;
if(e == LV_EVENT_STYLE_CHG) {
if(e == LV_EVENT_STYLE_CHANGED) {
/*Revert dots for proper refresh*/
lv_label_revert_dots(obj);
lv_label_refr_text(obj);
}
else if(e == LV_EVENT_COORD_CHG) {
else if(e == LV_EVENT_COORD_CHANGED) {
void * param = lv_event_get_param();
if(lv_area_get_width(&obj->coords) != lv_area_get_width(param) ||
lv_area_get_height(&obj->coords) != lv_area_get_height(param)) {
@ -758,7 +758,7 @@ static void lv_label_event_cb(lv_obj_t * obj, lv_event_t e)
lv_label_refr_text(obj);
}
}
else if(e == LV_EVENT_BASE_DIR_CHG) {
else if(e == LV_EVENT_BASE_DIR_CHANGED) {
#if LV_USE_BIDI
lv_label_t * label = (lv_label_t *)obj;
if(label->static_txt == 0) lv_label_set_text(obj, NULL);

View File

@ -327,14 +327,14 @@ static void lv_roller_event(lv_obj_t * obj, lv_event_t e)
lv_point_t * p = lv_event_get_param();
p->x = get_selected_label_width(obj);
}
else if(e == LV_EVENT_STYLE_CHG) {
else if(e == LV_EVENT_STYLE_CHANGED) {
lv_obj_t * label = get_label(obj);
/*Be sure the label's style is updated before processing the roller*/
if(label) lv_event_send(label, LV_EVENT_STYLE_CHG, NULL);
if(label) lv_event_send(label, LV_EVENT_STYLE_CHANGED, NULL);
lv_obj_handle_self_size_chg(obj);
refr_position(obj, false);
}
else if(e == LV_EVENT_COORD_CHG) {
else if(e == LV_EVENT_COORD_CHANGED) {
void * param = lv_event_get_param();
if(lv_obj_get_width(obj) != lv_area_get_width(param) ||
lv_obj_get_height(obj) != lv_area_get_height(param))

View File

@ -269,7 +269,7 @@ static void lv_slider_event(lv_obj_t * obj, lv_event_t e)
slider->left_knob_focus = 0;
}
}
else if(e == LV_EVENT_COORD_CHG) {
else if(e == LV_EVENT_COORD_CHANGED) {
/* The knob size depends on slider size.
* During the drawing method the obj. size is used by the knob so refresh the obj. size.*/
void * param = lv_event_get_param();
@ -316,7 +316,6 @@ static void lv_slider_event(lv_obj_t * obj, lv_event_t e)
if(res != LV_RES_OK) return;
}
} else if(e == LV_EVENT_DRAW_MAIN) {
const lv_area_t * clip_area = lv_event_get_param();
draw_knob(obj);
}
}

View File

@ -456,7 +456,7 @@ static void lv_table_event(lv_obj_t * obj, lv_event_t e)
lv_table_t * table = (lv_table_t *)obj;
if(e == LV_EVENT_STYLE_CHG) {
if(e == LV_EVENT_STYLE_CHANGED) {
refr_size(obj, 0);
}
else if(e == LV_EVENT_GET_SELF_SIZE) {

View File

@ -1029,7 +1029,7 @@ static void lv_textarea_event(lv_obj_t * obj, lv_event_t e)
lv_textarea_t * ta = (lv_textarea_t *)obj;
if(e == LV_EVENT_STYLE_CHG) {
if(e == LV_EVENT_STYLE_CHANGED) {
if(ta->label) {
if(ta->one_line) {
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
@ -1055,7 +1055,7 @@ static void lv_textarea_event(lv_obj_t * obj, lv_event_t e)
else if(e == LV_EVENT_FOCUSED) {
start_cursor_blink(obj);
}
else if(e == LV_EVENT_COORD_CHG) {
else if(e == LV_EVENT_COORD_CHANGED) {
/*Set the label width according to the text area width*/
if(ta->label) {
void * param = lv_event_get_param();