refactor(event): add _cb postfix to lv_obj_add_event()

This commit is contained in:
Gabor Kiss-Vamosi
2023-11-28 15:36:51 +01:00
parent d7981cf55f
commit f0988b8cf8
179 changed files with 362 additions and 362 deletions

View File

@@ -78,7 +78,7 @@ void lv_example_file_explorer_1(void)
#endif
#endif
lv_obj_add_event(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
}
#endif

View File

@@ -43,5 +43,5 @@ if LV_FILE_EXPLORER_QUICK_ACCESS :
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.DOCS_DIR, home_dir + "/Documents")
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.FS_DIR, "A:/")
file_explorer.add_event(file_explorer_event_handler, lv.EVENT.ALL, None)
file_explorer.add_event_cb(file_explorer_event_handler, lv.EVENT.ALL, None)

View File

@@ -108,7 +108,7 @@ void lv_example_file_explorer_2(void)
#endif
#endif
lv_obj_add_event(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
/*Quick access status control button*/
lv_obj_t * fe_quick_access_obj = lv_file_explorer_get_quick_access_area(file_explorer);
@@ -123,7 +123,7 @@ void lv_example_file_explorer_2(void)
lv_label_set_text(label, LV_SYMBOL_LIST);
lv_obj_center(label);
lv_obj_add_event(btn, btn_event_handler, LV_EVENT_VALUE_CHANGED, fe_quick_access_obj);
lv_obj_add_event_cb(btn, btn_event_handler, LV_EVENT_VALUE_CHANGED, fe_quick_access_obj);
/*Sort control*/
static const char * opts = "NONE\n"
@@ -136,7 +136,7 @@ void lv_example_file_explorer_2(void)
lv_dropdown_set_options_static(dd, opts);
lv_obj_align(dd, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_add_event(dd, dd_event_handler, LV_EVENT_VALUE_CHANGED, file_explorer);
lv_obj_add_event_cb(dd, dd_event_handler, LV_EVENT_VALUE_CHANGED, file_explorer);
}
#endif

View File

@@ -68,7 +68,7 @@ if LV_FILE_EXPLORER_QUICK_ACCESS :
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.DOCS_DIR, home_dir + "/Documents")
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.FS_DIR, "A:/")
file_explorer.add_event(file_explorer_event_handler, lv.EVENT.ALL, None)
file_explorer.add_event_cb(file_explorer_event_handler, lv.EVENT.ALL, None)
# Quick access status control button
fe_quick_access_obj = file_explorer.explorer_get_quick_access_area()
@@ -83,8 +83,8 @@ label = lv.label(button)
label.set_text(lv.SYMBOL.LIST)
label.center()
button.add_event(lambda evt: button_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
#button.add_event(lambda evt: button_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
button.add_event_cb(lambda evt: button_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
#button.add_event_cb(lambda evt: button_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
# Sort control
opts = "NONE\nKIND"
@@ -97,6 +97,6 @@ dd.set_options_static(opts)
dd.align(lv.ALIGN.RIGHT_MID, 0, 0)
# lv_obj_align_to(dd, button, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
dd.add_event(lambda evt: dd_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
#dd.add_event(lambda evt: dd_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)
dd.add_event_cb(lambda evt: dd_event_handler(evt,file_explorer), lv.EVENT.VALUE_CHANGED, None)
#dd.add_event_cb(lambda evt: dd_event_handler(evt,fe_quick_access_obj), lv.EVENT.VALUE_CHANGED, None)

View File

@@ -120,7 +120,7 @@ void lv_example_file_explorer_3(void)
#endif
#endif
lv_obj_add_event(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(file_explorer, file_explorer_event_handler, LV_EVENT_ALL, NULL);
}
#endif

View File

@@ -86,4 +86,4 @@ if LV_FILE_EXPLORER_QUICK_ACCESS :
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.DOCS_DIR, home_dir + "/Documents")
file_explorer.explorer_set_quick_access_path(lv.EXPLORER.FS_DIR, "A:/")
file_explorer.add_event(file_explorer_event_handler, lv.EVENT.ALL, None)
file_explorer.add_event_cb(file_explorer_event_handler, lv.EVENT.ALL, None)

View File

@@ -31,7 +31,7 @@ void lv_example_fragment_1(void)
lv_obj_set_size(root, LV_PCT(100), LV_PCT(100));
lv_fragment_manager_t * manager = lv_fragment_manager_create(NULL);
/* Clean up the fragment manager before objects in containers got deleted */
lv_obj_add_event(root, sample_container_delete, LV_EVENT_DELETE, manager);
lv_obj_add_event_cb(root, sample_container_delete, LV_EVENT_DELETE, manager);
lv_fragment_t * fragment = lv_fragment_create(&sample_cls, "Fragment");
lv_fragment_manager_replace(manager, fragment, &root);

View File

@@ -57,13 +57,13 @@ void lv_example_fragment_2(void)
lv_fragment_manager_t * manager = lv_fragment_manager_create(NULL);
/* Clean up the fragment manager before objects in containers got deleted */
lv_obj_add_event(root, sample_container_delete, LV_EVENT_DELETE, manager);
lv_obj_add_event_cb(root, sample_container_delete, LV_EVENT_DELETE, manager);
int depth = 0;
lv_fragment_t * fragment = lv_fragment_create(&sample_cls, &depth);
lv_fragment_manager_push(manager, fragment, &container);
lv_obj_add_event(push_btn, sample_push_click, LV_EVENT_CLICKED, manager);
lv_obj_add_event(pop_btn, sample_pop_click, LV_EVENT_CLICKED, manager);
lv_obj_add_event_cb(push_btn, sample_push_click, LV_EVENT_CLICKED, manager);
lv_obj_add_event_cb(pop_btn, sample_pop_click, LV_EVENT_CLICKED, manager);
}
static void sample_fragment_ctor(lv_fragment_t * self, void * args)
@@ -91,7 +91,7 @@ static lv_obj_t * sample_fragment_create_obj(lv_fragment_t * self, lv_obj_t * pa
lv_obj_t * inc_btn = lv_button_create(content);
lv_obj_t * inc_label = lv_label_create(inc_btn);
lv_label_set_text(inc_label, "+1");
lv_obj_add_event(inc_btn, sample_fragment_inc_click, LV_EVENT_CLICKED, fragment);
lv_obj_add_event_cb(inc_btn, sample_fragment_inc_click, LV_EVENT_CLICKED, fragment);
return content;
}

View File

@@ -71,7 +71,7 @@ void lv_example_gridnav_3(void)
/*Only the container needs to be in a group*/
lv_group_add_obj(lv_group_get_default(), cont_sub2);
lv_obj_add_event(cont_sub2, cont_sub_event_cb, LV_EVENT_KEY, NULL);
lv_obj_add_event_cb(cont_sub2, cont_sub_event_cb, LV_EVENT_KEY, NULL);
/*Use flex here, but works with grid or manually placed objects as well*/
lv_obj_set_flex_flow(cont_sub2, LV_FLEX_FLOW_ROW_WRAP);

View File

@@ -61,7 +61,7 @@ lv.gridnav_add(cont_sub2, lv.GRIDNAV_CTRL.ROLLOVER)
#Only the container needs to be in a group
lv.group_get_default().add_obj(cont_sub2)
cont_sub2.add_event(cont_sub_event_cb, lv.EVENT.KEY, None)
cont_sub2.add_event_cb(cont_sub_event_cb, lv.EVENT.KEY, None)
# Use flex here, but works with grid or manually placed objects as well
cont_sub2.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)

View File

@@ -33,7 +33,7 @@ void lv_example_gridnav_4(void)
lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
lv_obj_t * item = lv_list_add_button(list, LV_SYMBOL_FILE, buf);
lv_obj_add_event(item, event_handler, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(item, event_handler, LV_EVENT_CLICKED, NULL);
lv_group_remove_obj(item); /*The default group adds it automatically*/
}

View File

@@ -26,7 +26,7 @@ for i in range(20):
txt = "File {:d}".format(i + 1)
#lv_snprintf(buf, sizeof(buf), "File %d", i + 1);
item = list.add_button(lv.SYMBOL.FILE, txt)
item.add_event(event_handler, lv.EVENT.CLICKED, None)
item.add_event_cb(event_handler, lv.EVENT.CLICKED, None)
lv.group_remove_obj(item) # The default group adds it automatically
button = lv.button(lv.screen_active())

View File

@@ -37,7 +37,7 @@ void lv_example_ime_pinyin_1(void)
lv_ime_pinyin_set_keyboard(pinyin_ime, kb);
lv_keyboard_set_textarea(kb, ta1);
lv_obj_add_event(ta1, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(ta1, ta_event_cb, LV_EVENT_ALL, kb);
/*Get the cand_panel, and adjust its size and position*/
lv_obj_t * cand_panel = lv_ime_pinyin_get_cand_panel(pinyin_ime);

View File

@@ -36,7 +36,7 @@ kb = lv.keyboard(lv.screen_active())
pinyin_ime.pinyin_set_keyboard(kb)
kb.set_textarea(ta1)
ta1.add_event(lambda evt: ta_event_cb(evt,kb), lv.EVENT.ALL, None)
ta1.add_event_cb(lambda evt: ta_event_cb(evt,kb), lv.EVENT.ALL, None)
# Get the cand_panel, and adjust its size and position
cand_panel = pinyin_ime.pinyin_get_cand_panel()

View File

@@ -39,7 +39,7 @@ void lv_example_ime_pinyin_2(void)
lv_ime_pinyin_set_keyboard(pinyin_ime, kb);
lv_ime_pinyin_set_mode(pinyin_ime,
LV_IME_PINYIN_MODE_K9); // Set to 9-key input mode. Default: 26-key input(k26) mode.
lv_obj_add_event(ta1, ta_event_cb, LV_EVENT_ALL, kb);
lv_obj_add_event_cb(ta1, ta_event_cb, LV_EVENT_ALL, kb);
/*Get the cand_panel, and adjust its size and position*/
lv_obj_t * cand_panel = lv_ime_pinyin_get_cand_panel(pinyin_ime);

View File

@@ -38,7 +38,7 @@ kb.set_textarea(ta1)
pinyin_ime.pinyin_set_keyboard(kb)
pinyin_ime.pinyin_set_mode(lv.ime_pinyin.PINYIN_MODE.K9) # Set to 9-key input mode. Default: 26-key input(k26) mode.
ta1.add_event(lambda evt: ta_event_cb(evt,kb), lv.EVENT.ALL, None)
ta1.add_event_cb(lambda evt: ta_event_cb(evt,kb), lv.EVENT.ALL, None)
# Get the cand_panel, and adjust its size and position
cand_panel = pinyin_ime.pinyin_get_cand_panel()

View File

@@ -99,7 +99,7 @@ static void ui_init(void)
lv_textarea_set_one_line(ta, true);
lv_textarea_set_password_mode(ta, true);
lv_textarea_set_placeholder_text(ta, "The password is: hello");
lv_obj_add_event(ta, textarea_event_cb, LV_EVENT_READY, NULL);
lv_obj_add_event_cb(ta, textarea_event_cb, LV_EVENT_READY, NULL);
lv_obj_bind_state_if_eq(ta, &auth_state_subject, LV_STATE_DISABLED, LOGGED_IN);
lv_obj_t * kb = lv_keyboard_create(lv_screen_active());
@@ -111,7 +111,7 @@ static void ui_init(void)
/*Create a log out button which will be active only when logged in*/
btn = lv_button_create(lv_screen_active());
lv_obj_set_pos(btn, 220, 10);
lv_obj_add_event(btn, log_out_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, log_out_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_bind_state_if_not_eq(btn, &auth_state_subject, LV_STATE_DISABLED, LOGGED_IN);
label = lv_label_create(btn);

View File

@@ -55,7 +55,7 @@ void lv_example_observer_3(void)
lv_obj_t * set_btn = lv_button_create(lv_screen_active());
lv_obj_set_pos(set_btn, 180, 24);
lv_obj_add_event(set_btn, set_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(set_btn, set_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_t * set_label = lv_label_create(set_btn);
lv_label_set_text(set_label, "Set");
@@ -102,7 +102,7 @@ static void set_btn_clicked_event_cb(lv_event_t * e)
lv_obj_t * close_btn = lv_button_create(cont);
lv_obj_align(close_btn, LV_ALIGN_TOP_RIGHT, 0, 0);
/*Pass the set_btn as user_data to make it non-disabled on close*/
lv_obj_add_event(close_btn, close_clicked_event_cb, LV_EVENT_CLICKED, set_btn);
lv_obj_add_event_cb(close_btn, close_clicked_event_cb, LV_EVENT_CLICKED, set_btn);
lv_obj_t * close_label = lv_label_create(close_btn);
lv_label_set_text(close_label, LV_SYMBOL_CLOSE);

View File

@@ -156,7 +156,7 @@ static void btn_create(lv_obj_t * parent, const char * text)
lv_obj_set_height(btn, lv_pct(100));
lv_obj_set_style_radius(btn, 0, 0);
lv_subject_add_observer_obj(&current_tab_subject, btn_observer_cb, btn, NULL);
lv_obj_add_event(btn, btn_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, btn_click_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, text);

View File

@@ -34,7 +34,7 @@ void lv_example_observer_5(void)
/*Create start FW update button*/
lv_obj_t * btn = lv_btn_create(lv_screen_active());
lv_obj_add_event(btn, fw_update_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, fw_update_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_center(btn);
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, "Firmware update");
@@ -53,7 +53,7 @@ static void fw_update_btn_clicked_event_cb(lv_event_t * e)
lv_obj_set_style_shadow_color(win, lv_color_hex3(0x888), 0);
lv_win_add_title(win, "Firmware update");
lv_obj_t * btn = lv_win_add_button(win, LV_SYMBOL_CLOSE, 40);
lv_obj_add_event(btn, fw_update_close_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, fw_update_close_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_center(win);
lv_subject_set_int(&fw_update_status_subject, FW_UPDATE_STATE_IDLE);
@@ -110,7 +110,7 @@ static void fw_update_win_observer_cb(lv_subject_t * subject, lv_observer_t * ob
lv_obj_t * btn = lv_button_create(cont);
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 20);
lv_obj_add_event(btn, restart_btn_click_event_cb, LV_EVENT_CLICKED, win);
lv_obj_add_event_cb(btn, restart_btn_click_event_cb, LV_EVENT_CLICKED, win);
label = lv_label_create(btn);
lv_label_set_text(label, "Restart");

View File

@@ -179,7 +179,7 @@ static lv_obj_t * my_button_create(lv_obj_t * parent, const char * text, lv_even
lv_obj_remove_style_all(btn);
lv_obj_add_style(btn, &styles.style_main, 0);
lv_obj_add_style(btn, &styles.style_pressed, LV_STATE_PRESSED);
lv_obj_add_event(btn, event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text(label, text);

View File

@@ -50,8 +50,8 @@ void lv_example_snapshot_1(void)
lv_obj_set_style_bg_opa(img, LV_OPA_COVER, 0);
// lv_obj_set_style_transform_scale(img, 400, LV_STATE_PRESSED);
lv_obj_add_flag(img, LV_OBJ_FLAG_CLICKABLE);
lv_obj_add_event(img, event_cb, LV_EVENT_PRESSED, snapshot_obj);
lv_obj_add_event(img, event_cb, LV_EVENT_RELEASED, snapshot_obj);
lv_obj_add_event_cb(img, event_cb, LV_EVENT_PRESSED, snapshot_obj);
lv_obj_add_event_cb(img, event_cb, LV_EVENT_RELEASED, snapshot_obj);
}
}

View File

@@ -61,5 +61,5 @@ for i in range(4):
image.set_style_bg_opa(lv.OPA.COVER, 0)
image.set_style_transform_scale(400, lv.STATE.PRESSED)
image.add_flag(image.FLAG.CLICKABLE)
image.add_event(lambda e: event_cb(e, snapshot_obj), lv.EVENT.PRESSED, None)
image.add_event(lambda e: event_cb(e, snapshot_obj), lv.EVENT.RELEASED, None)
image.add_event_cb(lambda e: event_cb(e, snapshot_obj), lv.EVENT.PRESSED, None)
image.add_event_cb(lambda e: event_cb(e, snapshot_obj), lv.EVENT.RELEASED, None)