mikroSDK Reference Manual
lv_area.h
Go to the documentation of this file.
1
6#ifndef LV_AREA_H
7#define LV_AREA_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17#include <stdbool.h>
18#include <stdint.h>
19
20/*********************
21 * DEFINES
22 *********************/
23
24#if LV_USE_LARGE_COORD
25typedef int32_t lv_coord_t;
26#else
27typedef int16_t lv_coord_t;
28#endif
29
30/**********************
31 * TYPEDEFS
32 **********************/
33
37typedef struct {
38 lv_coord_t x;
39 lv_coord_t y;
41
43typedef struct {
44 lv_coord_t x1;
45 lv_coord_t y1;
46 lv_coord_t x2;
47 lv_coord_t y2;
48} lv_area_t;
49
51enum {
52 LV_ALIGN_DEFAULT = 0,
53 LV_ALIGN_TOP_LEFT,
54 LV_ALIGN_TOP_MID,
55 LV_ALIGN_TOP_RIGHT,
56 LV_ALIGN_BOTTOM_LEFT,
57 LV_ALIGN_BOTTOM_MID,
58 LV_ALIGN_BOTTOM_RIGHT,
59 LV_ALIGN_LEFT_MID,
60 LV_ALIGN_RIGHT_MID,
61 LV_ALIGN_CENTER,
62
63 LV_ALIGN_OUT_TOP_LEFT,
64 LV_ALIGN_OUT_TOP_MID,
65 LV_ALIGN_OUT_TOP_RIGHT,
66 LV_ALIGN_OUT_BOTTOM_LEFT,
67 LV_ALIGN_OUT_BOTTOM_MID,
68 LV_ALIGN_OUT_BOTTOM_RIGHT,
69 LV_ALIGN_OUT_LEFT_TOP,
70 LV_ALIGN_OUT_LEFT_MID,
71 LV_ALIGN_OUT_LEFT_BOTTOM,
72 LV_ALIGN_OUT_RIGHT_TOP,
73 LV_ALIGN_OUT_RIGHT_MID,
74 LV_ALIGN_OUT_RIGHT_BOTTOM,
75};
76typedef uint8_t lv_align_t;
77
78enum {
79 LV_DIR_NONE = 0x00,
80 LV_DIR_LEFT = (1 << 0),
81 LV_DIR_RIGHT = (1 << 1),
82 LV_DIR_TOP = (1 << 2),
83 LV_DIR_BOTTOM = (1 << 3),
84 LV_DIR_HOR = LV_DIR_LEFT | LV_DIR_RIGHT,
85 LV_DIR_VER = LV_DIR_TOP | LV_DIR_BOTTOM,
86 LV_DIR_ALL = LV_DIR_HOR | LV_DIR_VER,
87};
88
89typedef uint8_t lv_dir_t;
90
91/**********************
92 * GLOBAL PROTOTYPES
93 **********************/
94
103void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2);
104
110inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src)
111{
112 dest->x1 = src->x1;
113 dest->y1 = src->y1;
114 dest->x2 = src->x2;
115 dest->y2 = src->y2;
116}
117
123static inline lv_coord_t lv_area_get_width(const lv_area_t * area_p)
124{
125 return (lv_coord_t)(area_p->x2 - area_p->x1 + 1);
126}
127
133static inline lv_coord_t lv_area_get_height(const lv_area_t * area_p)
134{
135 return (lv_coord_t)(area_p->y2 - area_p->y1 + 1);
136}
137
143void lv_area_set_width(lv_area_t * area_p, lv_coord_t w);
144
150void lv_area_set_height(lv_area_t * area_p, lv_coord_t h);
151
158void _lv_area_set_pos(lv_area_t * area_p, lv_coord_t x, lv_coord_t y);
159
165uint32_t lv_area_get_size(const lv_area_t * area_p);
166
167void lv_area_increase(lv_area_t * area, lv_coord_t w_extra, lv_coord_t h_extra);
168
169void lv_area_move(lv_area_t * area, lv_coord_t x_ofs, lv_coord_t y_ofs);
170
178bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p);
179
186void _lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p);
187
195bool _lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, lv_coord_t radius);
196
203bool _lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p);
204
212bool _lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p, lv_coord_t radius);
213
214
222bool _lv_area_is_out(const lv_area_t * aout_p, const lv_area_t * aholder_p, lv_coord_t radius);
223
229bool _lv_area_is_equal(const lv_area_t * a, const lv_area_t * b);
230
237void lv_area_align(const lv_area_t * base, lv_area_t * to_align, lv_align_t align, lv_coord_t ofs_x, lv_coord_t ofs_y);
238
239void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom, const lv_point_t * pivot);
240
241/**********************
242 * MACROS
243 **********************/
244
245#if LV_USE_LARGE_COORD
246#define _LV_COORD_TYPE_SHIFT (29U)
247#else
248#define _LV_COORD_TYPE_SHIFT (13U)
249#endif
250
251#define _LV_COORD_TYPE_MASK (3 << _LV_COORD_TYPE_SHIFT)
252#define _LV_COORD_TYPE(x) ((x) & _LV_COORD_TYPE_MASK) /*Extract type specifiers*/
253#define _LV_COORD_PLAIN(x) ((x) & ~_LV_COORD_TYPE_MASK) /*Remove type specifiers*/
254
255#define _LV_COORD_TYPE_PX (0 << _LV_COORD_TYPE_SHIFT)
256#define _LV_COORD_TYPE_SPEC (1 << _LV_COORD_TYPE_SHIFT)
257#define _LV_COORD_TYPE_PX_NEG (3 << _LV_COORD_TYPE_SHIFT)
258
259#define LV_COORD_IS_PX(x) (_LV_COORD_TYPE(x) == _LV_COORD_TYPE_PX || \
260 _LV_COORD_TYPE(x) == _LV_COORD_TYPE_PX_NEG ? true : false)
261#define LV_COORD_IS_SPEC(x) (_LV_COORD_TYPE(x) == _LV_COORD_TYPE_SPEC ? true : false)
262
263#define LV_COORD_SET_SPEC(x) ((x) | _LV_COORD_TYPE_SPEC)
264
265/*Special coordinates*/
266#define LV_PCT(x) (x < 0 ? LV_COORD_SET_SPEC(1000 - (x)) : LV_COORD_SET_SPEC(x))
267#define LV_COORD_IS_PCT(x) ((LV_COORD_IS_SPEC(x) && _LV_COORD_PLAIN(x) <= 2000) ? true : false)
268#define LV_COORD_GET_PCT(x) (_LV_COORD_PLAIN(x) > 1000 ? 1000 - _LV_COORD_PLAIN(x) : _LV_COORD_PLAIN(x))
269#define LV_SIZE_CONTENT LV_COORD_SET_SPEC(2001)
270
271LV_EXPORT_CONST_INT(LV_SIZE_CONTENT);
272
273/*Max coordinate value*/
274#define LV_COORD_MAX ((1 << _LV_COORD_TYPE_SHIFT) - 1)
275#define LV_COORD_MIN (-LV_COORD_MAX)
276
277LV_EXPORT_CONST_INT(LV_COORD_MAX);
278LV_EXPORT_CONST_INT(LV_COORD_MIN);
279
286static inline lv_coord_t lv_pct(lv_coord_t x)
287{
288 return LV_PCT(x);
289}
290
291#ifdef __cplusplus
292} /*extern "C"*/
293#endif
294
295#endif
void lv_area_set_height(lv_area_t *area_p, lv_coord_t h)
bool _lv_area_is_in(const lv_area_t *ain_p, const lv_area_t *aholder_p, lv_coord_t radius)
bool _lv_area_is_equal(const lv_area_t *a, const lv_area_t *b)
bool _lv_area_is_point_on(const lv_area_t *a_p, const lv_point_t *p_p, lv_coord_t radius)
bool _lv_area_intersect(lv_area_t *res_p, const lv_area_t *a1_p, const lv_area_t *a2_p)
bool _lv_area_is_on(const lv_area_t *a1_p, const lv_area_t *a2_p)
void _lv_area_join(lv_area_t *a_res_p, const lv_area_t *a1_p, const lv_area_t *a2_p)
void lv_area_align(const lv_area_t *base, lv_area_t *to_align, lv_align_t align, lv_coord_t ofs_x, lv_coord_t ofs_y)
uint32_t lv_area_get_size(const lv_area_t *area_p)
void lv_area_set_width(lv_area_t *area_p, lv_coord_t w)
void lv_area_set(lv_area_t *area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2)
void _lv_area_set_pos(lv_area_t *area_p, lv_coord_t x, lv_coord_t y)
bool _lv_area_is_out(const lv_area_t *aout_p, const lv_area_t *aholder_p, lv_coord_t radius)
Definition lv_area.h:43
Definition lv_area.h:37