MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_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_slider.h
32 
33  Summary:
34 
35  Description:
36  This module implements slider control widget functions.
37 *******************************************************************************/
38 
45 #ifndef LEGATO_SLIDER_H
46 #define LEGATO_SLIDER_H
47 
49 
50 #if LE_SLIDER_WIDGET_ENABLED == 1
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
58 
59 // *****************************************************************************
60 // *****************************************************************************
61 // Section: Data Types and Constants
62 // *****************************************************************************
63 // *****************************************************************************
64 
65 // *****************************************************************************
66 /* Enumeration:
67  leSliderState
68 
69  Summary:
70  Describes various slider states
71 
72  Description:
73 
74 
75  Remarks:
76  None.
77 */
82 typedef enum leSliderState
83 {
84  LE_SLIDER_STATE_NONE,
85  LE_SLIDER_STATE_HANDLE_DOWN,
86  LE_SLIDER_STATE_AREA_DOWN
87 } leSliderState;
88 
89 typedef struct leSliderWidget leSliderWidget;
90 
91 // *****************************************************************************
92 /* Function Pointer:
93  leSliderWidget_ValueChangedEvent
94 
95  Summary:
96  Value changed event function callback type
97 */
103 typedef void (* leSliderWidget_ValueChangedEvent)(leSliderWidget*);
104 
105 /* internal use only */typedef struct leSliderWidget leSliderWidget;
110 
111 #define LE_SLIDERWIDGET_VTABLE(THIS_TYPE) \
112  LE_WIDGET_VTABLE(THIS_TYPE) \
113  \
114  leOrientation (*getOrientation)(const THIS_TYPE* _this); \
115  leResult (*setOrientation)(THIS_TYPE* _this, leOrientation align, leBool swapDimensions); \
116  uint32_t (*getGripSize)(const THIS_TYPE* _this); \
117  leResult (*setGripSize)(THIS_TYPE* _this, uint32_t sz); \
118  uint32_t (*getMininumValue)(const THIS_TYPE* _this); \
119  leResult (*setMinimumValue)(THIS_TYPE* _this, uint32_t min); \
120  uint32_t (*getMaximumValue)(const THIS_TYPE* _this); \
121  leResult (*setMaximumValue)(THIS_TYPE* _this, uint32_t max); \
122  uint32_t (*getPercentage)(const THIS_TYPE* _this); \
123  leResult (*setPercentage)(THIS_TYPE* _this, uint32_t per); \
124  int32_t (*getValue)(const THIS_TYPE* _this); \
125  leResult (*setValue)(THIS_TYPE* _this, int32_t val); \
126  leResult (*step)(THIS_TYPE* _this, int32_t amt); \
127  leSliderWidget_ValueChangedEvent (*getValueChangedEventCallback)(const THIS_TYPE* _this); \
128  leResult (*setValueChangedEventCallback)(THIS_TYPE* _this, leSliderWidget_ValueChangedEvent cb);
129 
130 typedef struct leSliderWidgetVTable
131 {
132  LE_SLIDERWIDGET_VTABLE(leSliderWidget)
133 } leSliderWidgetVTable;
134 
146 typedef struct leSliderWidget
147 {
148  leWidget widget; // widget base class
149 
150  const leSliderWidgetVTable* fn;
151 
152  leSliderState state; // slider state
153  leOrientation alignment; // slider alignment
154 
155  int32_t min; // slider min value
156  int32_t max; // slider max value
157  int32_t value; // slider current value
158  uint32_t grip; // slider grip size
159 
160  leSliderWidget_ValueChangedEvent valueChangedEvent; // value changed event
161 
162  lePoint handleDownOffset;
163 } leSliderWidget;
164 
165 // *****************************************************************************
166 // *****************************************************************************
167 // Section: Routines
168 // *****************************************************************************
169 // *****************************************************************************
170 
171 // *****************************************************************************
172 /* Function:
173  leSliderWidget* leSliderWidget_New()
174 
175  Summary:
176  Allocates memory for a new widget of this type. The application is
177  responsible for the managment of this memory until the widget is added to
178  a widget tree.
179 
180  Description:
181 
182 
183  Parameters:
184 
185  Returns:
186  leSliderWidget*
187 
188  Remarks:
189  Use leWidget_Delete() to free this pointer.
190 */
202 leSliderWidget* leSliderWidget_New(void);
203 
214 void leSliderWidget_Constructor(leSliderWidget* sld);
215 
216 #ifdef _DOXYGEN_
217 #define THIS_TYPE struct leWidget
218 
219 // *****************************************************************************
220 /* Virtual Member Function:
221  leOrientation getOrientation(const leSliderWidget* _this)
222 
223  Summary:
224  Gets the slider orientation
225 
226  Description:
227  Gets the slider orientation
228 
229  Parameters:
230  const leSliderWidget* _this - The Slider widget to operate on
231 
232  Remarks:
233  Usage - _this->fn->getOrientation(_this);
234 
235  Returns:
236  leOrientation - the orientation value
237 */
248 leOrientation getOrientation(const leSliderWidget* _this);
249 
250 
251 // *****************************************************************************
252 /* Virtual Member Function:
253  leResult
254 setOrientation(leSliderWidget* _this,
255  leOrientation align,
256  leBool swapDimensions)
257  Summary:
258  Sets the slider orientation
259 
260  Description:
261  Sets the slider orientation
262 
263  Parameters:
264  leSliderWidget* _this - The Slider widget to operate on
265  leOrientation align - the orientation value
266  leBool swapDimensions - swap the width and height values when changing this
267 
268  Remarks:
269  Usage - _this->fn->setOrientation(_this, align, swapDimensions);
270 
271  Returns:
272  leResult - the result of the operation
273 */
290 virtual leResult setOrientation(leSliderWidget* _this,
291  leOrientation align,
292  leBool swapDimensions);
293 
294 // *****************************************************************************
295 /* Virtual Member Function:
296  uint32_t getMaximumValue(const leSliderWidget* _this)
297 
298  Summary:
299  Gets the minimum slider value
300 
301  Description:
302  Gets the minimum slider value
303 
304  Parameters:
305  const leSliderWidget* _this - The Slider widget to operate on
306 
307  Remarks:
308  Usage - _this->fn->getMaximumValue(_this);
309 
310  Returns:
311  uint32_t - the value
312 */
323 virtual uint32_t getMaximumValue(const leSliderWidget* _this);
324 
325 // *****************************************************************************
326 /* Virtual Member Function:
327  leResult setMaximumValue(leSliderWidget* _this,
328  uint32_t val)
329 
330  Summary:
331  Sets the minimum slider value
332 
333  Description:
334  Sets the minimum slider value
335 
336  Parameters:
337  leSliderWidget* _this - The Slider widget to operate on
338  uint32_t val - the value
339 
340  Remarks:
341  Usage - _this->fn->setMaximumValue(_this, val);
342 
343  Returns:
344  leResult - the result of the operation
345 */
359 leResult setMaximumValue(leSliderWidget* _this,
360  uint32_t val);
361 
362 
363 // *****************************************************************************
364 /* Virtual Member Function:
365  uint32_t getMaximumValue(const leSliderWidget* _this)
366 
367  Summary:
368  Gets the maximum slider value
369 
370  Description:
371  Gets the maximum slider value
372 
373  Parameters:
374  const leSliderWidget* _this - The Slider widget to operate on
375 
376  Remarks:
377  Usage - _this->fn->getMaximumValue(_this);
378 
379  Returns:
380  uint32_t - the value
381 */
392 virtual uint32_t getMaximumValue(const leSliderWidget* _this);
393 
394 
395 // *****************************************************************************
396 /* Virtual Member Function:
397  leResult setMaximumValue(leSliderWidget* _this,
398  uint32_t val)
399 
400  Summary:
401  Sets the maximum slider value
402 
403  Description:
404  Sets the maximum slider value
405 
406  Parameters:
407  leSliderWidget* _this - The Slider widget to operate on
408  uint32_t val - the value
409 
410  Remarks:
411  Usage - _this->fn->setMaximumValue(_this, val);
412 
413  Returns:
414  leResult - the result of the operation
415 */
429 virtual leResult setMaximumValue(leSliderWidget* _this,
430  uint32_t val);
431 
432 
433 // *****************************************************************************
434 /* Virtual Member Function:
435  uint32_t getPercentage(const leSliderWidget* _this)
436 
437  Summary:
438  Gets the value as a percentage
439 
440  Description:
441  Gets the value as a percentage
442 
443  Parameters:
444  const leSliderWidget* _this - The Slider widget to operate on
445 
446  Remarks:
447  Usage - _this->fn->getPercentage(_this);
448 
449  Returns:
450  uint32_t - the percentage value
451 */
462 virtual uint32_t getPercentage(const leSliderWidget* _this);
463 
464 
465 // *****************************************************************************
466 /* Virtual Member Function:
467  leResult setPercentage(leSliderWidget* _this,
468  uint32_t val)
469 
470  Summary:
471  Sets the value using a percentage
472 
473  Description:
474  Sets the value using a percentage
475 
476  Parameters:
477  leSliderWidget* _this - The Slider widget to operate on
478  uint32_t val - the value
479 
480  Remarks:
481  Usage - _this->fn->setPercentage(_this, val);
482 
483  Returns:
484  leResult - the result of the operation
485 */
499 virtual leResult setPercentage(leSliderWidget* _this,
500  uint32_t val);
501 
502 
503 // *****************************************************************************
504 /* Virtual Member Function:
505  uint32_t getValue(const leSliderWidget* _this)
506 
507  Summary:
508  Gets the slider value
509 
510  Description:
511  Gets the slider value
512 
513  Parameters:
514  const leSliderWidget* _this - The Slider widget to operate on
515 
516  Remarks:
517  Usage - _this->fn->getValue(_this);
518 
519  Returns:
520  uint32_t - the value
521 */
532 virtual uint32_t getValue(const leSliderWidget* _this);
533 
534 
535 // *****************************************************************************
536 /* Virtual Member Function:
537  leResult setValue(leSliderWidget* _this,
538  uint32_t val)
539 
540  Summary:
541  Sets the slider value
542 
543  Description:
544  Sets the slider value
545 
546  Parameters:
547  leSliderWidget* _this - The Slider widget to operate on
548  uint32_t val - the value
549 
550  Remarks:
551  Usage - _this->fn->setValue(_this, val);
552 
553  Returns:
554  leResult - the result of the operation
555 */
569 virtual leResult setPercentage(leSliderWidget* _this,
570  uint32_t val);
571 
572 
573 // *****************************************************************************
574 /* Virtual Member Function:
575  leResult step(leSliderWidget* _this,
576  int32_t amt)
577 
578  Summary:
579  Step the slider by an amount
580 
581  Description:
582  Step the slider by an amount
583 
584  Parameters:
585  leSliderWidget* _this - The Slider widget to operate on
586  int32_t amt - the step amount
587 
588  Remarks:
589  Usage - _this->fn->step(_this, amt);
590 
591  Returns:
592  leResult - the result of the operation
593 */
607 virtual leResult step(leSliderWidget* _this,
608  int32_t amt);
609 
620 virtual leSliderWidget_ValueChangedEvent getValueChangedEventCallback
621  (const leSliderWidget* _this);
622 
636 virtual leResult setValueChangedEventCallback(leSliderWidget* _this,
637  leSliderWidget_ValueChangedEvent cb);
638 
639 #undef THIS_TYPE
640 #endif
641 
642 #ifdef __cplusplus
643 }
644 #endif
645 
646 #endif // LE_SLIDER_WIDGET_ENABLED
647 #endif /* LEGATO_SLIDER_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
leOrientation
This enum represents the orientation modes for objects.
Definition: legato_common.h:329
This structure represents a integer Cartesian point.
Definition: legato_common.h:346
Legato widget definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
Definition: widget.py:1
Fixed string functions and definitions.