rename lv_obj_set/get_style_... to lv_obj_set/get_style_local_...
This commit is contained in:
@@ -1185,7 +1185,7 @@ void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part)
|
||||
* For example: `lv_obj_style_get_border_opa()`
|
||||
* @note for performance reasons it's not checked if the property really has integer type
|
||||
*/
|
||||
void _lv_obj_set_style_int(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_int_t value)
|
||||
void _lv_obj_set_style_local_int(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_int_t value)
|
||||
{
|
||||
lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part);
|
||||
lv_style_list_set_local_int(style_dsc, prop, value);
|
||||
@@ -1207,7 +1207,7 @@ void _lv_obj_set_style_int(lv_obj_t * obj, uint8_t part, lv_style_property_t pro
|
||||
* For example: `lv_obj_style_get_border_opa()`
|
||||
* @note for performance reasons it's not checked if the property really has color type
|
||||
*/
|
||||
void _lv_obj_set_style_color(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_color_t color)
|
||||
void _lv_obj_set_style_local_color(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_color_t color)
|
||||
{
|
||||
lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part);
|
||||
lv_style_list_set_local_color(style_dsc, prop, color);
|
||||
@@ -1229,7 +1229,7 @@ void _lv_obj_set_style_color(lv_obj_t * obj, uint8_t part, lv_style_property_t p
|
||||
* For example: `lv_obj_style_get_border_opa()`
|
||||
* @note for performance reasons it's not checked if the property really has opacity type
|
||||
*/
|
||||
void _lv_obj_set_style_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_opa_t opa)
|
||||
void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_opa_t opa)
|
||||
{
|
||||
lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part);
|
||||
lv_style_list_set_local_opa(style_dsc, prop, opa);
|
||||
@@ -1251,7 +1251,7 @@ void _lv_obj_set_style_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t pro
|
||||
* For example: `lv_obj_style_get_border_opa()`
|
||||
* @note for performance reasons it's not checked if the property really has pointer type
|
||||
*/
|
||||
void _lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, const void * p)
|
||||
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, const void * p)
|
||||
{
|
||||
lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part);
|
||||
lv_style_list_set_local_ptr(style_dsc, prop, p);
|
||||
@@ -1262,17 +1262,22 @@ void _lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t pro
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the local style of a part of an object.
|
||||
* Remove a local style property from a part of an object with a given state.
|
||||
* @param obj pointer to an object
|
||||
* @param part the part of the object which style property should be set.
|
||||
* @param part the part of the object which style property should be removed.
|
||||
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
|
||||
* @return pointer to the local style if exists else `NULL`.
|
||||
* @param prop a style property ORed with a state.
|
||||
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
|
||||
* @note shouldn't be used directly. Use the specific property remove functions instead.
|
||||
* For example: `lv_obj_style_remove_border_opa()`
|
||||
* @return true: the property was found and removed; false: teh property was not found
|
||||
*/
|
||||
lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint8_t part)
|
||||
bool _lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
|
||||
{
|
||||
lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part);
|
||||
return lv_style_list_get_local_style(style_dsc);
|
||||
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_style_t * style = lv_obj_get_local_style(obj, part);
|
||||
if(style) return lv_style_remove_prop(style, prop);
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2417,6 +2422,19 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the local style of a part of an object.
|
||||
* @param obj pointer to an object
|
||||
* @param part the part of the object which style property should be set.
|
||||
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
|
||||
* @return pointer to the local style if exists else `NULL`.
|
||||
*/
|
||||
lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint8_t part)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_style_list_t * style_list = lv_obj_get_style_list(obj, part);
|
||||
return lv_style_list_get_local_style(style_list);
|
||||
}
|
||||
|
||||
/*-----------------
|
||||
* Attribute get
|
||||
@@ -3713,7 +3731,7 @@ static void trans_anim_ready_cb(lv_anim_t * a)
|
||||
|
||||
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v)
|
||||
{
|
||||
lv_obj_set_style_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v);
|
||||
lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -534,7 +534,7 @@ void lv_obj_report_style_mod(lv_style_t * style);
|
||||
* For example: `lv_obj_style_get_border_opa()`
|
||||
* @note for performance reasons it's not checked if the property really has color type
|
||||
*/
|
||||
void _lv_obj_set_style_color(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_color_t color);
|
||||
void _lv_obj_set_style_local_color(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_color_t color);
|
||||
|
||||
/**
|
||||
* Set a local style property of a part of an object in a given state.
|
||||
@@ -548,7 +548,7 @@ void _lv_obj_set_style_color(lv_obj_t * obj, uint8_t type, lv_style_property_t p
|
||||
* For example: `lv_obj_style_get_border_opa()`
|
||||
* @note for performance reasons it's not checked if the property really has integer type
|
||||
*/
|
||||
void _lv_obj_set_style_int(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_style_int_t value);
|
||||
void _lv_obj_set_style_local_int(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_style_int_t value);
|
||||
|
||||
/**
|
||||
* Set a local style property of a part of an object in a given state.
|
||||
@@ -562,7 +562,7 @@ void _lv_obj_set_style_int(lv_obj_t * obj, uint8_t type, lv_style_property_t pro
|
||||
* For example: `lv_obj_style_get_border_opa()`
|
||||
* @note for performance reasons it's not checked if the property really has opacity type
|
||||
*/
|
||||
void _lv_obj_set_style_opa(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_opa_t opa);
|
||||
void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Set a local style property of a part of an object in a given state.
|
||||
@@ -576,16 +576,20 @@ void _lv_obj_set_style_opa(lv_obj_t * obj, uint8_t type, lv_style_property_t pro
|
||||
* For example: `lv_obj_style_get_border_opa()`
|
||||
* @note for performance reasons it's not checked if the property really has pointer type
|
||||
*/
|
||||
void _lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, const void * value);
|
||||
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, const void * value);
|
||||
|
||||
/**
|
||||
* Get the local style of a part of an object.
|
||||
* Remove a local style property from a part of an object with a given state.
|
||||
* @param obj pointer to an object
|
||||
* @param part the part of the object which style property should be set.
|
||||
* @param part the part of the object which style property should be removed.
|
||||
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
|
||||
* @return pointer to the local style if exists else `NULL`.
|
||||
* @param prop a style property ORed with a state.
|
||||
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
|
||||
* @note shouldn't be used directly. Use the specific property remove functions instead.
|
||||
* For example: `lv_obj_style_remove_border_opa()`
|
||||
* @return true: the property was found and removed; false: teh property was not found
|
||||
*/
|
||||
lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint8_t part);
|
||||
bool _lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
|
||||
|
||||
/*-----------------
|
||||
* Attribute set
|
||||
@@ -1029,6 +1033,17 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop
|
||||
*/
|
||||
const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
|
||||
|
||||
|
||||
/**
|
||||
* Get the local style of a part of an object.
|
||||
* @param obj pointer to an object
|
||||
* @param part the part of the object which style property should be set.
|
||||
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
|
||||
* @return pointer to the local style if exists else `NULL`.
|
||||
*/
|
||||
lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint8_t part);
|
||||
|
||||
|
||||
#include "lv_obj_style_dec.h"
|
||||
|
||||
/*-----------------
|
||||
|
||||
@@ -18,53 +18,80 @@ extern "C" {
|
||||
/**
|
||||
* Macro to declare the most important style set/get API functions.
|
||||
*
|
||||
* - Get the value of a style property from an object in the object's current state.
|
||||
* If there is a transition animation in progress calculate the value accordingly.
|
||||
* If the property is not set in the object's style check the parent(s) if the property can be inherited
|
||||
* If still not found return a default value.
|
||||
* For example:
|
||||
* `lv_obj_get_style_border_width(btn1, LV_BTN_PART_MAIN);`
|
||||
* Get the value of a style property from an object in the object's current state
|
||||
* -----------------------------------------------------------------------------
|
||||
* - Get the value of a style property from an object in the object's current state.
|
||||
* - Transition animation is taken into account.
|
||||
* - If the property is not set in the object's styles check the parent(s) if the property can be inherited
|
||||
* - If still not found return a default value.
|
||||
* - For example:
|
||||
* `lv_style_int_t w = lv_obj_get_style_border_width(btn1, LV_BTN_PART_MAIN);`
|
||||
*
|
||||
* - Set a local style property for an object in a given state
|
||||
* For example:
|
||||
* `lv_obj_set_style_border_width(btn1, LV_BTN_PART_MAIN, LV_STATE_PRESSED, 2);`
|
||||
* Set a local style property for an object in a given state
|
||||
* ---------------------------------------------------------
|
||||
* - For example:
|
||||
* `lv_obj_set_style_local_border_width(btn1, LV_BTN_PART_MAIN, LV_STATE_PRESSED, 2);`
|
||||
*
|
||||
* - Get the value from a style in a given state:
|
||||
* For example
|
||||
* `int16_t weight = lv_style_get_border_width(&style1, LV_STATE_PRESSED, &result);`
|
||||
* Get a local style property's value of an object in a given state
|
||||
* ----------------------------------------------------------------
|
||||
* - Return the best matching property in the given state.
|
||||
* - E.g. if `state` parameter is LV_STATE_PRESSED | LV_STATE_CHECKED` but the property defined only in
|
||||
* `LV_STATE_PRESSED` and `LV_STATE_DEFAULT` the best matching state is `LV_STATE_PRESSED`
|
||||
* (because it has higher precedence) and it will be returned.
|
||||
* - If the property is not found even in `LV_STATE_DEFAULT` `-1` is returned.
|
||||
* - For example:
|
||||
* `//Type of result should be lv_style_int_t/lv_opa_t/lv_color_t/const void * according to the type of the property`
|
||||
* `lv_style_int_t result;`
|
||||
* `lv_obj_get_style_local_border_width(btn1, LV_BTN_PART_MAIN, LV_STATE_PRESSED, &result);`
|
||||
* `if(weight > 0) ...the property is found and loaded into result...`
|
||||
*
|
||||
* - Set a value in a style in a given state
|
||||
* For example
|
||||
* `lv_style_set_border_width(&style1, LV_STATE_PRESSED, 2);`
|
||||
* Get the value from a style in a given state
|
||||
* -------------------------------------------
|
||||
* - The same rules applies to the return value then for "lv_obj_get_style_local_...()" above
|
||||
* - For example
|
||||
* `int16_t weight = lv_style_get_border_width(&style1, LV_STATE_PRESSED, &result);`
|
||||
* `if(weight > 0) ...the property is found and loaded into result...`
|
||||
|
||||
* Set a value in a style in a given state
|
||||
* ---------------------------------------
|
||||
* - For example
|
||||
* `lv_style_set_border_width(&style1, LV_STATE_PRESSED, 2);`
|
||||
*/
|
||||
|
||||
|
||||
#define _LV_OBJ_STYLE_DECLARE_GET_scalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
|
||||
{ \
|
||||
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
|
||||
#define _LV_OBJ_STYLE_DECLARE_GET_scalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
|
||||
{ \
|
||||
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
|
||||
}
|
||||
|
||||
#define _LV_OBJ_STYLE_DECLARE_GET_nonscalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
|
||||
{ \
|
||||
return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
|
||||
#define _LV_OBJ_STYLE_DECLARE_GET_nonscalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
|
||||
{ \
|
||||
return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
|
||||
}
|
||||
|
||||
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \
|
||||
_LV_OBJ_STYLE_DECLARE_GET_##scalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline void lv_obj_set_style_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
|
||||
{ \
|
||||
_lv_obj_set_style##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
|
||||
} \
|
||||
static inline int16_t lv_style_get_##func_name (lv_style_t * style, lv_state_t state, void * res) \
|
||||
{ \
|
||||
return _lv_style_get##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
|
||||
} \
|
||||
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
|
||||
{ \
|
||||
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
|
||||
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \
|
||||
_LV_OBJ_STYLE_DECLARE_GET_##scalar(prop_name, func_name, value_type, style_type) \
|
||||
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
|
||||
{ \
|
||||
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
|
||||
} \
|
||||
static inline void lv_obj_get_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, void * res) \
|
||||
{ \
|
||||
_lv_style_get##style_type (lv_obj_get_local_style(obj, part), LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
|
||||
} \
|
||||
static inline void lv_obj_remove_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state) \
|
||||
{ \
|
||||
_lv_obj_remove_style_local_prop(obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS)); \
|
||||
} \
|
||||
static inline int16_t lv_style_get_##func_name (lv_style_t * style, lv_state_t state, void * res) \
|
||||
{ \
|
||||
return _lv_style_get##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
|
||||
} \
|
||||
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
|
||||
{ \
|
||||
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
|
||||
}
|
||||
|
||||
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t,_int, scalar)
|
||||
|
||||
@@ -253,10 +253,6 @@ static void basic_init(void)
|
||||
|
||||
lv_style_init(&pad);
|
||||
lv_style_set_pad_inner(&pad, LV_STATE_DEFAULT, LV_DPI / 10);
|
||||
lv_style_set_pad_left(&pad, LV_STATE_DEFAULT, LV_DPI / 10);
|
||||
lv_style_set_pad_right(&pad, LV_STATE_DEFAULT, LV_DPI / 10);
|
||||
lv_style_set_pad_top(&pad, LV_STATE_DEFAULT, LV_DPI / 10);
|
||||
lv_style_set_pad_bottom(&pad, LV_STATE_DEFAULT, LV_DPI / 10);
|
||||
}
|
||||
|
||||
static void cont_init(void)
|
||||
|
||||
Reference in New Issue
Block a user