group related fixes
This commit is contained in:
@@ -110,7 +110,6 @@ void lv_group_del(lv_group_t * group)
|
|||||||
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
if(group == NULL) return;
|
if(group == NULL) return;
|
||||||
|
|
||||||
/*Do not add the object twice*/
|
/*Do not add the object twice*/
|
||||||
lv_obj_t ** obj_i;
|
lv_obj_t ** obj_i;
|
||||||
LV_LL_READ(group->obj_ll, obj_i) {
|
LV_LL_READ(group->obj_ll, obj_i) {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ static void basic_init(void)
|
|||||||
lv_style_init(&style_bg);
|
lv_style_init(&style_bg);
|
||||||
lv_style_set_bg_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
|
lv_style_set_bg_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||||
lv_style_set_border_width(&style_bg, LV_STATE_DEFAULT, 1);
|
lv_style_set_border_width(&style_bg, LV_STATE_DEFAULT, 1);
|
||||||
|
lv_style_set_border_width(&style_bg, LV_STATE_FOCUSED, 2);
|
||||||
lv_style_set_border_color(&style_bg, LV_STATE_FOCUSED, _color_secondary);
|
lv_style_set_border_color(&style_bg, LV_STATE_FOCUSED, _color_secondary);
|
||||||
lv_style_set_border_color(&style_bg, LV_STATE_EDITED, lv_color_darken(_color_secondary, LV_OPA_30));
|
lv_style_set_border_color(&style_bg, LV_STATE_EDITED, lv_color_darken(_color_secondary, LV_OPA_30));
|
||||||
lv_style_set_line_width(&style_bg, LV_STATE_DEFAULT, 1);
|
lv_style_set_line_width(&style_bg, LV_STATE_DEFAULT, 1);
|
||||||
@@ -80,7 +81,6 @@ static void basic_init(void)
|
|||||||
lv_style_set_text_color(&style_btn, LV_STATE_DISABLED, LV_COLOR_GRAY);
|
lv_style_set_text_color(&style_btn, LV_STATE_DISABLED, LV_COLOR_GRAY);
|
||||||
lv_style_set_image_recolor(&style_btn, LV_STATE_DISABLED, LV_COLOR_GRAY);
|
lv_style_set_image_recolor(&style_btn, LV_STATE_DISABLED, LV_COLOR_GRAY);
|
||||||
|
|
||||||
|
|
||||||
lv_style_init(&style_round);
|
lv_style_init(&style_round);
|
||||||
lv_style_set_radius(&style_round, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
lv_style_set_radius(&style_round, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||||
|
|
||||||
|
|||||||
@@ -280,12 +280,11 @@ void lv_btnmatrix_set_ctrl_map(lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_m
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed button i.e. visually highlight it.
|
* Set the focused button i.e. visually highlight it.
|
||||||
* Mainly used a when the btnm is in a group to show the selected button
|
|
||||||
* @param btnm pointer to button matrix object
|
* @param btnm pointer to button matrix object
|
||||||
* @param id index of the currently pressed button (`LV_BTNMATRIX_BTN_NONE` to unpress)
|
* @param id index of the button to focus(`LV_BTNMATRIX_BTN_NONE` to remove focus)
|
||||||
*/
|
*/
|
||||||
void lv_btnmatrix_set_pressed(lv_obj_t * btnm, uint16_t id)
|
void lv_btnmatrix_set_focused_btn(lv_obj_t * btnm, uint16_t id)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
@@ -293,9 +292,9 @@ void lv_btnmatrix_set_pressed(lv_obj_t * btnm, uint16_t id)
|
|||||||
|
|
||||||
if(id >= ext->btn_cnt && id != LV_BTNMATRIX_BTN_NONE) return;
|
if(id >= ext->btn_cnt && id != LV_BTNMATRIX_BTN_NONE) return;
|
||||||
|
|
||||||
if(id == ext->btn_id_pr) return;
|
if(id == ext->btn_id_focused) return;
|
||||||
|
|
||||||
ext->btn_id_pr = id;
|
ext->btn_id_focused = id;
|
||||||
lv_obj_invalidate(btnm);
|
lv_obj_invalidate(btnm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +491,7 @@ const char * lv_btnmatrix_get_active_btn_text(const lv_obj_t * btnm)
|
|||||||
* @param btnm pointer to button matrix object
|
* @param btnm pointer to button matrix object
|
||||||
* @return index of the pressed button (LV_BTNMATRIX_BTN_NONE: if unset)
|
* @return index of the pressed button (LV_BTNMATRIX_BTN_NONE: if unset)
|
||||||
*/
|
*/
|
||||||
uint16_t lv_btnmatrix_get_pressed_btn(const lv_obj_t * btnm)
|
uint16_t lv_btnmatrix_get_focused_btn(const lv_obj_t * btnm)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
|||||||
@@ -108,12 +108,11 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]);
|
|||||||
void lv_btnmatrix_set_ctrl_map(lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_map[]);
|
void lv_btnmatrix_set_ctrl_map(lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_map[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the pressed button i.e. visually highlight it.
|
* Set the focused button i.e. visually highlight it.
|
||||||
* Mainly used a when the btnm is in a group to show the selected button
|
|
||||||
* @param btnm pointer to button matrix object
|
* @param btnm pointer to button matrix object
|
||||||
* @param id index of the currently pressed button (`LV_BTNMATRIX_BTN_NONE` to unpress)
|
* @param id index of the button to focus(`LV_BTNMATRIX_BTN_NONE` to remove focus)
|
||||||
*/
|
*/
|
||||||
void lv_btnmatrix_set_pressed(lv_obj_t * btnm, uint16_t id);
|
void lv_btnmatrix_set_focused_btn(lv_obj_t * btnm, uint16_t id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a style of a button matrix
|
* Set a style of a button matrix
|
||||||
@@ -214,12 +213,11 @@ uint16_t lv_btnmatrix_get_active_btn(const lv_obj_t * btnm);
|
|||||||
const char * lv_btnmatrix_get_active_btn_text(const lv_obj_t * btnm);
|
const char * lv_btnmatrix_get_active_btn_text(const lv_obj_t * btnm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the pressed button's index.
|
* Get the focused button's index.
|
||||||
* The button be really pressed by the user or manually set to pressed with `lv_btnmatrix_set_pressed`
|
|
||||||
* @param btnm pointer to button matrix object
|
* @param btnm pointer to button matrix object
|
||||||
* @return index of the pressed button (LV_BTNMATRIX_BTN_NONE: if unset)
|
* @return index of the focused button (LV_BTNMATRIX_BTN_NONE: if unset)
|
||||||
*/
|
*/
|
||||||
uint16_t lv_btnmatrix_get_pressed_btn(const lv_obj_t * btnm);
|
uint16_t lv_btnmatrix_get_focused_btn(const lv_obj_t * btnm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the button's text
|
* Get the button's text
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ lv_obj_t * lv_keyboard_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Initialize the allocated 'ext' */
|
/*Initialize the allocated 'ext' */
|
||||||
|
|
||||||
ext->ta = NULL;
|
ext->ta = NULL;
|
||||||
ext->mode = LV_KEYBOARD_MODE_TEXT_LOWER;
|
ext->mode = LV_KEYBOARD_MODE_TEXT_LOWER;
|
||||||
ext->cursor_mng = 0;
|
ext->cursor_mng = 0;
|
||||||
@@ -187,7 +186,7 @@ lv_obj_t * lv_keyboard_create(lv_obj_t * par, const lv_obj_t * copy)
|
|||||||
* @param kb pointer to a Keyboard object
|
* @param kb pointer to a Keyboard object
|
||||||
* @param ta pointer to a Text Area object to write there
|
* @param ta pointer to a Text Area object to write there
|
||||||
*/
|
*/
|
||||||
void lv_keyboard_set_ta(lv_obj_t * kb, lv_obj_t * ta)
|
void lv_keyboard_set_textarea(lv_obj_t * kb, lv_obj_t * ta)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
if(ta) LV_ASSERT_OBJ(ta, "lv_ta");
|
if(ta) LV_ASSERT_OBJ(ta, "lv_ta");
|
||||||
@@ -286,7 +285,7 @@ void lv_keyboard_set_ctrl_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const lv_b
|
|||||||
* @param kb pointer to a Keyboard object
|
* @param kb pointer to a Keyboard object
|
||||||
* @return pointer to the assigned Text Area object
|
* @return pointer to the assigned Text Area object
|
||||||
*/
|
*/
|
||||||
lv_obj_t * lv_keyboard_get_ta(const lv_obj_t * kb)
|
lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t * kb)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
|
||||||
|
|
||||||
@@ -371,7 +370,7 @@ void lv_keyboard_def_event_cb(lv_obj_t * kb, lv_event_t event)
|
|||||||
if(res != LV_RES_OK) return;
|
if(res != LV_RES_OK) return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lv_keyboard_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
lv_keyboard_set_textarea(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
||||||
lv_obj_del(kb);
|
lv_obj_del(kb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -383,7 +382,7 @@ void lv_keyboard_def_event_cb(lv_obj_t * kb, lv_event_t event)
|
|||||||
if(res != LV_RES_OK) return;
|
if(res != LV_RES_OK) return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lv_keyboard_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
lv_keyboard_set_textarea(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ lv_obj_t * lv_keyboard_create(lv_obj_t * par, const lv_obj_t * copy);
|
|||||||
* @param kb pointer to a Keyboard object
|
* @param kb pointer to a Keyboard object
|
||||||
* @param ta pointer to a Text Area object to write there
|
* @param ta pointer to a Text Area object to write there
|
||||||
*/
|
*/
|
||||||
void lv_keyboard_set_ta(lv_obj_t * kb, lv_obj_t * ta);
|
void lv_keyboard_set_textarea(lv_obj_t * kb, lv_obj_t * ta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a new a mode (text or number map)
|
* Set a new a mode (text or number map)
|
||||||
@@ -128,7 +128,7 @@ void lv_keyboard_set_ctrl_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const lv_b
|
|||||||
* @param kb pointer to a Keyboard object
|
* @param kb pointer to a Keyboard object
|
||||||
* @return pointer to the assigned Text Area object
|
* @return pointer to the assigned Text Area object
|
||||||
*/
|
*/
|
||||||
lv_obj_t * lv_keyboard_get_ta(const lv_obj_t * kb);
|
lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t * kb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a new a mode (text or number map)
|
* Set a new a mode (text or number map)
|
||||||
|
|||||||
@@ -1031,10 +1031,14 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(sign == LV_SIGNAL_FOCUS) {
|
else if(sign == LV_SIGNAL_FOCUS) {
|
||||||
res = lv_signal_send(page, LV_SIGNAL_FOCUS, NULL);
|
if(lv_obj_get_group(page)) {
|
||||||
if(res != LV_RES_OK) return res;
|
lv_group_focus_obj(page);
|
||||||
res = lv_event_send(page, LV_EVENT_FOCUSED, NULL);
|
} else {
|
||||||
if(res != LV_RES_OK) return res;
|
res = lv_signal_send(page, LV_SIGNAL_FOCUS, NULL);
|
||||||
|
if(res != LV_RES_OK) return res;
|
||||||
|
res = lv_event_send(page, LV_EVENT_FOCUSED, NULL);
|
||||||
|
if(res != LV_RES_OK) return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(sign == LV_SIGNAL_DEFOCUS) {
|
else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||||
res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL);
|
res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL);
|
||||||
|
|||||||
@@ -452,12 +452,9 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
|||||||
else return ancestor_signal(roller, sign, param);
|
else return ancestor_signal(roller, sign, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Don't let the drop down list to handle the control signals. It works differently*/
|
/* Include the ancient signal function */
|
||||||
if(sign != LV_SIGNAL_CONTROL && sign != LV_SIGNAL_FOCUS && sign != LV_SIGNAL_DEFOCUS) {
|
res = ancestor_signal(roller, sign, param);
|
||||||
/* Include the ancient signal function */
|
if(res != LV_RES_OK) return res;
|
||||||
res = ancestor_signal(roller, sign, param);
|
|
||||||
if(res != LV_RES_OK) return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||||
|
|
||||||
@@ -503,7 +500,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ext->sel_opt_id_ori = ext->sel_opt_id; /*Save the current value. Used to revert this state if
|
ext->sel_opt_id_ori = ext->sel_opt_id; /*Save the current value. Used to revert this state if
|
||||||
ENER wont't be pressed*/
|
ENTER wont't be pressed*/
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -752,11 +749,15 @@ static lv_res_t release_handler(lv_obj_t * roller)
|
|||||||
lv_indev_t * indev = lv_indev_get_act();
|
lv_indev_t * indev = lv_indev_get_act();
|
||||||
#if LV_USE_GROUP
|
#if LV_USE_GROUP
|
||||||
/*Leave edit mode once a new option is selected*/
|
/*Leave edit mode once a new option is selected*/
|
||||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
|
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||||
|
if(indev_type == LV_INDEV_TYPE_ENCODER || indev_type == LV_INDEV_TYPE_KEYPAD) {
|
||||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||||
lv_group_t * g = lv_obj_get_group(roller);
|
|
||||||
if(lv_group_get_editing(g)) {
|
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||||
lv_group_set_editing(g, false);
|
lv_group_t * g = lv_obj_get_group(roller);
|
||||||
|
if(lv_group_get_editing(g)) {
|
||||||
|
lv_group_set_editing(g, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -649,10 +649,16 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
|||||||
|
|
||||||
if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_PRESSED ||
|
if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_PRESSED ||
|
||||||
sign == LV_SIGNAL_RELEASED) {
|
sign == LV_SIGNAL_RELEASED) {
|
||||||
|
|
||||||
/* The button matrix is not in a group (the tab view is in it) but it should handle the
|
/* 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*/
|
* group signals. So propagate the related signals to the button matrix manually*/
|
||||||
if(ext->btns) {
|
if(ext->btns) {
|
||||||
ext->btns->signal_cb(ext->btns, sign, param);
|
ext->btns->signal_cb(ext->btns, sign, param);
|
||||||
|
|
||||||
|
/*Make the active tab's button focused*/
|
||||||
|
if(sign == LV_SIGNAL_FOCUS) {
|
||||||
|
lv_btnmatrix_set_focused_btn(ext->btns, ext->tab_cur);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,7 +726,7 @@ static lv_res_t tabview_scrl_signal(lv_obj_t * tabview_scrl, lv_signal_t sign, v
|
|||||||
lv_tabview_set_tab_act(tabview, tab_cur, LV_ANIM_ON);
|
lv_tabview_set_tab_act(tabview, tab_cur, LV_ANIM_ON);
|
||||||
uint32_t id_new = lv_tabview_get_tab_act(tabview);
|
uint32_t id_new = lv_tabview_get_tab_act(tabview);
|
||||||
|
|
||||||
if(id_prev != id_new) res = lv_event_send(tabview, LV_EVENT_VALUE_CHANGED, &id_new);
|
if(id_prev != id_new) res = lv_event_send(tabview, LV_EVENT_VALUE_CHANGED, &id_prev);
|
||||||
if(res != LV_RES_OK) return res;
|
if(res != LV_RES_OK) return res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1467,29 +1467,6 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param
|
|||||||
bool * editable = (bool *)param;
|
bool * editable = (bool *)param;
|
||||||
*editable = true;
|
*editable = true;
|
||||||
}
|
}
|
||||||
else if(sign == LV_SIGNAL_DEFOCUS) {
|
|
||||||
#if LV_USE_GROUP
|
|
||||||
if(lv_obj_get_group(ta)) {
|
|
||||||
lv_textarea_set_cursor_hidden(ta, true);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if(sign == LV_SIGNAL_FOCUS) {
|
|
||||||
#if LV_USE_GROUP
|
|
||||||
lv_group_t * g = lv_obj_get_group(ta);
|
|
||||||
bool editing = lv_group_get_editing(g);
|
|
||||||
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
|
||||||
|
|
||||||
/*Encoders need special handling*/
|
|
||||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
|
||||||
if(editing) lv_textarea_set_cursor_hidden(ta, false);
|
|
||||||
else lv_textarea_set_cursor_hidden(ta, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lv_textarea_set_cursor_hidden(ta, false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST ||
|
else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST ||
|
||||||
sign == LV_SIGNAL_RELEASED) {
|
sign == LV_SIGNAL_RELEASED) {
|
||||||
update_cursor_position_on_click(ta, sign, (lv_indev_t *)param);
|
update_cursor_position_on_click(ta, sign, (lv_indev_t *)param);
|
||||||
|
|||||||
Reference in New Issue
Block a user