popup_vm.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include "generic_view_module.h"
  3. #include <gui/modules/popup.h>
  4. class PopupVM : public GenericViewModule {
  5. public:
  6. PopupVM();
  7. ~PopupVM() final;
  8. View* get_view() final;
  9. void clean() final;
  10. /**
  11. * Set popup header text
  12. * @param text - text to be shown
  13. */
  14. void set_callback(PopupCallback callback);
  15. /**
  16. * Set popup context
  17. * @param context - context pointer, will be passed to result callback
  18. */
  19. void set_context(void* context);
  20. /**
  21. * Set popup header text
  22. * If text is null, popup header will not be rendered
  23. * @param text - text to be shown, can be multiline
  24. * @param x, y - text position
  25. * @param horizontal, vertical - text aligment
  26. */
  27. void set_header(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical);
  28. /**
  29. * Set popup text
  30. * If text is null, popup text will not be rendered
  31. * @param text - text to be shown, can be multiline
  32. * @param x, y - text position
  33. * @param horizontal, vertical - text aligment
  34. */
  35. void set_text(const char* text, uint8_t x, uint8_t y, Align horizontal, Align vertical);
  36. /**
  37. * Set popup icon
  38. * If icon position is negative, popup icon will not be rendered
  39. * @param x, y - icon position
  40. * @param name - icon to be shown
  41. */
  42. void set_icon(int8_t x, int8_t y, const Icon* icon);
  43. /**
  44. * Set popup timeout
  45. * @param timeout_in_ms - popup timeout value in milliseconds
  46. */
  47. void set_timeout(uint32_t timeout_in_ms);
  48. /**
  49. * Enable popup timeout
  50. */
  51. void enable_timeout();
  52. /**
  53. * Disable popup timeout
  54. */
  55. void disable_timeout();
  56. private:
  57. Popup* popup;
  58. };