MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_utils.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_utils.h
32 
33  Summary:
34  General internal utilities for the library
35 
36 *******************************************************************************/
37 
44 #ifndef LEGATO_UTILS_H
45 #define LEGATO_UTILS_H
46 
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 typedef struct leWidget leWidget;
56 typedef struct leList leList;
57 
58 #define LE_TEST_FLAG(val, flag) ((val & flag) > 0)
59 
60 // *****************************************************************************
61 // *****************************************************************************
62 // Section: Routines
63 // *****************************************************************************
64 // *****************************************************************************
65 
80  int32_t x,
81  int32_t y);
82 
98  lePoint* pnt);
99 
114  lePoint* pnt);
115 
130  leRect* rect);
131 
132 /* Function:
133  void leUtils_RectToParentSpace(leWidget* widget, leRect* rect)
134 
135  Summary:
136  Converts a rectangle from widget local space to widget parent
137  space. Widget must be a child of a layer for this to function.
138 
139  Parameters:
140  leWidget* widget - the subject widget
141  leRect* rect - the rectangle to convert
142 
143  Returns:
144  void
145 */
161  leRect* rect);
162 
177  leRect* rect);
178 
193  leRect* rect);
194 
209  const leWidget* child);
210 
223 void leUtils_ClipRectToAncestors(const leWidget* wgt,
224  struct leRect* rct);
225 
238 
239 /* Function:
240  void leUtils_ArrangeRectangle(leRect* sub,
241  leRect obj,
242  leRect bounds,
243  leHAlignment hAlignment,
244  leVAlignment vAlignment,
245  leRelativePosition position,
246  uint8_t leftMargin,
247  uint8_t topMargin,
248  uint8_t rightMargin,
249  uint8_t bottomMargin,
250  uint16_t rectMargin)
251 
252  Summary:
253  Calculates the position of a rectangle within the given bounds and
254  in accordance with the given parameters. A use case for this is
255  when an image and a text rectangle must be arranged in a button box.
256  This version of the algorithm will calculate the location of the
257  image rectangle.
258 
259  Parameters:
260  leRect* sub - the bounds of the subject rectangle (image)
261  leRect obj - the bounds of the object rectangle (text)
262  leRect bounds - the bounds of the bounding rectangle (widget)
263  leHAlignment hAlignment - the horizontal alignment of the rects
264  leVAlignment vAlignment - the vertical alignment of the rects
265  leRelativePosition position - the relative position of the rectangles
266  uint8_t leftMargin - the left margin of the bounding rectangle
267  uint8_t topMargin - the top margin of the bounding rectangle
268  uint8_t rightMargin - the right margin of the bounding rectangle
269  uint8_t bottomMargin - the bottom margin of the bounding rectangle
270  uint16_t rectMargin - the distance between the image and the text rects
271 
272  Returns:
273  void
274 
275  Remarks:
276  The x and y position of sub will be manipulated by this function. The
277  dimensions of the rectangle should be set before calling and should
278  remain unchanged after execution.
279 */
294  leRect obj,
295  leRect bounds,
296  leHAlignment hAlignment,
297  leVAlignment vAlignment,
298  leRelativePosition position,
299  uint8_t leftMargin,
300  uint8_t topMargin,
301  uint8_t rightMargin,
302  uint8_t bottomMargin,
303  uint16_t rectMargin);
304 
305 /* Function:
306  void leUtils_ArrangeRectangleRelative(leRect* sub,
307  leRect obj,
308  leRect bounds,
309  leHAlignment hAlignment,
310  leVAlignment vAlignment,
311  leRelativePosition position,
312  uint8_t leftMargin,
313  uint8_t topMargin,
314  uint8_t rightMargin,
315  uint8_t bottomMargin,
316  uint16_t rectMargin)
317 
318  Summary:
319  Calculates the position of a rectangle within the given bounds and
320  in accordance with the given parameters. A use case for this is
321  when an image and a text rectangle must be arranged in a button box.
322  This version of the algorithm will calculate the location of the
323  text rectangle.
324 
325  Parameters:
326  leRect* sub - the bounds of the subject rectangle (text)
327  leRect obj - the bounds of the object rectangle (image)
328  leRect bounds - the bounds of the bounding rectangle (widget)
329  leHAlignment hAlignment - the horizontal alignment of the rects
330  leVAlignment vAlignment - the vertical alignment of the rects
331  leRelativePosition position - the relative position of the rectangles
332  uint8_t leftMargin - the left margin of the bounding rectangle
333  uint8_t topMargin - the top margin of the bounding rectangle
334  uint8_t rightMargin - the right margin of the bounding rectangle
335  uint8_t bottomMargin - the bottom margin of the bounding rectangle
336  uint16_t rectMargin - the distance between the image and the text rects
337 
338  Returns:
339  void
340 
341  Remarks:
342  The x and y position of sub will be manipulated by this function. The
343  dimensions of the rectangle should be set before calling and should
344  remain unchanged after execution.
345 */
363  leRect obj,
364  leRect bounds,
365  leHAlignment hAlignment,
366  leVAlignment vAlignment,
367  leRelativePosition position,
368  uint8_t leftMargin,
369  uint8_t topMargin,
370  uint8_t rightMargin,
371  uint8_t bottomMargin,
372  uint16_t rectMargin);
373 
374 void leUtils_PointLogicalToScratch(int16_t* x,
375  int16_t* y);
376 
377 void leUtils_RectLogicalToScratch(leRect* rect);
378 
379 
380 const leBlendLookupTable* leUtils_GetSchemeLookupTable(const leScheme* schm,
381  leColor foreground,
382  leColor background);
383 
384 #ifdef __cplusplus
385 }
386 #endif
387 
388 #endif // LEGATO_UTILS_H
Color definitions and functions.
void leUtils_ArrangeRectangle(leRect *sub, leRect obj, leRect bounds, leHAlignment hAlignment, leVAlignment vAlignment, leRelativePosition position, uint8_t leftMargin, uint8_t topMargin, uint8_t rightMargin, uint8_t bottomMargin, uint16_t rectMargin)
Calculates the position of a rectangle within the given bound.
Definition: legato_utils.c:239
void leUtils_PointScreenToLocalSpace(const leWidget *widget, lePoint *pnt)
Convert point from layer space into the local space of a widget.
Definition: legato_utils.c:91
Common macros and definitions used by Legato.
void leUtils_ArrangeRectangleRelative(leRect *sub, leRect obj, leRect bounds, leHAlignment hAlignment, leVAlignment vAlignment, leRelativePosition position, uint8_t leftMargin, uint8_t topMargin, uint8_t rightMargin, uint8_t bottomMargin, uint16_t rectMargin)
Calculates the position of a rectangle within the given bounds.
Definition: legato_utils.c:312
void leUtils_RectToParentSpace(const leWidget *widget, leRect *rect)
Convert rectangle from widget local space to widget parent space.
Definition: legato_utils.c:132
void leUtils_ClipRectToAncestors(const leWidget *wgt, struct leRect *rct)
Clips a widget's rectangle to the widget tree hierarchy.
Definition: legato_utils.c:183
leWidget * leUtils_PickFromWidget(const leWidget *wgt, int32_t x, int32_t y)
Finds the top-most visible widget in a layer at the given coordinates.
Definition: legato_utils.c:35
This struct represents a rectangle.
Definition: legato_common.h:394
leBool leUtils_ChildIntersectsParent(const leWidget *parent, const leWidget *child)
Determines if parent and child intersect.
Definition: legato_utils.c:167
void leUtils_RectToScreenSpace(const leWidget *widget, leRect *rect)
Convert rectangle from widget local space to screen space.
Definition: legato_utils.c:152
This struct represents a list.
Definition: legato_list.h:94
leHAlignment
This enum represents the horizontal alignment mode of objects.
Definition: legato_common.h:195
Used to define a widget.
Definition: legato_widget.h:624
leRelativePosition
This enum represents the relative position modes for objects.
Definition: legato_common.h:302
void leUtils_PointToScreenSpace(const leWidget *widget, lePoint *pnt)
Converts a point from widget space into screen space.
Definition: legato_utils.c:76
This struct represents a blend color lookup table.
Definition: legato_color.h:293
void leUtils_RectFromParentSpace(const leWidget *widget, leRect *rect)
Convert rectangle from widget parent space to widget local space.
Definition: legato_utils.c:142
This structure represents a integer Cartesian point.
Definition: legato_common.h:346
leBool
This enum represents booleans.
Definition: legato_common.h:146
void leUtils_ClipRectToParent(const leWidget *widget, leRect *rect)
Clips a rectangle to the parent of a widge.
Definition: legato_utils.c:113
leWidget * leUtils_GetNextHighestWidget(const leWidget *wgt)
Get next highest Z order widget in the tree from 'wgt'.
Definition: legato_utils.c:208
Definition: legato_scheme.h:154
Schemes support various properties that make it possible to customize the color of widgets...
leVAlignment
This enum represents the vertical alignment mode of objects.
Definition: legato_common.h:170
Definition: widget.py:1