popup.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #pragma once
  2. #include <gui/view.h>
  3. /* Popup anonymous structure */
  4. typedef struct Popup Popup;
  5. /* Popup result callback type
  6. * @warning comes from GUI thread
  7. */
  8. typedef void (*PopupCallback)(void* context);
  9. /* Allocate and initialize popup
  10. * This popup used to ask simple questions like Yes/
  11. */
  12. Popup* popup_alloc();
  13. /* Deinitialize and free popup
  14. * @param popup - Popup instance
  15. */
  16. void popup_free(Popup* popup);
  17. /* Get popup view
  18. * @param popup - Popup instance
  19. * @return View instance that can be used for embedding
  20. */
  21. View* popup_get_view(Popup* popup);
  22. /* Set popup header text
  23. * @param popup - Popup instance
  24. * @param text - text to be shown
  25. */
  26. void popup_set_callback(Popup* popup, PopupCallback callback);
  27. /* Set popup context
  28. * @param popup - Popup instance
  29. * @param context - context pointer, will be passed to result callback
  30. */
  31. void popup_set_context(Popup* popup, void* context);
  32. /* Set popup header text
  33. * If text is null, popup header will not be rendered
  34. * @param popup - Popup instance
  35. * @param text - text to be shown, can be multiline
  36. * @param x, y - text position
  37. * @param horizontal, vertical - text aligment
  38. */
  39. void popup_set_header(
  40. Popup* popup,
  41. const char* text,
  42. uint8_t x,
  43. uint8_t y,
  44. Align horizontal,
  45. Align vertical);
  46. /* Set popup text
  47. * If text is null, popup text will not be rendered
  48. * @param popup - Popup instance
  49. * @param text - text to be shown, can be multiline
  50. * @param x, y - text position
  51. * @param horizontal, vertical - text aligment
  52. */
  53. void popup_set_text(
  54. Popup* popup,
  55. const char* text,
  56. uint8_t x,
  57. uint8_t y,
  58. Align horizontal,
  59. Align vertical);
  60. /* Set popup icon
  61. * @param popup - Popup instance
  62. * @param x, y - icon position
  63. * @param name - icon to be shown
  64. */
  65. void popup_set_icon(Popup* popup, int8_t x, int8_t y, IconName name);
  66. /* Set popup timeout
  67. * @param popup - Popup instance
  68. * @param timeout_in_ms - popup timeout value in milliseconds
  69. */
  70. void popup_set_timeout(Popup* popup, uint32_t timeout_in_ms);
  71. /* Enable popup timeout
  72. * @param popup - Popup instance
  73. */
  74. void popup_enable_timeout(Popup* popup);
  75. /* Disable popup timeout
  76. * @param popup - Popup instance
  77. */
  78. void popup_disable_timeout(Popup* popup);