MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_circular_slider.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_circular_slider.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements slider drawing widget functions.
38 *******************************************************************************/
39 
46 #ifndef LEGATO_WIDGET_CIRCULAR_SLIDER_H
47 #define LEGATO_WIDGET_CIRCULAR_SLIDER_H
48 
50 
51 #if LE_CIRCULARSLIDER_WIDGET_ENABLED == 1
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
58 
59 // *****************************************************************************
60 // *****************************************************************************
61 // Section: Data Types and Constants
62 // *****************************************************************************
63 // *****************************************************************************
64 
65 // *****************************************************************************
66 /* Structure:
67  leCircularSliderButtonState
68 
69  Summary:
70  State of the slider button
71 
72  Description:
73  State of the slider button
74 
75  Remarks:
76  None.
77 */
83 typedef enum leCircularSliderButtonState
84 {
85  LE_CIRCULAR_SLIDER_STATE_UP,
86  LE_CIRCULAR_SLIDER_STATE_DOWN,
87 } leCircularSliderButtonState;
88 
89 // *****************************************************************************
90 /* Enumeration:
91  leCircularSliderWidgetArcType
92 
93  Summary:
94  The arcs that compose the circular slider
95 
96  Description:
97  The arcs that compose the circular slider
98 
99  Remarks:
100  None.
101 */
107 typedef enum leCircularSliderWidgetArcType
108 {
109  OUTSIDE_CIRCLE_BORDER,
110  INSIDE_CIRCLE_BORDER,
111  ACTIVE_AREA,
112  INACTIVE_AREA,
113  CIRCLE_BUTTON,
114 } leCircularSliderWidgetArcType;
115 
116 // *****************************************************************************
117 /* Structure:
118  leCircularSliderArc
119 
120  Summary:
121  Internal structure for the arcs in the circular slider widget
122 
123  Description:
124  Describs the arc instances in the circular gauge widget
125 
126  Remarks:
127  None.
128 */
134 typedef struct leCircularSliderArc
135 {
136  leBool visible;
137  uint32_t radius;
138  uint32_t thickness;
139  const leScheme* scheme;
140 } leCircularSliderArc;
141 
142 typedef struct leCircularSliderWidget leCircularSliderWidget;
143 
144 // *****************************************************************************
145 /* Function Pointer:
146  leCircularSliderWidget_PressedEvent
147 
148  Summary:
149  Button pressed event function callback type
150 */
156 typedef void (*leCircularSliderWidget_PressedEvent)(leCircularSliderWidget *, int32_t);
157 
158 // *****************************************************************************
159 /* Function Pointer:
160  leCircularSliderWidget_ValueChangedEvent
161 
162  Summary:
163  Value changed event function callback type
164 */
170 typedef void (*leCircularSliderWidget_ValueChangedEvent)(leCircularSliderWidget *, int32_t);
171 
172 // *****************************************************************************
173 /* Function Pointer:
174  leCircularSliderWidget_ReleasedEvent
175 
176  Summary:
177  Button released event function callback type
178 */
184 typedef void (*leCircularSliderWidget_ReleasedEvent)(leCircularSliderWidget *, int32_t);
185 
186 /* internal use only */
191 #define LE_CIRCULARSLIDERWIDGET_VTABLE(THIS_TYPE) \
192  LE_WIDGET_VTABLE(THIS_TYPE) \
193  \
194  uint32_t (*getRadius)(const THIS_TYPE* _this); \
195  leResult (*setRadius)(THIS_TYPE* _this, uint32_t rad); \
196  int32_t (*getStartAngle)(const THIS_TYPE* _this); \
197  leResult (*setStartAngle)(THIS_TYPE* _this, int32_t ang); \
198  int32_t (*getSpanAngle)(const THIS_TYPE* _this); \
199  leResult (*setSpanAngle)(THIS_TYPE* _this, int32_t ang); \
200  uint32_t (*getArcThickness)(const THIS_TYPE* _this, leCircularSliderWidgetArcType type); \
201  leResult (*setArcThickness)(THIS_TYPE* _this, leCircularSliderWidgetArcType type, uint32_t thck); \
202  uint32_t (*getArcRadius)(const THIS_TYPE* _this, leCircularSliderWidgetArcType type); \
203  leResult (*setArcRadius)(THIS_TYPE* _this, leCircularSliderWidgetArcType type, uint32_t rad); \
204  leScheme* (*getArcScheme)(const THIS_TYPE* _this, leCircularSliderWidgetArcType type); \
205  leResult (*setArcScheme)(THIS_TYPE* _this, leCircularSliderWidgetArcType type, const leScheme* schm); \
206  leBool (*getArcVisible)(const THIS_TYPE* _this, leCircularSliderWidgetArcType type); \
207  leResult (*setArcVisible)(THIS_TYPE* _this, leCircularSliderWidgetArcType type, leBool vis); \
208  uint32_t (*getValue)(const THIS_TYPE* _this); \
209  leResult (*setValue)(THIS_TYPE* _this, uint32_t val); \
210  leBool (*getRoundEdges)(const THIS_TYPE* _this); \
211  leResult (*setRoundEdges)(THIS_TYPE* _this, leBool rnd); \
212  leBool (*getStickyButton)(const THIS_TYPE* _this); \
213  leResult (*setStickyButton)(THIS_TYPE* _this, leBool stk); \
214  uint32_t (*getSnapDivisions)(const THIS_TYPE* _this); \
215  leResult (*setSnapDivisions)(THIS_TYPE* _this, uint32_t div); \
216  leBool (*getTouchOnButtonOnly)(const THIS_TYPE* _this); \
217  leResult (*setTouchOnButtonOnly)(THIS_TYPE* _this, leBool tch); \
218  leRotationDirection (*getDirection)(const THIS_TYPE* _this); \
219  leResult (*setDirection)(THIS_TYPE* _this, leRotationDirection dir); \
220  leResult (*setPressedEventCallback)(THIS_TYPE* _this, leCircularSliderWidget_PressedEvent cb); \
221  leResult (*setValueChangedEventCallback)(THIS_TYPE* _this, leCircularSliderWidget_ValueChangedEvent cb); \
222  leResult (*setReleasedEventCallback)(THIS_TYPE* _this, leCircularSliderWidget_ReleasedEvent cb); \
223 
224 typedef struct leCircularSliderWidgetVTable
225 {
226  LE_CIRCULARSLIDERWIDGET_VTABLE(leCircularSliderWidget)
227 } leCircularSliderWidgetVTable;
228 
234 // *****************************************************************************
235 /* Structure:
236  leCircularSliderWidget
237 
238  Summary:
239  Implementation of a slider widget.
240 
241  Description:
242  A slider widget draws a slider of the specified origin and radius inside
243  the widget bounds. All coordinates are expressed in local widget space.
244 
245  The color of the slider is determined by the widget scheme's 'foreground'
246  color.
247 
248  Remarks:
249  None.
250 */
251 typedef struct leCircularSliderWidget
252 {
253  leWidget widget; // base widget header
254 
255  const leCircularSliderWidgetVTable* fn;
256 
257  uint32_t radius; // the radius of the slider
258 
259  int32_t startAngle; //the start angle of the slider
260  int32_t spanAngle; //the span angle of the slider
261 
262  uint32_t value; //the value of the slider
263 
264  leBool roundEdges; //round edges
265  leBool sticky; //snaps to start value before wrapping around
266  uint32_t snapDivisions;
267  leBool buttonTouch; //only button is active to touch
268 
269  leRotationDirection direction; //the direction of the slider
270 
271  leCircularSliderArc activeArc; //the arc for the slider value
272  leCircularSliderArc inActiveArc; //the arc for the slider remainder
273  leCircularSliderArc outsideBorderArc; //the arc for the outside border
274  leCircularSliderArc insideBorderArc; //the arc for the inside border
275  leCircularSliderArc circleButtonArc; //the arc for the circle button
276 
277  leCircularSliderButtonState btnState; //the state of the circular slider button
278 
279  leCircularSliderWidget_PressedEvent pressedCallback;
280  leCircularSliderWidget_ValueChangedEvent valueChangedCallback;
281  leCircularSliderWidget_ReleasedEvent releasedCallback;
282 } leCircularSliderWidget;
283 
284 // *****************************************************************************
285 // *****************************************************************************
286 // Section: Routines
287 // *****************************************************************************
288 // *****************************************************************************
289 
301 leCircularSliderWidget* leCircularSliderWidget_New(void);
302 
313 void leCircularSliderWidget_Constructor(leCircularSliderWidget* wgt);
314 
315 #ifdef _DOXYGEN_
316 #define THIS_TYPE struct leWidget
317 
318 // *****************************************************************************
329 virtual uint32_t getRadius(const leCircularSliderWidget* _this);
330 
331 
332 // *****************************************************************************
346 virtual leResult setRadius(leCircularSliderWidget* _this,
347  uint32_t rad);
348 
349 
350 // *****************************************************************************
361 virtual uint32_t getStartAngle(const leCircularSliderWidget* _this);
362 
363 
364 // *****************************************************************************
378 virtual leResult setStartAngle(leCircularSliderWidget* _this,
379  int32_t ang);
380 
381 
394 virtual uint32_t getArcThickness(const leCircularSliderWidget* _this,
395  leCircularSliderWidgetArcType type);
396 
397 
398 
399 
415 virtual leResult setArcThickness(leCircularSliderWidget* _this,
416  leCircularSliderWidgetArcType type,
417  uint32_t thck);
418 
419 / *****************************************************************************
432 virtual uint32_t getArcRadius(const leCircularSliderWidget* _this,
433  leCircularSliderWidgetArcType type);
434 
435 
436 // *****************************************************************************
451 virtual leResult setArcRadius(leCircularSliderWidget* _this,
452  leCircularSliderWidgetArcType type,
453  uint32_t rad);
454 
455 
468 virtual leScheme* getArcScheme(const leCircularSliderWidget* _this,
469  leCircularSliderWidgetArcType type);
470 
487 leResult setArcScheme(leCircularSliderWidget* _this,
488  leCircularSliderWidgetArcType type,
489  const leScheme* schm;
490 
491 * @brief Get arc visibility
492 * @details Gets arc visilibilty for <span class="param">type</span> using
493 * <span class="param">_this</span>.
494 * @code
495 * leCircularSliderWidget* _this;
496 * leCircularSliderWidgetArcType type;
497 * leBool visible = _this->fn->getArcVisible(_this, axis);
498 * @endcode
499 * @param _this is the widget to query.
500 * @param type the type to query.
501 * @returns LE_TRUE if set, otherwise LE_FALSE;
502 */
503 virtual leBool getArcVisible(const leCircularSliderWidget* _this,
504  leCircularSliderWidgetArcType type);
505 
520 virtual leBool setArcVisible(const leCircularSliderWidget* _this,
521  leCircularSliderWidgetArcType type);
522 
523 // *****************************************************************************
534 virtual uint32_t getStartValue(const leCircularSliderWidget* _this);
535 
536 
537 // *****************************************************************************
551 virtual leResult setStartValue(leCircularSliderWidget* _this,
552  uint32_t val);
553 
554 / *****************************************************************************
565 virtual uint32_t getEndValue(const leCircularSliderWidget* _this);
566 
567 
568 // *****************************************************************************
582 virtual leResult setEndValue(leCircularSliderWidget* _this,
583  uint32_t val);
584 
585 // *****************************************************************************
596 virtual leBool getRoundEdges(const leCircularSliderWidget* _this);
597 
598 
599 // *****************************************************************************
613 virtual leResult setRoundEdges(leCircularSliderWidget* _this,
614  leBool rnd);
615 
616 
617 // *****************************************************************************
628 virtual leBool getStickyButton(const leCircularSliderWidget* _this);
629 
630 
631 // *****************************************************************************
645 virtual leResult setStickyButton(leCircularSliderWidget* _this,
646  leBool stk);
647 
648 // *****************************************************************************
659 virtual leBool getTouchOnButtonOnly(const leCircularSliderWidget* _this);
660 
661 
662 // *****************************************************************************
676 virtual leResult setTouchOnButtonOnly(leCircularSliderWidget* _this,
677  leBool tch);
678 
679 
680 // *****************************************************************************
691 virtual leRotationDirection getDirection(const leCircularSliderWidget* _this);
692 
693 
694 // *****************************************************************************
708 virtual leResult setDirection(leCircularSliderWidget* _this,
709  leRotationDirection dir);
710 
711 
725 virtual leResult setPressedEventCallback(leCircularSliderWidget* _this,
726  leCircularSliderWidget_PressedEvent cb);
727 
728 
742 leResult setValueChangedEventCallback(leCircularSliderWidget* _this,
743  leCircularSliderWidget_ValueChangedEvent cb)
744 
745 
746 
759 virtual leResult setReleasedEventCallback(leCircularSliderWidget* _this,
760  leCircularSliderWidget_ReleasedEvent cb);
761 
762 #undef THIS_TYPE
763 #endif
764 
765 #ifdef __cplusplus
766 }
767 #endif
768 
769 #endif // LE_CIRCULARSLIDER_WIDGET_ENABLED
770 #endif /* LEGATO_WIDGET_CIRCULAR_SLIDER_H */
Definition: legato_common.h:149
Common macros and definitions used by Legato.
leRotationDirection
This enum represents the two rotation direction modes for objects.
Definition: legato_common.h:278
leResult
This enum represents function call results.
Definition: legato_common.h:123
virtual leResult setStartAngle(leArcWidget *_this, int32_t angle)
Set start angle of an arc.
virtual uint32_t getRadius(const leArcWidget *_this)
Get radius of an arc.
Used to define a widget.
Definition: legato_widget.h:624
virtual leResult setRadius(leArcWidget *_this, uint32_t rad)
Set radius of an arc.
Definition: legato_common.h:148
Legato widget definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
virtual int32_t getStartAngle(const leArcWidget *_this)
Get start angle of the arc.
Definition: scheme.py:1
Definition: legato_scheme.h:154
Definition: widget.py:1