MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_drawsurface.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_drawsurface.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements surface container drawing functions.
38 *******************************************************************************/
39 
46 #ifndef LEGATO_DRAWSURFACE_H
47 #define LEGATO_DRAWSURFACE_H
48 
50 
51 #if LE_DRAWSURFACE_WIDGET_ENABLED == 1
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
58 
59 typedef struct leDrawSurfaceWidget leDrawSurfaceWidget;
60 
61 // *****************************************************************************
62 /* Function Pointer:
63  leDrawSurfaceWidget_DrawCallback
64 
65  Summary:
66  Draw surface draw event function callback type
67 */
73 typedef leBool (* leDrawSurfaceWidget_DrawCallback)(leDrawSurfaceWidget* sfc,
74  leRect* bounds);
75 
76 // *****************************************************************************
77 // *****************************************************************************
78 // Section: Data Types and Constants
79 // *****************************************************************************
80 // *****************************************************************************
81 
82 /* internal use only */
87 typedef struct leDrawSurfaceWidget leDrawSurfaceWidget;
88 
89 #define LE_DRAWSURFACEWIDGET_VTABLE(THIS_TYPE) \
90  LE_WIDGET_VTABLE(THIS_TYPE) \
91  \
92  leDrawSurfaceWidget_DrawCallback (*getDrawCallback)(const THIS_TYPE* _this); \
93  leResult (*setDrawCallback)(THIS_TYPE* _this, leDrawSurfaceWidget_DrawCallback cb); \
94 
95 typedef struct leDrawSurfaceWidgetVTable
96 {
97  LE_DRAWSURFACEWIDGET_VTABLE(leDrawSurfaceWidget)
98 } leDrawSurfaceWidgetVTable;
99 
105 // *****************************************************************************
106 /* Structure:
107  leDrawSurfaceWidget
108 
109  Summary:
110  Implementation of a Drawsurface widget.
111 
112  Description:
113  A draw surface widget is a special widget that allows an application to
114  perform custom HAL draw calls during Legato's paint loop. To use, create
115  and add a draw surface widget to the desired place in the widget tree.
116  Then register for the callback through the API
117  'leDrawSurfaceWidget_SetDrawCallback'. This callback occurs during the
118  paint loop. The application should then be free to adjust the HAL
119  draw state and issue draw calls as desired. The HAL layer, buffer, or
120  context state must not be adjusted in any way.
121 
122  It is also important to not stall for too long during the draw callback.
123 
124  Remarks:
125  None.
126 */
127 
139 typedef struct leDrawSurfaceWidget
140 {
141  leWidget widget; // the widget base class
142 
143  const leDrawSurfaceWidgetVTable* fn;
144 
145  leDrawSurfaceWidget_DrawCallback cb; // the draw callback
146 } leDrawSurfaceWidget;
147 
148 // *****************************************************************************
149 // *****************************************************************************
150 // Section: Routines
151 // *****************************************************************************
152 // *****************************************************************************
153 
165 leDrawSurfaceWidget* leDrawSurfaceWidget_New(void);
166 
177 void leDrawSurfaceWidget_Constructor(leDrawSurfaceWidget* sfc);
178 // *****************************************************************************
179 
180 #ifdef _DOXYGEN_
181 #define THIS_TYPE struct leWidget
182 
183 // *****************************************************************************
194 virtual leDrawSurfaceWidget_DrawCallback getDrawCallback(const leDrawSurfaceWidget* _this);
195 
196 // *****************************************************************************
210 virtual leResult setDrawCallback(leDrawSurfaceWidget* _this,
211  leDrawSurfaceWidget_DrawCallback cb);
212 
213 #undef THIS_TYPE
214 #endif
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #endif // LE_DRAWSURFACE_WIDGET_ENABLED
221 #endif /* LEGATO_DRAWSURFACE_H */
Common macros and definitions used by Legato.
leResult
This enum represents function call results.
Definition: legato_common.h:123
This struct represents a rectangle.
Definition: legato_common.h:394
Used to define a widget.
Definition: legato_widget.h:624
Legato widget definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
Definition: widget.py:1