xremote_common_view.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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_SETUP "Setup"
  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. /* Navigation */
  42. XRemoteIconOk,
  43. XRemoteIconEnter,
  44. XRemoteIconBack,
  45. XRemoteIconArrowUp,
  46. XRemoteIconArrowDown,
  47. XRemoteIconArrowLeft,
  48. XRemoteIconArrowRight,
  49. /* Playback */
  50. XRemoteIconPlay,
  51. XRemoteIconPause,
  52. XRemoteIconStop,
  53. XRemoteIconPlayPause,
  54. XRemoteIconFastForward,
  55. XRemoteIconFastBackward,
  56. XRemoteIconJumpForward,
  57. XRemoteIconJumpBackward
  58. } XRemoteIcon;
  59. typedef struct {
  60. bool ok_pressed;
  61. bool back_pressed;
  62. bool up_pressed;
  63. bool down_pressed;
  64. bool left_pressed;
  65. bool right_pressed;
  66. uint32_t reserverd;
  67. } XRemoteViewModel;
  68. typedef enum {
  69. XRemoteViewNone,
  70. /* Main page */
  71. XRemoteViewSubmenu,
  72. XRemoteViewLearn,
  73. XRemoteViewSaved,
  74. XRemoteViewSettings,
  75. XRemoteViewAbout,
  76. /* Remote app */
  77. XRemoteViewIRSubmenu,
  78. XRemoteViewIRGeneral,
  79. XRemoteViewIRControl,
  80. XRemoteViewIRNavigation,
  81. XRemoteViewIRPlayer,
  82. XRemoteViewIRCustom
  83. } XRemoteViewID;
  84. typedef struct XRemoteView XRemoteView;
  85. typedef void (*XRemoteViewClearCallback)(void *context);
  86. void xremote_canvas_draw_header(Canvas* canvas, const char* section);
  87. void xremote_canvas_draw_exit_footer(Canvas* canvas, char *text);
  88. void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon);
  89. void xremote_canvas_draw_button(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, XRemoteIcon icon);
  90. void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, XRemoteIcon icon);
  91. XRemoteView* xremote_view_alloc(NotificationApp* notifications, ViewInputCallback input_cb, ViewDrawCallback draw_cb);
  92. void xremote_view_free(XRemoteView* rview);
  93. View* xremote_view_get_view(XRemoteView* rview);
  94. void xremote_view_send_ir(XRemoteView *rview, const char *name);
  95. void xremote_view_set_context(XRemoteView* rview, void *context, XRemoteViewClearCallback on_clear);
  96. void* xremote_view_get_context(XRemoteView* rview);
  97. void xremote_view_clear_context(XRemoteView* rview);