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 @@
/*********************
* INCLUDES
*********************/
#include <stddef.h>
#include "lv_group.h"
#if LV_OBJ_GROUP != 0
#include <stddef.h>
/*********************
* DEFINES
......@@ -20,7 +21,7 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void style_activate_def(lv_style_t * style);
static void style_mod_def(lv_style_t * style);
/**********************
* STATIC VARIABLES
......@@ -34,18 +35,27 @@ static void style_activate_def(lv_style_t * style);
* GLOBAL FUNCTIONS
**********************/
/**
* Create a new object group
* @return pointer to the new object group
*/
lv_group_t * lv_group_create(void)
{
lv_group_t * group = dm_alloc(sizeof(lv_group_t));
ll_init(&group->obj_ll, sizeof(lv_obj_t *));
group->style_activate = style_activate_def;
group->actve_obj = NULL;
group->style_mod = style_mod_def;
group->obj_focus = NULL;
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;
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)
/* If the head and the tail is equal then there is only one object in the linked list.
* In this case automatically activate it*/
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) {
(*group->actve_obj)->signal_f(*group->actve_obj, LV_SIGNAL_DEACTIVATE, 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;
if(group->actve_obj == NULL) obj_next = ll_get_head(&group->obj_ll);
else obj_next = ll_get_next(&group->obj_ll, group->actve_obj);
if(group->obj_focus == NULL) obj_next = ll_get_head(&group->obj_ll);
else obj_next = ll_get_next(&group->obj_ll, group->obj_focus);
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){
(*group->actve_obj)->signal_f(*group->actve_obj, LV_SIGNAL_ACTIVATE, 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);
}
}
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;
if(group->actve_obj == NULL) obj_next = ll_get_tail(&group->obj_ll);
else obj_next = ll_get_prev(&group->obj_ll, group->actve_obj);
if(group->obj_focus == NULL) obj_next = ll_get_tail(&group->obj_ll);
else obj_next = ll_get_prev(&group->obj_ll, group->obj_focus);
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);
if(group->style_activate != NULL) group->style_activate(&group->style_tmp);
else style_activate_def(&group->style_tmp);
lv_obj_t * act = lv_group_get_focused(group);
if(act == NULL) return;
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);
if(act == NULL) return;
act->signal_f(act, LV_SIGNAL_INCREASE, NULL);
group->style_mod = style_cb;
if(group->obj_focus != NULL) lv_obj_inv(*group->obj_focus);
}
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);
if(act == NULL) return;
act->signal_f(act, LV_SIGNAL_DECREASE, NULL);
}
lv_style_cpy(&group->style_tmp, style);
void lv_group_sel_active(lv_group_t * group)
{
lv_obj_t * act = lv_group_get_active(group);
if(act == NULL) return;
if(group->style_mod != NULL) group->style_mod(&group->style_tmp);
else style_mod_def(&group->style_tmp);
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->actve_obj == NULL) return NULL;
if(group->obj_focus == NULL) return NULL;
return *group->actve_obj;
return *group->obj_focus;
}
/**********************
* 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->bopa = OPA_COVER;
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)
style->mcolor = color_mix(style->mcolor, 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" {
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#include "lv_obj.h"
/*********************
* 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
**********************/
typedef struct
{
ll_dsc_t obj_ll;
lv_obj_t ** actve_obj;
void (*style_activate)(lv_style_t * style);
lv_obj_t ** obj_focus;
void (*style_mod)(lv_style_t * style);
lv_style_t style_tmp;
}lv_group_t;
......@@ -34,20 +45,20 @@ typedef struct
* GLOBAL PROTOTYPES
**********************/
lv_group_t * lv_group_create(void);
void lv_group_add(lv_group_t * group, lv_obj_t * obj);
void lv_group_activate_obj(lv_group_t * group, lv_obj_t * obj);
void lv_group_activate_next(lv_group_t * group);
void lv_group_activate_prev(lv_group_t * group);
lv_style_t * lv_group_activate_style(lv_group_t * group, lv_style_t * style);
lv_obj_t * lv_group_get_active(lv_group_t * group);
void lv_group_inc_active(lv_group_t * group);
void lv_group_dec_active(lv_group_t * group);
void lv_group_sel_active(lv_group_t * group);
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj);
void lv_group_rem_obj(lv_obj_t * obj);
void lv_group_focus_obj(lv_obj_t * obj);
void lv_group_focus_next(lv_group_t * group);
void lv_group_focus_prev(lv_group_t * group);
void lv_group_send(lv_group_t * group, char c);
lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style);
lv_obj_t * lv_group_get_focused(lv_group_t * group);
/**********************
* MACROS
**********************/
#endif /*LV_OBJ_GROUP != 0*/
#ifdef __cplusplus
} /* extern "C" */
......
......@@ -234,7 +234,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy)
#if LV_OBJ_GROUP != 0
/*Add to the same group*/
if(copy->group_p != NULL) {
lv_group_add(copy->group_p, new_obj);
lv_group_add_obj(copy->group_p, new_obj);
}
#endif
......@@ -1265,8 +1265,8 @@ lv_style_t * lv_obj_get_style(lv_obj_t * obj)
}
#if LV_OBJ_GROUP != 0
if(obj->group_p != NULL) {
if(lv_group_get_active(obj->group_p) == obj) {
style_act = lv_group_activate_style(obj->group_p, style_act);
if(lv_group_get_focused(obj->group_p) == obj) {
style_act = lv_group_mod_style(obj->group_p, style_act);
}
}
#endif
......@@ -1558,13 +1558,16 @@ static void lv_obj_del_child(lv_obj_t * obj)
/*Remove the animations from this object*/
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*/
lv_obj_t * par = lv_obj_get_parent(obj);
ll_rem(&(par->child_ll), obj);
/* All children deleted.
* Now clean up the object specific data*/
/* Clean up the object specific data*/
obj->signal_f(obj, LV_SIGNAL_CLEANUP, NULL);
/*Delete the base objects*/
......
......@@ -90,11 +90,9 @@ typedef enum
LV_SIGNAL_DRAG_END,
/*Group related*/
LV_SIGNAL_ACTIVATE,
LV_SIGNAL_DEACTIVATE,
LV_SIGNAL_INCREASE,
LV_SIGNAL_DECREASE,
LV_SIGNAL_SELECT,
LV_SIGNAL_FOCUS,
LV_SIGNAL_DEFOCUS,
LV_SIGNAL_CONTROLL,
}lv_signal_t;
typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void * param);
......
......@@ -10,11 +10,11 @@
#include "lv_conf.h"
#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/color.h"
#include "../lv_draw/lv_draw.h"
#include "lv_btn.h"
#include <stdbool.h>
#include <string.h>
......@@ -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) {
valid = ext->lpr_rep_action(btn, param);
}
} else if(sign == LV_SIGNAL_INCREASE) {
if(lv_btn_get_tgl(btn) != false) {
lv_btn_set_state(btn, LV_BTN_STATE_TREL);
if(ext->rel_action != NULL) valid = ext->rel_action(btn, param);
} else if(sign == LV_SIGNAL_CONTROLL) {
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
char c = *((char*)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);
if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
valid = ext->rel_action(btn, param);
}
} else if(sign == LV_SIGNAL_DECREASE) {
if(lv_btn_get_tgl(btn) != false) {
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);
if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
valid = ext->rel_action(btn, param);
}
} else if(sign == LV_SIGNAL_SELECT) {
} else if(c == LV_GROUP_KEY_ENTER) {
if(lv_btn_get_tgl(btn) != false) {
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(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) valid = ext->rel_action(btn, param);
}
if(ext->rel_action != NULL && lv_btn_get_state(btn) != LV_BTN_STATE_INA) {
valid = ext->rel_action(btn, param);
}
}
}
}
......
......@@ -10,9 +10,10 @@
#if USE_LV_BTNM != 0
#include "lv_btnm.h"
#include "misc/gfx/text.h"
#include "../lv_obj/lv_group.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_obj/lv_refr.h"
#include "misc/gfx/text.h"
/*********************
* DEFINES
......@@ -172,28 +173,32 @@ bool lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
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;
lv_obj_inv(btnm);
} else if(sign == LV_SIGNAL_ACTIVATE) {
} else if(sign == LV_SIGNAL_FOCUS) {
ext->btn_pr = 0;
lv_obj_inv(btnm);
} else if(sign == LV_SIGNAL_INCREASE) {
} else if(sign == LV_SIGNAL_CONTROLL) {
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
if(ext->btn_pr == LV_BTNM_PR_NONE) ext->btn_pr = 0;
else ext->btn_pr++;
if(ext->btn_pr >= ext->btn_cnt - 1) ext->btn_pr = ext->btn_cnt - 1;
lv_obj_inv(btnm);
} else if(sign == LV_SIGNAL_DECREASE) {
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
if(ext->btn_pr == LV_BTNM_PR_NONE) ext->btn_pr = 0;
if(ext->btn_pr > 0) ext->btn_pr--;
lv_obj_inv(btnm);
} else if(sign == LV_SIGNAL_SELECT) {
} 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);
}
}
}
}
return valid;
}
......
......@@ -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));
} else if(sign == LV_SIGNAL_PRESSED ||
sign == LV_SIGNAL_RELEASED ||
sign == LV_SIGNAL_PRESS_LOST ||
sign == LV_SIGNAL_INCREASE ||
sign == LV_SIGNAL_DECREASE ||
sign == LV_SIGNAL_SELECT) {
sign == LV_SIGNAL_PRESS_LOST) {
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
lv_style_t * style_page = lv_obj_get_style(bg);
lv_group_t * g = lv_obj_get_group(bg);
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;
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 */
}
}
......
......@@ -13,6 +13,7 @@
#include "lv_ddlist.h"
#include "../lv_draw/lv_draw.h"
#include "misc/gfx/anim.h"
#include "../lv_obj/lv_group.h"
/*********************
* DEFINES
......@@ -131,20 +132,22 @@ 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_obj_set_style(ext->opt_label, lv_obj_get_style(ddlist));
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);
if(ext->opened == false) {
ext->opened = 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);
if(ext->opened != false) {
ext->opened = false;
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);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
if(ext->sel_opt < ext->num_opt - 1) {
ext->sel_opt ++;
lv_obj_inv(ddlist);
......@@ -152,8 +155,7 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
ext->cb(ddlist, NULL);
}
}
} else if(sign == LV_SIGNAL_DECREASE) {
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
if(ext->sel_opt > 0) {
ext->sel_opt --;
lv_obj_inv(ddlist);
......@@ -161,6 +163,12 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
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
#if LV_OBJ_GROUP != 0
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);
}
#endif
......
......@@ -10,6 +10,7 @@
#if USE_LV_LIST != 0
#include "lv_list.h"
#include "lvgl/lv_obj/lv_group.h"
#include "lvgl/lv_objx/lv_cont.h"
#include "misc/gfx/anim.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)
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
if(sign == LV_SIGNAL_ACTIVATE) {
if(sign == LV_SIGNAL_FOCUS) {
/*Get the first button*/
lv_obj_t * btn = 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)
if(btn_prev != NULL) {
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*/
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
......@@ -141,7 +142,9 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
if(btn != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_REL);
}
} else if(sign == LV_SIGNAL_INCREASE) {
} else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
/*Get the last pressed button*/
lv_obj_t * btn = NULL;
lv_obj_t * btn_prev = NULL;
......@@ -157,7 +160,7 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
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) {
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
/*Get the last pressed button*/
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
......@@ -174,7 +177,7 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME);
}
}
} else if(sign == LV_SIGNAL_SELECT) {
} else if(c == LV_GROUP_KEY_ENTER) {
/*Get the 'pressed' button*/
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
......@@ -190,6 +193,7 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
}
}
}
}
return valid;
}
......
......@@ -11,6 +11,7 @@
#if USE_LV_MBOX != 0
#include "lv_mbox.h"
#include "lvgl/lv_obj/lv_group.h"
#include "misc/gfx/anim.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)
btn = lv_obj_get_child(ext->btnh, btn);
}
}
} else if(sign == LV_SIGNAL_ACTIVATE) {
} else if(sign == LV_SIGNAL_FOCUS) {
/*Get the first button*/
if(ext->btnh != NULL) {
lv_obj_t * btn = NULL;
......@@ -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);
}
}
} else if(sign == LV_SIGNAL_DEACTIVATE) {
} else if(sign == LV_SIGNAL_DEFOCUS) {
/*Get the 'pressed' button*/
if(ext->btnh != NULL) {
lv_obj_t * btn = NULL;
......@@ -176,7 +177,10 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
lv_btn_set_state(btn, LV_BTN_STATE_REL);
}
}
} else if(sign == LV_SIGNAL_INCREASE) {
} else if(sign == LV_SIGNAL_CONTROLL) {
lv_mbox_ext_t * ext = lv_obj_get_ext(mbox);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
/*Get the last pressed button*/
if(ext->btnh != NULL) {
lv_obj_t * btn = NULL;
......@@ -193,7 +197,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);
}
}
} else if(sign == LV_SIGNAL_DECREASE) {
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
/*Get the last pressed button*/
if(ext->btnh != NULL) {
lv_obj_t * btn = NULL;
......@@ -210,8 +214,9 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
lv_btn_set_state(btn_prev, LV_BTN_STATE_PR);
}
}
}
} else if(sign == LV_SIGNAL_SELECT) {
} else if(c == LV_GROUP_KEY_ENTER) {
/*Get the 'pressed' button*/
if(ext->btnh != NULL) {
lv_obj_t * btn = NULL;
......@@ -229,6 +234,7 @@ bool lv_mbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param)
}
}
}
}
return valid;
}
......
......@@ -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_group_t * g = lv_obj_get_group(page);
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;
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 */
}
}
......
......@@ -10,6 +10,7 @@
#if USE_LV_SLIDER != 0
#include "lv_slider.h"
#include "lvgl/lv_obj/lv_group.h"
#include "misc/math/math_base.h"
#include "../lv_draw/lv_draw.h"
......@@ -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)
{
/*Create the ancestor slider*/
/*TODO modify it to the ancestor create function */
lv_obj_t * new_slider = lv_bar_create(par, copy);
dm_assert(new_slider);
......@@ -102,7 +102,6 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
bool valid;
/* Include the ancient signal function */
/* TODO update it to the ancestor's signal function*/
valid = lv_bar_signal(slider, sign, param);
/* The object can be deleted so check its validity and then
......@@ -148,14 +147,18 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param)
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
cord_t x = MATH_MIN(w, h);
if(slider->ext_size < x) slider->ext_size = x;
} else if(sign == LV_SIGNAL_INCREASE) {
} else if(sign == LV_SIGNAL_CONTROLL) {
lv_slider_ext_t * ext = lv_obj_get_ext(slider);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
lv_bar_set_value(slider, lv_bar_get_value(slider) + 1);
if(ext->cb != NULL) ext->cb(slider, NULL);
} else if(sign == LV_SIGNAL_DECREASE) {
} 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);
}
}
}
return valid;
}
......
......@@ -11,6 +11,7 @@
#if USE_LV_TA != 0
#include "lv_ta.h"
#include "lvgl/lv_obj/lv_group.h"
#include "misc/gfx/anim.h"
#include "../lv_draw/lv_draw.h"
......@@ -175,11 +176,18 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
(style->hpad + style->hpad));
lv_label_set_text(ext->label, NULL);
}
} else if(sign == LV_SIGNAL_INCREASE) {
lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) + 1);
} else if(sign == LV_SIGNAL_DECREASE) {
uint16_t cur_pos = lv_ta_get_cursor_pos(ta);
if(cur_pos > 0) lv_ta_set_cursor_pos(ta, cur_pos - 1);
} else if (sign == LV_SIGNAL_CONTROLL) {
lv_ta_ext_t * ext = lv_obj_get_ext(ta);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT) {
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;
......
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