MPLABĀ® Harmony Graphics Suite
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 
35 
36 #include "gfx/driver/gfx_driver.h"
41 
42 // *****************************************************************************
48 typedef void (*leLanguageChangedCallback_FnPtr)(uint32_t);
49 
50 // *****************************************************************************
56 typedef struct
57 {
58  leColorMode colorMode;
59  leBool renderHorizontal;
60  lePoint driverPosition;
61 } leLayerState;
62 
63 // *****************************************************************************
68 typedef struct leState
69 {
71  uint32_t languageID;
73  uint32_t widgetIDs;
83  leWidget rootWidget[LE_LAYER_COUNT];
84  leLayerState layerStates[LE_LAYER_COUNT];
86 #if LE_STREAMING_ENABLED == 1
87  leStreamManager* activeStream;
88 #endif
90 
91 /* internal use only */
95 leState* leGetState();
101 // *****************************************************************************
115 leResult leInitialize(const gfxDisplayDriver* dispDriver,
116  const gfxGraphicsProcessor* gpuDriver);
117 
118 // *****************************************************************************
127 LIB_EXPORT void leShutdown();
128 
129 // *****************************************************************************
146 LIB_EXPORT leResult leUpdate(uint32_t dt);
147 
148 // *****************************************************************************
159 
169 LIB_EXPORT leColorMode leGetLayerColorMode(uint32_t lyrIdx);
170 
181 leResult leSetLayerColorMode(uint32_t lyrIdx, leColorMode mode);
182 
192 leBool leGetLayerRenderHorizontal(uint32_t lyrIdx);
193 
208 leResult leSetLayerRenderHorizontal(uint32_t lyrIdx, leBool horz);
209 
210 #if 0
211 // *****************************************************************************
221 LIB_EXPORT leRect leGetDisplayRect();
222 #endif
223 
224 // *****************************************************************************
235 LIB_EXPORT leStringTable* leGetStringTable();
236 
237 // *****************************************************************************
238 /* Function:
239  void leSetStringTable(leStringTable* table)
240 
241  Summary:
242  Set the StringTable pointer to the specified new StringTableAsset structure
243 
244  Description:
245  Set the StringTable pointer to the specified new StringTableAsset structure
246 
247  Precondition:
248 
249  Parameters:
250  leStringTable*
251 
252  Returns:
253  void
254 
255  Remarks:
256 
257 */
268 LIB_EXPORT void leSetStringTable(const leStringTable* table);
269 
270 // *****************************************************************************
271 /* Function:
272  uint32_t leGetStringLanguage()
273 
274  Summary:
275  Returns the language index of the current context
276 
277  Description:
278  Returns the language index of the current context
279 
280  Precondition:
281 
282  Parameters:
283 
284  Returns:
285  uint32_t
286 
287  Remarks:
288 
289 */
299 LIB_EXPORT uint32_t leGetStringLanguage();
300 
301 // *****************************************************************************
302 /* Function:
303  void leSetStringLanguage(uint32_t id)
304 
305  Summary:
306  Sets the current language index
307 
308  Description:
309  Sets the current language index
310 
311  Precondition:
312 
313  Parameters:
314  uint32_t
315 
316  Returns:
317  void
318 
319  Remarks:
320 
321 */
332 LIB_EXPORT void leSetStringLanguage(uint32_t id);
333 
334 // *****************************************************************************
335 /* Function:
336  leScheme* leGetDefaultScheme()
337 
338  Summary:
339  Returns the pointer to the current default scheme
340 
341  Description:
342  Returns the pointer to the current default scheme
343 
344  Precondition:
345 
346  Parameters:
347 
348  Returns:
349  leScheme*
350 
351  Remarks:
352 
353 */
363 LIB_EXPORT leScheme* leGetDefaultScheme();
364 
365 // *****************************************************************************
366 /* Function:
367  leWidget* leGetFocusWidget()
368 
369  Summary:
370  Return a pointer to the widget in focus
371 
372  Description:
373  The focus widget is the widget that is currently receiving all input events.
374  This can happen when the user initiates a touch down event on the widget
375  and is currently dragging their finger on the display. The widget will
376  receive all touch moved events until a touch up event is received.
377 
378  Precondition:
379 
380  Parameters:
381 
382  Returns:
383  leWidget*
384 
385  Remarks:
386 
387 */
400 LIB_EXPORT leWidget* leGetFocusWidget();
401 
402 // *****************************************************************************
403 /* Function:
404  leResult leSetFocusWidget(leWidget* widget)
405 
406  Summary:
407  Set into focus the widget specified as the argument
408 
409  Description:
410  Set into focus the widget specified as the argument
411 
412  Precondition:
413 
414  Parameters:
415  leWidget*
416 
417  Returns:
418  leResult
419 
420  Remarks:
421 
422 */
433 LIB_EXPORT leResult leSetFocusWidget(leWidget* widget);
434 
435 // *****************************************************************************
436 /* Function:
437  leEditWidget* leGetEditWidget()
438 
439  Summary:
440  Gets the widget that is currently recieving all widget edit events.
441 
442  Description:
443  Edit widgets are widgets that inherit the 'edit widget' API function list.
444  These widgets are capable of receiving edit events from other widgets
445  that are edit event broadcasters. A broadcaster could be a 'key pad' and
446  a receiver could be a 'text edit' box.
447 
448  Precondition:
449 
450  Parameters:
451  void
452 
453  Returns:
454  leEditWidget*
455 
456  Remarks:
457 
458 */
471 LIB_EXPORT leEditWidget* leGetEditWidget();
472 
473 // *****************************************************************************
474 /* Function:
475  leResult leSetEditWidget(leEditWidget* widget)
476 
477  Summary:
478  Sets the currently active edit widget.
479 
480  Precondition:
481 
482  Parameters:
483  leEditWidget* - a widget that inherits the edit widget API
484 
485  Returns:
486  leResult
487 
488  Remarks:
489 
490 */
503 LIB_EXPORT leResult leSetEditWidget(leEditWidget* widget);
504 
505 // *****************************************************************************
506 /* Function:
507  leResult leSetLanguageChangedCallback(leLanguageChangedCallback_FnPtr cb)
508 
509  Summary:
510  Set the callback function pointer when the language change event occurs
511 
512  Description:
513  Set the callback function pointer when the language change event occurs
514 
515  Precondition:
516 
517  Parameters:
518  leLanguageChangedCallback_FnPtr
519 
520  Returns:
521  leResult
522 
523  Remarks:
524 
525 */
538 
539 // *****************************************************************************
540 /* Function:
541  void leRedrawAll()
542 
543  Summary:
544  Forces the library to redraw the currently active scene in its entirety.
545 
546  Precondition:
547 
548  Parameters:
549 
550  Returns:
551  void
552 
553  Remarks:
554 
555 */
565 LIB_EXPORT void leRedrawAll();
566 
567 /* Function:
568  leBool leIsDrawing()
569 
570  Summary:
571  Indicates if any layers of the active screen are currently drawing a
572  frame.
573 
574  Description:
575  Indicates if the library currently drawing a frame. Because frame updates
576  can asynchronous to making changes to the UI state it is best to only make
577  updates to the state of a widget only when the layer is not drawing.
578 
579  Returns:
580  leResult
581 
582 */
594 LIB_EXPORT leBool leIsDrawing();
595 
596 /* Function:
597  leResult leAddRootWidget(leWidget* wgt, uint32_t layer)
598 
599  Summary:
600  Adds a custom widget to a static scene root widget.
601 
602  Description:
603  The library maintains a static list of widgets that are considered
604  to be scene roots. The library treats these roots as layers and
605  the display driver may configure itself to render these roots
606  to different hardware layers.
607 
608  This API adds a child widget to one of the static roots.
609 
610  Returns:
611  leResult
612 
613 */
629 LIB_EXPORT leResult leAddRootWidget(leWidget* wgt,
630  uint32_t layer);
631 
632 /* Function:
633  leResult leRemoveRootWidget(leWidget* wgt, uint32_t layer)
634 
635  Summary:
636  Removes a custom widget from a static scene root widget.
637 
638  Description:
639  The library maintains a static list of widgets that are considered
640  to be scene roots. This API removes a child widget from one of the
641  static roots.
642 
643  Returns:
644  leResult
645 
646 */
662 LIB_EXPORT leResult leRemoveRootWidget(leWidget* wgt,
663  uint32_t layer);
664 
665 /* Function:
666  leBool leWidgetIsInScene(const leWidget* wgt)
667 
668  Summary:
669  Searches the active scene for a given widget.
670 
671  Description:
672  Searches the active scene for a given widget.
673 
674  Returns:
675  leResult - LE_TRUE if the widget is in the current scene
676 
677 */
689 leBool leWidgetIsInScene(const leWidget* wgt);
690 
691 int32_t leGetWidgetLayer(const leWidget* wgt);
692 
693 
694 /* Function:
695  leResult leEdit_StartEdit(const leWidget* wgt)
696 
697  Summary:
698  Passes a 'start edit' command to the current edit widget,
699  if one exists
700 
701  Description:
702  The edit widget is the widget in the scene that is currently receiving
703  edit events.
704 
705  Returns:
706  leResult - LE_TRUE the command was processed successfully
707 
708 */
719 
728 void leEdit_EndEdit();
729 
738 void leEdit_Clear();
739 
748 void leEdit_Accept();
749 
750 /* Function:
751  leResult leEdit_Accept(const leWidget* wgt)
752 
753  Summary:
754  Passes a 'set' command and a string to the current edit widget,
755  if one exists
756 
757  Description:
758  Passes a 'set' command and a string to the current edit widget,
759  if one exists
760 
761  Returns:
762 
763 */
773 void leEdit_Set(leString* str);
774 
775 /* Function:
776  leResult leEdit_Append(const leWidget* wgt)
777 
778  Summary:
779  Passes an 'append' command and a string to the current edit widget,
780  if one exists
781 
782  Description:
783  Passes an 'append' command and a string to the current edit widget,
784  if one exists
785 
786  Returns:
787 
788 */
799 void leEdit_Append(leString* str);
800 
801 /* Function:
802  leResult leEdit_Append(const leWidget* wgt)
803 
804  Summary:
805  Passes a 'backspace' command to the current edit widget,
806  if one exists
807 
808  Description:
809  Passes a 'backspace' command to the current edit widget,
810  if one exists
811 
812  Returns:
813 
814 */
824 void leEdit_Backspace();
825 
826 #if LE_STREAMING_ENABLED == 1
827 /* Function:
828  leStreamManager* leGetActiveStream()
829 
830  Summary:
831  Gets the global active data stream manager for the library.
832 
833  Description:
834  A data stream manager is a state machine that is currently
835  attempting to stream data from a source that is external
836  to the library and possibly local memory. This stream must
837  be handled to completion before any further rendering can take place.
838 
839  Returns:
840 
841 */
842 leStreamManager* leGetActiveStream();
843 
844 /* Function:
845  leResult leRunActiveStream()
846 
847  Summary:
848  Allows the current active data stream to run until it preempts or
849  completes.
850 
851  Description:
852  Allows the current active data stream to run until it preempts or
853  completes.
854 
855  Returns:
856 
857 */
858 leResult leRunActiveStream();
859 
860 /* Function:
861  void leAbortActiveStream
862 
863  Summary:
864  Terminates the current active data stream regardless of whether
865  it still has data to receive.
866 
867  Description:
868  Terminates the current active data stream regardless of whether
869  it still has data to receive. It will likely attempt to clean itself up
870  as best it can. Care should be taken in the application to not send data
871  to the stream after it has been aborted.
872 
873  Returns:
874 
875 */
876 void leAbortActiveStream();
877 #endif
878 
879 #endif /* LEGATO_STATE_H */
leState
struct leState leState
This struct represents the state of the library.
leSetLayerRenderHorizontal
leResult leSetLayerRenderHorizontal(uint32_t lyrIdx, leBool horz)
Set layer render direction.
Definition: legato_state.c:421
leUpdate
LIB_EXPORT leResult leUpdate(uint32_t dt)
Shutdown Legato library.
Definition: legato_state.c:342
leShutdown
LIB_EXPORT void leShutdown()
Shutdown Legato library.
Definition: legato_state.c:289
leEditWidget
Definition: legato_editwidget.h:91
legato_input.h
Legato input definitions.
leResult
leResult
This enum represents function call results.
Definition: legato_common.h:134
leColorMode
leColorMode
This enum represents the supported RGB color formats.
Definition: legato_color.h:146
leRect
This struct represents a rectangle.
Definition: legato_common.h:405
leArray::size
uint32_t size
Definition: legato_array.h:63
leAddRootWidget
LIB_EXPORT leResult leAddRootWidget(leWidget *wgt, uint32_t layer)
Add root widget to layer.
Definition: legato_state.c:566
legato_image.h
Image functions and defintions.
leGetLayerColorMode
LIB_EXPORT leColorMode leGetLayerColorMode(uint32_t lyrIdx)
Get layer color mode.
Definition: legato_state.c:394
leSetEditWidget
LIB_EXPORT leResult leSetEditWidget(leEditWidget *widget)
Set edit widget.
Definition: legato_state.c:526
leEvent
This enum presents a event. An event contains valid event ids.
Definition: legato_event.h:88
legato_memory.h
Memory functions and definitions.
leState::languageID
uint32_t languageID
Definition: legato_state.h:71
leRedrawAll
LIB_EXPORT void leRedrawAll()
Redraw All.
Definition: legato_state.c:548
leGetFocusWidget
LIB_EXPORT leWidget * leGetFocusWidget()
Get focus widget.
Definition: legato_state.c:490
legato_renderer.h
legato_stringtable.h
String table functions and definitions.
leEdit_Append
void leEdit_Append(leString *str)
Send start edit command.
Definition: legato_state.c:725
leEdit_Backspace
void leEdit_Backspace()
Send backspace command.
Definition: legato_state.c:735
leArray::values
void ** values
Definition: legato_array.h:62
leString
This struct represents a string.
Definition: legato_string.h:108
LE_WIDGET_EVENT_FOCUS_LOST
@ LE_WIDGET_EVENT_FOCUS_LOST
Definition: legato_event.h:78
leBool
leBool
This enum represents booleans.
Definition: legato_common.h:157
leImage_InitDecoders
void leImage_InitDecoders()
Get Event Count.
Definition: legato_image.c:42
legato_editwidget.h
Edit widget functions and definitions.
LE_FALSE
@ LE_FALSE
Definition: legato_common.h:158
leGetEditWidget
LIB_EXPORT leEditWidget * leGetEditWidget()
Get edit widget.
Definition: legato_state.c:521
leEdit_Accept
void leEdit_Accept()
Send accept command.
Definition: legato_state.c:705
leEdit_StartEdit
leResult leEdit_StartEdit()
Send start edit command.
Definition: legato_state.c:675
leGetStringTable
LIB_EXPORT leStringTable * leGetStringTable()
Get string table.
Definition: legato_state.c:437
leState::stringTable
const leStringTable * stringTable
Definition: legato_state.h:70
leRemoveRootWidget
LIB_EXPORT leResult leRemoveRootWidget(leWidget *wgt, uint32_t layer)
Remove root widget to layer.
Definition: legato_state.c:577
leEvent_ProcessEvents
leResult leEvent_ProcessEvents()
Process events.
Definition: legato_event.c:90
leIsDrawing
LIB_EXPORT leBool leIsDrawing()
Check active screen drawing state.
Definition: legato_state.c:561
leGetLayerRenderHorizontal
leBool leGetLayerRenderHorizontal(uint32_t lyrIdx)
Get layer render direction.
Definition: legato_state.c:413
leState::focus
leWidget * focus
Definition: legato_state.h:78
leWidgetIsInScene
leBool leWidgetIsInScene(const leWidget *wgt)
Determines whether the widget is in the scene.
Definition: legato_state.c:596
leGetStringLanguage
LIB_EXPORT uint32_t leGetStringLanguage()
Get language index.
Definition: legato_state.c:449
leEvent::id
leEventID id
Definition: legato_event.h:89
leGetColorMode
LIB_EXPORT leColorMode leGetColorMode()
Get color mode.
leWidget
Used to define a widget.
Definition: legato_widget.h:623
leEdit_Clear
void leEdit_Clear()
Send clear command.
Definition: legato_state.c:695
legato_scheme.h
Schemes support various properties that make it possible to customize the color of widgets.
leState
This struct represents the state of the library.
Definition: legato_state.h:69
leSetStringLanguage
LIB_EXPORT void leSetStringLanguage(uint32_t id)
Get language by index.
Definition: legato_state.c:469
leScheme
Definition: legato_scheme.h:154
leSetStringTable
LIB_EXPORT void leSetStringTable(const leStringTable *table)
Set string table.
Definition: legato_state.c:442
LE_WIDGET_EVENT_FOCUS_GAINED
@ LE_WIDGET_EVENT_FOCUS_GAINED
Definition: legato_event.h:77
leSetLayerColorMode
leResult leSetLayerColorMode(uint32_t lyrIdx, leColorMode mode)
Set layer color mode.
Definition: legato_state.c:402
leEdit_EndEdit
void leEdit_EndEdit()
Send end edit command.
Definition: legato_state.c:685
leState::rootWidget
leWidget rootWidget[LE_LAYER_COUNT]
Definition: legato_state.h:83
leState::defaultScheme
leScheme defaultScheme
Definition: legato_state.h:75
leWidget_Constructor
LIB_EXPORT void leWidget_Constructor(leWidget *wgt)
Initialize widget.
Definition: legato_widget.c:67
LE_TRUE
@ LE_TRUE
Definition: legato_common.h:159
leState::edit
leEditWidget * edit
Definition: legato_state.h:79
legato_common.h
Common macros and definitions used by Legato.
legato_state.h
leLayerState
This struct describes the layer state for a layer.
Definition: legato_state.h:57
leGetDefaultScheme
LIB_EXPORT leScheme * leGetDefaultScheme()
Get default scheme.
Definition: legato_state.c:485
leState::widgetIDs
uint32_t widgetIDs
Definition: legato_state.h:73
leStringTable
This struct represents string a string table.
Definition: legato_stringtable.h:80
leEdit_Set
void leEdit_Set(leString *str)
Send set command.
Definition: legato_state.c:715
leSetLanguageChangedCallback
LIB_EXPORT leResult leSetLanguageChangedCallback(leLanguageChangedCallback_FnPtr cb)
Set language change callback.
leLanguageChangedCallback_FnPtr
void(* leLanguageChangedCallback_FnPtr)(uint32_t)
This function pointer represents a language change callback.
Definition: legato_state.h:48
leSetFocusWidget
LIB_EXPORT leResult leSetFocusWidget(leWidget *widget)
Get language by index.
Definition: legato_state.c:495
leState::layerStates
leLayerState layerStates[LE_LAYER_COUNT]
Definition: legato_state.h:84
lePoint
This structure represents a integer Cartesian point.
Definition: legato_common.h:357
leInitialize
leResult leInitialize(const gfxDisplayDriver *dispDriver, const gfxGraphicsProcessor *gpuDriver)
Initialize Legato library.
Definition: legato_state.c:228
leState::languageChangedCB
leLanguageChangedCallback_FnPtr languageChangedCB
Definition: legato_state.h:81