xremote_common_view.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 "Next"
  29. #define XREMOTE_COMMAND_JUMP_BACKWARD "Prev"
  30. #define XREMOTE_COMMAND_FAST_FORWARD "Fast_fo"
  31. #define XREMOTE_COMMAND_FAST_BACKWARD "Fast_ba"
  32. #define XREMOTE_COMMAND_PLAY_PAUSE "Play_pa"
  33. #define XREMOTE_COMMAND_PAUSE "Pause"
  34. #define XREMOTE_COMMAND_PLAY "Play"
  35. #define XREMOTE_COMMAND_STOP "Stop"
  36. #define XREMOTE_COMMAND_MUTE "Mute"
  37. #define XREMOTE_COMMAND_MODE "Mode"
  38. #define XREMOTE_COMMAND_VOL_UP "Vol_up"
  39. #define XREMOTE_COMMAND_VOL_DOWN "Vol_dn"
  40. #define XREMOTE_COMMAND_NEXT_CHAN "Ch_next"
  41. #define XREMOTE_COMMAND_PREV_CHAN "Ch_prev"
  42. typedef enum {
  43. /* Navigation */
  44. XRemoteIconOk,
  45. XRemoteIconEnter,
  46. XRemoteIconBack,
  47. XRemoteIconArrowUp,
  48. XRemoteIconArrowDown,
  49. XRemoteIconArrowLeft,
  50. XRemoteIconArrowRight,
  51. /* Playback */
  52. XRemoteIconPlay,
  53. XRemoteIconPause,
  54. XRemoteIconStop,
  55. XRemoteIconPlayPause,
  56. XRemoteIconFastForward,
  57. XRemoteIconFastBackward,
  58. XRemoteIconJumpForward,
  59. XRemoteIconJumpBackward
  60. } XRemoteIcon;
  61. typedef struct {
  62. bool ok_pressed;
  63. bool back_pressed;
  64. bool up_pressed;
  65. bool down_pressed;
  66. bool left_pressed;
  67. bool right_pressed;
  68. uint32_t reserverd;
  69. } XRemoteViewModel;
  70. typedef enum {
  71. XRemoteViewNone,
  72. /* Main page */
  73. XRemoteViewSubmenu,
  74. XRemoteViewLearn,
  75. XRemoteViewSaved,
  76. XRemoteViewSettings,
  77. XRemoteViewAbout,
  78. /* Remote app */
  79. XRemoteViewIRSubmenu,
  80. XRemoteViewIRGeneral,
  81. XRemoteViewIRControl,
  82. XRemoteViewIRNavigation,
  83. XRemoteViewIRPlayer,
  84. XRemoteViewIRCustom
  85. } XRemoteViewID;
  86. typedef struct XRemoteView XRemoteView;
  87. typedef void (*XRemoteViewClearCallback)(void *context);
  88. void xremote_canvas_draw_header(Canvas* canvas, const char* section);
  89. void xremote_canvas_draw_exit_footer(Canvas* canvas, char *text);
  90. void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon);
  91. void xremote_canvas_draw_button(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, XRemoteIcon icon);
  92. void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, XRemoteIcon icon);
  93. void xremote_canvas_draw_frame(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xl, const char *text);
  94. XRemoteView* xremote_view_alloc(NotificationApp* notifications, ViewInputCallback input_cb, ViewDrawCallback draw_cb);
  95. void xremote_view_free(XRemoteView* rview);
  96. View* xremote_view_get_view(XRemoteView* rview);
  97. void xremote_view_send_ir(XRemoteView *rview, const char *name);
  98. void xremote_view_set_context(XRemoteView* rview, void *context, XRemoteViewClearCallback on_clear);
  99. void* xremote_view_get_context(XRemoteView* rview);
  100. void xremote_view_clear_context(XRemoteView* rview);