1 /**
2  * @file lv_obj.h
3  *
4  */
5 
6 #ifndef LV_OBJ_H
7 #define LV_OBJ_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 #include <stddef.h>
23 #include <stdbool.h>
24 #include "lv_style.h"
25 #include "../lv_misc/lv_types.h"
26 #include "../lv_misc/lv_area.h"
27 #include "../lv_misc/lv_mem.h"
28 #include "../lv_misc/lv_ll.h"
29 #include "../lv_misc/lv_color.h"
30 #include "../lv_misc/lv_log.h"
31 #include "../lv_hal/lv_hal.h"
32 
33 /*********************
34  *      DEFINES
35  *********************/
36 
37 /*Error check of lv_conf.h*/
38 #if LV_HOR_RES_MAX == 0 || LV_VER_RES_MAX == 0
39 #error "LittlevGL: LV_HOR_RES_MAX and LV_VER_RES_MAX must be greater than 0"
40 #endif
41 
42 #if LV_ANTIALIAS > 1
43 #error "LittlevGL: LV_ANTIALIAS can be only 0 or 1"
44 #endif
45 
46 #define LV_MAX_ANCESTOR_NUM 8
47 
48 #define LV_EXT_CLICK_AREA_OFF 0
49 #define LV_EXT_CLICK_AREA_TINY 1
50 #define LV_EXT_CLICK_AREA_FULL 2
51 
52 /**********************
53  *      TYPEDEFS
54  **********************/
55 
56 struct _lv_obj_t;
57 
58 
59 /** Design modes */
60 enum {
61     LV_DESIGN_DRAW_MAIN, /**< Draw the main portion of the object */
62     LV_DESIGN_DRAW_POST, /**< Draw extras on the object */
63     LV_DESIGN_COVER_CHK, /**< Check if the object fully covers the 'mask_p' area */
64 };
65 typedef uint8_t lv_design_mode_t;
66 
67 /**
68  * The design callback is used to draw the object on the screen.
69  * It accepts the object, a mask area, and the mode in which to draw the object.
70  */
71 typedef bool (*lv_design_cb_t)(struct _lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
72 
73 enum {
74     LV_EVENT_PRESSED,             /**< The object has been pressed*/
75     LV_EVENT_PRESSING,            /**< The object is being pressed (called continuously while pressing)*/
76     LV_EVENT_PRESS_LOST,          /**< User is still pressing but slid cursor/finger off of the object */
77     LV_EVENT_SHORT_CLICKED,       /**< User pressed object for a short period of time, then released it. Not called if dragged. */
78     LV_EVENT_LONG_PRESSED,        /**< Object has been pressed for at least `LV_INDEV_LONG_PRESS_TIME`.  Not called if dragged.*/
79     LV_EVENT_LONG_PRESSED_REPEAT, /**< Called after `LV_INDEV_LONG_PRESS_TIME` in every
80                                        `LV_INDEV_LONG_PRESS_REP_TIME` ms.  Not called if dragged.*/
81     LV_EVENT_CLICKED,             /**< Called on release if not dragged (regardless to long press)*/
82     LV_EVENT_RELEASED,            /**< Called in every cases when the object has been released*/
83     LV_EVENT_DRAG_BEGIN,
84     LV_EVENT_DRAG_END,
85     LV_EVENT_DRAG_THROW_BEGIN,
86     LV_EVENT_KEY,
87     LV_EVENT_FOCUSED,
88     LV_EVENT_DEFOCUSED,
89     LV_EVENT_VALUE_CHANGED,		 /**< The object's value has changed (i.e. slider moved) */
90     LV_EVENT_INSERT,
91     LV_EVENT_REFRESH,
92     LV_EVENT_APPLY,  /**< "Ok", "Apply" or similar specific button has clicked*/
93     LV_EVENT_CANCEL, /**< "Close", "Cancel" or similar specific button has clicked*/
94     LV_EVENT_DELETE, /**< Object is being deleted */
95 };
96 typedef uint8_t lv_event_t; /**< Type of event being sent to the object. */
97 
98 /**
99  * @brief Event callback.
100  * Events are used to notify the user of some action being taken on the object.
101  * For details, see ::lv_event_t.
102  */
103 typedef void (*lv_event_cb_t)(struct _lv_obj_t * obj, lv_event_t event);
104 
105 /** Signals are for use by the object itself or to extend the object's functionality.
106   * Applications should use ::lv_obj_set_event_cb to be notified of events that occur
107   * on the object. */
108 enum {
109     /*General signals*/
110     LV_SIGNAL_CLEANUP, /**< Object is being deleted */
111     LV_SIGNAL_CHILD_CHG, /**< Child was removed/added */
112     LV_SIGNAL_CORD_CHG, /**< Object coordinates/size have changed */
113     LV_SIGNAL_PARENT_SIZE_CHG, /**< Parent's size has changed */
114     LV_SIGNAL_STYLE_CHG, /**< Object's style has changed */
115     LV_SIGNAL_REFR_EXT_DRAW_PAD, /**< Object's extra padding has changed */
116     LV_SIGNAL_GET_TYPE, /**< LittlevGL needs to retrieve the object's type */
117 
118     /*Input device related*/
119     LV_SIGNAL_PRESSED,           /**< The object has been pressed*/
120     LV_SIGNAL_PRESSING,          /**< The object is being pressed (called continuously while pressing)*/
121     LV_SIGNAL_PRESS_LOST,        /**< User is still pressing but slid cursor/finger off of the object */
122     LV_SIGNAL_RELEASED,          /**< User pressed object for a short period of time, then released it. Not called if dragged. */
123     LV_SIGNAL_LONG_PRESS,        /**< Object has been pressed for at least `LV_INDEV_LONG_PRESS_TIME`.  Not called if dragged.*/
124     LV_SIGNAL_LONG_PRESS_REP,    /**< Called after `LV_INDEV_LONG_PRESS_TIME` in every `LV_INDEV_LONG_PRESS_REP_TIME` ms.  Not called if dragged.*/
125     LV_SIGNAL_DRAG_BEGIN,
126     LV_SIGNAL_DRAG_END,
127     /*Group related*/
128     LV_SIGNAL_FOCUS,
129     LV_SIGNAL_DEFOCUS,
130     LV_SIGNAL_CONTROL,
131     LV_SIGNAL_GET_EDITABLE,
132 };
133 typedef uint8_t lv_signal_t;
134 
135 typedef lv_res_t (*lv_signal_cb_t)(struct _lv_obj_t * obj, lv_signal_t sign, void * param);
136 
137 /** Object alignment. */
138 enum {
139     LV_ALIGN_CENTER = 0,
140     LV_ALIGN_IN_TOP_LEFT,
141     LV_ALIGN_IN_TOP_MID,
142     LV_ALIGN_IN_TOP_RIGHT,
143     LV_ALIGN_IN_BOTTOM_LEFT,
144     LV_ALIGN_IN_BOTTOM_MID,
145     LV_ALIGN_IN_BOTTOM_RIGHT,
146     LV_ALIGN_IN_LEFT_MID,
147     LV_ALIGN_IN_RIGHT_MID,
148     LV_ALIGN_OUT_TOP_LEFT,
149     LV_ALIGN_OUT_TOP_MID,
150     LV_ALIGN_OUT_TOP_RIGHT,
151     LV_ALIGN_OUT_BOTTOM_LEFT,
152     LV_ALIGN_OUT_BOTTOM_MID,
153     LV_ALIGN_OUT_BOTTOM_RIGHT,
154     LV_ALIGN_OUT_LEFT_TOP,
155     LV_ALIGN_OUT_LEFT_MID,
156     LV_ALIGN_OUT_LEFT_BOTTOM,
157     LV_ALIGN_OUT_RIGHT_TOP,
158     LV_ALIGN_OUT_RIGHT_MID,
159     LV_ALIGN_OUT_RIGHT_BOTTOM,
160 };
161 typedef uint8_t lv_align_t;
162 
163 #if LV_USE_OBJ_REALIGN
164 typedef struct
165 {
166     const struct _lv_obj_t * base;
167     lv_coord_t xofs;
168     lv_coord_t yofs;
169     lv_align_t align;
170     uint8_t auto_realign : 1;
171     uint8_t origo_align : 1; /**< 1: the origo (center of the object) was aligned with
172                                 `lv_obj_align_origo`*/
173 } lv_reailgn_t;
174 #endif
175 
176 enum {
177     LV_DRAG_DIR_HOR = 0x1, /**< Object can be dragged horizontally. */
178     LV_DRAG_DIR_VER = 0x2, /**< Object can be dragged vertically. */
179     LV_DRAG_DIR_ALL = 0x3, /**< Object can be dragged in all directions. */
180 };
181 
182 typedef uint8_t lv_drag_dir_t;
183 
184 typedef struct _lv_obj_t
185 {
186     struct _lv_obj_t * par; /**< Pointer to the parent object*/
187     lv_ll_t child_ll;       /**< Linked list to store the children objects*/
188 
189     lv_area_t coords; /**< Coordinates of the object (x1, y1, x2, y2)*/
190 
191     lv_event_cb_t event_cb; /**< Event callback function */
192     lv_signal_cb_t signal_cb; /**< Object type specific signal function*/
193     lv_design_cb_t design_cb; /**< Object type specific design function*/
194 
195     void * ext_attr;            /**< Object type specific extended data*/
196     const lv_style_t * style_p; /**< Pointer to the object's style*/
197 
198 #if LV_USE_GROUP != 0
199     void * group_p; /**< Pointer to the group of the object*/
200 #endif
201 
202 #if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
203     uint8_t ext_click_pad_hor; /**< Extra click padding in horizontal direction */
204     uint8_t ext_click_pad_ver; /**< Extra click padding in vertical direction */
205 #endif
206 
207 #if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
208     lv_area_t ext_click_pad;   /**< Extra click padding area. */
209 #endif
210 
211     /*Attributes and states*/
212     uint8_t click : 1;          /**< 1: Can be pressed by an input device*/
213     uint8_t drag : 1;           /**< 1: Enable the dragging*/
214     uint8_t drag_throw : 1;     /**< 1: Enable throwing with drag*/
215     uint8_t drag_parent : 1;    /**< 1: Parent will be dragged instead*/
216     uint8_t hidden : 1;         /**< 1: Object is hidden*/
217     uint8_t top : 1;            /**< 1: If the object or its children is clicked it goes to the foreground*/
218     uint8_t opa_scale_en : 1;   /**< 1: opa_scale is set*/
219     uint8_t parent_event : 1;   /**< 1: Send the object's events to the parent too. */
220     lv_drag_dir_t drag_dir : 2; /**<  Which directions the object can be dragged in */
221     uint8_t reserved : 6;       /**<  Reserved for future use*/
222     uint8_t protect;            /**< Automatically happening actions can be prevented. 'OR'ed values from
223                                    `lv_protect_t`*/
224     lv_opa_t opa_scale;         /**< Scale down the opacity by this factor. Effects all children as well*/
225 
226     lv_coord_t ext_draw_pad; /**< EXTtend the size in every direction for drawing. */
227 
228 #if LV_USE_OBJ_REALIGN
229     lv_reailgn_t realign;       /**< Information about the last call to ::lv_obj_align. */
230 #endif
231 
232 #if LV_USE_USER_DATA
233     lv_obj_user_data_t user_data; /**< Custom user data for object. */
234 #endif
235 
236 } lv_obj_t;
237 
238 /*Protect some attributes (max. 8 bit)*/
239 enum {
240     LV_PROTECT_NONE      = 0x00,
241     LV_PROTECT_CHILD_CHG = 0x01,   /**< Disable the child change signal. Used by the library*/
242     LV_PROTECT_PARENT    = 0x02,   /**< Prevent automatic parent change (e.g. in lv_page)*/
243     LV_PROTECT_POS       = 0x04,   /**< Prevent automatic positioning (e.g. in lv_cont layout)*/
244     LV_PROTECT_FOLLOW    = 0x08,   /**< Prevent the object be followed in automatic ordering (e.g. in
245                                       lv_cont PRETTY layout)*/
246     LV_PROTECT_PRESS_LOST = 0x10,  /**< If the `indev` was pressing this object but swiped out while
247                                       pressing do not search other object.*/
248     LV_PROTECT_CLICK_FOCUS = 0x20, /**< Prevent focusing the object by clicking on it*/
249 };
250 typedef uint8_t lv_protect_t;
251 
252 /** Used by `lv_obj_get_type()`. The object's and its ancestor types are stored here*/
253 typedef struct
254 {
255     const char * type[LV_MAX_ANCESTOR_NUM]; /**< [0]: the actual type, [1]: ancestor, [2] #1's ancestor
256                                                ... [x]: "lv_obj" */
257 } lv_obj_type_t;
258 
259 /**********************
260  * GLOBAL PROTOTYPES
261  **********************/
262 
263 /**
264  * Init. the 'lv' library.
265  */
266 void lv_init(void);
267 
268 /*--------------------
269  * Create and delete
270  *-------------------*/
271 
272 /**
273  * Create a basic object
274  * @param parent pointer to a parent object.
275  *                  If NULL then a screen will be created
276  * @param copy pointer to a base object, if not NULL then the new object will be copied from it
277  * @return pointer to the new object
278  */
279 lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy);
280 
281 /**
282  * Delete 'obj' and all of its children
283  * @param obj pointer to an object to delete
284  * @return LV_RES_INV because the object is deleted
285  */
286 lv_res_t lv_obj_del(lv_obj_t * obj);
287 
288 /**
289  * Helper function for asynchronously deleting objects.
290  * Useful for cases where you can't delete an object directly in an `LV_EVENT_DELETE` handler (i.e. parent).
291  * @param obj object to delete
292  * @see lv_async_call
293  */
294 void lv_obj_del_async(struct _lv_obj_t *obj);
295 
296 /**
297  * Delete all children of an object
298  * @param obj pointer to an object
299  */
300 void lv_obj_clean(lv_obj_t * obj);
301 
302 /**
303  * Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
304  * @param obj pointer to an object
305  */
306 void lv_obj_invalidate(const lv_obj_t * obj);
307 
308 /*=====================
309  * Setter functions
310  *====================*/
311 
312 /*--------------------
313  * Parent/children set
314  *--------------------*/
315 
316 /**
317  * Set a new parent for an object. Its relative position will be the same.
318  * @param obj pointer to an object. Can't be a screen.
319  * @param parent pointer to the new parent object. (Can't be NULL)
320  */
321 void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);
322 
323 /**
324  * Move and object to the foreground
325  * @param obj pointer to an object
326  */
327 void lv_obj_move_foreground(lv_obj_t * obj);
328 
329 /**
330  * Move and object to the background
331  * @param obj pointer to an object
332  */
333 void lv_obj_move_background(lv_obj_t * obj);
334 
335 /*--------------------
336  * Coordinate set
337  * ------------------*/
338 
339 /**
340  * Set relative the position of an object (relative to the parent)
341  * @param obj pointer to an object
342  * @param x new distance from the left side of the parent
343  * @param y new distance from the top of the parent
344  */
345 void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y);
346 
347 /**
348  * Set the x coordinate of a object
349  * @param obj pointer to an object
350  * @param x new distance from the left side from the parent
351  */
352 void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x);
353 
354 /**
355  * Set the y coordinate of a object
356  * @param obj pointer to an object
357  * @param y new distance from the top of the parent
358  */
359 void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y);
360 
361 /**
362  * Set the size of an object
363  * @param obj pointer to an object
364  * @param w new width
365  * @param h new height
366  */
367 void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h);
368 
369 /**
370  * Set the width of an object
371  * @param obj pointer to an object
372  * @param w new width
373  */
374 void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w);
375 
376 /**
377  * Set the height of an object
378  * @param obj pointer to an object
379  * @param h new height
380  */
381 void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h);
382 
383 /**
384  * Align an object to an other object.
385  * @param obj pointer to an object to align
386  * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
387  * @param align type of alignment (see 'lv_align_t' enum)
388  * @param x_mod x coordinate shift after alignment
389  * @param y_mod y coordinate shift after alignment
390  */
391 void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
392 
393 /**
394  * Align an object to an other object.
395  * @param obj pointer to an object to align
396  * @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
397  * @param align type of alignment (see 'lv_align_t' enum)
398  * @param x_mod x coordinate shift after alignment
399  * @param y_mod y coordinate shift after alignment
400  */
401 void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
402 
403 /**
404  * Realign the object based on the last `lv_obj_align` parameters.
405  * @param obj pointer to an object
406  */
407 void lv_obj_realign(lv_obj_t * obj);
408 
409 /**
410  * Enable the automatic realign of the object when its size has changed based on the last
411  * `lv_obj_align` parameters.
412  * @param obj pointer to an object
413  * @param en true: enable auto realign; false: disable auto realign
414  */
415 void lv_obj_set_auto_realign(lv_obj_t * obj, bool en);
416 
417 /**
418  * Set the size of an extended clickable area
419  * @param obj pointer to an object
420  * @param left extended clickable are on the left [px]
421  * @param right extended clickable are on the right [px]
422  * @param top extended clickable are on the top [px]
423  * @param bottom extended clickable are on the bottom [px]
424  */
425 void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right, lv_coord_t top, lv_coord_t bottom);
426 
427 /*---------------------
428  * Appearance set
429  *--------------------*/
430 
431 /**
432  * Set a new style for an object
433  * @param obj pointer to an object
434  * @param style_p pointer to the new style
435  */
436 void lv_obj_set_style(lv_obj_t * obj, const lv_style_t * style);
437 
438 /**
439  * Notify an object about its style is modified
440  * @param obj pointer to an object
441  */
442 void lv_obj_refresh_style(lv_obj_t * obj);
443 
444 /**
445  * Notify all object if a style is modified
446  * @param style pointer to a style. Only the objects with this style will be notified
447  *               (NULL to notify all objects)
448  */
449 void lv_obj_report_style_mod(lv_style_t * style);
450 
451 /*-----------------
452  * Attribute set
453  *----------------*/
454 
455 /**
456  * Hide an object. It won't be visible and clickable.
457  * @param obj pointer to an object
458  * @param en true: hide the object
459  */
460 void lv_obj_set_hidden(lv_obj_t * obj, bool en);
461 
462 /**
463  * Enable or disable the clicking of an object
464  * @param obj pointer to an object
465  * @param en true: make the object clickable
466  */
467 void lv_obj_set_click(lv_obj_t * obj, bool en);
468 
469 /**
470  * Enable to bring this object to the foreground if it
471  * or any of its children is clicked
472  * @param obj pointer to an object
473  * @param en true: enable the auto top feature
474  */
475 void lv_obj_set_top(lv_obj_t * obj, bool en);
476 
477 /**
478  * Enable the dragging of an object
479  * @param obj pointer to an object
480  * @param en true: make the object dragable
481  */
482 void lv_obj_set_drag(lv_obj_t * obj, bool en);
483 
484 /**
485  * Set the directions an object can be dragged in
486  * @param obj pointer to an object
487  * @param drag_dir bitwise OR of allowed drag directions
488  */
489 void lv_obj_set_drag_dir(lv_obj_t * obj, lv_drag_dir_t drag_dir);
490 
491 /**
492  * Enable the throwing of an object after is is dragged
493  * @param obj pointer to an object
494  * @param en true: enable the drag throw
495  */
496 void lv_obj_set_drag_throw(lv_obj_t * obj, bool en);
497 
498 /**
499  * Enable to use parent for drag related operations.
500  * If trying to drag the object the parent will be moved instead
501  * @param obj pointer to an object
502  * @param en true: enable the 'drag parent' for the object
503  */
504 void lv_obj_set_drag_parent(lv_obj_t * obj, bool en);
505 
506 /**
507  * Propagate the events to the parent too
508  * @param obj pointer to an object
509  * @param en true: enable the event propagation
510  */
511 void lv_obj_set_parent_event(lv_obj_t * obj, bool en);
512 
513 /**
514  * Set the opa scale enable parameter (required to set opa_scale with `lv_obj_set_opa_scale()`)
515  * @param obj pointer to an object
516  * @param en true: opa scaling is enabled for this object and all children; false: no opa scaling
517  */
518 void lv_obj_set_opa_scale_enable(lv_obj_t * obj, bool en);
519 
520 /**
521  * Set the opa scale of an object.
522  * The opacity of this object and all it's children will be scaled down with this factor.
523  * `lv_obj_set_opa_scale_enable(obj, true)` needs to be called to enable it.
524  * (not for all children just for the parent where to start the opa scaling)
525  * @param obj pointer to an object
526  * @param opa_scale a factor to scale down opacity [0..255]
527  */
528 void lv_obj_set_opa_scale(lv_obj_t * obj, lv_opa_t opa_scale);
529 
530 /**
531  * Set a bit or bits in the protect filed
532  * @param obj pointer to an object
533  * @param prot 'OR'-ed values from `lv_protect_t`
534  */
535 void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
536 
537 /**
538  * Clear a bit or bits in the protect filed
539  * @param obj pointer to an object
540  * @param prot 'OR'-ed values from `lv_protect_t`
541  */
542 void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot);
543 
544 /**
545  * Set a an event handler function for an object.
546  * Used by the user to react on event which happens with the object.
547  * @param obj pointer to an object
548  * @param event_cb the new event function
549  */
550 void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb);
551 
552 /**
553  * Send an event to the object
554  * @param obj pointer to an object
555  * @param event the type of the event from `lv_event_t`.
556  * @param data arbitrary data depending on the object type and the event. (Usually `NULL`)
557  * @return LV_RES_OK: `obj` was not deleted in the event; LV_RES_INV: `obj` was deleted in the event
558  */
559 lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data);
560 
561 /**
562  * Call an event function with an object, event, and data.
563  * @param event_xcb an event callback function. If `NULL` `LV_RES_OK` will return without any actions.
564  *        (the 'x' in the argument name indicates that its not a fully generic function because it not follows
565  *         the `func_name(object, callback, ...)` convention)
566  * @param obj pointer to an object to associate with the event (can be `NULL` to simply call the `event_cb`)
567  * @param event an event
568  * @param data pointer to a custom data
569  * @return LV_RES_OK: `obj` was not deleted in the event; LV_RES_INV: `obj` was deleted in the event
570  */
571 lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t event, const void * data);
572 
573 /**
574  * Get the `data` parameter of the current event
575  * @return the `data` parameter
576  */
577 const void * lv_event_get_data(void);
578 
579 /**
580  * Set the a signal function of an object. Used internally by the library.
581  * Always call the previous signal function in the new.
582  * @param obj pointer to an object
583  * @param signal_cb the new signal function
584  */
585 void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t signal_cb);
586 
587 /**
588  * Send an event to the object
589  * @param obj pointer to an object
590  * @param event the type of the event from `lv_event_t`.
591  */
592 void lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param);
593 
594 /**
595  * Set a new design function for an object
596  * @param obj pointer to an object
597  * @param design_cb the new design function
598  */
599 void lv_obj_set_design_cb(lv_obj_t * obj, lv_design_cb_t design_cb);
600 
601 /*----------------
602  * Other set
603  *--------------*/
604 
605 /**
606  * Allocate a new ext. data for an object
607  * @param obj pointer to an object
608  * @param ext_size the size of the new ext. data
609  * @return pointer to the allocated ext
610  */
611 void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size);
612 
613 /**
614  * Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
615  * @param obj pointer to an object
616  */
617 void lv_obj_refresh_ext_draw_pad(lv_obj_t * obj);
618 
619 /*=======================
620  * Getter functions
621  *======================*/
622 
623 /**
624  * Return with the screen of an object
625  * @param obj pointer to an object
626  * @return pointer to a screen
627  */
628 lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj);
629 
630 /**
631  * Get the display of an object
632  * @param scr pointer to an object
633  * @return pointer the object's display
634  */
635 lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj);
636 
637 /*---------------------
638  * Parent/children get
639  *--------------------*/
640 
641 /**
642  * Returns with the parent of an object
643  * @param obj pointer to an object
644  * @return pointer to the parent of  'obj'
645  */
646 lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj);
647 
648 /**
649  * Iterate through the children of an object (start from the "youngest, lastly created")
650  * @param obj pointer to an object
651  * @param child NULL at first call to get the next children
652  *                  and the previous return value later
653  * @return the child after 'act_child' or NULL if no more child
654  */
655 lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child);
656 
657 /**
658  * Iterate through the children of an object (start from the "oldest", firstly created)
659  * @param obj pointer to an object
660  * @param child NULL at first call to get the next children
661  *                  and the previous return value later
662  * @return the child after 'act_child' or NULL if no more child
663  */
664 lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child);
665 
666 /**
667  * Count the children of an object (only children directly on 'obj')
668  * @param obj pointer to an object
669  * @return children number of 'obj'
670  */
671 uint16_t lv_obj_count_children(const lv_obj_t * obj);
672 
673 /** Recursively count the children of an object
674  * @param obj pointer to an object
675  * @return children number of 'obj'
676  */
677 uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj);
678 
679 /*---------------------
680  * Coordinate get
681  *--------------------*/
682 
683 /**
684  * Copy the coordinates of an object to an area
685  * @param obj pointer to an object
686  * @param cords_p pointer to an area to store the coordinates
687  */
688 void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p);
689 
690 /**
691  * Reduce area retried by `lv_obj_get_coords()` the get graphically usable area of an object.
692  * (Without the size of the border or other extra graphical elements)
693  * @param coords_p store the result area here
694  */
695 void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p);
696 
697 /**
698  * Get the x coordinate of object
699  * @param obj pointer to an object
700  * @return distance of 'obj' from the left side of its parent
701  */
702 lv_coord_t lv_obj_get_x(const lv_obj_t * obj);
703 
704 /**
705  * Get the y coordinate of object
706  * @param obj pointer to an object
707  * @return distance of 'obj' from the top of its parent
708  */
709 lv_coord_t lv_obj_get_y(const lv_obj_t * obj);
710 
711 /**
712  * Get the width of an object
713  * @param obj pointer to an object
714  * @return the width
715  */
716 lv_coord_t lv_obj_get_width(const lv_obj_t * obj);
717 
718 /**
719  * Get the height of an object
720  * @param obj pointer to an object
721  * @return the height
722  */
723 lv_coord_t lv_obj_get_height(const lv_obj_t * obj);
724 
725 /**
726  * Get that width reduced by the left and right padding.
727  * @param obj pointer to an object
728  * @return the width which still fits into the container
729  */
730 lv_coord_t lv_obj_get_width_fit(lv_obj_t * obj);
731 
732 /**
733  * Get that height reduced by the top an bottom padding.
734  * @param obj pointer to an object
735  * @return the height which still fits into the container
736  */
737 lv_coord_t lv_obj_get_height_fit(lv_obj_t * obj);
738 
739 /**
740  * Get the automatic realign property of the object.
741  * @param obj pointer to an object
742  * @return  true: auto realign is enabled; false: auto realign is disabled
743  */
744 bool lv_obj_get_auto_realign(lv_obj_t * obj);
745 
746 /**
747  * Get the left padding of extended clickable area
748  * @param obj pointer to an object
749  * @return the extended left padding
750  */
751 lv_coord_t lv_obj_get_ext_click_pad_left(const lv_obj_t * obj);
752 
753 /**
754  * Get the right padding of extended clickable area
755  * @param obj pointer to an object
756  * @return the extended right padding
757  */
758 lv_coord_t lv_obj_get_ext_click_pad_right(const lv_obj_t * obj);
759 
760 /**
761  * Get the top padding of extended clickable area
762  * @param obj pointer to an object
763  * @return the extended top padding
764  */
765 lv_coord_t lv_obj_get_ext_click_pad_top(const lv_obj_t * obj);
766 
767 /**
768  * Get the bottom padding of extended clickable area
769  * @param obj pointer to an object
770  * @return the extended bottom padding
771  */
772 lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj);
773 
774 /**
775  * Get the extended size attribute of an object
776  * @param obj pointer to an object
777  * @return the extended size attribute
778  */
779 lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj);
780 
781 /*-----------------
782  * Appearance get
783  *---------------*/
784 
785 /**
786  * Get the style pointer of an object (if NULL get style of the parent)
787  * @param obj pointer to an object
788  * @return pointer to a style
789  */
790 const lv_style_t * lv_obj_get_style(const lv_obj_t * obj);
791 
792 /*-----------------
793  * Attribute get
794  *----------------*/
795 
796 /**
797  * Get the hidden attribute of an object
798  * @param obj pointer to an object
799  * @return true: the object is hidden
800  */
801 bool lv_obj_get_hidden(const lv_obj_t * obj);
802 
803 /**
804  * Get the click enable attribute of an object
805  * @param obj pointer to an object
806  * @return true: the object is clickable
807  */
808 bool lv_obj_get_click(const lv_obj_t * obj);
809 
810 /**
811  * Get the top enable attribute of an object
812  * @param obj pointer to an object
813  * @return true: the auto top feature is enabled
814  */
815 bool lv_obj_get_top(const lv_obj_t * obj);
816 
817 /**
818  * Get the drag enable attribute of an object
819  * @param obj pointer to an object
820  * @return true: the object is dragable
821  */
822 bool lv_obj_get_drag(const lv_obj_t * obj);
823 
824 /**
825  * Get the directions an object can be dragged
826  * @param obj pointer to an object
827  * @return bitwise OR of allowed directions an object can be dragged in
828  */
829 lv_drag_dir_t lv_obj_get_drag_dir(const lv_obj_t * obj);
830 
831 /**
832  * Get the drag throw enable attribute of an object
833  * @param obj pointer to an object
834  * @return true: drag throw is enabled
835  */
836 bool lv_obj_get_drag_throw(const lv_obj_t * obj);
837 
838 /**
839  * Get the drag parent attribute of an object
840  * @param obj pointer to an object
841  * @return true: drag parent is enabled
842  */
843 bool lv_obj_get_drag_parent(const lv_obj_t * obj);
844 
845 /**
846  * Get the drag parent attribute of an object
847  * @param obj pointer to an object
848  * @return true: drag parent is enabled
849  */
850 bool lv_obj_get_parent_event(const lv_obj_t * obj);
851 
852 /**
853  * Get the opa scale enable parameter
854  * @param obj pointer to an object
855  * @return true: opa scaling is enabled for this object and all children; false: no opa scaling
856  */
857 lv_opa_t lv_obj_get_opa_scale_enable(const lv_obj_t * obj);
858 
859 /**
860  * Get the opa scale parameter of an object
861  * @param obj pointer to an object
862  * @return opa scale [0..255]
863  */
864 lv_opa_t lv_obj_get_opa_scale(const lv_obj_t * obj);
865 
866 /**
867  * Get the protect field of an object
868  * @param obj pointer to an object
869  * @return protect field ('OR'ed values of `lv_protect_t`)
870  */
871 uint8_t lv_obj_get_protect(const lv_obj_t * obj);
872 
873 /**
874  * Check at least one bit of a given protect bitfield is set
875  * @param obj pointer to an object
876  * @param prot protect bits to test ('OR'ed values of `lv_protect_t`)
877  * @return false: none of the given bits are set, true: at least one bit is set
878  */
879 bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot);
880 
881 /**
882  * Get the signal function of an object
883  * @param obj pointer to an object
884  * @return the signal function
885  */
886 lv_signal_cb_t lv_obj_get_signal_cb(const lv_obj_t * obj);
887 
888 /**
889  * Get the design function of an object
890  * @param obj pointer to an object
891  * @return the design function
892  */
893 lv_design_cb_t lv_obj_get_design_cb(const lv_obj_t * obj);
894 
895 /**
896  * Get the event function of an object
897  * @param obj pointer to an object
898  * @return the event function
899  */
900 lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj);
901 
902 /*------------------
903  * Other get
904  *-----------------*/
905 
906 /**
907  * Get the ext pointer
908  * @param obj pointer to an object
909  * @return the ext pointer but not the dynamic version
910  *         Use it as ext->data1, and NOT da(ext)->data1
911  */
912 void * lv_obj_get_ext_attr(const lv_obj_t * obj);
913 
914 /**
915  * Get object's and its ancestors type. Put their name in `type_buf` starting with the current type.
916  * E.g. buf.type[0]="lv_btn", buf.type[1]="lv_cont", buf.type[2]="lv_obj"
917  * @param obj pointer to an object which type should be get
918  * @param buf pointer to an `lv_obj_type_t` buffer to store the types
919  */
920 void lv_obj_get_type(lv_obj_t * obj, lv_obj_type_t * buf);
921 
922 #if LV_USE_USER_DATA
923 /**
924  * Get the object's user data
925  * @param obj pointer to an object
926  * @return user data
927  */
928 lv_obj_user_data_t lv_obj_get_user_data(lv_obj_t * obj);
929 
930 /**
931  * Get a pointer to the object's user data
932  * @param obj pointer to an object
933  * @return pointer to the user data
934  */
935 lv_obj_user_data_t * lv_obj_get_user_data_ptr(lv_obj_t * obj);
936 
937 /**
938  * Set the object's user data. The data will be copied.
939  * @param obj pointer to an object
940  * @param data user data
941  */
942 void lv_obj_set_user_data(lv_obj_t * obj, lv_obj_user_data_t data);
943 
944 #endif
945 
946 #if LV_USE_GROUP
947 /**
948  * Get the group of the object
949  * @param obj pointer to an object
950  * @return the pointer to group of the object
951  */
952 void * lv_obj_get_group(const lv_obj_t * obj);
953 
954 /**
955  * Tell whether the object is the focused object of a group or not.
956  * @param obj pointer to an object
957  * @return true: the object is focused, false: the object is not focused or not in a group
958  */
959 bool lv_obj_is_focused(const lv_obj_t * obj);
960 
961 #endif
962 
963 /**********************
964  *      MACROS
965  **********************/
966 
967 /**
968  * Helps to quickly declare an event callback function.
969  * Will be expanded to: `void <name> (lv_obj_t * obj, lv_event_t e)`
970  *
971  * Examples:
972  * static LV_EVENT_CB_DECLARE(my_event1);  //Protoype declaration
973  *
974  * static LV_EVENT_CB_DECLARE(my_event1)
975  * {
976  *   if(e == LV_EVENT_CLICKED) {
977  *      lv_obj_set_hidden(obj ,true);
978  *   }
979  * }
980  */
981 #define LV_EVENT_CB_DECLARE(name) void name(lv_obj_t * obj, lv_event_t e)
982 
983 #ifdef __cplusplus
984 } /* extern "C" */
985 #endif
986 
987 #endif /*LV_OBJ_H*/
988