dialogs.h 3.5 KB

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