gui.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**
  2. * @file gui.h
  3. * GUI: main API
  4. */
  5. #pragma once
  6. #include "view_port.h"
  7. #include "canvas.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /** Gui layers */
  12. typedef enum {
  13. GuiLayerDesktop, /**< Desktop layer for internal use. Like fullscreen but with status bar */
  14. GuiLayerWindow, /**< Window layer, status bar is shown */
  15. GuiLayerStatusBarLeft, /**< Status bar left-side layer, auto-layout */
  16. GuiLayerStatusBarRight, /**< Status bar right-side layer, auto-layout */
  17. GuiLayerFullscreen, /**< Fullscreen layer, no status bar */
  18. GuiLayerMAX /**< Don't use or move, special value */
  19. } GuiLayer;
  20. /** Gui Canvas Commit Callback */
  21. typedef void (*GuiCanvasCommitCallback)(
  22. uint8_t* data,
  23. size_t size,
  24. CanvasOrientation orientation,
  25. void* context);
  26. #define RECORD_GUI "gui"
  27. typedef struct Gui Gui;
  28. /** Add view_port to view_port tree
  29. *
  30. * @remark thread safe
  31. *
  32. * @param gui Gui instance
  33. * @param view_port ViewPort instance
  34. * @param[in] layer GuiLayer where to place view_port
  35. */
  36. void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer);
  37. /** Remove view_port from rendering tree
  38. *
  39. * @remark thread safe
  40. *
  41. * @param gui Gui instance
  42. * @param view_port ViewPort instance
  43. */
  44. void gui_remove_view_port(Gui* gui, ViewPort* view_port);
  45. /** Send ViewPort to the front
  46. *
  47. * Places selected ViewPort to the top of the drawing stack
  48. *
  49. * @param gui Gui instance
  50. * @param view_port ViewPort instance
  51. */
  52. void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port);
  53. /** Send ViewPort to the back
  54. *
  55. * Places selected ViewPort to the bottom of the drawing stack
  56. *
  57. * @param gui Gui instance
  58. * @param view_port ViewPort instance
  59. */
  60. void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port);
  61. /** Add gui canvas commit callback
  62. *
  63. * This callback will be called upon Canvas commit Callback dispatched from GUI
  64. * thread and is time critical
  65. *
  66. * @param gui Gui instance
  67. * @param callback GuiCanvasCommitCallback
  68. * @param context GuiCanvasCommitCallback context
  69. */
  70. void gui_add_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context);
  71. /** Remove gui canvas commit callback
  72. *
  73. * @param gui Gui instance
  74. * @param callback GuiCanvasCommitCallback
  75. * @param context GuiCanvasCommitCallback context
  76. */
  77. void gui_remove_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context);
  78. /** Get gui canvas frame buffer size
  79. * *
  80. * @param gui Gui instance
  81. * @return size_t size of frame buffer in bytes
  82. */
  83. size_t gui_get_framebuffer_size(const Gui* gui);
  84. /** Set lockdown mode
  85. *
  86. * When lockdown mode is enabled, only GuiLayerDesktop is shown.
  87. * This feature prevents services from showing sensitive information when flipper is locked.
  88. *
  89. * @param gui Gui instance
  90. * @param lockdown bool, true if enabled
  91. */
  92. void gui_set_lockdown(Gui* gui, bool lockdown);
  93. /** Acquire Direct Draw lock and get Canvas instance
  94. *
  95. * This method return Canvas instance for use in monopoly mode. Direct draw lock
  96. * disables input and draw call dispatch functions in GUI service. No other
  97. * applications or services will be able to draw until gui_direct_draw_release
  98. * call.
  99. *
  100. * @param gui The graphical user interface
  101. *
  102. * @return Canvas instance
  103. */
  104. Canvas* gui_direct_draw_acquire(Gui* gui);
  105. /** Release Direct Draw Lock
  106. *
  107. * Release Direct Draw Lock, enables Input and Draw call processing. Canvas
  108. * acquired in gui_direct_draw_acquire will become invalid after this call.
  109. *
  110. * @param gui Gui instance
  111. */
  112. void gui_direct_draw_release(Gui* gui);
  113. #ifdef __cplusplus
  114. }
  115. #endif