You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.1KB

  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. #include <stdint.h>
  6. typedef enum {
  7. OSDIALOG_INFO,
  8. OSDIALOG_WARNING,
  9. OSDIALOG_ERROR,
  10. } osdialog_message_level;
  11. typedef enum {
  12. OSDIALOG_OK,
  13. OSDIALOG_OK_CANCEL,
  14. OSDIALOG_YES_NO,
  15. } osdialog_message_buttons;
  16. /** Launches a message box
  17. Returns 1 if the "OK" or "Yes" button was pressed
  18. */
  19. int osdialog_message(osdialog_message_level level, osdialog_message_buttons buttons, const char *message);
  20. typedef enum {
  21. OSDIALOG_OPEN,
  22. OSDIALOG_OPEN_DIR,
  23. OSDIALOG_SAVE,
  24. } osdialog_file_action;
  25. /** Linked list of patterns */
  26. typedef struct osdialog_filter_patterns {
  27. char *pattern;
  28. struct osdialog_filter_patterns *next;
  29. } osdialog_filter_patterns;
  30. /** Linked list of file filters */
  31. typedef struct osdialog_filters {
  32. char *name;
  33. osdialog_filter_patterns *patterns;
  34. struct osdialog_filters *next;
  35. } osdialog_filters;
  36. /** Launches a file dialog and returns the selected path or NULL if nothing was selected
  37. If the return result is not NULL, caller must free() it
  38. `path` is the default folder the file dialog will attempt to open in.
  39. `filename` is the default text that will appear in the filename input. Relevant to save dialog only.
  40. `filters` is a list of patterns to filter the file selection, or NULL
  41. */
  42. char *osdialog_file(osdialog_file_action action, const char *path, const char *filename, osdialog_filters *filters);
  43. /** Parses a filter string of the form
  44. Source:c,cpp,m;Header:h,hpp
  45. Caller must eventually free with osdialog_filters_free()
  46. */
  47. osdialog_filters *osdialog_filters_parse(const char *str);
  48. void osdialog_filters_free(osdialog_filters *filters);
  49. typedef struct {
  50. uint8_t r, g, b, a;
  51. } osdialog_color;
  52. /** Launches an RGBA color picker dialog and sets `color` to the selected color
  53. Returns 1 if "OK" was pressed
  54. `color` should be set to the initial color before calling. It is only overwritten if the user selects "OK".
  55. `opacity` enables the opacity slider by setting to 1. Not supported on Windows.
  56. TODO Implement on Mac
  57. */
  58. int osdialog_color_picker(osdialog_color *color, int opacity);
  59. #ifdef __cplusplus
  60. }
  61. #endif