dialogs.h 3.5 KB

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