MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_imagesequence.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_imagesequence.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements image sequence (slide show) widget drawing functions.
38 *******************************************************************************/
39 
46 #ifndef LEGATO_IMAGESEQUENCE_H
47 #define LEGATO_IMAGESEQUENCE_H
48 
50 
51 #if LE_IMAGESEQUENCE_WIDGET_ENABLED
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
60 
61 /* internal use only */
66 #define LE_IMAGESEQ_RESTART -1
67 
72 typedef struct leImageSequenceWidget leImageSequenceWidget;
73 
74 // *****************************************************************************
75 /* Function Pointer:
76  leImageSequenceImageChangedEvent_FnPtr
77 
78  Summary:
79  Image changed event function callback type
80 */
86 typedef void (*leImageSequenceImageChangedEvent_FnPtr)(leImageSequenceWidget*);
87 
88 // *****************************************************************************
89 // *****************************************************************************
90 // Section: Data Types and Constants
91 // *****************************************************************************
92 // *****************************************************************************
93 
94 // *****************************************************************************
95 /* Enumeration:
96  leImageSequenceEntry
97 
98  Summary:
99  Image sequence entry definition
100 
101  Description:
102  Defines a single entry for the image sequence widget
103 
104  Remarks:
105  None.
106 */
111 typedef struct leImageSequenceEntry
112 {
113  const leImage* image; // image asset pointer
114 
115  uint32_t delay; // how many time units to display this entry
116 
117  leHAlignment halign; // the horizontal alignment for this entry
118  leVAlignment valign; // the vertical alignment for this entry
119 } leImageSequenceEntry;
120 
121 /* internal use only */
126 #define LE_IMAGESEQUENCEWIDGET_VTABLE(THIS_TYPE) \
127  LE_WIDGET_VTABLE(THIS_TYPE) \
128  \
129  uint32_t (*getImageCount)(const THIS_TYPE* _this); \
130  leResult (*setImageCount)(THIS_TYPE* _this, uint32_t cnt); \
131  leImage* (*getImage)(const THIS_TYPE* _this, uint32_t idx); \
132  leResult (*setImage)(THIS_TYPE* _this, uint32_t idx, const leImage* img); \
133  uint32_t (*getImageDelay)(const THIS_TYPE* _this, uint32_t idx); \
134  leResult (*setImageDelay)(THIS_TYPE* _this, uint32_t idx, uint32_t dly); \
135  leHAlignment (*getImageHAlignment)(const THIS_TYPE* _this, uint32_t idx); \
136  leResult (*setImageHAlignment)(THIS_TYPE* _this, uint32_t idx, leHAlignment align); \
137  leVAlignment (*getImageVAlignment)(const THIS_TYPE* _this, uint32_t idx); \
138  leResult (*setImageVAlignment)(THIS_TYPE* _this, uint32_t idx, leVAlignment align); \
139  leResult (*stop)(THIS_TYPE* _this); \
140  leResult (*play)(THIS_TYPE* _this); \
141  leResult (*rewind)(THIS_TYPE* _this); \
142  leBool (*isPlaying)(const THIS_TYPE* _this); \
143  leBool (*getRepeat)(const THIS_TYPE* _this); \
144  leResult (*setRepeat)(THIS_TYPE* _this, leBool rpt); \
145  leResult (*showImage)(THIS_TYPE* _this, uint32_t idx); \
146  leResult (*showNextImage)(THIS_TYPE* _this); \
147  leResult (*showPreviousImage)(THIS_TYPE* _this); \
148  leImageSequenceImageChangedEvent_FnPtr (*getImageChangedEventCallback)(const THIS_TYPE* _this); \
149  leResult (*setImageChangedEventCallback)(THIS_TYPE* _this, leImageSequenceImageChangedEvent_FnPtr cb); \
150 
151 typedef struct leImageSequenceWidgetVTable
152 {
153  LE_IMAGESEQUENCEWIDGET_VTABLE(leImageSequenceWidget)
154 } leImageSequenceWidgetVTable;
155 
161 // *****************************************************************************
170 typedef struct leImageSequenceWidget
171 {
172  leWidget widget; // widget base class
173 
174  const leImageSequenceWidgetVTable* fn;
175 
176  uint32_t count; // number of image entries for this widget
177  leImageSequenceEntry* images; // image entry array
178 
179  int32_t activeIdx; // currently displayed entry
180 
181  leBool playing; // indicates that the widget is automatically cycling
182  uint32_t time; // current cycle time
183 
184  leBool repeat; // indicates that the sequence should repeat when it
185  // reaches the end of the sequence
186 
187  leImageSequenceImageChangedEvent_FnPtr cb; // callback when the image changes
188 } leImageSequenceWidget;
189 
190 // *****************************************************************************
191 // *****************************************************************************
192 // Section: Routines
193 // *****************************************************************************
194 // *****************************************************************************
195 
207 leImageSequenceWidget* leImageSequenceWidget_New(void);
208 
219 void leImageSequenceWidget_Constructor(leImageSequenceWidget* wgt);
220 
221 #ifdef _DOXYGEN_
222 #define THIS_TYPE struct leWidget
223 
224 // *****************************************************************************
225 /* Virtual Member Function:
226  uint32_t getImageCount(const leImageSequenceWidget* _this)
227 
228  Summary:
229  Gets the image count
230 
231  Description:
232  Gets the image count
233 
234  Parameters:
235  const leImageSequenceWidget* _this - The image sequence widget to operate on
236 
237  Remarks:
238  Usage - _this->fn->getImageCount(_this);
239 
240  Returns:
241  uint32_t - the image count
242 */
253 virtual uint32_t getImageCount(const leImageSequenceWidget* _this);
254 
255 
256 // *****************************************************************************
257 /* Virtual Member Function:
258  leResult setImageCount(leImageSequenceWidget* _this,
259  uint32_t cnt)
260 
261  Summary:
262  Sets the image count
263 
264  Description:
265  Sets the image count
266 
267  Parameters:
268  leImageSequenceWidget* _this - The image sequence widget to operate on
269  uint32_t cnt - the image count
270 
271  Remarks:
272  Usage - _this->fn->setImageCount(_this, cnt);
273 
274  Returns:
275  leResult - the result of the operation
276 */
290 virtual leResult setImageCount(leImageSequenceWidget* _this,
291  uint32_t cnt);
292 
293 // *****************************************************************************
294 /* Virtual Member Function:
295  leImage* getImage(const leImageSequenceWidget* _this,
296  uint32_t idx)
297 
298  Summary:
299  Gets the image pointer
300 
301  Description:
302  Gets the image pointer
303 
304  Parameters:
305  const leImageSequenceWidget* _this - The image sequence widget to operate on
306  uint32_t idx - the index
307 
308  Remarks:
309  Usage - _this->fn->getImage(_this, idx);
310 
311  Returns:
312  leImage* - the image pointer
313 */
324 virtual leImage* getImage(const leImageSequenceWidget* _this,
325  uint32_t idx);
326 
327 // *****************************************************************************
328 /* Virtual Member Function:
329  leResult setImage(leImageSequenceWidget* _this,
330  uint32_t idx,
331  const leImage* img)
332 
333  Summary:
334  Sets the image pointer
335 
336  Description:
337  Sets the image pointer
338 
339  Parameters:
340  leImageSequenceWidget* _this - The image sequence widget to operate on
341  uint32_t idx - the index
342  const leImage* img - the image pointer
343 
344  Remarks:
345  Usage - _this->fn->setImage(_this, idx, img);
346 
347  Returns:
348  leResult - the result of the operation
349 */
365 virtual leResult setImage(leImageSequenceWidget* _this,
366  uint32_t idx,
367  const leImage* img);
368 
369 
370 // *****************************************************************************
371 /* Virtual Member Function:
372  uint32_t getImageDelay(const leImageSequenceWidget* _this,
373  uint32_t idx)
374 
375  Summary:
376  Gets the image cycle delay
377 
378  Description:
379  Gets the image cycle delay
380 
381  Parameters:
382  const leImageSequenceWidget* _this - The image sequence widget to operate on
383  uint32_t idx - the index
384 
385  Remarks:
386  Usage - _this->fn->getImageDelay(_this, idx);
387 
388  Returns:
389  uint32_t - the image delay
390 */
401 virtual uint32_t getImageDelay(const leImageSequenceWidget* _this,
402  uint32_t idx);
403 
404 // *****************************************************************************
405 /* Virtual Member Function:
406  leResult setImageDelay(leImageSequenceWidget* _this,
407  uint32_t idx,
408  uint32_t dly)
409 
410  Summary:
411  Sets the image cycle delay
412 
413  Description:
414  Sets the image cycle delay
415 
416  Parameters:
417  leImageSequenceWidget* _this - The image sequence widget to operate on
418  uint32_t idx - the index
419  uint32_t dly - the image delay
420 
421  Remarks:
422  Usage - _this->fn->setImageDelay(_this, idx, dly);
423 
424  Returns:
425  leResult - the result of the operation
426 */
443 virtual leResult setImageDelay(leImageSequenceWidget* _this,
444  uint32_t idx,
445  uint32_t dly);
446 
447 
448 // *****************************************************************************
449 /* Virtual Member Function:
450  leHAlignment getImageHAlignment(const leImageSequenceWidget* _this,
451  uint32_t idx)
452 
453  Summary:
454  Gets the image horizontal alignment
455 
456  Description:
457  Gets the image horizontal alignment
458 
459  Parameters:
460  const leImageSequenceWidget* _this - The image sequence widget to operate on
461  uint32_t idx - the index
462 
463  Remarks:
464  Usage - _this->fn->getImageHAlignment(_this, idx);
465 
466  Returns:
467  leHAlignment - the alignment
468 */
481 virtual leHAlignment getImageHAlignment(const leImageSequenceWidget* _this,
482  uint32_t idx);
483 
484 // *****************************************************************************
485 /* Virtual Member Function:
486  leResult setImageHAlignment(leImageSequenceWidget* _this,
487  uint32_t idx,
488  leHAlignment align)
489 
490  Summary:
491  Sets the image horizontal alignment
492 
493  Description:
494  Sets the image horizontal alignment
495 
496  Parameters:
497  leImageSequenceWidget* _this - The image sequence widget to operate on
498  uint32_t idx - the index
499  leHAlignment align - the alignment
500 
501  Remarks:
502  Usage - _this->fn->setImageHAlignment(_this, idx, align);
503 
504  Returns:
505  leResult - the result of the operation
506 */
523 virtual leResult setImageHAlignment(leImageSequenceWidget* _this,
524  uint32_t idx,
525  leHAlignment align);
526 
527 // *****************************************************************************
528 /* Virtual Member Function:
529  leVAlignment getImageVAlignment(const leImageSequenceWidget* _this,
530  uint32_t idx)
531 
532  Summary:
533  Gets the image vertical alignment
534 
535  Description:
536  Gets the image vertical alignment
537 
538  Parameters:
539  const leImageSequenceWidget* _this - The image sequence widget to operate on
540  uint32_t idx - the index
541 
542  Remarks:
543  Usage - _this->fn->getImageVAlignment(_this, idx);
544 
545  Returns:
546  leVAlignment - the alignment
547 */
560 virtual leVAlignment getImageVAlignment(const leImageSequenceWidget* _this,
561  uint32_t idx);
562 
563 // *****************************************************************************
564 /* Virtual Member Function:
565  leResult setImageVAlignment(leImageSequenceWidget* _this,
566  uint32_t idx,
567  leVAlignment align)
568 
569  Summary:
570  Sets the image vertical alignment
571 
572  Description:
573  Sets the image vertical alignment
574 
575  Parameters:
576  leImageSequenceWidget* _this - The image sequence widget to operate on
577  uint32_t idx - the index
578  leVAlignment align - the alignment
579 
580  Remarks:
581  Usage - _this->fn->setImageVAlignment(_this, idx, align);
582 
583  Returns:
584  leResult - the result of the operation
585 */
602 virtual leResult setImageVAlignment(leImageSequenceWidget* _this,
603  uint32_t idx,
604  leVAlignment align);
605 
606 // *****************************************************************************
607 /* Virtual Member Function:
608  leResult stop(leImageSequenceWidget* _this)
609 
610  Summary:
611  Stops the sequence from automatically cycling
612 
613  Description:
614  Stops the sequence from automatically cycling
615 
616  Parameters:
617  leImageSequenceWidget* _this - The image sequence widget to operate on
618 
619  Remarks:
620  Usage - _this->fn->stop(_this);
621 
622  Returns:
623  leResult - the result of the operation
624 */
636 virtual leResult stop(leImageSequenceWidget* _this);
637 
638 // *****************************************************************************
639 /* Virtual Member Function:
640  leResult play(leImageSequenceWidget* _this)
641 
642  Summary:
643  Starts the sequence automatic cycle
644 
645  Description:
646  Starts the sequence automatic cycle
647 
648  Parameters:
649  leImageSequenceWidget* _this - The image sequence widget to operate on
650 
651  Remarks:
652  Usage - _this->fn->play(_this);
653 
654  Returns:
655  leResult - the result of the operation
656 */
668 leResult play(leImageSequenceWidget* _this);
669 
670 // *****************************************************************************
671 /* Virtual Member Function:
672  leResult rewind(leImageSequenceWidget* _this)
673 
674  Summary:
675  Returns the sequence to the first image
676 
677  Description:
678  Returns the sequence to the first image
679 
680  Parameters:
681  leImageSequenceWidget* _this - The image sequence widget to operate on
682 
683  Remarks:
684  Usage - _this->fn->rewind(_this);
685 
686  Returns:
687  leResult - the result of the operation
688 */
700 leResult play(leImageSequenceWidget* _this);
701 
702 
703 // *****************************************************************************
704 /* Virtual Member Function:
705  leBool isPlaying(const leImageSequenceWidget* _this)
706 
707  Summary:
708  Indicates of the sequence is automatically cycling
709 
710  Description:
711  Indicates of the sequence is automatically cycling
712 
713  Parameters:
714  const leImageSequenceWidget* _this - The image sequence widget to operate on
715 
716  Remarks:
717  Usage - _this->fn->isPlaying(_this);
718 
719  Returns:
720  leBool - the setting value
721 */
732 virtual leBool isPlaying(const leImageSequenceWidget* _this);
733 
734 // *****************************************************************************
735 /* Virtual Member Function:
736  leBool getRepeat(const leImageSequenceWidget* _this)
737 
738  Summary:
739  Indicates if the sequence will repeat the cycle
740 
741  Description:
742  Indicates if the sequence will repeat the cycle
743 
744  Parameters:
745  const leImageSequenceWidget* _this - The image sequence widget to operate on
746 
747  Remarks:
748  Usage - _this->fn->getRepeat(_this);
749 
750  Returns:
751  leBool - the setting value
752 */
763 virtual leBool getRepeat(const leImageSequenceWidget* _this);
764 
765 // *****************************************************************************
766 /* Virtual Member Function:
767  leResult setRepeat(leImageSequenceWidget* _this,
768  leBool rpt)
769 
770  Summary:
771  Sets the repeat flag
772 
773  Description:
774  Sets the repeat flag
775 
776  Parameters:
777  leImageSequenceWidget* _this - The image sequence widget to operate on
778  leBool rpt - the setting value
779 
780  Remarks:
781  Usage - _this->fn->setRepeat(_this, rpt);
782 
783  Returns:
784  leResult - the result of the operation
785 */
798 virtual leResult setRepeat(leImageSequenceWidget* _this,
799  leBool rpt);
800 
801 // *****************************************************************************
802 /* Virtual Member Function:
803  leResult showImage(leImageSequenceWidget* _this,
804  uint32_t idx)
805 
806  Summary:
807  Sets the current visible image index
808 
809  Description:
810  Sets the current visible image index
811 
812  Parameters:
813  leImageSequenceWidget* _this - The image sequence widget to operate on
814  uint32_t idx - the index
815 
816  Remarks:
817  Usage - _this->fn->showImage(_this, idx);
818 
819  Returns:
820  leResult - the result of the operation
821 */
834 virtual leResult showImage(leImageSequenceWidget* _this,
835  uint32_t idx);
836 
837 
838 // *****************************************************************************
839 /* Virtual Member Function:
840  leResult showNextImage(leImageSequenceWidget* _this)
841 
842  Summary:
843  Advance to the next image
844 
845  Description:
846  Advance to the next image
847 
848  Parameters:
849  leImageSequenceWidget* _this - The image sequence widget to operate on
850 
851  Remarks:
852  Usage - _this->fn->showNextImage(_this);
853 
854  Returns:
855  leResult - the result of the operation
856 */
867 virtual leResult showNextImage(leImageSequenceWidget* _this);
868 
869 // *****************************************************************************
870 /* Virtual Member Function:
871  leResult showPreviousImage(leImageSequenceWidget* _this)
872 
873  Summary:
874  Return to the previous image
875 
876  Description:
877  Return to the previous image
878 
879  Parameters:
880  leImageSequenceWidget* _this - The image sequence widget to operate on
881 
882  Remarks:
883  Usage - _this->fn->showPreviousImage(_this);
884 
885  Returns:
886  leResult - the result of the operation
887 */
898 virtual leResult showPreviousImage(leImageSequenceWidget* _this);
899 
910 virtual leImageSequenceImageChangedEvent_FnPtr getImageChangedEventCallback(const leImageSequenceWidget* _this);
911 
925 virtual leResult setImageChangedEventCallback(leImageSequenceWidget* _this,
926  leImageSequenceImageChangedEvent_FnPtr cb);
927 
928 #undef THIS_TYPE
929 #endif
930 
931 #ifdef __cplusplus
932 }
933 #endif
934 
935 #endif // LE_IMAGESEQUENCE_WIDGET_ENABLED
936 #endif /* LEGATO_IMAGESEQUENCE_H */
Common macros and definitions used by Legato.
Image functions and defintions.
Definition: legato_image.h:181
leResult
This enum represents function call results.
Definition: legato_common.h:123
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
Legato widget definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
leVAlignment
This enum represents the vertical alignment mode of objects.
Definition: legato_common.h:170
Definition: widget.py:1
Fixed string functions and definitions.