acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_obj_style.h (8688B)

      1 /**
      2  * @file lv_obj_style.h
      3  *
      4  */
      5 
      6 #ifndef LV_OBJ_STYLE_H
      7 #define LV_OBJ_STYLE_H
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 /*********************
     14  *      INCLUDES
     15  *********************/
     16 #include <stdint.h>
     17 #include <stdbool.h>
     18 #include "../misc/lv_bidi.h"
     19 
     20 /*********************
     21  *      DEFINES
     22  *********************/
     23 
     24 /**********************
     25  *      TYPEDEFS
     26  **********************/
     27 /*Can't include lv_obj.h because it includes this header file*/
     28 struct _lv_obj_t;
     29 
     30 typedef enum {
     31     _LV_STYLE_STATE_CMP_SAME,           /*The style properties in the 2 states are identical*/
     32     _LV_STYLE_STATE_CMP_DIFF_REDRAW,    /*The differences can be shown with a simple redraw*/
     33     _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD,  /*The differences can be shown with a simple redraw*/
     34     _LV_STYLE_STATE_CMP_DIFF_LAYOUT,    /*The differences can be shown with a simple redraw*/
     35 } _lv_style_state_cmp_t;
     36 
     37 typedef uint32_t lv_style_selector_t;
     38 
     39 typedef struct {
     40     lv_style_t * style;
     41     uint32_t selector : 24;
     42     uint32_t is_local : 1;
     43     uint32_t is_trans : 1;
     44 } _lv_obj_style_t;
     45 
     46 typedef struct {
     47     uint16_t time;
     48     uint16_t delay;
     49     lv_style_selector_t selector;
     50     lv_style_prop_t prop;
     51     lv_anim_path_cb_t path_cb;
     52 #if LV_USE_USER_DATA
     53     void * user_data;
     54 #endif
     55 } _lv_obj_style_transition_dsc_t;
     56 
     57 /**********************
     58  * GLOBAL PROTOTYPES
     59  **********************/
     60 
     61 /**
     62  * Initialize the object related style manager module.
     63  * Called by LVGL in `lv_init()`
     64  */
     65 void _lv_obj_style_init(void);
     66 
     67 /**
     68  * Add a style to an object.
     69  * @param obj       pointer to an object
     70  * @param style     pointer to a style to add
     71  * @param selector  OR-ed value of parts and state to which the style should be added
     72  * @example         lv_obj_add_style(btn, &style_btn, 0); //Default button style
     73  * @example         lv_obj_add_style(btn, &btn_red, LV_STATE_PRESSED); //Overwrite only some colors to red when pressed
     74  */
     75 void lv_obj_add_style(struct _lv_obj_t * obj, lv_style_t * style, lv_style_selector_t selector);
     76 
     77 /**
     78  * Add a style to an object.
     79  * @param obj       pointer to an object
     80  * @param style     pointer to a style to remove. Can be NULL to check only the selector
     81  * @param selector  OR-ed values of states and a part to remove only styles with matching selectors. LV_STATE_ANY and LV_PART_ANY can be used
     82  * @example lv_obj_remove_style(obj, &style, LV_PART_ANY | LV_STATE_ANY); //Remove a specific style
     83  * @example lv_obj_remove_style(obj, NULL, LV_PART_MAIN | LV_STATE_ANY); //Remove all styles from the main part
     84  * @example lv_obj_remove_style(obj, NULL, LV_PART_ANY | LV_STATE_ANY); //Remove all styles
     85  */
     86 void lv_obj_remove_style(struct _lv_obj_t * obj, lv_style_t * style, lv_style_selector_t selector);
     87 
     88 /**
     89  * Remove all styles from an object
     90  * @param obj       pointer to an object
     91  */
     92 static inline void lv_obj_remove_style_all(struct _lv_obj_t * obj)
     93 {
     94     lv_obj_remove_style(obj, NULL, LV_PART_ANY | LV_STATE_ANY);
     95 }
     96 
     97 /**
     98  * Notify all object if a style is modified
     99  * @param style     pointer to a style. Only the objects with this style will be notified
    100  *                  (NULL to notify all objects)
    101  */
    102 void lv_obj_report_style_change(lv_style_t * style);
    103 
    104 /**
    105  * Notify an object and its children about its style is modified.
    106  * @param obj       pointer to an object
    107  * @param part      the part whose style was changed. E.g. `LV_PART_ANY`, `LV_PART_MAIN`
    108  * @param prop      `LV_STYLE_PROP_ANY` or an `LV_STYLE_...` property.
    109  *                  It is used to optimize what needs to be refreshed.
    110  *                  `LV_STYLE_PROP_INV` to perform only a style cache update
    111  */
    112 void lv_obj_refresh_style(struct _lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop);
    113 
    114 /**
    115  * Enable or disable automatic style refreshing when a new style is added/removed to/from an object
    116  * or any other style change happens.
    117  * @param en        true: enable refreshing; false: disable refreshing
    118  */
    119 void lv_obj_enable_style_refresh(bool en);
    120 
    121 /**
    122  * Get the value of a style property. The current state of the object will be considered.
    123  * Inherited properties will be inherited.
    124  * If a property is not set a default value will be returned.
    125  * @param obj       pointer to an object
    126  * @param part      a part from which the property should be get
    127  * @param prop      the property to get
    128  * @return          the value of the property.
    129  *                  Should be read from the correct field of the `lv_style_value_t` according to the type of the property.
    130  */
    131 lv_style_value_t lv_obj_get_style_prop(const struct _lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop);
    132 
    133 /**
    134  * Set local style property on an object's part and state.
    135  * @param obj       pointer to an object
    136  * @param prop      the property
    137  * @param value     value of the property. The correct element should be set according to the type of the property
    138  * @param selector  OR-ed value of parts and state for which the style should be set
    139  */
    140 void lv_obj_set_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value,
    141                                  lv_style_selector_t selector);
    142 
    143 lv_res_t lv_obj_get_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value,
    144                                      lv_style_selector_t selector);
    145 
    146 /**
    147  * Remove a local style property from a part of an object with a given state.
    148  * @param obj       pointer to an object
    149  * @param prop      a style property to remove.
    150  * @param selector  OR-ed value of parts and state for which the style should be removed
    151  * @return true     the property was found and removed; false: the property was not found
    152  */
    153 bool lv_obj_remove_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_selector_t selector);
    154 
    155 /**
    156  * Used internally for color filtering
    157  */
    158 lv_style_value_t _lv_obj_style_apply_color_filter(const struct _lv_obj_t * obj, uint32_t part, lv_style_value_t v);
    159 
    160 /**
    161  * Used internally to create a style transition
    162  * @param obj
    163  * @param part
    164  * @param prev_state
    165  * @param new_state
    166  * @param tr
    167  */
    168 void _lv_obj_style_create_transition(struct _lv_obj_t * obj, lv_part_t part, lv_state_t prev_state,
    169                                      lv_state_t new_state, const _lv_obj_style_transition_dsc_t * tr);
    170 
    171 /**
    172  * Used internally to compare the appearance of an object in 2 states
    173  * @param obj
    174  * @param state1
    175  * @param state2
    176  * @return
    177  */
    178 _lv_style_state_cmp_t _lv_obj_style_state_compare(struct _lv_obj_t * obj, lv_state_t state1, lv_state_t state2);
    179 
    180 /**
    181  * Fade in an an object and all its children.
    182  * @param obj       the object to fade in
    183  * @param time      time of fade
    184  * @param delay     delay to start the animation
    185  */
    186 void lv_obj_fade_in(struct _lv_obj_t * obj, uint32_t time, uint32_t delay);
    187 
    188 /**
    189  * Fade out an an object and all its children.
    190  * @param obj       the object to fade out
    191  * @param time      time of fade
    192  * @param delay     delay to start the animation
    193  */
    194 void lv_obj_fade_out(struct _lv_obj_t * obj, uint32_t time, uint32_t delay);
    195 
    196 lv_state_t lv_obj_style_get_selector_state(lv_style_selector_t selector);
    197 
    198 lv_part_t lv_obj_style_get_selector_part(lv_style_selector_t selector);
    199 
    200 #include "lv_obj_style_gen.h"
    201 
    202 static inline void lv_obj_set_style_pad_all(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
    203 {
    204     lv_obj_set_style_pad_left(obj, value, selector);
    205     lv_obj_set_style_pad_right(obj, value, selector);
    206     lv_obj_set_style_pad_top(obj, value, selector);
    207     lv_obj_set_style_pad_bottom(obj, value, selector);
    208 }
    209 
    210 static inline void lv_obj_set_style_pad_hor(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
    211 {
    212     lv_obj_set_style_pad_left(obj, value, selector);
    213     lv_obj_set_style_pad_right(obj, value, selector);
    214 }
    215 
    216 static inline void lv_obj_set_style_pad_ver(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
    217 {
    218     lv_obj_set_style_pad_top(obj, value, selector);
    219     lv_obj_set_style_pad_bottom(obj, value, selector);
    220 }
    221 
    222 static inline void lv_obj_set_style_pad_gap(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
    223 {
    224     lv_obj_set_style_pad_row(obj, value, selector);
    225     lv_obj_set_style_pad_column(obj, value, selector);
    226 }
    227 
    228 static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
    229 {
    230     lv_obj_set_style_width(obj, value, selector);
    231     lv_obj_set_style_height(obj, value, selector);
    232 }
    233 
    234 lv_text_align_t lv_obj_calculate_style_text_align(const struct _lv_obj_t * obj, lv_part_t part, const char * txt);
    235 
    236 
    237 /**********************
    238  *      MACROS
    239  **********************/
    240 
    241 #ifdef __cplusplus
    242 } /*extern "C"*/
    243 #endif
    244 
    245 #endif /*LV_OBJ_STYLE_H*/