new_style: implement generic style set/get functions
This commit is contained in:
@@ -30,6 +30,7 @@ extern "C" {
|
||||
#include "../lv_misc/lv_log.h"
|
||||
#include "../lv_misc/lv_bidi.h"
|
||||
#include "../lv_hal/lv_hal.h"
|
||||
#include "../lv_draw/lv_draw_rect.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -46,9 +47,9 @@ extern "C" {
|
||||
|
||||
#define LV_MAX_ANCESTOR_NUM 8
|
||||
|
||||
#define LV_EXT_CLICK_AREA_OFF 0
|
||||
#define LV_EXT_CLICK_AREA_TINY 1
|
||||
#define LV_EXT_CLICK_AREA_FULL 2
|
||||
#define LV_EXT_CLICK_AREA_OFF 0
|
||||
#define LV_EXT_CLICK_AREA_TINY 1
|
||||
#define LV_EXT_CLICK_AREA_FULL 2
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -126,6 +127,7 @@ enum {
|
||||
LV_SIGNAL_BASE_DIR_CHG, /**<The base dir has changed*/
|
||||
LV_SIGNAL_REFR_EXT_DRAW_PAD, /**< Object's extra padding has changed */
|
||||
LV_SIGNAL_GET_TYPE, /**< LittlevGL needs to retrieve the object's type */
|
||||
LV_SIGNAL_GET_STYLE, /**<Get the style of an object*/
|
||||
|
||||
/*Input device related*/
|
||||
LV_SIGNAL_PRESSED, /**< The object has been pressed*/
|
||||
@@ -187,11 +189,6 @@ typedef struct
|
||||
} lv_reailgn_t;
|
||||
#endif
|
||||
|
||||
typedef struct _lv_obj_style_chian_t {
|
||||
lv_style_t * style;
|
||||
struct _lv_obj_style_chian_t * next;
|
||||
}lv_obj_style_chian_t;
|
||||
|
||||
typedef struct _lv_obj_t
|
||||
{
|
||||
struct _lv_obj_t * par; /**< Pointer to the parent object*/
|
||||
@@ -204,8 +201,7 @@ typedef struct _lv_obj_t
|
||||
lv_design_cb_t design_cb; /**< Object type specific design function*/
|
||||
|
||||
void * ext_attr; /**< Object type specific extended data*/
|
||||
lv_style_t style_local;
|
||||
lv_obj_style_chian_t style_chain;
|
||||
lv_style_dsc_t style_dsc;
|
||||
|
||||
#if LV_USE_GROUP != 0
|
||||
void * group_p; /**< Pointer to the group of the object*/
|
||||
@@ -248,6 +244,12 @@ typedef struct _lv_obj_t
|
||||
|
||||
} lv_obj_t;
|
||||
|
||||
enum {
|
||||
LV_OBJ_STYLE_MAIN
|
||||
};
|
||||
|
||||
typedef uint8_t lv_obj_style_t;
|
||||
|
||||
/*Protect some attributes (max. 8 bit)*/
|
||||
enum {
|
||||
LV_PROTECT_NONE = 0x00,
|
||||
@@ -454,11 +456,12 @@ void lv_obj_set_style_value(lv_obj_t * obj, lv_style_property_t prop, lv_style_v
|
||||
|
||||
void lv_obj_set_style_opa(lv_obj_t * obj, lv_style_property_t prop, lv_opa_t opa);
|
||||
|
||||
void lv_obj_add_style_class(lv_obj_t * obj, uint8_t type, lv_style_t * style);
|
||||
/**
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refresh_style(lv_obj_t * obj);
|
||||
void lv_obj_refresh_style(lv_obj_t * obj, uint8_t type);
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
@@ -604,12 +607,14 @@ const void * lv_event_get_data(void);
|
||||
*/
|
||||
void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t signal_cb);
|
||||
|
||||
|
||||
/**
|
||||
* Send an event to the object
|
||||
* @param obj pointer to an object
|
||||
* @param event the type of the event from `lv_event_t`.
|
||||
* @return LV_RES_OK or LV_RES_INV
|
||||
*/
|
||||
void lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param);
|
||||
lv_res_t lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param);
|
||||
|
||||
/**
|
||||
* Set a new design function for an object
|
||||
@@ -802,11 +807,13 @@ lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj);
|
||||
* Appearance get
|
||||
*---------------*/
|
||||
|
||||
lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, lv_style_property_t prop);
|
||||
lv_style_dsc_t * lv_obj_get_style(const lv_obj_t * obj, uint8_t type);
|
||||
|
||||
lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, lv_style_property_t prop);
|
||||
lv_style_value_t lv_obj_get_style_value(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop);
|
||||
|
||||
lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, lv_style_property_t prop);
|
||||
lv_color_t lv_obj_get_style_color(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop);
|
||||
|
||||
lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t type, lv_style_property_t prop);
|
||||
|
||||
///**
|
||||
// * Get the style pointer of an object (if NULL get style of the parent)
|
||||
@@ -1001,6 +1008,18 @@ bool lv_obj_is_focused(const lv_obj_t * obj);
|
||||
*/
|
||||
lv_res_t lv_obj_handle_get_type_signal(lv_obj_type_t * buf, const char * name);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a rectangle descriptor from an object's styles
|
||||
* @param obj pointer to an object
|
||||
* @param type type of style. E.g. `LV_OBJ_STYLE_MAIN`, `LV_BTN_STYLE_REL` or `LV_PAGE_STYLE_SCRL`
|
||||
* @param draw_dsc the descriptor the initialize
|
||||
* @note Only the relevant fields will be set.
|
||||
* E.g. if `border width == 0` the other border properties won't be evaluated.
|
||||
*/
|
||||
void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t type, lv_draw_rect_dsc_t * draw_dsc);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
Reference in New Issue
Block a user