obs-properties.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /******************************************************************************
  2. Copyright (C) 2014 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include "util/c99defs.h"
  16. #include "obs-data.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. enum obs_property_type {
  21. OBS_PROPERTY_INVALID,
  22. OBS_PROPERTY_BOOL,
  23. OBS_PROPERTY_INT,
  24. OBS_PROPERTY_FLOAT,
  25. OBS_PROPERTY_TEXT,
  26. OBS_PROPERTY_PATH,
  27. OBS_PROPERTY_LIST,
  28. OBS_PROPERTY_COLOR,
  29. OBS_PROPERTY_BUTTON,
  30. };
  31. enum obs_combo_format {
  32. OBS_COMBO_FORMAT_INVALID,
  33. OBS_COMBO_FORMAT_INT,
  34. OBS_COMBO_FORMAT_FLOAT,
  35. OBS_COMBO_FORMAT_STRING
  36. };
  37. enum obs_combo_type {
  38. OBS_COMBO_TYPE_INVALID,
  39. OBS_COMBO_TYPE_EDITABLE,
  40. OBS_COMBO_TYPE_LIST,
  41. };
  42. enum obs_path_type {
  43. OBS_PATH_FILE,
  44. OBS_PATH_DIRECTORY
  45. };
  46. enum obs_text_type {
  47. OBS_TEXT_DEFAULT,
  48. OBS_TEXT_PASSWORD,
  49. OBS_TEXT_MULTILINE,
  50. };
  51. struct obs_properties;
  52. struct obs_property;
  53. typedef struct obs_properties *obs_properties_t;
  54. typedef struct obs_property *obs_property_t;
  55. /* ------------------------------------------------------------------------- */
  56. EXPORT obs_properties_t obs_properties_create(void);
  57. EXPORT obs_properties_t obs_properties_create_param(void *param,
  58. void (*destroy)(void *param));
  59. EXPORT void obs_properties_destroy(obs_properties_t props);
  60. EXPORT void obs_properties_set_param(obs_properties_t props,
  61. void *param, void (*destroy)(void *param));
  62. EXPORT void *obs_properties_get_param(obs_properties_t props);
  63. EXPORT obs_property_t obs_properties_first(obs_properties_t props);
  64. EXPORT obs_property_t obs_properties_get(obs_properties_t props,
  65. const char *property);
  66. /* used internally by libobs */
  67. extern void obs_properties_apply_settings(obs_properties_t props,
  68. obs_data_t settings);
  69. /* ------------------------------------------------------------------------- */
  70. /**
  71. * Callback for when a button property is clicked. If the properties
  72. * need to be refreshed due to changes to the property layout, return true,
  73. * otherwise return false.
  74. */
  75. typedef bool (*obs_property_clicked_t)(obs_properties_t props,
  76. obs_property_t property, void *data);
  77. EXPORT obs_property_t obs_properties_add_bool(obs_properties_t props,
  78. const char *name, const char *description);
  79. EXPORT obs_property_t obs_properties_add_int(obs_properties_t props,
  80. const char *name, const char *description,
  81. int min, int max, int step);
  82. EXPORT obs_property_t obs_properties_add_float(obs_properties_t props,
  83. const char *name, const char *description,
  84. double min, double max, double step);
  85. EXPORT obs_property_t obs_properties_add_text(obs_properties_t props,
  86. const char *name, const char *description,
  87. enum obs_text_type type);
  88. /**
  89. * Adds a 'path' property. Can be a directory or a file.
  90. *
  91. * If target is a file path, the filters should be this format, separated by
  92. * double semi-colens, and extensions separated by space:
  93. * "Example types 1 and 2 (*.ex1 *.ex2);;Example type 3 (*.ex3)"
  94. *
  95. * @param props Properties object
  96. * @param name Settings name
  97. * @param description Description (display name) of the property
  98. * @param type Type of path (directory or file)
  99. * @param filter If type is a file path, then describes the file filter
  100. * that the user can browse. Items are separated via
  101. * double semi-colens. If multiple file types in a
  102. * filter, separate with space.
  103. */
  104. EXPORT obs_property_t obs_properties_add_path(obs_properties_t props,
  105. const char *name, const char *description,
  106. enum obs_path_type type, const char *filter,
  107. const char *default_path);
  108. EXPORT obs_property_t obs_properties_add_list(obs_properties_t props,
  109. const char *name, const char *description,
  110. enum obs_combo_type type, enum obs_combo_format format);
  111. EXPORT obs_property_t obs_properties_add_color(obs_properties_t props,
  112. const char *name, const char *description);
  113. EXPORT obs_property_t obs_properties_add_button(obs_properties_t props,
  114. const char *name, const char *text,
  115. obs_property_clicked_t callback);
  116. /* ------------------------------------------------------------------------- */
  117. /**
  118. * Optional callback for when a property is modified. If the properties
  119. * need to be refreshed due to changes to the property layout, return true,
  120. * otherwise return false.
  121. */
  122. typedef bool (*obs_property_modified_t)(obs_properties_t props,
  123. obs_property_t property, obs_data_t settings);
  124. EXPORT void obs_property_set_modified_callback(obs_property_t p,
  125. obs_property_modified_t modified);
  126. EXPORT bool obs_property_modified(obs_property_t p, obs_data_t settings);
  127. EXPORT bool obs_property_button_clicked(obs_property_t p, void *obj);
  128. EXPORT void obs_property_set_visible(obs_property_t p, bool visible);
  129. EXPORT void obs_property_set_enabled(obs_property_t p, bool enabled);
  130. EXPORT const char * obs_property_name(obs_property_t p);
  131. EXPORT const char * obs_property_description(obs_property_t p);
  132. EXPORT enum obs_property_type obs_property_get_type(obs_property_t p);
  133. EXPORT bool obs_property_enabled(obs_property_t p);
  134. EXPORT bool obs_property_visible(obs_property_t p);
  135. EXPORT bool obs_property_next(obs_property_t *p);
  136. EXPORT int obs_property_int_min(obs_property_t p);
  137. EXPORT int obs_property_int_max(obs_property_t p);
  138. EXPORT int obs_property_int_step(obs_property_t p);
  139. EXPORT double obs_property_float_min(obs_property_t p);
  140. EXPORT double obs_property_float_max(obs_property_t p);
  141. EXPORT double obs_property_float_step(obs_property_t p);
  142. EXPORT enum obs_text_type obs_proprety_text_type(obs_property_t p);
  143. EXPORT enum obs_path_type obs_property_path_type(obs_property_t p);
  144. EXPORT const char * obs_property_path_filter(obs_property_t p);
  145. EXPORT const char * obs_property_path_default_path(obs_property_t p);
  146. EXPORT enum obs_combo_type obs_property_list_type(obs_property_t p);
  147. EXPORT enum obs_combo_format obs_property_list_format(obs_property_t p);
  148. EXPORT void obs_property_list_clear(obs_property_t p);
  149. EXPORT size_t obs_property_list_add_string(obs_property_t p,
  150. const char *name, const char *val);
  151. EXPORT size_t obs_property_list_add_int(obs_property_t p,
  152. const char *name, long long val);
  153. EXPORT size_t obs_property_list_add_float(obs_property_t p,
  154. const char *name, double val);
  155. EXPORT void obs_property_list_item_disable(obs_property_t p, size_t idx,
  156. bool disabled);
  157. EXPORT bool obs_property_list_item_disabled(obs_property_t p, size_t idx);
  158. EXPORT void obs_property_list_item_remove(obs_property_t p, size_t idx);
  159. EXPORT size_t obs_property_list_item_count(obs_property_t p);
  160. EXPORT const char *obs_property_list_item_name(obs_property_t p, size_t idx);
  161. EXPORT const char *obs_property_list_item_string(obs_property_t p, size_t idx);
  162. EXPORT long long obs_property_list_item_int(obs_property_t p, size_t idx);
  163. EXPORT double obs_property_list_item_float(obs_property_t p, size_t idx);
  164. #ifdef __cplusplus
  165. }
  166. #endif