1 /**
2  * @file lv_line.h
3  *
4  */
5 
6 #ifndef LV_LINE_H
7 #define LV_LINE_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #ifdef LV_CONF_INCLUDE_SIMPLE
17 #include "lv_conf.h"
18 #else
19 #include "../../lv_conf.h"
20 #endif
21 
22 #if LV_USE_LINE != 0
23 
24 #include "../lv_core/lv_obj.h"
25 
26 /*********************
27  *      DEFINES
28  *********************/
29 
30 /**********************
31  *      TYPEDEFS
32  **********************/
33 
34 /*Data of line*/
35 typedef struct
36 {
37     /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/
38     const lv_point_t * point_array;                    /*Pointer to an array with the points of the line*/
39     uint16_t point_num;                                /*Number of points in 'point_array' */
40     uint8_t auto_size : 1;                             /*1: set obj. width to x max and obj. height to y max */
41     uint8_t y_inv : 1;                                 /*1: y == 0 will be on the bottom*/
42 } lv_line_ext_t;
43 
44 /*Styles*/
45 enum {
46     LV_LINE_STYLE_MAIN,
47 };
48 typedef uint8_t lv_line_style_t;
49 
50 /**********************
51  * GLOBAL PROTOTYPES
52  **********************/
53 
54 /**
55  * Create a line objects
56  * @param par pointer to an object, it will be the parent of the new line
57  * @return pointer to the created line
58  */
59 lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy);
60 
61 /*=====================
62  * Setter functions
63  *====================*/
64 
65 /**
66  * Set an array of points. The line object will connect these points.
67  * @param line pointer to a line object
68  * @param point_a an array of points. Only the address is saved,
69  * so the array can NOT be a local variable which will be destroyed
70  * @param point_num number of points in 'point_a'
71  */
72 void lv_line_set_points(lv_obj_t * line, const lv_point_t point_a[], uint16_t point_num);
73 
74 /**
75  * Enable (or disable) the auto-size option. The size of the object will fit to its points.
76  * (set width to x max and height to y max)
77  * @param line pointer to a line object
78  * @param en true: auto size is enabled, false: auto size is disabled
79  */
80 void lv_line_set_auto_size(lv_obj_t * line, bool en);
81 
82 /**
83  * Enable (or disable) the y coordinate inversion.
84  * If enabled then y will be subtracted from the height of the object,
85  * therefore the y=0 coordinate will be on the bottom.
86  * @param line pointer to a line object
87  * @param en true: enable the y inversion, false:disable the y inversion
88  */
89 void lv_line_set_y_invert(lv_obj_t * line, bool en);
90 
91 #define lv_line_set_y_inv                                                                                              \
92     lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will                         \
93                             work */
94 
95 /**
96  * Set the style of a line
97  * @param line pointer to a line object
98  * @param type which style should be set (can be only `LV_LINE_STYLE_MAIN`)
99  * @param style pointer to a style
100  */
lv_line_set_style(lv_obj_t * line,lv_line_style_t type,const lv_style_t * style)101 static inline void lv_line_set_style(lv_obj_t * line, lv_line_style_t type, const lv_style_t * style)
102 {
103     (void)type; /*Unused*/
104     lv_obj_set_style(line, style);
105 }
106 
107 /*=====================
108  * Getter functions
109  *====================*/
110 
111 /**
112  * Get the auto size attribute
113  * @param line pointer to a line object
114  * @return true: auto size is enabled, false: disabled
115  */
116 bool lv_line_get_auto_size(const lv_obj_t * line);
117 
118 /**
119  * Get the y inversion attribute
120  * @param line pointer to a line object
121  * @return true: y inversion is enabled, false: disabled
122  */
123 bool lv_line_get_y_invert(const lv_obj_t * line);
124 
125 /**
126  * Get the style of an line object
127  * @param line pointer to an line object
128  * @param type which style should be get (can be only `LV_LINE_STYLE_MAIN`)
129  * @return pointer to the line's style
130  */
lv_line_get_style(const lv_obj_t * line,lv_line_style_t type)131 static inline const lv_style_t * lv_line_get_style(const lv_obj_t * line, lv_line_style_t type)
132 {
133     (void)type; /*Unused*/
134     return lv_obj_get_style(line);
135 }
136 
137 /**********************
138  *      MACROS
139  **********************/
140 
141 #endif /*LV_USE_LINE*/
142 
143 #ifdef __cplusplus
144 } /* extern "C" */
145 #endif
146 
147 #endif /*LV_LINE_H*/
148