BigW Consortium Gitlab

Commit 9fcb8e0d by Gabor

lv_group: LV_SIGNAL_SEND sends a character instead of LV_SIGNAL_INC/DEC

parent adbd9781
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
/********************* /*********************
* INCLUDES * INCLUDES
*********************/ *********************/
#include <stddef.h>
#include "lv_group.h" #include "lv_group.h"
#if LV_OBJ_GROUP != 0
#include <stddef.h>
/********************* /*********************
* DEFINES * DEFINES
...@@ -20,7 +21,7 @@ ...@@ -20,7 +21,7 @@
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void style_activate_def(lv_style_t * style); static void style_mod_def(lv_style_t * style);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
...@@ -34,18 +35,27 @@ static void style_activate_def(lv_style_t * style); ...@@ -34,18 +35,27 @@ static void style_activate_def(lv_style_t * style);
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
**********************/ **********************/
/**
* Create a new object group
* @return pointer to the new object group
*/
lv_group_t * lv_group_create(void) lv_group_t * lv_group_create(void)
{ {
lv_group_t * group = dm_alloc(sizeof(lv_group_t)); lv_group_t * group = dm_alloc(sizeof(lv_group_t));
ll_init(&group->obj_ll, sizeof(lv_obj_t *)); ll_init(&group->obj_ll, sizeof(lv_obj_t *));
group->style_activate = style_activate_def; group->style_mod = style_mod_def;
group->actve_obj = NULL; group->obj_focus = NULL;
return group; return group;
} }
void lv_group_add(lv_group_t * group, lv_obj_t * obj) /**
* Add an object to a group
* @param group pointer to a group
* @param obj pointer to an object to add
*/
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
{ {
obj->group_p = group; obj->group_p = group;
lv_obj_t ** next = ll_ins_tail(&group->obj_ll); lv_obj_t ** next = ll_ins_tail(&group->obj_ll);
...@@ -54,104 +64,171 @@ void lv_group_add(lv_group_t * group, lv_obj_t * obj) ...@@ -54,104 +64,171 @@ void lv_group_add(lv_group_t * group, lv_obj_t * obj)
/* If the head and the tail is equal then there is only one object in the linked list. /* If the head and the tail is equal then there is only one object in the linked list.
* In this case automatically activate it*/ * In this case automatically activate it*/
if(ll_get_head(&group->obj_ll) == next) { if(ll_get_head(&group->obj_ll) == next) {
lv_group_activate_next(group); lv_group_focus_next(group);
} }
} }
void lv_group_activate_obj(lv_group_t * group, lv_obj_t * obj) /**
* Remove an object from its group
* @param obj pointer to an objectto remove
*/
void lv_group_rem_obj(lv_obj_t * obj)
{ {
lv_group_t * g = obj->group_p;
if(g == NULL) return;
lv_obj_t ** i;
LL_READ(g->obj_ll, i) {
if(*i == obj) {
ll_rem(&g->obj_ll, i);
break;
}
}
} }
void lv_group_set_style_cb(lv_group_t * group, void (*style_cb)(lv_style_t * style))
/**
* Focus on an object (defocus the current)
* @param obj pointer to an object to focus on
*/
void lv_group_focus_obj(lv_obj_t * obj)
{ {
group->style_activate = style_cb; lv_group_t * g = obj->group_p;
if(g == NULL) return;
lv_obj_t ** i;
LL_READ(g->obj_ll, i) {
if(*i == obj) {
if(g->obj_focus != NULL) {
(*g->obj_focus)->signal_f(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
lv_obj_inv(*g->obj_focus);
}
g->obj_focus = i;
if(g->obj_focus != NULL){
(*g->obj_focus)->signal_f(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
lv_obj_inv(*g->obj_focus);
}
break;
}
}
} }
void lv_group_activate_next(lv_group_t * group) /**
* Focus the next object in a group (defocus the current)
* @param group pointer to a group
*/
void lv_group_focus_next(lv_group_t * group)
{ {
if(group->actve_obj != NULL) { if(group->obj_focus != NULL) {
(*group->actve_obj)->signal_f(*group->actve_obj, LV_SIGNAL_DEACTIVATE, NULL); (*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
lv_obj_inv(*group->actve_obj); lv_obj_inv(*group->obj_focus);
} }
lv_obj_t ** obj_next; lv_obj_t ** obj_next;
if(group->actve_obj == NULL) obj_next = ll_get_head(&group->obj_ll); if(group->obj_focus == NULL) obj_next = ll_get_head(&group->obj_ll);
else obj_next = ll_get_next(&group->obj_ll, group->actve_obj); else obj_next = ll_get_next(&group->obj_ll, group->obj_focus);
if(obj_next == NULL) obj_next = ll_get_head(&group->obj_ll); if(obj_next == NULL) obj_next = ll_get_head(&group->obj_ll);
group->actve_obj = obj_next; group->obj_focus = obj_next;
if(group->actve_obj != NULL){ if(group->obj_focus != NULL){
(*group->actve_obj)->signal_f(*group->actve_obj, LV_SIGNAL_ACTIVATE, NULL); (*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
lv_obj_inv(*group->actve_obj); lv_obj_inv(*group->obj_focus);
} }
} }
void lv_group_activate_prev(lv_group_t * group) /**
* Focus the previous object in a group (defocus the current)
* @param group pointer to a group
*/
void lv_group_focus_prev(lv_group_t * group)
{ {
if(group->actve_obj != NULL) lv_obj_inv(*group->actve_obj); if(group->obj_focus != NULL) {
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
lv_obj_inv(*group->obj_focus);
}
lv_obj_t ** obj_next; lv_obj_t ** obj_next;
if(group->actve_obj == NULL) obj_next = ll_get_tail(&group->obj_ll); if(group->obj_focus == NULL) obj_next = ll_get_tail(&group->obj_ll);
else obj_next = ll_get_prev(&group->obj_ll, group->actve_obj); else obj_next = ll_get_prev(&group->obj_ll, group->obj_focus);
if(obj_next == NULL) obj_next = ll_get_tail(&group->obj_ll); if(obj_next == NULL) obj_next = ll_get_tail(&group->obj_ll);
group->actve_obj = obj_next; group->obj_focus = obj_next;
if(group->actve_obj != NULL) lv_obj_inv(*group->actve_obj); if(group->obj_focus != NULL){
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
lv_obj_inv(*group->obj_focus);
}
} }
lv_style_t * lv_group_activate_style(lv_group_t * group, lv_style_t * style) /**
* Send a control character to the focuses object of a group
* @param group pointer to a group
* @param c a control character (use LV_GROUP_KEY_.. to navigate)
*/
void lv_group_send(lv_group_t * group, char c)
{ {
lv_style_cpy(&group->style_tmp, style); lv_obj_t * act = lv_group_get_focused(group);
if(act == NULL) return;
if(group->style_activate != NULL) group->style_activate(&group->style_tmp);
else style_activate_def(&group->style_tmp);
return &group->style_tmp; act->signal_f(act, LV_SIGNAL_CONTROLL, &c);
} }
void lv_group_inc_active(lv_group_t * group) /**
* Set a function for a group which will modify the object's style if it is in focus
* @param group pointer to a group
* @param style_cb the style modifier function pointer
*/
void lv_group_set_style_mod_cb(lv_group_t * group, void (*style_cb)(lv_style_t * style))
{ {
lv_obj_t * act = lv_group_get_active(group); group->style_mod = style_cb;
if(act == NULL) return; if(group->obj_focus != NULL) lv_obj_inv(*group->obj_focus);
act->signal_f(act, LV_SIGNAL_INCREASE, NULL);
} }
void lv_group_dec_active(lv_group_t * group) /**
* Modify a style with the set 'style_mod' function. The input style remains unchanged.
* @param group pointer to group
* @param style pointer to a style to modify
* @return a copy of the input style but modified with the 'style_mod' function
*/
lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style)
{ {
lv_obj_t * act = lv_group_get_active(group); lv_style_cpy(&group->style_tmp, style);
if(act == NULL) return;
act->signal_f(act, LV_SIGNAL_DECREASE, NULL);
}
void lv_group_sel_active(lv_group_t * group) if(group->style_mod != NULL) group->style_mod(&group->style_tmp);
{ else style_mod_def(&group->style_tmp);
lv_obj_t * act = lv_group_get_active(group);
if(act == NULL) return;
act->signal_f(act, LV_SIGNAL_SELECT, NULL); return &group->style_tmp;
} }
lv_obj_t * lv_group_get_active(lv_group_t * group) /**
* Get the focused object or NULL if there isn't one
* @param group pointer to a group
* @return pointer to the focused object
*/
lv_obj_t * lv_group_get_focused(lv_group_t * group)
{ {
if(group == NULL) return NULL; if(group == NULL) return NULL;
if(group->actve_obj == NULL) return NULL; if(group->obj_focus == NULL) return NULL;
return *group->actve_obj; return *group->obj_focus;
} }
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
static void style_activate_def(lv_style_t * style) /**
* Default style modifier function
* @param style pointer to a style to modify. (Typically &group->style_tmp) It will be OVERWRITTEN.
*/
static void style_mod_def(lv_style_t * style)
{ {
/*Make the style a little bit orange*/
style->bcolor = COLOR_ORANGE; style->bcolor = COLOR_ORANGE;
style->bopa = OPA_COVER; style->bopa = OPA_COVER;
if(style->bwidth == 0 && style->empty == 0) style->bwidth = 2 * LV_DOWNSCALE; /*Add border to not transparent styles*/ if(style->bwidth == 0 && style->empty == 0) style->bwidth = 2 * LV_DOWNSCALE; /*Add border to not transparent styles*/
...@@ -159,3 +236,5 @@ static void style_activate_def(lv_style_t * style) ...@@ -159,3 +236,5 @@ static void style_activate_def(lv_style_t * style)
style->mcolor = color_mix(style->mcolor, COLOR_ORANGE, OPA_80); style->mcolor = color_mix(style->mcolor, COLOR_ORANGE, OPA_80);
style->gcolor = color_mix(style->gcolor, COLOR_ORANGE, OPA_80); style->gcolor = color_mix(style->gcolor, COLOR_ORANGE, OPA_80);
} }
#endif /*LV_OBJ_GROUP != 0*/
...@@ -13,20 +13,31 @@ extern "C" { ...@@ -13,20 +13,31 @@ extern "C" {
/********************* /*********************
* INCLUDES * INCLUDES
*********************/ *********************/
#include "lv_conf.h"
#include "lv_obj.h" #include "lv_obj.h"
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
/*Predefined keys to control the focused object via lv_group_send(group, c)*/
/*For compatibility in signal function define the keys regardless to LV_OBJ_GROUP*/
#define LV_GROUP_KEY_UP 17 /*0x11*/
#define LV_GROUP_KEY_DOWN 18 /*0x12*/
#define LV_GROUP_KEY_RIGHT 19 /*0x13*/
#define LV_GROUP_KEY_LEFT 20 /*0x14*/
#define LV_GROUP_KEY_ESC 33 /*0x1B*/
#define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/
#if LV_OBJ_GROUP != 0
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
typedef struct typedef struct
{ {
ll_dsc_t obj_ll; ll_dsc_t obj_ll;
lv_obj_t ** actve_obj; lv_obj_t ** obj_focus;
void (*style_activate)(lv_style_t * style); void (*style_mod)(lv_style_t * style);
lv_style_t style_tmp; lv_style_t style_tmp;
}lv_group_t; }lv_group_t;
...@@ -34,20 +45,20 @@ typedef struct ...@@ -34,20 +45,20 @@ typedef struct
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/
lv_group_t * lv_group_create(void); lv_group_t * lv_group_create(void);
void lv_group_add(lv_group_t * group, lv_obj_t * obj); void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj);
void lv_group_activate_obj(lv_group_t * group, lv_obj_t * obj); void lv_group_rem_obj(lv_obj_t * obj);
void lv_group_activate_next(lv_group_t * group); void lv_group_focus_obj(lv_obj_t * obj);
void lv_group_activate_prev(lv_group_t * group); void lv_group_focus_next(lv_group_t * group);
lv_style_t * lv_group_activate_style(lv_group_t * group, lv_style_t * style); void lv_group_focus_prev(lv_group_t * group);
lv_obj_t * lv_group_get_active(lv_group_t * group); void lv_group_send(lv_group_t * group, char c);
void lv_group_inc_active(lv_group_t * group); lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style);
void lv_group_dec_active(lv_group_t * group); lv_obj_t * lv_group_get_focused(lv_group_t * group);
void lv_group_sel_active(lv_group_t * group);
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/
#endif /*LV_OBJ_GROUP != 0*/
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
......
...@@ -234,7 +234,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy) ...@@ -234,7 +234,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
#if LV_OBJ_GROUP != 0 #if LV_OBJ_GROUP != 0
/*Add to the same group*/ /*Add to the same group*/
if(copy->group_p != NULL) { if(copy->group_p != NULL) {
lv_group_add(copy->group_p, new_obj); lv_group_add_obj(copy->group_p, new_obj);
} }
#endif #endif
...@@ -1265,8 +1265,8 @@ lv_style_t * lv_obj_get_style(lv_obj_t * obj) ...@@ -1265,8 +1265,8 @@ lv_style_t * lv_obj_get_style(lv_obj_t * obj)
} }
#if LV_OBJ_GROUP != 0 #if LV_OBJ_GROUP != 0
if(obj->group_p != NULL) { if(obj->group_p != NULL) {
if(lv_group_get_active(obj->group_p) == obj) { if(lv_group_get_focused(obj->group_p) == obj) {
style_act = lv_group_activate_style(obj->group_p, style_act); style_act = lv_group_mod_style(obj->group_p, style_act);
} }
} }
#endif #endif
...@@ -1558,13 +1558,16 @@ static void lv_obj_del_child(lv_obj_t * obj) ...@@ -1558,13 +1558,16 @@ static void lv_obj_del_child(lv_obj_t * obj)
/*Remove the animations from this object*/ /*Remove the animations from this object*/
anim_del(obj, NULL); anim_del(obj, NULL);
/*Delete from the group*/
#if LV_OBJ_GROUP != 0
if(obj->group_p != NULL) lv_group_rem_obj(obj);
#endif
/*Remove the object from parent's children list*/ /*Remove the object from parent's children list*/
lv_obj_t * par = lv_obj_get_parent(obj); lv_obj_t * par = lv_obj_get_parent(obj);
ll_rem(&(par->child_ll), obj); ll_rem(&(par->child_ll), obj);
/* All children deleted. /* Clean up the object specific data*/
* Now clean up the object specific data*/
obj->signal_f(obj, LV_SIGNAL_CLEANUP, NULL); obj->signal_f(obj, LV_SIGNAL_CLEANUP, NULL);
/*Delete the base objects*/ /*Delete the base objects*/
......
...@@ -90,11 +90,9 @@ typedef enum ...@@ -90,11 +90,9 @@ typedef enum
LV_SIGNAL_DRAG_END, LV_SIGNAL_DRAG_END,
/*Group related*/ /*Group related*/
LV_SIGNAL_ACTIVATE, LV_SIGNAL_FOCUS,
LV_SIGNAL_DEACTIVATE, LV_SIGNAL_DEFOCUS,
LV_SIGNAL_INCREASE, LV_SIGNAL_CONTROLL,
LV_SIGNAL_DECREASE,
LV_SIGNAL_SELECT,
}lv_signal_t; }lv_signal_t;
typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void * param); typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void * param);
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
#include "lv_conf.h" #include "lv_conf.h"
#if USE_LV_BTN != 0 #if USE_LV_BTN != 0
#include "lvgl/lv_obj/lv_obj.h" #include "lv_btn.h"
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "misc/gfx/area.h" #include "misc/gfx/area.h"
#include "misc/gfx/color.h" #include "misc/gfx/color.h"
#include "../lv_draw/lv_draw.h"
#include "lv_btn.h"
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
...@@ -185,24 +185,30 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param) ...@@ -185,24 +185,30 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
if(ext->lpr_rep_action != NULL && state != LV_BTN_STATE_INA) { if(ext->lpr_rep_action != NULL && state != LV_BTN_STATE_INA) {
valid = ext->lpr_rep_action(btn, param); valid = ext->lpr_rep_action(btn, param);
} }
} else if(sign == LV_SIGNAL_INCREASE) { } else if(sign == LV_SIGNAL_CONTROLL) {
if(lv_btn_get_tgl(btn) != false) { lv_btn_ext_t * ext = lv_obj_get_ext(btn);
lv_btn_set_state(btn, LV_BTN_STATE_TREL); char c = *((char*)param);
if(ext->rel_action != NULL) valid = ext->rel_action(btn, param); if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
} if(lv_btn_get_tgl(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
} else if(sign == LV_SIGNAL_DECREASE) { if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
if(lv_btn_get_tgl(btn) != false) { valid = ext->rel_action(btn, param);
lv_btn_set_state(btn, LV_BTN_STATE_REL); }
if(ext->rel_action != NULL) valid = ext->rel_action(btn, param); } else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
} if(lv_btn_get_tgl(btn) != false) lv_btn_set_state(btn, LV_BTN_STATE_REL);
} else if(sign == LV_SIGNAL_SELECT) { if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
if(lv_btn_get_tgl(btn) != false) { valid = ext->rel_action(btn, param);
lv_btn_state_t state = lv_btn_get_state(btn); }
if(state == LV_BTN_STATE_REL) lv_btn_set_state(btn, LV_BTN_STATE_TREL); } else if(c == LV_GROUP_KEY_ENTER) {
else if(state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TPR); if(lv_btn_get_tgl(btn) != false) {
else if(state == LV_BTN_STATE_TREL) lv_btn_set_state(btn, LV_BTN_STATE_REL); lv_btn_state_t state = lv_btn_get_state(btn);
else if(state == LV_BTN_STATE_TPR) lv_btn_set_state(btn, LV_BTN_STATE_PR); if(state == LV_BTN_STATE_REL) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
if(ext->rel_action != NULL) valid = ext->rel_action(btn, param); else if(state == LV_BTN_STATE_PR) lv_btn_set_state(btn, LV_BTN_STATE_TPR);
else if(state == LV_BTN_STATE_TREL) lv_btn_set_state(btn, LV_BTN_STATE_REL);
else if(state == LV_BTN_STATE_TPR) lv_btn_set_state(btn, LV_BTN_STATE_PR);
}
if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
valid = ext->rel_action(btn, param);
}
} }
} }
} }
......
...@@ -10,9 +10,10 @@ ...@@ -10,9 +10,10 @@
#if USE_LV_BTNM != 0 #if USE_LV_BTNM != 0
#include "lv_btnm.h" #include "lv_btnm.h"
#include "misc/gfx/text.h" #include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h" #include "../lv_draw/lv_draw.h"
#include "../lv_obj/lv_refr.h" #include "../lv_obj/lv_refr.h"
#include "misc/gfx/text.h"
/********************* /*********************
* DEFINES * DEFINES
...@@ -172,25 +173,29 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) ...@@ -172,25 +173,29 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
ext->btn_pr = LV_BTNM_PR_NONE; ext->btn_pr = LV_BTNM_PR_NONE;
} }
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEACTIVATE) { } else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->btn_pr = LV_BTNM_PR_NONE; ext->btn_pr = LV_BTNM_PR_NONE;
lv_obj_inv(btnm); lv_obj_inv(btnm);
} else if(sign == LV_SIGNAL_ACTIVATE) { } else if(sign == LV_SIGNAL_FOCUS) {
ext->btn_pr = 0; ext->btn_pr = 0;
lv_obj_inv(btnm); lv_obj_inv(btnm);
} else if(sign == LV_SIGNAL_INCREASE) { } else if(sign == LV_SIGNAL_CONTROLL) {
if(ext->btn_pr == LV_BTNM_PR_NONE) ext->btn_pr = 0; lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
else ext->btn_pr++; char c = *((char*)param);
if(ext->btn_pr >= ext->btn_cnt - 1) ext->btn_pr = ext->btn_cnt - 1; if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
lv_obj_inv(btnm); if(ext->btn_pr == LV_BTNM_PR_NONE) ext->btn_pr = 0;
} else if(sign == LV_SIGNAL_DECREASE) { else ext->btn_pr++;
if(ext->btn_pr == LV_BTNM_PR_NONE) ext->btn_pr = 0; if(ext->btn_pr >= ext->btn_cnt - 1) ext->btn_pr = ext->btn_cnt - 1;
if(ext->btn_pr > 0) ext->btn_pr--; lv_obj_inv(btnm);
lv_obj_inv(btnm); } else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
} else if(sign == LV_SIGNAL_SELECT) { if(ext->btn_pr == LV_BTNM_PR_NONE) ext->btn_pr = 0;
if(ext->cb != NULL) { if(ext->btn_pr > 0) ext->btn_pr--;
uint16_t txt_i = lv_btnm_get_btn_txt(btnm, ext->btn_pr); lv_obj_inv(btnm);
if(txt_i != LV_BTNM_PR_NONE) ext->cb(btnm, txt_i); } else if(c == LV_GROUP_KEY_ENTER) {
if(ext->cb != NULL) {
uint16_t txt_i = lv_btnm_get_btn_txt(btnm, ext->btn_pr);
if(txt_i != LV_BTNM_PR_NONE) ext->cb(btnm, txt_i);
}
} }
} }
} }
......
...@@ -122,11 +122,15 @@ bool lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param) ...@@ -122,11 +122,15 @@ bool lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
lv_obj_set_size(ext->bullet, font_get_height(style->font), font_get_height(style->font)); lv_obj_set_size(ext->bullet, font_get_height(style->font), font_get_height(style->font));
} else if(sign == LV_SIGNAL_PRESSED || } else if(sign == LV_SIGNAL_PRESSED ||
sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_RELEASED ||
sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_PRESS_LOST) {
sign == LV_SIGNAL_INCREASE ||
sign == LV_SIGNAL_DECREASE ||
sign == LV_SIGNAL_SELECT) {
lv_btn_set_state(lv_cb_get_bullet(cb), lv_btn_get_state(cb)); lv_btn_set_state(lv_cb_get_bullet(cb), lv_btn_get_state(cb));
} else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN ||
c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP ||
c == LV_GROUP_KEY_ENTER) {
lv_btn_set_state(lv_cb_get_bullet(cb), lv_btn_get_state(cb));
}
} }
} }
...@@ -235,9 +239,9 @@ static bool lv_bullet_design(lv_obj_t * bullet, const area_t * mask, lv_design_m ...@@ -235,9 +239,9 @@ static bool lv_bullet_design(lv_obj_t * bullet, const area_t * mask, lv_design_m
lv_style_t * style_page = lv_obj_get_style(bg); lv_style_t * style_page = lv_obj_get_style(bg);
lv_group_t * g = lv_obj_get_group(bg); lv_group_t * g = lv_obj_get_group(bg);
if(style_page->empty != 0 || style_page->opa == OPA_TRANSP) { /*Background is visible?*/ if(style_page->empty != 0 || style_page->opa == OPA_TRANSP) { /*Background is visible?*/
if(lv_group_get_active(g) == bg) { if(lv_group_get_focused(g) == bg) {
lv_style_t * style_mod; lv_style_t * style_mod;
style_mod = lv_group_activate_style(g, style_ori); style_mod = lv_group_mod_style(g, style_ori);
bullet->style_p = style_mod; /*Temporally change the style to the activated */ bullet->style_p = style_mod; /*Temporally change the style to the activated */
} }
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "lv_ddlist.h" #include "lv_ddlist.h"
#include "../lv_draw/lv_draw.h" #include "../lv_draw/lv_draw.h"
#include "misc/gfx/anim.h" #include "misc/gfx/anim.h"
#include "../lv_obj/lv_group.h"
/********************* /*********************
* DEFINES * DEFINES
...@@ -131,35 +132,42 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param) ...@@ -131,35 +132,42 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist); lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
lv_obj_set_style(ext->opt_label, lv_obj_get_style(ddlist)); lv_obj_set_style(ext->opt_label, lv_obj_get_style(ddlist));
lv_ddlist_refr_size(ddlist, 0); lv_ddlist_refr_size(ddlist, 0);
} else if(sign == LV_SIGNAL_ACTIVATE) { } else if(sign == LV_SIGNAL_FOCUS) {
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist); lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
if(ext->opened == false) { if(ext->opened == false) {
ext->opened = true; ext->opened = true;
lv_ddlist_refr_size(ddlist, true); lv_ddlist_refr_size(ddlist, true);
} }
} else if(sign == LV_SIGNAL_DEACTIVATE) { } else if(sign == LV_SIGNAL_DEFOCUS) {
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist); lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
if(ext->opened != false) { if(ext->opened != false) {
ext->opened = false; ext->opened = false;
lv_ddlist_refr_size(ddlist, true); lv_ddlist_refr_size(ddlist, true);
} }
} else if(sign == LV_SIGNAL_INCREASE) { } else if(sign == LV_SIGNAL_CONTROLL) {
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist); lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
if(ext->sel_opt < ext->num_opt - 1) { char c = *((char*)param);
ext->sel_opt ++; if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
lv_obj_inv(ddlist); if(ext->sel_opt < ext->num_opt - 1) {
if(ext->cb != NULL) { ext->sel_opt ++;
ext->cb(ddlist, NULL); lv_obj_inv(ddlist);
if(ext->cb != NULL) {
ext->cb(ddlist, NULL);
}
} }
} } else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
} else if(sign == LV_SIGNAL_DECREASE) { if(ext->sel_opt > 0) {
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist); ext->sel_opt --;
if(ext->sel_opt > 0) { lv_obj_inv(ddlist);
ext->sel_opt --; if(ext->cb != NULL) {
lv_obj_inv(ddlist); ext->cb(ddlist, NULL);
if(ext->cb != NULL) { }
ext->cb(ddlist, NULL);
} }
} else if(c == LV_GROUP_KEY_ENTER || c == LV_GROUP_KEY_ESC) {
if(ext->opened != false) ext->opened = false;
if(ext->opened == false) ext->opened = true;
lv_ddlist_refr_size(ddlist, true);
} }
} }
} }
......
...@@ -501,7 +501,7 @@ static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mod ...@@ -501,7 +501,7 @@ static bool lv_label_design(lv_obj_t * label, const area_t * mask, lv_design_mod
#if LV_OBJ_GROUP != 0 #if LV_OBJ_GROUP != 0
lv_group_t * g = lv_obj_get_group(label); lv_group_t * g = lv_obj_get_group(label);
if(lv_group_get_active(g) == label) { if(lv_group_get_focused(g) == label) {
lv_draw_rect(&cords, mask, style); lv_draw_rect(&cords, mask, style);
} }
#endif #endif
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#if USE_LV_LIST != 0 #if USE_LV_LIST != 0
#include "lv_list.h" #include "lv_list.h"
#include "lvgl/lv_obj/lv_group.h"
#include "lvgl/lv_objx/lv_cont.h" #include "lvgl/lv_objx/lv_cont.h"
#include "misc/gfx/anim.h" #include "misc/gfx/anim.h"
#include "misc/math/math_base.h" #include "misc/math/math_base.h"
...@@ -117,7 +118,7 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) ...@@ -117,7 +118,7 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
/* The object can be deleted so check its validity and then /* The object can be deleted so check its validity and then
* make the object specific signal handling */ * make the object specific signal handling */
if(valid != false) { if(valid != false) {
if(sign == LV_SIGNAL_ACTIVATE) { if(sign == LV_SIGNAL_FOCUS) {
/*Get the first button*/ /*Get the first button*/
lv_obj_t * btn = NULL; lv_obj_t * btn = NULL;
lv_obj_t * btn_prev = NULL; lv_obj_t * btn_prev = NULL;
...@@ -129,7 +130,7 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) ...@@ -129,7 +130,7 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
if(btn_prev != NULL) { if(btn_prev != NULL) {
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR); lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
} }
} else if(sign == LV_SIGNAL_DEACTIVATE) { } else if(sign == LV_SIGNAL_DEFOCUS) {
/*Get the 'pressed' button*/ /*Get the 'pressed' button*/
lv_obj_t * btn = NULL; lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn); btn = lv_list_get_next_btn(list, btn);
...@@ -141,52 +142,55 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) ...@@ -141,52 +142,55 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
if(btn != NULL) { if(btn != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_REL); lv_btn_set_state(btn, LV_BTN_STATE_REL);
} }
} else if(sign == LV_SIGNAL_INCREASE) { } else if(sign == LV_SIGNAL_CONTROLL) {
/*Get the last pressed button*/ char c = *((char*)param);
lv_obj_t * btn = NULL; if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
lv_obj_t * btn_prev = NULL; /*Get the last pressed button*/
btn = lv_list_get_next_btn(list, btn); lv_obj_t * btn = NULL;
while(btn != NULL) { lv_obj_t * btn_prev = NULL;
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn_prev = btn;
btn = lv_list_get_next_btn(list, btn); btn = lv_list_get_next_btn(list, btn);
} while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
if(btn_prev != NULL && btn != NULL) { btn_prev = btn;
lv_btn_set_state(btn, LV_BTN_STATE_REL); btn = lv_list_get_next_btn(list, btn);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR); }
lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME);
}
} else if(sign == LV_SIGNAL_DECREASE) {
/*Get the last pressed button*/
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn = lv_list_get_next_btn(list, btn);
}
if(btn != NULL) { if(btn_prev != NULL && btn != NULL) {
lv_obj_t * btn_prev = lv_list_get_next_btn(list, btn);
if(btn_prev != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_REL); lv_btn_set_state(btn, LV_BTN_STATE_REL);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR); lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME); lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME);
} }
} } else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
} else if(sign == LV_SIGNAL_SELECT) { /*Get the last pressed button*/
/*Get the 'pressed' button*/ lv_obj_t * btn = NULL;
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn = lv_list_get_next_btn(list, btn); btn = lv_list_get_next_btn(list, btn);
} while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn = lv_list_get_next_btn(list, btn);
}
if(btn != NULL) { if(btn != NULL) {
lv_action_t rel_action; lv_obj_t * btn_prev = lv_list_get_next_btn(list, btn);
rel_action = lv_btn_get_rel_action(btn); if(btn_prev != NULL) {
if(rel_action != NULL) rel_action(btn, NULL); lv_btn_set_state(btn, LV_BTN_STATE_REL);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME);
}
}
} else if(c == LV_GROUP_KEY_ENTER) {
/*Get the 'pressed' button*/
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn = lv_list_get_next_btn(list, btn);
}
if(btn != NULL) {
lv_action_t rel_action;
rel_action = lv_btn_get_rel_action(btn);
if(rel_action != NULL) rel_action(btn, NULL);
}
} }
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#if USE_LV_MBOX != 0 #if USE_LV_MBOX != 0
#include "lv_mbox.h" #include "lv_mbox.h"
#include "lvgl/lv_obj/lv_group.h"
#include "misc/gfx/anim.h" #include "misc/gfx/anim.h"
#include "misc/math/math_base.h" #include "misc/math/math_base.h"
...@@ -148,7 +149,7 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param) ...@@ -148,7 +149,7 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
btn = lv_obj_get_child(ext->btnh, btn); btn = lv_obj_get_child(ext->btnh, btn);
} }
} }
} else if(sign == LV_SIGNAL_ACTIVATE) { } else if(sign == LV_SIGNAL_FOCUS) {
/*Get the first button*/ /*Get the first button*/
if(ext->btnh != NULL) { if(ext->btnh != NULL) {
lv_obj_t * btn = NULL; lv_obj_t * btn = NULL;
...@@ -162,7 +163,7 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param) ...@@ -162,7 +163,7 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR); lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
} }
} }
} else if(sign == LV_SIGNAL_DEACTIVATE) { } else if(sign == LV_SIGNAL_DEFOCUS) {
/*Get the 'pressed' button*/ /*Get the 'pressed' button*/
if(ext->btnh != NULL) { if(ext->btnh != NULL) {
lv_obj_t * btn = NULL; lv_obj_t * btn = NULL;
...@@ -176,56 +177,61 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param) ...@@ -176,56 +177,61 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
lv_btn_set_state(btn, LV_BTN_STATE_REL); lv_btn_set_state(btn, LV_BTN_STATE_REL);
} }
} }
} else if(sign == LV_SIGNAL_INCREASE) { } else if(sign == LV_SIGNAL_CONTROLL) {
/*Get the last pressed button*/ lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
if(ext->btnh != NULL) { char c = *((char*)param);
lv_obj_t * btn = NULL; if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
lv_obj_t * btn_prev = NULL; /*Get the last pressed button*/
btn = lv_obj_get_child(ext->btnh, btn); if(ext->btnh != NULL) {
while(btn != NULL) { lv_obj_t * btn = NULL;
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break; lv_obj_t * btn_prev = NULL;
btn_prev = btn;
btn = lv_obj_get_child(ext->btnh, btn);
}
if(btn_prev != NULL && btn != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_REL);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
}
}
} else if(sign == LV_SIGNAL_DECREASE) {
/*Get the last pressed button*/
if(ext->btnh != NULL) {
lv_obj_t * btn = NULL;
btn = lv_obj_get_child(ext->btnh, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn = lv_obj_get_child(ext->btnh, btn); btn = lv_obj_get_child(ext->btnh, btn);
} while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn_prev = btn;
btn = lv_obj_get_child(ext->btnh, btn);
}
if(btn != NULL) { if(btn_prev != NULL && btn != NULL) {
lv_obj_t * btn_prev = lv_obj_get_child(ext->btnh, btn);
if(btn_prev != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_REL); lv_btn_set_state(btn, LV_BTN_STATE_REL);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR); lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
} }
} }
} } else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
} else if(sign == LV_SIGNAL_SELECT) { /*Get the last pressed button*/
/*Get the 'pressed' button*/ if(ext->btnh != NULL) {
if(ext->btnh != NULL) { lv_obj_t * btn = NULL;
lv_obj_t * btn = NULL;
btn = lv_obj_get_child(ext->btnh, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn = lv_obj_get_child(ext->btnh, btn); btn = lv_obj_get_child(ext->btnh, btn);
} while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn = lv_obj_get_child(ext->btnh, btn);
}
if(btn != NULL) {
lv_obj_t * btn_prev = lv_obj_get_child(ext->btnh, btn);
if(btn_prev != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_REL);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
}
}
if(btn != NULL) {
lv_action_t rel_action;
rel_action = lv_btn_get_rel_action(btn);
if(rel_action != NULL) rel_action(btn, NULL);
} }
} else if(c == LV_GROUP_KEY_ENTER) {
/*Get the 'pressed' button*/
if(ext->btnh != NULL) {
lv_obj_t * btn = NULL;
btn = lv_obj_get_child(ext->btnh, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
btn = lv_obj_get_child(ext->btnh, btn);
}
if(btn != NULL) {
lv_action_t rel_action;
rel_action = lv_btn_get_rel_action(btn);
if(rel_action != NULL) rel_action(btn, NULL);
}
}
} }
} }
} }
......
...@@ -592,9 +592,9 @@ static bool lv_scrl_design(lv_obj_t * scrl, const area_t * mask, lv_design_mode_ ...@@ -592,9 +592,9 @@ static bool lv_scrl_design(lv_obj_t * scrl, const area_t * mask, lv_design_mode_
lv_style_t * style_page = lv_obj_get_style(page); lv_style_t * style_page = lv_obj_get_style(page);
lv_group_t * g = lv_obj_get_group(page); lv_group_t * g = lv_obj_get_group(page);
if(style_page->empty != 0 || style_page->opa == OPA_TRANSP) { /*Background is visible?*/ if(style_page->empty != 0 || style_page->opa == OPA_TRANSP) { /*Background is visible?*/
if(lv_group_get_active(g) == page) { if(lv_group_get_focused(g) == page) {
lv_style_t * style_mod; lv_style_t * style_mod;
style_mod = lv_group_activate_style(g, style_ori); style_mod = lv_group_mod_style(g, style_ori);
scrl->style_p = style_mod; /*Temporally change the style to the activated */ scrl->style_p = style_mod; /*Temporally change the style to the activated */
} }
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#if USE_LV_SLIDER != 0 #if USE_LV_SLIDER != 0
#include "lv_slider.h" #include "lv_slider.h"
#include "lvgl/lv_obj/lv_group.h"
#include "misc/math/math_base.h" #include "misc/math/math_base.h"
#include "../lv_draw/lv_draw.h" #include "../lv_draw/lv_draw.h"
...@@ -52,7 +53,6 @@ static lv_design_f_t ancestor_design_f; ...@@ -52,7 +53,6 @@ static lv_design_f_t ancestor_design_f;
lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy) lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
{ {
/*Create the ancestor slider*/ /*Create the ancestor slider*/
/*TODO modify it to the ancestor create function */
lv_obj_t * new_slider = lv_bar_create(par, copy); lv_obj_t * new_slider = lv_bar_create(par, copy);
dm_assert(new_slider); dm_assert(new_slider);
...@@ -102,7 +102,6 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param) ...@@ -102,7 +102,6 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
bool valid; bool valid;
/* Include the ancient signal function */ /* Include the ancient signal function */
/* TODO update it to the ancestor's signal function*/
valid = lv_bar_signal(slider, sign, param); valid = lv_bar_signal(slider, sign, param);
/* The object can be deleted so check its validity and then /* The object can be deleted so check its validity and then
...@@ -148,12 +147,16 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param) ...@@ -148,12 +147,16 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) { } else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
cord_t x = MATH_MIN(w, h); cord_t x = MATH_MIN(w, h);
if(slider->ext_size < x) slider->ext_size = x; if(slider->ext_size < x) slider->ext_size = x;
} else if(sign == LV_SIGNAL_INCREASE) { } else if(sign == LV_SIGNAL_CONTROLL) {
lv_bar_set_value(slider, lv_bar_get_value(slider) + 1); lv_slider_ext_t * ext = lv_obj_get_ext(slider);
if(ext->cb != NULL) ext->cb(slider, NULL); char c = *((char*)param);
} else if(sign == LV_SIGNAL_DECREASE) { if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
lv_bar_set_value(slider, lv_bar_get_value(slider) - 1); lv_bar_set_value(slider, lv_bar_get_value(slider) + 1);
if(ext->cb != NULL) ext->cb(slider, NULL); if(ext->cb != NULL) ext->cb(slider, NULL);
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
lv_bar_set_value(slider, lv_bar_get_value(slider) - 1);
if(ext->cb != NULL) ext->cb(slider, NULL);
}
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#if USE_LV_TA != 0 #if USE_LV_TA != 0
#include "lv_ta.h" #include "lv_ta.h"
#include "lvgl/lv_obj/lv_group.h"
#include "misc/gfx/anim.h" #include "misc/gfx/anim.h"
#include "../lv_draw/lv_draw.h" #include "../lv_draw/lv_draw.h"
...@@ -175,14 +176,21 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) ...@@ -175,14 +176,21 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
(style->hpad + style->hpad)); (style->hpad + style->hpad));
lv_label_set_text(ext->label, NULL); lv_label_set_text(ext->label, NULL);
} }
} else if(sign == LV_SIGNAL_INCREASE) { } else if (sign == LV_SIGNAL_CONTROLL) {
lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) + 1); lv_ta_ext_t * ext = lv_obj_get_ext(ta);
} else if(sign == LV_SIGNAL_DECREASE) { char c = *((char*)param);
uint16_t cur_pos = lv_ta_get_cursor_pos(ta); if(c == LV_GROUP_KEY_RIGHT) {
if(cur_pos > 0) lv_ta_set_cursor_pos(ta, cur_pos - 1); lv_ta_cursor_right(ta);
} else if(c == LV_GROUP_KEY_LEFT) {
lv_ta_cursor_left(ta);
} else if(c == LV_GROUP_KEY_UP) {
lv_ta_cursor_up(ta);
} else if(c == LV_GROUP_KEY_DOWN) {
lv_ta_cursor_down(ta);
}
} }
} }
return valid; return valid;
} }
/*===================== /*=====================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment