1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix: follow changes of lvgl in examples and extra widgets

This commit is contained in:
Gabor Kiss-Vamosi 2021-02-24 10:00:54 +01:00
parent 0aff24505e
commit a2b29c091f
6 changed files with 17 additions and 17 deletions

View File

@ -16,14 +16,15 @@ static void sw_event_cb(lv_obj_t * sw, lv_event_t e)
*/
void lv_example_scroll_2(void)
{
lv_obj_t * list = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_size(list, 280, 150);
lv_obj_set_scroll_snap_x(list, LV_SCROLL_SNAP_CENTER);
lv_obj_set_layout(list, &lv_flex_queue);
lv_obj_t * panel = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_size(panel, 280, 150);
lv_obj_set_scroll_snap_x(panel, LV_SCROLL_SNAP_CENTER);
lv_obj_set_layout(panel, &lv_flex_queue);
lv_obj_center(panel);
uint32_t i;
for(i = 0; i < 10; i++) {
lv_obj_t * btn = lv_btn_create(list, NULL);
lv_obj_t * btn = lv_btn_create(panel, NULL);
lv_obj_clear_flag(btn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); /* It does similar thing than snapping so disable it.*/
lv_obj_set_size(btn, 150, 100);
@ -37,16 +38,15 @@ void lv_example_scroll_2(void)
lv_obj_center(label);
}
lv_obj_update_snap(list, LV_ANIM_ON);
lv_obj_update_snap(panel, LV_ANIM_ON);
/*Switch between "One scroll" and "Normal scroll" mode*/
lv_obj_t * sw = lv_switch_create(lv_scr_act(), NULL);
lv_obj_align(sw, NULL, LV_ALIGN_IN_TOP_RIGHT, -20, 10);
lv_obj_add_event_cb(sw, sw_event_cb, list);
lv_obj_add_event_cb(sw, sw_event_cb, panel);
lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
lv_label_set_text(label, "One scroll");
lv_obj_align(label, sw, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
lv_obj_align(label, sw, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
}
#endif

View File

@ -6,7 +6,7 @@ static void btnm_event_handler(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_VALUE_CHANGED) {
lv_obj_t * ta = lv_event_get_user_data();
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_active_btn(obj));
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_selected_btn(obj));
if(strcmp(txt, LV_SYMBOL_BACKSPACE) == 0) lv_textarea_del_char(ta);
else if(strcmp(txt, LV_SYMBOL_NEW_LINE) == 0) lv_textarea_add_char(ta, '\n');

View File

@ -183,7 +183,7 @@ uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * obj)
bool lv_calendar_get_pressed_date(const lv_obj_t * obj, lv_calendar_date_t * date)
{
lv_calendar_t * calendar = (lv_calendar_t *) obj;
uint16_t d = lv_btnmatrix_get_active_btn(obj);
uint16_t d = lv_btnmatrix_get_selected_btn(obj);
if(d == LV_BTNMATRIX_BTN_NONE) {
date->year = 0;
date->month = 0;
@ -191,7 +191,7 @@ bool lv_calendar_get_pressed_date(const lv_obj_t * obj, lv_calendar_date_t * dat
return false;
}
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_active_btn(obj));
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_selected_btn(obj));
if(txt[1] == 0) date->day = txt[0] - '0';
else date->day = (txt[0] - '0') * 10 + (txt[1] - '0');
@ -273,7 +273,7 @@ static void draw_event_cb(lv_obj_t * obj, lv_event_t e)
if(lv_btnmatrix_has_btn_ctrl(obj, hook_dsc->id, LV_CALENDAR_CTRL_HIGHLIGHT)) {
hook_dsc->rect_dsc->bg_opa = LV_OPA_40;
hook_dsc->rect_dsc->bg_color = lv_theme_get_color_primary();
if(lv_btnmatrix_get_active_btn(obj) == hook_dsc->id) {
if(lv_btnmatrix_get_selected_btn(obj) == hook_dsc->id) {
hook_dsc->rect_dsc->bg_opa = LV_OPA_70;
}
}

View File

@ -224,12 +224,12 @@ void lv_keyboard_def_event_cb(lv_obj_t * obj, lv_event_t event)
if(event != LV_EVENT_VALUE_CHANGED) return;
lv_keyboard_t * keyboard = (lv_keyboard_t *) obj;
uint16_t btn_id = lv_btnmatrix_get_active_btn(obj);
uint16_t btn_id = lv_btnmatrix_get_selected_btn(obj);
if(btn_id == LV_BTNMATRIX_BTN_NONE) return;
if(lv_btnmatrix_has_btn_ctrl(obj, btn_id, LV_BTNMATRIX_CTRL_HIDDEN | LV_BTNMATRIX_CTRL_DISABLED)) return;
if(lv_btnmatrix_has_btn_ctrl(obj, btn_id, LV_BTNMATRIX_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return;
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_active_btn(obj));
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_selected_btn(obj));
if(txt == NULL) return;
if(strcmp(txt, "abc") == 0) {

View File

@ -127,7 +127,7 @@ lv_obj_t * lv_msgbox_get_btns(lv_obj_t * mbox)
const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox)
{
lv_obj_t * btnm = lv_msgbox_get_btns(mbox);
return lv_btnmatrix_get_btn_text(btnm, lv_btnmatrix_get_active_btn(btnm));
return lv_btnmatrix_get_btn_text(btnm, lv_btnmatrix_get_selected_btn(btnm));
}
void lv_msgbox_close(lv_obj_t * mbox)

View File

@ -229,7 +229,7 @@ static void btns_event_cb(lv_obj_t * btns, lv_event_t e)
{
if(e == LV_EVENT_VALUE_CHANGED) {
lv_obj_t * tv = lv_obj_get_parent(btns);
uint32_t id = lv_btnmatrix_get_active_btn(btns);
uint32_t id = lv_btnmatrix_get_selected_btn(btns);
lv_tabview_set_act(tv, id, LV_ANIM_ON);
}
}