xremote_common_view.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*!
  2. * @file flipper-xremote/views/xremote_common_view.h
  3. @license This project is released under the GNU GPLv3 License
  4. * @copyright (c) 2023 Sandro Kalatozishvili (s.kalatoz@gmail.com)
  5. *
  6. * @brief Common view and canvas functionality shared between the pages.
  7. */
  8. #pragma once
  9. #include <furi.h>
  10. #include <gui/view.h>
  11. #include <gui/elements.h>
  12. #include <notification/notification.h>
  13. #include <notification/notification_messages.h>
  14. #include <infrared_transmit.h>
  15. #include <xc_icons.h>
  16. #include "../infrared/infrared_remote.h"
  17. #define XREMOTE_BUTTON_COUNT 26
  18. #define XREMOTE_COMMAND_POWER "Power"
  19. #define XREMOTE_COMMAND_SETUP "Setup"
  20. #define XREMOTE_COMMAND_INPUT "Input"
  21. #define XREMOTE_COMMAND_MENU "Menu"
  22. #define XREMOTE_COMMAND_LIST "List"
  23. #define XREMOTE_COMMAND_INFO "Info"
  24. #define XREMOTE_COMMAND_BACK "Back"
  25. #define XREMOTE_COMMAND_OK "Ok"
  26. #define XREMOTE_COMMAND_UP "Up"
  27. #define XREMOTE_COMMAND_DOWN "Down"
  28. #define XREMOTE_COMMAND_LEFT "Left"
  29. #define XREMOTE_COMMAND_RIGHT "Right"
  30. #define XREMOTE_COMMAND_JUMP_FORWARD "Next"
  31. #define XREMOTE_COMMAND_JUMP_BACKWARD "Prev"
  32. #define XREMOTE_COMMAND_FAST_FORWARD "Fast_fo"
  33. #define XREMOTE_COMMAND_FAST_BACKWARD "Fast_ba"
  34. #define XREMOTE_COMMAND_PLAY_PAUSE "Play_pa"
  35. #define XREMOTE_COMMAND_PAUSE "Pause"
  36. #define XREMOTE_COMMAND_PLAY "Play"
  37. #define XREMOTE_COMMAND_STOP "Stop"
  38. #define XREMOTE_COMMAND_MUTE "Mute"
  39. #define XREMOTE_COMMAND_MODE "Mode"
  40. #define XREMOTE_COMMAND_VOL_UP "Vol_up"
  41. #define XREMOTE_COMMAND_VOL_DOWN "Vol_dn"
  42. #define XREMOTE_COMMAND_NEXT_CHAN "Ch_next"
  43. #define XREMOTE_COMMAND_PREV_CHAN "Ch_prev"
  44. typedef enum {
  45. XRemoteEventReserved = 200,
  46. XRemoteEventSignalReceived,
  47. XRemoteEventSignalFinish,
  48. XRemoteEventSignalSave,
  49. XRemoteEventSignalRetry,
  50. XRemoteEventSignalSend,
  51. XRemoteEventSignalSkip,
  52. XRemoteEventSignalAskExit,
  53. XRemoteEventSignalExit
  54. } XRemoteEvent;
  55. typedef enum {
  56. /* Navigation */
  57. XRemoteIconOk,
  58. XRemoteIconEnter,
  59. XRemoteIconBack,
  60. XRemoteIconArrowUp,
  61. XRemoteIconArrowDown,
  62. XRemoteIconArrowLeft,
  63. XRemoteIconArrowRight,
  64. /* Playback */
  65. XRemoteIconPlay,
  66. XRemoteIconPause,
  67. XRemoteIconStop,
  68. XRemoteIconPlayPause,
  69. XRemoteIconFastForward,
  70. XRemoteIconFastBackward,
  71. XRemoteIconJumpForward,
  72. XRemoteIconJumpBackward
  73. } XRemoteIcon;
  74. typedef struct {
  75. bool ok_pressed;
  76. bool back_pressed;
  77. bool up_pressed;
  78. bool down_pressed;
  79. bool left_pressed;
  80. bool right_pressed;
  81. void* context;
  82. } XRemoteViewModel;
  83. typedef enum {
  84. XRemoteViewNone,
  85. XRemoteViewSignal,
  86. XRemoteViewTextInput,
  87. XRemoteViewDialogExit,
  88. /* Main page */
  89. XRemoteViewSubmenu,
  90. XRemoteViewLearn,
  91. XRemoteViewSaved,
  92. XRemoteViewAnalyzer,
  93. XRemoteViewSettings,
  94. XRemoteViewAbout,
  95. /* Remote app */
  96. XRemoteViewIRSubmenu,
  97. XRemoteViewIRGeneral,
  98. XRemoteViewIRControl,
  99. XRemoteViewIRNavigation,
  100. XRemoteViewIRPlayer,
  101. XRemoteViewIRCustom
  102. } XRemoteViewID;
  103. typedef struct XRemoteView XRemoteView;
  104. typedef void (*XRemoteClearCallback)(void* context);
  105. typedef void (*XRemoteViewDrawFunction)(Canvas*, XRemoteViewModel*);
  106. typedef XRemoteView* (*XRemoteViewAllocator)(void* app_ctx);
  107. const char* xremote_button_get_name(int index);
  108. void xremote_canvas_draw_header(Canvas* canvas, ViewOrientation orient, const char* section);
  109. void xremote_canvas_draw_exit_footer(Canvas* canvas, ViewOrientation orient, const char* text);
  110. void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon);
  111. void xremote_canvas_draw_button(
  112. Canvas* canvas,
  113. bool pressed,
  114. uint8_t x,
  115. uint8_t y,
  116. XRemoteIcon icon);
  117. void xremote_canvas_draw_button_png(
  118. Canvas* canvas,
  119. bool pressed,
  120. uint8_t x,
  121. uint8_t y,
  122. const Icon* icon);
  123. void xremote_canvas_draw_button_wide(
  124. Canvas* canvas,
  125. bool pressed,
  126. uint8_t x,
  127. uint8_t y,
  128. char* text,
  129. XRemoteIcon icon);
  130. void xremote_canvas_draw_button_size(
  131. Canvas* canvas,
  132. bool pressed,
  133. uint8_t x,
  134. uint8_t y,
  135. uint8_t xy,
  136. char* text,
  137. XRemoteIcon icon);
  138. void xremote_canvas_draw_frame(
  139. Canvas* canvas,
  140. bool pressed,
  141. uint8_t x,
  142. uint8_t y,
  143. uint8_t xl,
  144. const char* text);
  145. XRemoteView*
  146. xremote_view_alloc(void* app_ctx, ViewInputCallback input_cb, ViewDrawCallback draw_cb);
  147. void xremote_view_free(XRemoteView* rview);
  148. InfraredRemoteButton* xremote_view_get_button_by_name(XRemoteView* rview, const char* name);
  149. bool xremote_view_press_button(XRemoteView* rview, InfraredRemoteButton* button);
  150. bool xremote_view_send_ir_msg_by_name(XRemoteView* rview, const char* name);
  151. void xremote_view_set_context(XRemoteView* rview, void* context, XRemoteClearCallback on_clear);
  152. void* xremote_view_get_context(XRemoteView* rview);
  153. void xremote_view_clear_context(XRemoteView* rview);
  154. void* xremote_view_get_app_context(XRemoteView* rview);
  155. View* xremote_view_get_view(XRemoteView* rview);