Skip to content

Commit

Permalink
Merge pull request lvgl#1619 from liangyongxiang/master
Browse files Browse the repository at this point in the history
Add conditional macro LV_USE_GROUP to more GROUP related singles:
  • Loading branch information
kisvegabor authored Jun 29, 2020
2 parents 069e24b + d055944 commit edeca8c
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/lv_widgets/lv_btn.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
}
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
if(lv_btn_get_checkable(btn)) {
Expand All @@ -309,6 +310,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
if(res != LV_RES_OK) return res;
}
}
#endif
}

return res;
Expand Down
4 changes: 4 additions & 0 deletions src/lv_widgets/lv_btnmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT) {
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE)
Expand Down Expand Up @@ -1059,10 +1060,13 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
}
#endif
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}
return res;
}
Expand Down
2 changes: 2 additions & 0 deletions src/lv_widgets/lv_calendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
lv_obj_invalidate(calendar);
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint8_t c = *((uint8_t *)param);
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
Expand All @@ -537,6 +538,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
}
lv_obj_invalidate(calendar);
}
#endif
}

return res;
Expand Down
2 changes: 2 additions & 0 deletions src/lv_widgets/lv_checkbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) {
/*Follow the backgrounds state with the bullet*/
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
}
#endif
}

return res;
Expand Down
2 changes: 2 additions & 0 deletions src/lv_widgets/lv_cpicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
lv_obj_invalidate(cpicker);
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/

if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
Expand Down Expand Up @@ -745,6 +746,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
if(res != LV_RES_OK) return res;
}
}
#endif
}
else if(sign == LV_SIGNAL_PRESSED) {
ext->last_change_time = lv_tick_get();
Expand Down
4 changes: 4 additions & 0 deletions src/lv_widgets/lv_dropdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p
if(ext->page) lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL);
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
if(ext->page == NULL) {
Expand All @@ -992,10 +993,13 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p
ext->sel_opt_id = ext->sel_opt_id_orig;
lv_dropdown_close(ddlist);
}
#endif
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}

return res;
Expand Down
2 changes: 2 additions & 0 deletions src/lv_widgets/lv_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,10 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
#endif
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}
else if(sign == LV_SIGNAL_CONTROL) {

Expand Down
9 changes: 7 additions & 2 deletions src/lv_widgets/lv_msgbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param
{
lv_res_t res;

#if LV_USE_GROUP
/*Translate LV_KEY_UP/DOWN to LV_KEY_LEFT/RIGHT */
char c_trans = 0;
if(sign == LV_SIGNAL_CONTROL) {
Expand All @@ -421,6 +422,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param

param = &c_trans;
}
#endif

if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param;
Expand Down Expand Up @@ -460,8 +462,11 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param
if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
}
}
else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL ||
sign == LV_SIGNAL_GET_EDITABLE) {
else if(
#if LV_USE_GROUP
sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_GET_EDITABLE ||
#endif
sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) {
if(ext->btnm) {
ext->btnm->signal_cb(ext->btnm, sign, param);
}
Expand Down
4 changes: 4 additions & 0 deletions src/lv_widgets/lv_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
refr_ext_draw_pad(page);
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint32_t c = *((uint32_t *)param);

if(c == LV_KEY_DOWN) {
Expand All @@ -883,10 +884,13 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
else
lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
}
#endif
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}

return res;
Expand Down
5 changes: 5 additions & 0 deletions src/lv_widgets/lv_roller.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,16 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par

/* Include the ancient signal function */
if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/
#if LV_USE_GROUP
res = ancestor_signal(roller, sign, param);
if(res != LV_RES_OK) return res;
#endif
}

if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
LV_UNUSED(ext);

if(sign == LV_SIGNAL_STYLE_CHG) {
lv_obj_t * label = get_label(roller);
Expand Down Expand Up @@ -556,6 +559,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
#endif
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
if(ext->sel_opt_id + 1 < ext->option_cnt) {
Expand All @@ -572,6 +576,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
ext->sel_opt_id_ori = ori_id;
}
}
#endif
}
else if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(roller, LV_ROLLER_PART_SELECTED);
Expand Down
4 changes: 4 additions & 0 deletions src/lv_widgets/lv_slider.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par

}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);

if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
Expand All @@ -419,13 +420,16 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
#endif
}
else if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(slider, LV_SLIDER_PART_KNOB);
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}

return res;
Expand Down
4 changes: 4 additions & 0 deletions src/lv_widgets/lv_spinbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,10 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p

/* Include the ancient signal function */
if(sign != LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
res = ancestor_signal(spinbox, sign, param);
if(res != LV_RES_OK) return res;
#endif
}
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

Expand Down Expand Up @@ -464,6 +466,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
}
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());

uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
Expand All @@ -488,6 +491,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
else {
lv_textarea_add_char(spinbox, c);
}
#endif
}

return res;
Expand Down
4 changes: 4 additions & 0 deletions src/lv_widgets/lv_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,14 @@ static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param)

}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) lv_switch_on(sw, LV_ANIM_ON);
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) lv_switch_off(sw, LV_ANIM_ON);

res = lv_event_send(sw, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
#endif
}
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_style_int_t knob_left = lv_obj_get_style_pad_left(sw, LV_SWITCH_PART_KNOB);
Expand All @@ -320,8 +322,10 @@ static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
sw->ext_draw_pad = LV_MATH_MAX(sw->ext_draw_pad, knob_size);
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = false; /*The ancestor slider is editable the switch is not*/
#endif
}

return res;
Expand Down
9 changes: 7 additions & 2 deletions src/lv_widgets/lv_tabview.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,17 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
#endif
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}

if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_PRESSED ||
sign == LV_SIGNAL_RELEASED) {
if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS ||
#if LV_USE_GROUP
sign == LV_SIGNAL_CONTROL ||
#endif
sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED) {

/* The button matrix is not in a group (the tab view is in it) but it should handle the
* group signals. So propagate the related signals to the button matrix manually*/
Expand Down
4 changes: 4 additions & 0 deletions src/lv_widgets/lv_textarea.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,7 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param
}
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
if(c == LV_KEY_RIGHT)
lv_textarea_cursor_right(ta);
Expand All @@ -1486,10 +1487,13 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param
else {
lv_textarea_add_char(ta, c);
}
#endif
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}
else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST ||
sign == LV_SIGNAL_RELEASED) {
Expand Down
2 changes: 2 additions & 0 deletions src/lv_widgets/lv_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,10 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
ext->title_txt = NULL;
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
/*Forward all the control signals to the page*/
ext->page->signal_cb(ext->page, sign, param);
#endif
}

return res;
Expand Down

0 comments on commit edeca8c

Please sign in to comment.