xremote_common_view.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. #define XREMOTE_COMMAND_POWER "Power"
  17. #define XREMOTE_COMMAND_SETTINGS "Settings"
  18. #define XREMOTE_COMMAND_INPUT "Input"
  19. #define XREMOTE_COMMAND_MENU "Menu"
  20. #define XREMOTE_COMMAND_LIST "List"
  21. #define XREMOTE_COMMAND_INFO "Info"
  22. #define XREMOTE_COMMAND_BACK "Back"
  23. #define XREMOTE_COMMAND_OK "Ok"
  24. #define XREMOTE_COMMAND_UP "Up"
  25. #define XREMOTE_COMMAND_DOWN "Down"
  26. #define XREMOTE_COMMAND_LEFT "Left"
  27. #define XREMOTE_COMMAND_RIGHT "Right"
  28. #define XREMOTE_COMMAND_JUMP_FORWARD "Jump_forward"
  29. #define XREMOTE_COMMAND_JUMP_BACKWARD "Jump_backward"
  30. #define XREMOTE_COMMAND_FAST_FORWARD "Fast_forward"
  31. #define XREMOTE_COMMAND_FAST_BACKWARD "Fast_backward"
  32. #define XREMOTE_COMMAND_PAUSE_PLAY "Pause_play"
  33. #define XREMOTE_COMMAND_PAUSE "Pause"
  34. #define XREMOTE_COMMAND_PLAY "Play"
  35. #define XREMOTE_COMMAND_STOP "Stop"
  36. #define XREMOTE_COMMAND_VOL_UP "Vol_up"
  37. #define XREMOTE_COMMAND_VOL_DOWN "Vol_down"
  38. #define XREMOTE_COMMAND_NEXT_CHAN "Next_chan"
  39. #define XREMOTE_COMMAND_PREV_CHAN "Prev_chan"
  40. typedef enum {
  41. /* Controller */
  42. XRemoteIconOk,
  43. XRemoteIconArrowUp,
  44. XRemoteIconArrowDown,
  45. XRemoteIconArrowLeft,
  46. XRemoteIconArrowRight,
  47. /* Playback */
  48. XRemoteIconPlay,
  49. XRemoteIconPause,
  50. XRemoteIconStop,
  51. XRemoteIconPlayPause,
  52. XRemoteIconFastForward,
  53. XRemoteIconFastBackward,
  54. XRemoteIconJumpForward,
  55. XRemoteIconJumpBackward
  56. } XRemoteIcon;
  57. typedef struct {
  58. bool ok_pressed;
  59. bool back_pressed;
  60. bool up_pressed;
  61. bool down_pressed;
  62. bool left_pressed;
  63. bool right_pressed;
  64. uint32_t reserverd;
  65. } XRemoteViewModel;
  66. typedef enum {
  67. XRemoteViewNone,
  68. /* Main page */
  69. XRemoteViewSubmenu,
  70. XRemoteViewLearn,
  71. XRemoteViewSaved,
  72. XRemoteViewSettings,
  73. XRemoteViewAbout,
  74. /* Remote app */
  75. XRemoteViewIRSubmenu,
  76. XRemoteViewIRGeneral,
  77. XRemoteViewIRControl,
  78. XRemoteViewIRNavigation,
  79. XRemoteViewIRPlayer,
  80. XRemoteViewIRCustom
  81. } XRemoteViewID;
  82. typedef struct XRemoteView XRemoteView;
  83. typedef void (*XRemoteViewClearCallback)(void *context);
  84. void xremote_canvas_draw_header(Canvas* canvas, const char* section);
  85. void xremote_canvas_draw_exit_footer(Canvas* canvas, char *text);
  86. void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon);
  87. void xremote_canvas_draw_button(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, XRemoteIcon icon);
  88. void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, const Icon* icon);
  89. XRemoteView* xremote_view_alloc(NotificationApp* notifications, ViewInputCallback input_cb, ViewDrawCallback draw_cb);
  90. void xremote_view_free(XRemoteView* rview);
  91. View* xremote_view_get_view(XRemoteView* rview);
  92. void xremote_view_send_ir(XRemoteView *rview, const char *name);
  93. void xremote_view_set_context(XRemoteView* rview, void *context, XRemoteViewClearCallback on_clear);
  94. void* xremote_view_get_context(XRemoteView* rview);
  95. void xremote_view_clear_context(XRemoteView* rview);