gui.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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)(uint8_t* data, size_t size, void* context);
  22. #define RECORD_GUI "gui"
  23. typedef struct Gui Gui;
  24. /** Add view_port to view_port tree
  25. *
  26. * @remark thread safe
  27. *
  28. * @param gui Gui instance
  29. * @param view_port ViewPort instance
  30. * @param[in] layer GuiLayer where to place view_port
  31. */
  32. void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer);
  33. /** Remove view_port from rendering tree
  34. *
  35. * @remark thread safe
  36. *
  37. * @param gui Gui instance
  38. * @param view_port ViewPort instance
  39. */
  40. void gui_remove_view_port(Gui* gui, ViewPort* view_port);
  41. /** Send ViewPort to the front
  42. *
  43. * Places selected ViewPort to the top of the drawing stack
  44. *
  45. * @param gui Gui instance
  46. * @param view_port ViewPort instance
  47. */
  48. void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port);
  49. /** Send ViewPort to the back
  50. *
  51. * Places selected ViewPort to the bottom of the drawing stack
  52. *
  53. * @param gui Gui instance
  54. * @param view_port ViewPort instance
  55. */
  56. void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port);
  57. /** Add gui canvas commit callback
  58. *
  59. * This callback will be called upon Canvas commit Callback dispatched from GUI
  60. * thread and is time critical
  61. *
  62. * @param gui Gui instance
  63. * @param callback GuiCanvasCommitCallback
  64. * @param context GuiCanvasCommitCallback context
  65. */
  66. void gui_add_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context);
  67. /** Remove gui canvas commit callback
  68. *
  69. * @param gui Gui instance
  70. * @param callback GuiCanvasCommitCallback
  71. * @param context GuiCanvasCommitCallback context
  72. */
  73. void gui_remove_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context);
  74. /** Get gui canvas frame buffer size
  75. * *
  76. * @param gui Gui instance
  77. * @return size_t size of frame buffer in bytes
  78. */
  79. size_t gui_get_framebuffer_size(Gui* gui);
  80. /** Set lockdown mode
  81. *
  82. * When lockdown mode is enabled, only GuiLayerDesktop is shown.
  83. * This feature prevents services from showing sensitive information when flipper is locked.
  84. *
  85. * @param gui Gui instance
  86. * @param lockdown bool, true if enabled
  87. */
  88. void gui_set_lockdown(Gui* gui, bool lockdown);
  89. #ifdef __cplusplus
  90. }
  91. #endif