mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
feat(style): add lv_style_get_prop_inlined and use it in the core main object style getter
This commit is contained in:
parent
347680a3c0
commit
bdef86faf2
@ -979,7 +979,7 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
|
|||||||
if(obj_style->is_trans) continue;
|
if(obj_style->is_trans) continue;
|
||||||
|
|
||||||
lv_style_value_t v;
|
lv_style_value_t v;
|
||||||
if(lv_style_get_prop(obj_style->style, LV_STYLE_TRANSITION, &v) == false) continue;
|
if(lv_style_get_prop_inlined(obj_style->style, LV_STYLE_TRANSITION, &v) == false) continue;
|
||||||
const lv_style_transition_dsc_t * tr = v.ptr;
|
const lv_style_transition_dsc_t * tr = v.ptr;
|
||||||
|
|
||||||
/*Add the props t the set is not added yet or added but with smaller weight*/
|
/*Add the props t the set is not added yet or added but with smaller weight*/
|
||||||
|
@ -184,26 +184,7 @@ void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_
|
|||||||
|
|
||||||
bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value)
|
bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value)
|
||||||
{
|
{
|
||||||
if(style->prop_cnt == 0) return false;
|
return lv_style_get_prop_inlined(style, prop, value);
|
||||||
|
|
||||||
if(style->allocated) {
|
|
||||||
uint8_t * tmp = style->v_p.values_and_props + style->prop_cnt * sizeof(lv_style_value_t);
|
|
||||||
uint16_t * props = (uint16_t *) tmp;
|
|
||||||
uint32_t i;
|
|
||||||
for(i = 0; i < style->prop_cnt; i++) {
|
|
||||||
if(props[i] == prop) {
|
|
||||||
lv_style_value_t * values = (lv_style_value_t *)style->v_p.values_and_props;
|
|
||||||
*value = values[i];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(style->prop1 == prop) {
|
|
||||||
*value = style->v_p.value1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay)
|
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay)
|
||||||
|
@ -326,6 +326,42 @@ void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_
|
|||||||
* @note For performance reasons there are no sanity check on `style`
|
* @note For performance reasons there are no sanity check on `style`
|
||||||
*/
|
*/
|
||||||
bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value);
|
bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a property
|
||||||
|
* @param style: pointer to a style
|
||||||
|
* @param prop: the ID of a property
|
||||||
|
* @param value: pointer to a `lv_style_value_t` variable to store the value
|
||||||
|
* @return false: the property wsn't found in the style (`value` is unchanged)
|
||||||
|
* true: the property was fond, and `value` is set accordingly
|
||||||
|
* @note For performance reasons there are no sanity check on `style`
|
||||||
|
* @note This function is the same as ::lv_style_get_prop but inlined. Use it only on performance critical places
|
||||||
|
*/
|
||||||
|
static inline bool lv_style_get_prop_inlined(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value)
|
||||||
|
{
|
||||||
|
if(style->prop_cnt == 0) return false;
|
||||||
|
|
||||||
|
if(style->allocated) {
|
||||||
|
uint8_t * tmp = style->v_p.values_and_props + style->prop_cnt * sizeof(lv_style_value_t);
|
||||||
|
uint16_t * props = (uint16_t *) tmp;
|
||||||
|
uint32_t i;
|
||||||
|
for(i = 0; i < style->prop_cnt; i++) {
|
||||||
|
if(props[i] == prop) {
|
||||||
|
lv_style_value_t * values = (lv_style_value_t *)style->v_p.values_and_props;
|
||||||
|
*value = values[i];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(style->prop1 == prop) {
|
||||||
|
*value = style->v_p.value1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a transition descriptor.
|
* Initialize a transition descriptor.
|
||||||
* @param tr: pointer to a transition descriptor to initialize
|
* @param tr: pointer to a transition descriptor to initialize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user