dialogs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #pragma once
  2. #include <furi.h>
  3. #include <gui/canvas.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /****************** COMMON ******************/
  8. typedef struct DialogsApp DialogsApp;
  9. /****************** FILE SELECT ******************/
  10. /**
  11. * Shows and processes the file selection dialog
  12. * @param context api pointer
  13. * @param path path to directory
  14. * @param extension file extension to be offered for selection
  15. * @param selected_filename buffer where the selected filename will be saved
  16. * @param selected_filename_size and the size of this buffer
  17. * @param preselected_filename filename to be preselected
  18. * @return bool whether a file was selected
  19. */
  20. bool dialog_file_select_show(
  21. DialogsApp* context,
  22. const char* path,
  23. const char* extension,
  24. char* result,
  25. uint8_t result_size,
  26. const char* preselected_filename);
  27. /****************** MESSAGE ******************/
  28. /**
  29. * Message result type
  30. */
  31. typedef enum {
  32. DialogMessageButtonBack,
  33. DialogMessageButtonLeft,
  34. DialogMessageButtonCenter,
  35. DialogMessageButtonRight,
  36. } DialogMessageButton;
  37. /**
  38. * Message struct
  39. */
  40. typedef struct DialogMessage DialogMessage;
  41. /**
  42. * Allocate and fill message
  43. * @return DialogMessage*
  44. */
  45. DialogMessage* dialog_message_alloc();
  46. /**
  47. * Free message struct
  48. * @param message message pointer
  49. */
  50. void dialog_message_free(DialogMessage* message);
  51. /**
  52. * Set message text
  53. * @param message message pointer
  54. * @param text text, can be NULL if you don't want to display the text
  55. * @param x x position
  56. * @param y y position
  57. * @param horizontal horizontal alignment
  58. * @param vertical vertical alignment
  59. */
  60. void dialog_message_set_text(
  61. DialogMessage* message,
  62. const char* text,
  63. uint8_t x,
  64. uint8_t y,
  65. Align horizontal,
  66. Align vertical);
  67. /**
  68. * Set message header
  69. * @param message message pointer
  70. * @param text text, can be NULL if you don't want to display the header
  71. * @param x x position
  72. * @param y y position
  73. * @param horizontal horizontal alignment
  74. * @param vertical vertical alignment
  75. */
  76. void dialog_message_set_header(
  77. DialogMessage* message,
  78. const char* text,
  79. uint8_t x,
  80. uint8_t y,
  81. Align horizontal,
  82. Align vertical);
  83. /**
  84. * Set message icon
  85. * @param message message pointer
  86. * @param icon icon pointer, can be NULL if you don't want to display the icon
  87. * @param x x position
  88. * @param y y position
  89. */
  90. void dialog_message_set_icon(DialogMessage* message, const Icon* icon, uint8_t x, uint8_t y);
  91. /**
  92. * Set message buttons text, button text can be NULL if you don't want to display and process some buttons
  93. * @param message message pointer
  94. * @param left left button text, can be NULL if you don't want to display the left button
  95. * @param center center button text, can be NULL if you don't want to display the center button
  96. * @param right right button text, can be NULL if you don't want to display the right button
  97. */
  98. void dialog_message_set_buttons(
  99. DialogMessage* message,
  100. const char* left,
  101. const char* center,
  102. const char* right);
  103. /**
  104. * Show message from filled struct
  105. * @param context api pointer
  106. * @param message message struct pointer to be shown
  107. * @return DialogMessageButton type
  108. */
  109. DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage* message);
  110. #ifdef __cplusplus
  111. }
  112. #endif