MPLABĀ® Harmony Graphics Suite
legato_common.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
3 *
4 * Subject to your compliance with these terms, you may use Microchip software
5 * and any derivatives exclusively with Microchip products. It is your
6 * responsibility to comply with third party license terms applicable to your
7 * use of third party software (including open source software) that may
8 * accompany Microchip software.
9 *
10 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
11 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
12 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
13 * PARTICULAR PURPOSE.
14 *
15 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
16 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
17 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
18 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
19 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
20 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
21 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
22 *******************************************************************************/
23 
24 /*******************************************************************************
25  Module for Microchip Graphics Library - Legato User Interface Library
26 
27  Company:
28  Microchip Technology Inc.
29 
30  File Name:
31  legato_common.h
32 
33  Summary:
34  This file defines the common macros and definitions used by the gfx
35  definition and implementation headers.
36 
37  Description:
38  This file defines the common macros and definitions used by the gfx
39  definition and the implementation header.
40 
41  Remarks:
42  The directory in which this file resides should be added to the compiler's
43  search path for header files.
44  *******************************************************************************/
45 
56 #ifndef LEGATO_COMMON_H
57 #define LEGATO_COMMON_H
58 
59 #include "gfx/legato/legato_config.h"
60 
61 #include <stddef.h>
62 #include <assert.h>
63 #include <string.h>
64 
65 #ifdef _WIN32
66 #ifndef int8_t
67 typedef signed __int8 int8_t;
68 typedef signed __int16 int16_t;
69 typedef signed __int32 int32_t;
70 typedef unsigned __int8 uint8_t;
71 typedef unsigned __int16 uint16_t;
72 typedef unsigned __int32 uint32_t;
73 typedef signed __int64 int64_t;
74 typedef unsigned __int64 uint64_t;
75 #endif
76 #else
77 #include <stdint.h>
78 #endif
79 
80 /* export macros for shared libraries */
81 #ifdef _WIN32
82 #ifdef LIBRARY
83 #define LIB_EXPORT __declspec( dllexport )
84 #else
85 #define LIB_EXPORT __declspec( dllimport )
86 #endif
87 #else
88 #define LIB_EXPORT
89 #endif
90 
91 #ifndef WIN32
92 //#include "osal/osal.h" FIXME for H3
93 #endif
94 
100 #ifndef LE_DEFAULT_SCHEME_COLOR_MODE
101 #define LE_DEFAULT_SCHEME_COLOR_MODE LE_COLOR_MODE_RGB_565
102 #endif
103 
104 #ifdef __cplusplus
105  extern "C" {
106 #endif
107 
108 // *****************************************************************************
109 // *****************************************************************************
110 // Section: Data Types and Constants
111 // *****************************************************************************
112 // *****************************************************************************
113 
114 // *****************************************************************************
115 /* Enumeration:
116  leResult
117 
118  Summary:
119  legato results (success and failure codes).
120 
121  Description:
122  Various definitions for success and failure codes.
123 
124  Remarks:
125  None.
126 */
127 
133 typedef enum leResult
134 {
135  LE_FAILURE = -1,
136  LE_SUCCESS = 0
138 
139 // *****************************************************************************
140 /* Enumeration:
141  leBool
142 
143  Summary:
144  legato bool values
145 
146  Description:
147  legato bool values
148 
149  Remarks:
150  None.
151 */
156 typedef enum leBool
157 {
158  LE_FALSE = 0,
159  LE_TRUE
161 
162 // *****************************************************************************
163 /* Enumeration:
164  leVAlignment
165 
166  Summary:
167  legato vertical alignment values
168 
169  Description:
170  legato vertical alignment values
171 
172  Remarks:
173  None.
174 */
180 typedef enum
181 {
186 
187 // *****************************************************************************
188 /* Enumeration:
189  leHAlignment
190 
191  Summary:
192  legato horizontal alignment values
193 
194  Description:
195  legato horizontal alignment values
196 
197  Remarks:
198  None.
199 */
205 typedef enum
206 {
211 
212 // *****************************************************************************
213 /* Enumeration:
214  leMargin
215 
216  Summary:
217  legato margin values
218 
219  Description:
220  legato margin values
221 
222  Remarks:
223  None.
224 */
230 typedef struct leMargin
231 {
232  uint8_t left;
233  uint8_t top;
234  uint8_t right;
235  uint8_t bottom;
237 
242 static const leMargin leMargin_Zero = {0, 0, 0, 0};
243 
244 // *****************************************************************************
245 /* Enumeration:
246  leDirection
247 
248  Summary:
249  legato direction values
250 
251  Description:
252  legato direction values
253 
254  Remarks:
255  None.
256 */
262 typedef enum leDirection
263 {
269 
270 // *****************************************************************************
271 /* Structure:
272  leRotationDirection
273 
274  Summary:
275  Describes rotational direction
276 
277  Description:
278  Describes rotational direction
279 
280  Remarks:
281  None.
282 */
289 {
293 
294 // *****************************************************************************
295 /* Enumeration:
296  leRelativePosition
297 
298  Summary:
299  legato relative position values
300 
301  Description:
302  legato relative position values
303 
304  Remarks:
305  None.
306 */
312 typedef enum leRelativePosition
313 {
320 
321 // *****************************************************************************
322 /* Enumeration:
323  leOrientation
324 
325  Summary:
326  legato orientation values
327 
328  Description:
329  legato orientation values
330 
331  Remarks:
332  None.
333 */
339 typedef enum leOrientation
340 {
341  LE_ORIENTATION_HORIZONTAL,
342  LE_ORIENTATION_VERTICAL,
344 
345 // *****************************************************************************
346 /* Structure:
347  lePoint
348 
349  Summary:
350  A two dimensional Cartesian point.
351 */
356 typedef struct lePoint
357 {
358  int32_t x;
359  int32_t y;
361 
366 static const lePoint lePoint_Zero = {0, 0};
367 
368 // *****************************************************************************
369 /* Structure:
370  leSize
371 
372  Summary:
373  A two dimensional indication of size. Values are signed but should never be
374  negative.
375 */
380 typedef struct leSize
381 {
382  int32_t width;
383  int32_t height;
385 
390 static const leSize leSize_Zero = {0, 0};
391 
392 // *****************************************************************************
393 /* Structure:
394  leRect
395 
396  Summary:
397  A rectangle definition.
398 */
404 typedef struct leRect
405 {
406  int16_t x;
407  int16_t y;
408  int16_t width;
409  int16_t height;
411 
417 typedef void* leBuffer;
418 
419 /* library configuration flags */
424 typedef uint16_t leChar;
425 
426 #define LE_UNKNOWN_GLYPH 0xFFFF
427 
428 #ifdef __cplusplus
429  }
430 #endif
431 
432 #define ASSIGN_VIRTUAL_FUNCTION(name) .name = name
433 #define ASSIGN_VTABLE_FUNCTION(vtable, name) vtable.name = name
434 #endif // LEGATO_COMMON_H
435 
436 /*******************************************************************************
437  End of File
438 */
LE_HALIGN_RIGHT
@ LE_HALIGN_RIGHT
Definition: legato_common.h:209
legato_math.h
Defines common math functions for general use.
leResult
leResult
This enum represents function call results.
Definition: legato_common.h:134
leLerp
LIB_EXPORT int32_t leLerp(int32_t x, int32_t y, uint32_t per)
Calculates a linear interpolation of an integer based on a percentage between two signed points.
Definition: legato_math.c:290
leColorMode
leColorMode
This enum represents the supported RGB color formats.
Definition: legato_color.h:146
leRect
This struct represents a rectangle.
Definition: legato_common.h:405
legato_color.h
Color definitions and functions.
leMargin::left
uint8_t left
Definition: legato_common.h:232
leDirection
leDirection
This enum represents the four directions modes for objects.
Definition: legato_common.h:263
legato_pixelbuffer.h
Pixel Buffer functions and definitions.
leColorName
leColorName
This enum represents predefined color options.
Definition: legato_color.h:262
leHAlignment
leHAlignment
This enum represents the horizontal alignment mode of objects.
Definition: legato_common.h:206
LE_VALIGN_MIDDLE
@ LE_VALIGN_MIDDLE
Definition: legato_common.h:183
LE_DIRECTION_LEFT
@ LE_DIRECTION_LEFT
Definition: legato_common.h:266
lePercent
LIB_EXPORT uint32_t lePercent(uint32_t l, uint32_t r)
Calculate percent of number.
Definition: legato_math.c:199
legato_renderer.h
leColorLerp
LIB_EXPORT leColor leColorLerp(leColor l, leColor r, uint32_t percent, leColorMode mode)
Get color from linear interpolate of two colors.
Definition: legato_color_lerp.c:284
leSize::width
int32_t width
Definition: legato_common.h:382
leSize
struct leSize leSize
This structure is used represents the size of an item.
LE_COUNTER_CLOCKWISE
@ LE_COUNTER_CLOCKWISE
Definition: legato_common.h:290
LE_HALIGN_CENTER
@ LE_HALIGN_CENTER
Definition: legato_common.h:208
leColorBlend_RGBA_8888
LIB_EXPORT leColor leColorBlend_RGBA_8888(leColor fore, leColor back)
Get color from RGBA blend.
Definition: legato_color_blend.c:77
leOrientation
leOrientation
This enum represents the orientation modes for objects.
Definition: legato_common.h:340
LE_RELATIVE_POSITION_BEHIND
@ LE_RELATIVE_POSITION_BEHIND
Definition: legato_common.h:318
leRect
struct leRect leRect
This struct represents a rectangle.
leColorBlend_ARGB_8888
LIB_EXPORT leColor leColorBlend_ARGB_8888(leColor fore, leColor back)
Get color from ARGB blend.
Definition: legato_color_blend.c:125
leBool
leBool
This enum represents booleans.
Definition: legato_common.h:157
LE_DIRECTION_DOWN
@ LE_DIRECTION_DOWN
Definition: legato_common.h:265
LE_FALSE
@ LE_FALSE
Definition: legato_common.h:158
LE_VALIGN_TOP
@ LE_VALIGN_TOP
Definition: legato_common.h:182
leSize
This structure is used represents the size of an item.
Definition: legato_common.h:381
LE_RELATIVE_POSITION_RIGHTOF
@ LE_RELATIVE_POSITION_RIGHTOF
Definition: legato_common.h:317
LE_HALIGN_LEFT
@ LE_HALIGN_LEFT
Definition: legato_common.h:207
leRotationDirection
leRotationDirection
This enum represents the two rotation direction modes for objects.
Definition: legato_common.h:289
lePoint
struct lePoint lePoint
This structure represents a integer Cartesian point.
leColorConvert
LIB_EXPORT leColor leColorConvert(leColorMode mode_in, leColorMode mode_out, leColor color)
Convert to color value.
Definition: legato_color_convert.c:579
leMargin
This struct represents the four margin settings for objects.
Definition: legato_common.h:231
leMargin::right
uint8_t right
Definition: legato_common.h:234
LE_VALIGN_BOTTOM
@ LE_VALIGN_BOTTOM
Definition: legato_common.h:184
LE_DIRECTION_UP
@ LE_DIRECTION_UP
Definition: legato_common.h:267
leChar
uint16_t leChar
This typedef represents Legato character.
Definition: legato_common.h:424
LE_RELATIVE_POSITION_LEFTOF
@ LE_RELATIVE_POSITION_LEFTOF
Definition: legato_common.h:314
leScaleInteger
LIB_EXPORT uint32_t leScaleInteger(uint32_t num, uint32_t oldMax, uint32_t newMax)
Calculate the scale of an integer.
Definition: legato_math.c:256
leMargin::top
uint8_t top
Definition: legato_common.h:233
leRelativePosition
leRelativePosition
This enum represents the relative position modes for objects.
Definition: legato_common.h:313
leColorValue
LIB_EXPORT leColor leColorValue(leColorMode mode, leColorName name)
Get color by name and mode.
Definition: legato_color_value.c:51
LE_TRUE
@ LE_TRUE
Definition: legato_common.h:159
LE_RELATIVE_POSITION_BELOW
@ LE_RELATIVE_POSITION_BELOW
Definition: legato_common.h:316
LE_RELATIVE_POSITION_ABOVE
@ LE_RELATIVE_POSITION_ABOVE
Definition: legato_common.h:315
leSize::height
int32_t height
Definition: legato_common.h:383
LE_DIRECTION_RIGHT
@ LE_DIRECTION_RIGHT
Definition: legato_common.h:264
leMargin
struct leMargin leMargin
This struct represents the four margin settings for objects.
leBuffer
void * leBuffer
This typedef represents general-purpose buffer.
Definition: legato_common.h:417
leMargin::bottom
uint8_t bottom
Definition: legato_common.h:235
LE_CLOCKWISE
@ LE_CLOCKWISE
Definition: legato_common.h:291
leVAlignment
leVAlignment
This enum represents the vertical alignment mode of objects.
Definition: legato_common.h:181
lePoint
This structure represents a integer Cartesian point.
Definition: legato_common.h:357
leColorBilerp
LIB_EXPORT leColor leColorBilerp(leColor c00, leColor c01, leColor c10, leColor c11, uint32_t xper, uint32_t yper, leColorMode mode)
Get color from bi-linear interpolation of four colors.
Definition: legato_color_lerp.c:301