How to get value of style (LVGL V7.0.2)

Description

Hello, i use lv_obj_set_style_local_<property_name>(obj, <part>, <state>, <value>); for set value of style i work but how i got value of style ? i found lv_obj_get_style_<property_name>(obj, <part>) but it return current state, I want to select state for get.

What MCU/Processor/Board and compiler are you using?

IOXGD4 (K210 + TFT LCD)

What do you want to achieve?

Get value of style with part and state

What have you tried so far?

Read docs i found lv_obj_get_style_<property_name>(obj, <part>) but it return current state, I want to select state for get.

Code to reproduce

lv_color_t color = lv_obj_get_style_bg_color(btn, LV_BTN_PART_MAIN); // These functions uses the object's current state
lv_color_t color = lv_obj_get_style_bg_color(btn, LV_BTN_PART_MAIN, LV_STATE_DEFAULT); // I want this.
lv_color_t color = lv_obj_get_style_bg_color(btn, LV_BTN_PART_MAIN, LV_STATE_PRESSED); // I want this.

Screenshot and/or video

No

Hi,

There is no API for it because the current value depends on too many things (state, transition, parent if the property is inherited) and therefore it’s complicated to use on the user’s level.

It’s quite hacky but you can do this:

  lv_state_t s = btn->state;
  btn->state = LV_STATE_PRESSED;
  list->ignore_trans = 1;
  color = lv_obj_get_style_bg_color(btn, LV_BTN_PART_MAIN);
  btn->state = s;
  list->ignore_trans = 0;

Why do you need to get the current value? Maybe there is a better way to do it.