1 /**
2  * @file lv_flex.h
3  *
4  */
5 
6 #ifndef LV_FLEX_H
7 #define LV_FLEX_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../../lv_conf_internal.h"
17 #include "../../misc/lv_area.h"
18 
19 #if LV_USE_FLEX
20 
21 /*********************
22  *      DEFINES
23  *********************/
24 
25 #define LV_FLEX_COLUMN        (1 << 0)
26 #define LV_FLEX_WRAP       (1 << 2)
27 #define LV_FLEX_REVERSE    (1 << 3)
28 
29 /**********************
30  *      TYPEDEFS
31  **********************/
32 
33 /*Can't include lv_obj.h because it includes this header file*/
34 
35 typedef enum {
36     LV_FLEX_ALIGN_START,
37     LV_FLEX_ALIGN_END,
38     LV_FLEX_ALIGN_CENTER,
39     LV_FLEX_ALIGN_SPACE_EVENLY,
40     LV_FLEX_ALIGN_SPACE_AROUND,
41     LV_FLEX_ALIGN_SPACE_BETWEEN,
42 } lv_flex_align_t;
43 
44 typedef enum {
45     LV_FLEX_FLOW_ROW                 = 0x00,
46     LV_FLEX_FLOW_COLUMN              = LV_FLEX_COLUMN,
47     LV_FLEX_FLOW_ROW_WRAP            = LV_FLEX_FLOW_ROW | LV_FLEX_WRAP,
48     LV_FLEX_FLOW_ROW_REVERSE         = LV_FLEX_FLOW_ROW | LV_FLEX_REVERSE,
49     LV_FLEX_FLOW_ROW_WRAP_REVERSE    = LV_FLEX_FLOW_ROW | LV_FLEX_WRAP | LV_FLEX_REVERSE,
50     LV_FLEX_FLOW_COLUMN_WRAP         = LV_FLEX_FLOW_COLUMN | LV_FLEX_WRAP,
51     LV_FLEX_FLOW_COLUMN_REVERSE      = LV_FLEX_FLOW_COLUMN | LV_FLEX_REVERSE,
52     LV_FLEX_FLOW_COLUMN_WRAP_REVERSE = LV_FLEX_FLOW_COLUMN | LV_FLEX_WRAP | LV_FLEX_REVERSE,
53 } lv_flex_flow_t;
54 
55 /**********************
56  * GLOBAL VARIABLES
57  **********************/
58 
59 /**********************
60  * GLOBAL PROTOTYPES
61  **********************/
62 
63 /**
64  * Initialize a flex layout to default values
65  */
66 void lv_flex_init(void);
67 
68 /**
69  * Set how the item should flow
70  * @param obj pointer to an object. The parent must have flex layout else nothing will happen.
71  * @param flow an element of `lv_flex_flow_t`.
72  */
73 void lv_obj_set_flex_flow(lv_obj_t * obj, lv_flex_flow_t flow);
74 
75 /**
76  * Set how to place (where to align) the items and tracks
77  * @param obj pointer to an object. The parent must have flex layout else nothing will happen.
78  * @param main_place where to place the items on main axis (in their track). Any value of `lv_flex_align_t`.
79  * @param cross_place where to place the item in their track on the cross axis. `LV_FLEX_ALIGN_START/END/CENTER`
80  * @param track_cross_place where to place the tracks in the cross direction. Any value of `lv_flex_align_t`.
81  */
82 void lv_obj_set_flex_align(lv_obj_t * obj, lv_flex_align_t main_place, lv_flex_align_t cross_place,
83                            lv_flex_align_t track_cross_place);
84 
85 /**
86  * Sets the width or height (on main axis) to grow the object in order fill the free space
87  * @param obj pointer to an object. The parent must have flex layout else nothing will happen.
88  * @param grow a value to set how much free space to take proportionally to other growing items.
89  */
90 void lv_obj_set_flex_grow(lv_obj_t * obj, uint8_t grow);
91 
92 /**********************
93  *      MACROS
94  **********************/
95 
96 #endif  /*LV_USE_FLEX*/
97 
98 #ifdef __cplusplus
99 } /*extern "C"*/
100 #endif
101 
102 #endif /*LV_FLEX_H*/
103