MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_state.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 
30 #ifndef LEGATO_STATE_H
31 #define LEGATO_STATE_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
38 
39 #include "gfx/driver/gfx_driver.h"
44 
45 // *****************************************************************************
51 typedef void (*leLanguageChangedCallback_FnPtr)(uint32_t);
52 
53 typedef enum leLayerClearMode
54 {
55  LE_LAYERCLEARMODE_DEFAULT,
56  LE_LAYERCLEARMODE_DISABLE,
57  LE_LAYERCLEARMODE_FORCE,
58 } leLayerClearMode;
59 
60 // *****************************************************************************
66 struct leLayerState;
67 
68 typedef struct leLayerState
69 {
70  leWidget root;
71  leColorMode colorMode;
72  leBool renderHorizontal;
73  lePoint driverPosition;
74  leLayerClearMode clearMode;
75 
76  void* rendererData;
77 
78  struct leLayerState* prev;
79  struct leLayerState* next;
80 } leLayerState;
81 
82 // *****************************************************************************
87 typedef struct leState
88 {
90  uint32_t languageID;
92  uint32_t widgetIDs;
104 #if LE_STREAMING_ENABLED == 1
105  leStreamManager* activeStream;
106 #endif
107 } leState;
108 
109 /* internal use only */
113 leState* leGetState(void);
119 // *****************************************************************************
133 leResult leInitialize(const gfxDisplayDriver* dispDriver,
134  const gfxGraphicsProcessor* gpuDriver);
135 
136 // *****************************************************************************
145 void leShutdown(void);
146 
147 // *****************************************************************************
164 leResult leUpdate(uint32_t dt);
165 
166 // TODO documentation
167 uint32_t leLayerCount(void);
168 
169 // TODO documentation
170 int32_t leAddLayer(void);
171 
172 // TODO documentation
173 leResult leRemoveLayer(uint32_t idx);
174 
175 // TODO documentation
176 leLayerState* leGetLayerState(uint32_t idx);
177 
187 leColorMode leGetLayerColorMode(uint32_t lyrIdx);
188 
199 leResult leSetLayerColorMode(uint32_t lyrIdx, leColorMode mode);
200 
217  uint32_t layer);
218 
219 /* Function:
220  leResult leRemoveRootWidget(leWidget* wgt, uint32_t layer)
221 
222  Summary:
223  Removes a custom widget from a static scene root widget.
224 
225  Description:
226  The library maintains a static list of widgets that are considered
227  to be scene roots. This API removes a child widget from one of the
228  static roots.
229 
230  Returns:
231  leResult
232 
233 */
250  uint32_t layer);
251 
252 
253 
254 
264 leBool leGetLayerRenderHorizontal(uint32_t lyrIdx);
265 
280 leResult leSetLayerRenderHorizontal(uint32_t lyrIdx, leBool horz);
281 
291 leLayerClearMode leGetLayerClearMode(uint32_t lyrIdx);
292 
303 leResult leSetLayerClearMode(uint32_t lyrIdx,
304  leLayerClearMode mode);
305 
306 #if 0
307 // *****************************************************************************
317 leRect leGetDisplayRect();
318 #endif
319 
320 // *****************************************************************************
332 
333 // *****************************************************************************
334 /* Function:
335  void leSetStringTable(leStringTable* table)
336 
337  Summary:
338  Set the StringTable pointer to the specified new StringTableAsset structure
339 
340  Description:
341  Set the StringTable pointer to the specified new StringTableAsset structure
342 
343  Precondition:
344 
345  Parameters:
346  leStringTable*
347 
348  Returns:
349  void
350 
351  Remarks:
352 
353 */
364 void leSetStringTable(const leStringTable* table);
365 
366 // *****************************************************************************
367 /* Function:
368  uint32_t leGetStringLanguage()
369 
370  Summary:
371  Returns the language index of the current context
372 
373  Description:
374  Returns the language index of the current context
375 
376  Precondition:
377 
378  Parameters:
379 
380  Returns:
381  uint32_t
382 
383  Remarks:
384 
385 */
395 uint32_t leGetStringLanguage(void);
396 
397 // *****************************************************************************
398 /* Function:
399  void leSetStringLanguage(uint32_t id)
400 
401  Summary:
402  Sets the current language index
403 
404  Description:
405  Sets the current language index
406 
407  Precondition:
408 
409  Parameters:
410  uint32_t
411 
412  Returns:
413  void
414 
415  Remarks:
416 
417 */
428 void leSetStringLanguage(uint32_t id);
429 
430 // *****************************************************************************
431 /* Function:
432  leScheme* leGetDefaultScheme()
433 
434  Summary:
435  Returns the pointer to the current default scheme
436 
437  Description:
438  Returns the pointer to the current default scheme
439 
440  Precondition:
441 
442  Parameters:
443 
444  Returns:
445  leScheme*
446 
447  Remarks:
448 
449 */
460 
461 // *****************************************************************************
462 /* Function:
463  leWidget* leGetFocusWidget()
464 
465  Summary:
466  Return a pointer to the widget in focus
467 
468  Description:
469  The focus widget is the widget that is currently receiving all input events.
470  This can happen when the user initiates a touch down event on the widget
471  and is currently dragging their finger on the display. The widget will
472  receive all touch moved events until a touch up event is received.
473 
474  Precondition:
475 
476  Parameters:
477 
478  Returns:
479  leWidget*
480 
481  Remarks:
482 
483 */
497 
498 // *****************************************************************************
499 /* Function:
500  leResult leSetFocusWidget(leWidget* widget)
501 
502  Summary:
503  Set into focus the widget specified as the argument
504 
505  Description:
506  Set into focus the widget specified as the argument
507 
508  Precondition:
509 
510  Parameters:
511  leWidget*
512 
513  Returns:
514  leResult
515 
516  Remarks:
517 
518 */
530 
531 // *****************************************************************************
532 /* Function:
533  leEditWidget* leGetEditWidget()
534 
535  Summary:
536  Gets the widget that is currently recieving all widget edit events.
537 
538  Description:
539  Edit widgets are widgets that inherit the 'edit widget' API function list.
540  These widgets are capable of receiving edit events from other widgets
541  that are edit event broadcasters. A broadcaster could be a 'key pad' and
542  a receiver could be a 'text edit' box.
543 
544  Precondition:
545 
546  Parameters:
547  void
548 
549  Returns:
550  leEditWidget*
551 
552  Remarks:
553 
554 */
568 
569 // *****************************************************************************
570 /* Function:
571  leResult leSetEditWidget(leEditWidget* widget)
572 
573  Summary:
574  Sets the currently active edit widget.
575 
576  Precondition:
577 
578  Parameters:
579  leEditWidget* - a widget that inherits the edit widget API
580 
581  Returns:
582  leResult
583 
584  Remarks:
585 
586 */
600 
601 // *****************************************************************************
602 /* Function:
603  leResult leSetLanguageChangedCallback(leLanguageChangedCallback_FnPtr cb)
604 
605  Summary:
606  Set the callback function pointer when the language change event occurs
607 
608  Description:
609  Set the callback function pointer when the language change event occurs
610 
611  Precondition:
612 
613  Parameters:
614  leLanguageChangedCallback_FnPtr
615 
616  Returns:
617  leResult
618 
619  Remarks:
620 
621 */
634 
635 // *****************************************************************************
636 /* Function:
637  void leRedrawAll()
638 
639  Summary:
640  Forces the library to redraw the currently active scene in its entirety.
641 
642  Precondition:
643 
644  Parameters:
645 
646  Returns:
647  void
648 
649  Remarks:
650 
651 */
661 void leRedrawAll(void);
662 
663 /* Function:
664  leBool leIsDrawing()
665 
666  Summary:
667  Indicates if any layers of the active screen are currently drawing a
668  frame.
669 
670  Description:
671  Indicates if the library currently drawing a frame. Because frame updates
672  can asynchronous to making changes to the UI state it is best to only make
673  updates to the state of a widget only when the layer is not drawing.
674 
675  Returns:
676  leResult
677 
678 */
690 leBool leIsDrawing(void);
691 
692 /* Function:
693  leResult leAddRootWidget(leWidget* wgt, uint32_t layer)
694 
695  Summary:
696  Adds a custom widget to a static scene root widget.
697 
698  Description:
699  The library maintains a static list of widgets that are considered
700  to be scene roots. The library treats these roots as layers and
701  the display driver may configure itself to render these roots
702  to different hardware layers.
703 
704  This API adds a child widget to one of the static roots.
705 
706  Returns:
707  leResult
708 
709 */
710 
711 
712 /* Function:
713  leBool leWidgetIsInScene(const leWidget* wgt)
714 
715  Summary:
716  Searches the active scene for a given widget.
717 
718  Description:
719  Searches the active scene for a given widget.
720 
721  Returns:
722  leResult - LE_TRUE if the widget is in the current scene
723 
724 */
736 leBool leWidgetIsInScene(const leWidget* wgt);
737 
738 int32_t leGetWidgetLayer(const leWidget* wgt);
739 
740 
741 /* Function:
742  leResult leEdit_StartEdit(const leWidget* wgt)
743 
744  Summary:
745  Passes a 'start edit' command to the current edit widget,
746  if one exists
747 
748  Description:
749  The edit widget is the widget in the scene that is currently receiving
750  edit events.
751 
752  Returns:
753  leResult - LE_TRUE the command was processed successfully
754 
755 */
766 
775 void leEdit_EndEdit(void);
776 
785 void leEdit_Clear(void);
786 
795 void leEdit_Accept(void);
796 
797 /* Function:
798  leResult leEdit_Accept(const leWidget* wgt)
799 
800  Summary:
801  Passes a 'set' command and a string to the current edit widget,
802  if one exists
803 
804  Description:
805  Passes a 'set' command and a string to the current edit widget,
806  if one exists
807 
808  Returns:
809 
810 */
820 void leEdit_Set(leString* str);
821 
822 /* Function:
823  leResult leEdit_Append(const leWidget* wgt)
824 
825  Summary:
826  Passes an 'append' command and a string to the current edit widget,
827  if one exists
828 
829  Description:
830  Passes an 'append' command and a string to the current edit widget,
831  if one exists
832 
833  Returns:
834 
835 */
846 void leEdit_Append(leString* str);
847 
848 /* Function:
849  leResult leEdit_Append(const leWidget* wgt)
850 
851  Summary:
852  Passes a 'backspace' command to the current edit widget,
853  if one exists
854 
855  Description:
856  Passes a 'backspace' command to the current edit widget,
857  if one exists
858 
859  Returns:
860 
861 */
871 void leEdit_Backspace(void);
872 
873 #if LE_STREAMING_ENABLED == 1
874 /* Function:
875  leStreamManager* leGetActiveStream()
876 
877  Summary:
878  Gets the global active data stream manager for the library.
879 
880  Description:
881  A data stream manager is a state machine that is currently
882  attempting to stream data from a source that is external
883  to the library and possibly local memory. This stream must
884  be handled to completion before any further rendering can take place.
885 
886  Returns:
887 
888 */
889 leStreamManager* leGetActiveStream(void);
890 
891 /* Function:
892  leResult leRunActiveStream()
893 
894  Summary:
895  Allows the current active data stream to run until it preempts or
896  completes.
897 
898  Description:
899  Allows the current active data stream to run until it preempts or
900  completes.
901 
902  Returns:
903 
904 */
905 leResult leRunActiveStream(void);
906 
907 /* Function:
908  void leAbortActiveStream
909 
910  Summary:
911  Terminates the current active data stream regardless of whether
912  it still has data to receive.
913 
914  Description:
915  Terminates the current active data stream regardless of whether
916  it still has data to receive. It will likely attempt to clean itself up
917  as best it can. Care should be taken in the application to not send data
918  to the stream after it has been aborted.
919 
920  Returns:
921 
922 */
923 void leAbortActiveStream(void);
924 #endif
925 
926 #ifdef __cplusplus
927 }
928 #endif
929 
930 #endif /* LEGATO_STATE_H */
uint32_t languageID
Definition: legato_state.h:90
Common macros and definitions used by Legato.
leResult leUpdate(uint32_t dt)
Shutdown Legato library.
Definition: legato_state.c:376
void leEdit_Backspace(void)
Send backspace command.
Definition: legato_state.c:934
struct leState leState
This struct represents the state of the library.
uint32_t widgetIDs
Definition: legato_state.h:92
This struct represents a string.
Definition: legato_string.h:107
leResult leEdit_StartEdit(void)
Send start edit command.
Definition: legato_state.c:874
void leEdit_Append(leString *str)
Send start edit command.
Definition: legato_state.c:924
leEditWidget * leGetEditWidget(void)
Get edit widget.
Definition: legato_state.c:710
leResult leSetFocusWidget(leWidget *widget)
Get language by index.
Definition: legato_state.c:684
uint32_t leGetStringLanguage(void)
Get language index.
Definition: legato_state.c:634
leScheme * leGetDefaultScheme(void)
Get default scheme.
Definition: legato_state.c:674
leResult
This enum represents function call results.
Definition: legato_common.h:123
leResult leSetEditWidget(leEditWidget *widget)
Set edit widget.
Definition: legato_state.c:715
leScheme defaultScheme
Definition: legato_state.h:94
leLanguageChangedCallback_FnPtr languageChangedCB
Definition: legato_state.h:100
leBool leGetLayerRenderHorizontal(uint32_t lyrIdx)
Get layer render direction.
Definition: legato_state.c:563
This struct represents a rectangle.
Definition: legato_common.h:394
Edit widget functions and definitions.
leWidget * leGetFocusWidget(void)
Get focus widget.
Definition: legato_state.c:679
This struct represents a list.
Definition: legato_list.h:94
Definition: legato_state.h:68
leResult leRemoveRootWidget(leWidget *wgt, uint32_t layer)
Remove root widget to layer.
Definition: legato_state.c:770
const leStringTable * stringTable
Definition: legato_state.h:89
leBool leWidgetIsInScene(const leWidget *wgt)
Determines whether the widget is in the scene.
Definition: legato_state.c:792
Used to define a widget.
Definition: legato_widget.h:624
void leSetStringTable(const leStringTable *table)
Set string table.
Definition: legato_state.c:627
void leEdit_Accept(void)
Send accept command.
Definition: legato_state.c:904
leEditWidget * edit
Definition: legato_state.h:98
This struct represents string a string table.
Definition: legato_stringtable.h:83
leStringTable * leGetStringTable(void)
Get string table.
Definition: legato_state.c:622
This struct represents the graphics processor interface.
Definition: gfx_driver.h.ftl:1227
This structure represents a integer Cartesian point.
Definition: legato_common.h:346
leBool leIsDrawing(void)
Check active screen drawing state.
Definition: legato_state.c:750
leList layerList
Definition: legato_state.h:102
void leEdit_Clear(void)
Send clear command.
Definition: legato_state.c:894
leLayerClearMode leGetLayerClearMode(uint32_t lyrIdx)
Get layer clear mode.
Definition: legato_state.c:590
leColorMode
This enum represents the supported RGB color formats.
Definition: legato_color.h:148
void leShutdown(void)
Shutdown Legato library.
Definition: legato_state.c:317
leBool
This enum represents booleans.
Definition: legato_common.h:146
leWidget * focus
Definition: legato_state.h:97
This struct represents the display driver interface.
Definition: gfx_driver.h.ftl:1206
leResult leSetLayerColorMode(uint32_t lyrIdx, leColorMode mode)
Set layer color mode.
Definition: legato_state.c:543
String table functions and definitions.
void leEdit_EndEdit(void)
Send end edit command.
Definition: legato_state.c:884
void leSetStringLanguage(uint32_t id)
Get language by index.
Definition: legato_state.c:654
void leEdit_Set(leString *str)
Send set command.
Definition: legato_state.c:914
Legato input definitions.
Definition: legato_scheme.h:154
leColorMode leGetLayerColorMode(uint32_t lyrIdx)
Get layer color mode.
Definition: legato_state.c:531
leResult leAddRootWidget(leWidget *wgt, uint32_t layer)
Add root widget to layer.
Definition: legato_state.c:755
leResult leSetLayerClearMode(uint32_t lyrIdx, leLayerClearMode mode)
Set layer clear mode.
Definition: legato_state.c:602
leResult leSetLanguageChangedCallback(leLanguageChangedCallback_FnPtr cb)
Set language change callback.
leResult leInitialize(const gfxDisplayDriver *dispDriver, const gfxGraphicsProcessor *gpuDriver)
Initialize Legato library.
Definition: legato_state.c:228
leResult leSetLayerRenderHorizontal(uint32_t lyrIdx, leBool horz)
Set layer render direction.
Definition: legato_state.c:575
This struct represents the state of the library.
Definition: legato_state.h:87
Schemes support various properties that make it possible to customize the color of widgets...
Definition: legato_editwidget.h:90
void leRedrawAll(void)
Redraw All.
Definition: legato_state.c:737
Definition: widget.py:1
void(* leLanguageChangedCallback_FnPtr)(uint32_t)
This function pointer represents a language change callback.
Definition: legato_state.h:51