2017-07-19 15:19:10 +02:00
|
|
|
/**
|
|
|
|
* @file lv_group.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_GROUP_H
|
|
|
|
#define LV_GROUP_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2017-11-26 23:57:39 +01:00
|
|
|
#include "../../lv_conf.h"
|
2017-07-19 15:19:10 +02:00
|
|
|
#include "lv_obj.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
2017-07-25 09:02:21 +02:00
|
|
|
/*Predefined keys to control the focused object via lv_group_send(group, c)*/
|
2017-11-30 11:35:33 +01:00
|
|
|
/*For compatibility in signal function define the keys regardless to LV_GROUP*/
|
2017-07-25 09:02:21 +02:00
|
|
|
#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*/
|
2018-02-24 14:39:15 +01:00
|
|
|
#define LV_GROUP_KEY_ESC 27 /*0x1B*/
|
2017-07-25 09:02:21 +02:00
|
|
|
#define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/
|
2017-11-18 00:18:19 +01:00
|
|
|
#define LV_GROUP_KEY_NEXT 9 /*0x09, '\t'*/
|
|
|
|
#define LV_GROUP_KEY_PREV 11 /*0x0B, '*/
|
2017-07-19 15:19:10 +02:00
|
|
|
|
2018-02-24 14:39:15 +01:00
|
|
|
#define LV_GROUP_KEY_ENTER_LONG 14 /*0x0E, Sent by the library if ENTER is long pressed*/
|
|
|
|
|
2017-12-07 19:22:23 +01:00
|
|
|
#if USE_LV_GROUP != 0
|
2017-07-19 15:19:10 +02:00
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
2018-02-24 11:55:39 +01:00
|
|
|
struct _lv_group_t;
|
|
|
|
|
|
|
|
typedef void (*lv_group_style_mod_func_t)(lv_style_t *);
|
|
|
|
typedef void (*lv_group_focus_cb_t)(struct _lv_group_t *);
|
|
|
|
|
2017-11-19 19:28:45 +01:00
|
|
|
typedef struct _lv_group_t
|
2017-07-19 15:19:10 +02:00
|
|
|
{
|
2018-02-24 11:55:39 +01:00
|
|
|
lv_ll_t obj_ll; /*Linked list to store the objects in the group */
|
|
|
|
lv_obj_t ** obj_focus; /*The object in focus*/
|
2018-06-17 16:43:28 +02:00
|
|
|
lv_group_style_mod_func_t style_mod; /*A function which modifies the style of the focused object*/
|
2018-02-24 11:55:39 +01:00
|
|
|
lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/
|
|
|
|
lv_style_t style_tmp; /*Stores the modified style of the focused object */
|
|
|
|
uint8_t frozen:1; /*1: can't focus to new object*/
|
2017-07-19 15:19:10 +02:00
|
|
|
}lv_group_t;
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
2017-11-19 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new object group
|
|
|
|
* @return pointer to the new object group
|
|
|
|
*/
|
2017-07-19 15:19:10 +02:00
|
|
|
lv_group_t * lv_group_create(void);
|
2017-11-19 20:45:40 +01:00
|
|
|
|
2018-04-04 10:24:53 -07:00
|
|
|
/**
|
|
|
|
* Delete a group object
|
|
|
|
* @param group pointer to a group
|
|
|
|
*/
|
2018-04-09 12:39:58 +02:00
|
|
|
void lv_group_del(lv_group_t * group);
|
2018-04-04 10:24:53 -07:00
|
|
|
|
2017-11-19 20:45:40 +01:00
|
|
|
/**
|
|
|
|
* Add an object to a group
|
|
|
|
* @param group pointer to a group
|
|
|
|
* @param obj pointer to an object to add
|
|
|
|
*/
|
2017-07-25 09:02:21 +02:00
|
|
|
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj);
|
2017-11-19 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an object from its group
|
|
|
|
* @param obj pointer to an object to remove
|
|
|
|
*/
|
|
|
|
void lv_group_remove_obj(lv_obj_t * obj);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Focus on an object (defocus the current)
|
|
|
|
* @param obj pointer to an object to focus on
|
|
|
|
*/
|
2017-07-25 09:02:21 +02:00
|
|
|
void lv_group_focus_obj(lv_obj_t * obj);
|
2017-11-19 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Focus the next object in a group (defocus the current)
|
|
|
|
* @param group pointer to a group
|
|
|
|
*/
|
2017-07-25 09:02:21 +02:00
|
|
|
void lv_group_focus_next(lv_group_t * group);
|
2017-11-19 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Focus the previous object in a group (defocus the current)
|
|
|
|
* @param group pointer to a group
|
|
|
|
*/
|
2017-07-25 09:02:21 +02:00
|
|
|
void lv_group_focus_prev(lv_group_t * group);
|
2017-11-19 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Do not let to change the focus from the current object
|
|
|
|
* @param group pointer to a group
|
|
|
|
* @param en true: freeze, false: release freezing (normal mode)
|
|
|
|
*/
|
2017-07-27 12:07:16 +02:00
|
|
|
void lv_group_focus_freeze(lv_group_t * group, bool en);
|
2017-11-19 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a control character to the focuses object of a group
|
|
|
|
* @param group pointer to a group
|
|
|
|
* @param c a character (use LV_GROUP_KEY_.. to navigate)
|
|
|
|
*/
|
|
|
|
void lv_group_send_data(lv_group_t * group, uint32_t c);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a function for a group which will modify the object's style if it is in focus
|
|
|
|
* @param group pointer to a group
|
2018-02-24 11:55:39 +01:00
|
|
|
* @param style_mod_func the style modifier function pointer
|
|
|
|
*/
|
|
|
|
void lv_group_set_style_mod_cb(lv_group_t * group,lv_group_style_mod_func_t style_mod_func);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a function for a group which will be called when a new object is focused
|
|
|
|
* @param group pointer to a group
|
|
|
|
* @param focus_cb the call back function or NULL if unused
|
2017-11-19 20:45:40 +01:00
|
|
|
*/
|
2018-02-24 11:55:39 +01:00
|
|
|
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb);
|
2017-11-19 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2017-07-25 09:02:21 +02:00
|
|
|
lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style);
|
2017-11-19 20:45:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the focused object or NULL if there isn't one
|
|
|
|
* @param group pointer to a group
|
|
|
|
* @return pointer to the focused object
|
|
|
|
*/
|
2017-07-25 09:02:21 +02:00
|
|
|
lv_obj_t * lv_group_get_focused(lv_group_t * group);
|
2017-07-19 15:19:10 +02:00
|
|
|
|
2018-02-24 11:55:39 +01:00
|
|
|
/**
|
|
|
|
* Get a the style modifier function of a group
|
|
|
|
* @param group pointer to a group
|
|
|
|
* @return pointer to the style modifier function
|
|
|
|
*/
|
|
|
|
lv_group_style_mod_func_t lv_group_get_style_mod_cb(lv_group_t * group);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the focus callback function of a group
|
|
|
|
* @param group pointer to a group
|
|
|
|
* @return the call back function or NULL if not set
|
|
|
|
*/
|
|
|
|
lv_group_focus_cb_t lv_group_get_focus_cb(lv_group_t * group);
|
|
|
|
|
2017-07-19 15:19:10 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2017-12-07 19:22:23 +01:00
|
|
|
#endif /*USE_LV_GROUP != 0*/
|
2017-07-19 15:19:10 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /*LV_GROUP_H*/
|