MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_touchtest.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_widget_touchtest.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements graphical touch test (box) widget functions.
38 *******************************************************************************/
39 
46 #ifndef LEGATO_TOUCHTEST_H
47 #define LEGATO_TOUCHTEST_H
48 
50 
51 #if LE_TOUCHTEST_WIDGET_ENABLED == 1
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
58 
59 /* internal use only */
64 #define LE_TOUCHTEST_MEMORY_SIZE 20
65 
70 // *****************************************************************************
71 // *****************************************************************************
72 // Section: Data Types and Constants
73 // *****************************************************************************
74 // *****************************************************************************
75 
76 // *****************************************************************************
77 /* Enumeration:
78  leTouchTestState
79 
80  Summary:
81  Touch test states
82 
83  Description:
84 
85 
86  Remarks:
87  None.
88 */
94 typedef enum leTouchTestState
95 {
96  LE_TOUCHTEST_STATE_UP,
97  LE_TOUCHTEST_STATE_DOWN
98 } leTouchTestState;
99 
100 typedef struct leTouchTestWidget leTouchTestWidget;
101 
102 // *****************************************************************************
103 /* Function Pointer:
104  leTouchTestWidget_PointAddedEventCallback
105 
106  Summary:
107  Point added event function callback type
108 */
113 typedef void (* leTouchTestWidget_PointAddedEventCallback)(leTouchTestWidget*, lePoint*);
114 
115 
116 /* internal use only */typedef struct leTouchTestWidget leTouchTestWidget;
121 
122 #define LE_TOUCHTESTWIDGET_VTABLE(THIS_TYPE) \
123  LE_WIDGET_VTABLE(THIS_TYPE) \
124  \
125  leResult (*addPoint)(THIS_TYPE* _this, lePoint* pnt); \
126  leResult (*clearPoints)(THIS_TYPE* _this); \
127  leTouchTestWidget_PointAddedEventCallback (*getPointAddedEventCallback)(const THIS_TYPE* _this); \
128  leResult (*setPointAddedEventCallback)(THIS_TYPE* _this, leTouchTestWidget_PointAddedEventCallback cb); \
129 
130 typedef struct leTouchTestWidgetVTable
131 {
132  LE_TOUCHTESTWIDGET_VTABLE(leTouchTestWidget)
133 } leTouchTestWidgetVTable;
134 
142 // *****************************************************************************
143 /* Structure:
144  leTouchTestWidget
145 
146  Summary:
147  Implementation of a touch test widget struct
148 
149  Description:
150  The touch test widget is a specialized widget that displays intersecting
151  lines based on input events. This can help visualize touch interaction
152  and aid determining accurate input coordinates.
153 
154  Remarks:
155  None.
156 */
163 typedef struct leTouchTestWidget
164 {
165  leWidget widget; // widget base class
166 
167  const leTouchTestWidgetVTable* fn;
168 
169  leTouchTestState state; // touch test state
170 
171  lePoint pnts[LE_TOUCHTEST_MEMORY_SIZE]; // touch point array
172  uint32_t size; // current number of valid touch points
173 
174  uint32_t start; // first valid touch point
175  uint32_t next; // next available touch point entry
176 
177  leTouchTestWidget_PointAddedEventCallback cb; // point added callback
178 } leTouchTestWidget;
179 
180 // *****************************************************************************
181 // *****************************************************************************
182 // Section: Routines
183 // *****************************************************************************
184 // *****************************************************************************
185 
197 leTouchTestWidget* leTouchTestWidget_New(void);
198 
209 void leTouchTestWidget_Constructor(leTouchTestWidget* wgt);
210 
211 #ifdef _DOXYGEN_
212 #define THIS_TYPE struct leWidget
213 
214 // *****************************************************************************
227 virtual leResult addPoint(leTouchTestWidget* _this,
228  lePoint* pnt);
229 
230 // *****************************************************************************
241 virtual leResult clearPoints(leTouchTestWidget* _this);
242 
243 // *****************************************************************************
257 virtual leResult setPointAddedEventCallback(leTouchTestWidget* _this,
258  leTouchTestWidget_PointAddedEventCallback cb);
259 
260 #undef THIS_TYPE
261 #endif
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 
267 #endif // LE_TOUCHTEST_WIDGET_ENABLED
268 #endif /* LEGATO_TOUCHTEST_H */
Common macros and definitions used by Legato.
leResult
This enum represents function call results.
Definition: legato_common.h:123
Used to define a widget.
Definition: legato_widget.h:624
This structure represents a integer Cartesian point.
Definition: legato_common.h:346
Legato widget definitions.
Definition: widget.py:1