xremote_common_view.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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_COMMAND_POWER "Power"
  18. #define XREMOTE_COMMAND_SETUP "Setup"
  19. #define XREMOTE_COMMAND_INPUT "Input"
  20. #define XREMOTE_COMMAND_MENU "Menu"
  21. #define XREMOTE_COMMAND_LIST "List"
  22. #define XREMOTE_COMMAND_INFO "Info"
  23. #define XREMOTE_COMMAND_BACK "Back"
  24. #define XREMOTE_COMMAND_OK "Ok"
  25. #define XREMOTE_COMMAND_UP "Up"
  26. #define XREMOTE_COMMAND_DOWN "Down"
  27. #define XREMOTE_COMMAND_LEFT "Left"
  28. #define XREMOTE_COMMAND_RIGHT "Right"
  29. #define XREMOTE_COMMAND_JUMP_FORWARD "Next"
  30. #define XREMOTE_COMMAND_JUMP_BACKWARD "Prev"
  31. #define XREMOTE_COMMAND_FAST_FORWARD "Fast_fo"
  32. #define XREMOTE_COMMAND_FAST_BACKWARD "Fast_ba"
  33. #define XREMOTE_COMMAND_PLAY_PAUSE "Play_pa"
  34. #define XREMOTE_COMMAND_PAUSE "Pause"
  35. #define XREMOTE_COMMAND_PLAY "Play"
  36. #define XREMOTE_COMMAND_STOP "Stop"
  37. #define XREMOTE_COMMAND_MUTE "Mute"
  38. #define XREMOTE_COMMAND_MODE "Mode"
  39. #define XREMOTE_COMMAND_VOL_UP "Vol_up"
  40. #define XREMOTE_COMMAND_VOL_DOWN "Vol_dn"
  41. #define XREMOTE_COMMAND_NEXT_CHAN "Ch_next"
  42. #define XREMOTE_COMMAND_PREV_CHAN "Ch_prev"
  43. typedef enum {
  44. /* Navigation */
  45. XRemoteIconOk,
  46. XRemoteIconEnter,
  47. XRemoteIconBack,
  48. XRemoteIconArrowUp,
  49. XRemoteIconArrowDown,
  50. XRemoteIconArrowLeft,
  51. XRemoteIconArrowRight,
  52. /* Playback */
  53. XRemoteIconPlay,
  54. XRemoteIconPause,
  55. XRemoteIconStop,
  56. XRemoteIconPlayPause,
  57. XRemoteIconFastForward,
  58. XRemoteIconFastBackward,
  59. XRemoteIconJumpForward,
  60. XRemoteIconJumpBackward
  61. } XRemoteIcon;
  62. typedef struct {
  63. bool ok_pressed;
  64. bool back_pressed;
  65. bool up_pressed;
  66. bool down_pressed;
  67. bool left_pressed;
  68. bool right_pressed;
  69. void* context;
  70. } XRemoteViewModel;
  71. typedef enum {
  72. XRemoteViewNone,
  73. /* Main page */
  74. XRemoteViewSubmenu,
  75. XRemoteViewLearn,
  76. XRemoteViewSaved,
  77. XRemoteViewSettings,
  78. XRemoteViewAbout,
  79. /* Remote app */
  80. XRemoteViewIRSubmenu,
  81. XRemoteViewIRGeneral,
  82. XRemoteViewIRControl,
  83. XRemoteViewIRNavigation,
  84. XRemoteViewIRPlayer,
  85. XRemoteViewIRCustom
  86. } XRemoteViewID;
  87. typedef struct XRemoteView XRemoteView;
  88. typedef void (*XRemoteViewClearCallback)(void *context);
  89. typedef void (*XRemoteViewDrawFunction)(Canvas*, XRemoteViewModel*);
  90. void xremote_canvas_draw_header(Canvas* canvas, ViewOrientation orient, const char* section);
  91. void xremote_canvas_draw_exit_footer(Canvas* canvas, ViewOrientation orient, const char *text);
  92. void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon);
  93. void xremote_canvas_draw_button(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, XRemoteIcon icon);
  94. void xremote_canvas_draw_button_png(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, const Icon* icon);
  95. void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, XRemoteIcon icon);
  96. void xremote_canvas_draw_button_size(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xy, char* text, XRemoteIcon icon);
  97. void xremote_canvas_draw_frame(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xl, const char *text);
  98. XRemoteView* xremote_view_alloc(void *app_ctx, ViewInputCallback input_cb, ViewDrawCallback draw_cb);
  99. void xremote_view_free(XRemoteView* rview);
  100. InfraredRemoteButton* xremote_view_get_button_by_name(XRemoteView *rview, const char* name);
  101. bool xremote_view_press_button(XRemoteView *rview, InfraredRemoteButton* button);
  102. bool xremote_view_send_ir_msg_by_name(XRemoteView *rview, const char *name);
  103. void xremote_view_set_context(XRemoteView* rview, void *context, XRemoteViewClearCallback on_clear);
  104. void* xremote_view_get_context(XRemoteView* rview);
  105. void xremote_view_clear_context(XRemoteView* rview);
  106. void* xremote_view_get_app_context(XRemoteView* rview);
  107. View* xremote_view_get_view(XRemoteView* rview);