Add conditional macro LV_USE_GROUP to more GROUP related singles:

- LV_SIGNAL_CONTROL
- LV_SIGNAL_GET_EDITABLE
This commit is contained in:
liangyongxiang
2020-06-28 12:13:39 +08:00
parent 3e8b39c404
commit d055944ebb
16 changed files with 59 additions and 4 deletions

View File

@@ -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)) {
@@ -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;

View File

@@ -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)
@@ -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;
}

View File

@@ -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) {
@@ -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;

View File

@@ -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;

View File

@@ -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) {
@@ -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();

View File

@@ -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) {
@@ -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;

View File

@@ -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) {

View File

@@ -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) {
@@ -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;
@@ -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);
}

View File

@@ -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) {
@@ -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;

View File

@@ -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);
@@ -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) {
@@ -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);

View File

@@ -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) {
@@ -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;

View File

@@ -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);
@@ -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*/
@@ -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;

View File

@@ -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);
@@ -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;

View File

@@ -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*/

View File

@@ -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);
@@ -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) {

View File

@@ -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;