infrared_app_view_manager.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /**
  2. * @file infrared_app_view_manager.h
  3. * Infrared: Scene events description
  4. */
  5. #pragma once
  6. #include <gui/modules/button_menu.h>
  7. #include <gui/modules/text_input.h>
  8. #include <gui/view_stack.h>
  9. #include <gui/modules/button_panel.h>
  10. #include <furi.h>
  11. #include <gui/view_dispatcher.h>
  12. #include <gui/modules/dialog_ex.h>
  13. #include <gui/modules/submenu.h>
  14. #include <gui/modules/popup.h>
  15. #include <gui/modules/loading.h>
  16. #include "infrared_app_event.h"
  17. #include "view/infrared_progress_view.h"
  18. /** Infrared View manager class */
  19. class InfraredAppViewManager {
  20. public:
  21. /** Infrared View Id enum, it is used
  22. * to identify added views */
  23. enum class ViewId : uint8_t {
  24. DialogEx,
  25. TextInput,
  26. Submenu,
  27. ButtonMenu,
  28. UniversalRemote,
  29. Popup,
  30. };
  31. /** Class constructor */
  32. InfraredAppViewManager();
  33. /** Class destructor */
  34. ~InfraredAppViewManager();
  35. /** Switch to another view
  36. *
  37. * @param id - view id to switch to
  38. */
  39. void switch_to(ViewId id);
  40. /** Receive event from queue
  41. *
  42. * @param event - received event
  43. */
  44. void receive_event(InfraredAppEvent* event);
  45. /** Send event to queue
  46. *
  47. * @param event - event to send
  48. */
  49. void send_event(InfraredAppEvent* event);
  50. /** Clear events that already in queue
  51. *
  52. * @param event - event to send
  53. */
  54. void clear_events();
  55. /** Get dialog_ex view module
  56. *
  57. * @retval dialog_ex view module
  58. */
  59. DialogEx* get_dialog_ex();
  60. /** Get submenu view module
  61. *
  62. * @retval submenu view module
  63. */
  64. Submenu* get_submenu();
  65. /** Get popup view module
  66. *
  67. * @retval popup view module
  68. */
  69. Popup* get_popup();
  70. /** Get text_input view module
  71. *
  72. * @retval text_input view module
  73. */
  74. TextInput* get_text_input();
  75. /** Get button_menu view module
  76. *
  77. * @retval button_menu view module
  78. */
  79. ButtonMenu* get_button_menu();
  80. /** Get button_panel view module
  81. *
  82. * @retval button_panel view module
  83. */
  84. ButtonPanel* get_button_panel();
  85. /** Get view_stack view module used in universal remote
  86. *
  87. * @retval view_stack view module
  88. */
  89. ViewStack* get_universal_view_stack();
  90. /** Get progress view module
  91. *
  92. * @retval progress view module
  93. */
  94. InfraredProgressView* get_progress();
  95. /** Get loading view module
  96. *
  97. * @retval loading view module
  98. */
  99. Loading* get_loading();
  100. /** Get event queue
  101. *
  102. * @retval event queue
  103. */
  104. osMessageQueueId_t get_event_queue();
  105. /** Callback to handle back button
  106. *
  107. * @param context - context to pass to callback
  108. * @retval always returns VIEW_IGNORE
  109. */
  110. uint32_t previous_view_callback(void* context);
  111. private:
  112. /** View Dispatcher instance.
  113. * It handles view switching */
  114. ViewDispatcher* view_dispatcher;
  115. /** Gui instance */
  116. Gui* gui;
  117. /** Text input view module instance */
  118. TextInput* text_input;
  119. /** DialogEx view module instance */
  120. DialogEx* dialog_ex;
  121. /** Submenu view module instance */
  122. Submenu* submenu;
  123. /** Popup view module instance */
  124. Popup* popup;
  125. /** ButtonMenu view module instance */
  126. ButtonMenu* button_menu;
  127. /** ButtonPanel view module instance */
  128. ButtonPanel* button_panel;
  129. /** ViewStack view module instance */
  130. ViewStack* universal_view_stack;
  131. /** ProgressView view module instance */
  132. InfraredProgressView* progress_view;
  133. /** Loading view module instance */
  134. Loading* loading_view;
  135. /** Queue to handle events, which are processed in scenes */
  136. osMessageQueueId_t event_queue;
  137. /** Add View to pull of views
  138. *
  139. * @param view_id - id to identify view
  140. * @param view - view to add
  141. */
  142. void add_view(ViewId view_id, View* view);
  143. };