xremote_app.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*!
  2. * @file flipper-xremote/xremote_app.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 Shared functionality and data types between the apps.
  7. */
  8. #pragma once
  9. #include <furi.h>
  10. #include <gui/gui.h>
  11. #include <gui/view.h>
  12. #include <gui/view_dispatcher.h>
  13. #include <gui/modules/submenu.h>
  14. #include <gui/modules/dialog_ex.h>
  15. #include <gui/modules/variable_item_list.h>
  16. #include <notification/notification.h>
  17. #include <notification/notification_messages.h>
  18. #include <flipper_format/flipper_format.h>
  19. #include <storage/storage.h>
  20. #include <dialogs/dialogs.h>
  21. #include "views/xremote_common_view.h"
  22. #include "xc_icons.h"
  23. #define xremote_app_assert_void(cond) if (!cond) return
  24. #define xremote_app_assert(cond, var) if (!cond) return var
  25. typedef struct {
  26. ViewOrientation orientation;
  27. uint32_t repeat_count;
  28. } XRemoteAppSettings;
  29. XRemoteAppSettings* xremote_app_settings_alloc();
  30. void xremote_app_settings_free(XRemoteAppSettings* settings);
  31. typedef struct {
  32. XRemoteAppSettings* app_settings;
  33. NotificationApp* notifications;
  34. ViewDispatcher* view_dispatcher;
  35. void* app_argument;
  36. Gui* gui;
  37. } XRemoteAppContext;
  38. XRemoteAppContext* xremote_app_context_alloc(void* arg);
  39. void xremote_app_context_free(XRemoteAppContext* ctx);
  40. bool xremote_app_settings_store(XRemoteAppSettings* settings);
  41. bool xremote_app_settings_load(XRemoteAppSettings* settings);
  42. typedef XRemoteView* (*XRemoteViewAllocator)(NotificationApp* notifications);
  43. typedef void (*XRemoteAppClearCallback)(void *context);
  44. typedef struct {
  45. XRemoteAppClearCallback on_clear;
  46. XRemoteAppContext* app_ctx;
  47. XRemoteViewID submenu_id;
  48. XRemoteViewID view_id;
  49. XRemoteView* view_ctx;
  50. Submenu* submenu;
  51. void *context;
  52. } XRemoteApp;
  53. void xremote_app_submenu_add(XRemoteApp* app, const char *name, uint32_t index, SubmenuItemCallback callback);
  54. void xremote_app_submenu_alloc(XRemoteApp* app, uint32_t index, ViewNavigationCallback prev_cb);
  55. void xremote_app_submenu_free(XRemoteApp *app);
  56. void xremote_app_view_alloc(XRemoteApp *app, uint32_t view_id, XRemoteViewAllocator allocator);
  57. void xremote_app_view_free(XRemoteApp* app);
  58. void xremote_app_view_set_previous_callback(XRemoteApp* app, ViewNavigationCallback callback);
  59. void xremote_app_set_view_context(XRemoteApp* app, void *context, XRemoteViewClearCallback on_clear);
  60. void xremote_app_set_user_context(XRemoteApp* app, void *context, XRemoteAppClearCallback on_clear);
  61. void xremote_app_user_context_free(XRemoteApp* app);
  62. bool xremote_app_has_view(XRemoteApp *app, uint32_t view_id);
  63. void xremote_app_switch_to_view(XRemoteApp *app, uint32_t view_id);
  64. void xremote_app_switch_to_submenu(XRemoteApp *app);
  65. XRemoteApp* xremote_app_alloc(XRemoteAppContext *ctx);
  66. void xremote_app_free(XRemoteApp* app);