obs-ui.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /******************************************************************************
  2. Copyright (C) 2013 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 "obs.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. struct obs_modal_ui {
  20. const char *name;
  21. const char *task;
  22. const char *target;
  23. bool (*callback)(void *object, void *ui_data);
  24. };
  25. struct obs_modeless_ui {
  26. const char *name;
  27. const char *task;
  28. const char *target;
  29. void *(*callback)(void *object, void *ui_data);
  30. };
  31. /*
  32. * ===========================================
  33. * Module UI calls
  34. * ===========================================
  35. *
  36. * Modules can specify custom user-interface-specific exports. UI exports
  37. * can be within the same library as the actual core logic, or separated in to
  38. * different modules to split up UI logic and core module logic.
  39. *
  40. * The reasoning for this is to allow for custom user interface of differing
  41. * toolkits or for automatically generated user interface, or to simply allow
  42. * separation of UI code from core code (which may often be in differing
  43. * languages)
  44. *
  45. * A module with UI calls needs to export one or both of these functions:
  46. * + enum_modal_ui
  47. * + enum_modeless_ui
  48. *
  49. * The enum_ui function provides an obs_ui_info structure for each
  50. * input/output/etc. Modeless UI should be exported enum_modeless_ui. For
  51. * example, to export Qt-specific configuration functions, the values given to
  52. * enum_modal_ui might look something like this:
  53. *
  54. * struct obs_modal_ui ui_list[] = {
  55. * {"mysource", "config", "qt", mysource_config},
  56. * {"myoutput", "config", "qt", myoutput_config},
  57. * {"myencoder", "config", "qt", myenoder_config}
  58. * };
  59. *
  60. * 'qt' could be replaced with 'wx' or something similar if using wxWidgets,
  61. * or 'win32' if using bare windows API. It could also specify a custom name
  62. * if desired (use with discretion).
  63. *
  64. * ===========================================
  65. * Primary Exports
  66. * ===========================================
  67. * bool enum_modal_ui(size_t idx, struct obs_modal_ui *ui_info);
  68. *
  69. * idx: index of the enumeration
  70. * ui_info: pointer to the ui data for this enumeration
  71. * Return value: false when no more available.
  72. *
  73. * ---------------------------------------------------------
  74. * bool enum_modeless_ui(size_t idx, struct obs_modeless_ui *ui_info);
  75. *
  76. * idx: index of the enumeration
  77. * ui_info: pointer to the ui data for this enumeration
  78. * Return value: false when no more available.
  79. *
  80. * ===========================================
  81. * Modal UI Callback
  82. * ===========================================
  83. * bool modal_callback(void *object, void *ui_data);
  84. *
  85. * The 'object' variable points to the input/output/encoder/etc. The
  86. * 'ui_data' varaible points to the UI parent or UI-specific data to be used
  87. * with the custom user interface.
  88. *
  89. * What 'ui_data' points to differs depending on the target, and you should
  90. * use discretion and consistency when using this variable to relay
  91. * information to the UI function. For example, it would be ideal to have
  92. * 'ui_data' point to a parent, QWidget for Qt, or a wxWindow for wxWidgets,
  93. * etc., though it's up to the discretion of the developer to define that
  94. * value. Because of the nature of void pointers, discretion and consistency
  95. * is advised.
  96. *
  97. * ===========================================
  98. * Modeless UI Callback
  99. * ===========================================
  100. * void *modeless_callback(void *data, void *ui_data);
  101. *
  102. * Modeless UI calls return immediately, and typically are supposed to return
  103. * a pointer or handle to the specific UI object that was created. For
  104. * example, a Qt object would ideally return a pointer to a QWidget. Again,
  105. * discretion and consistency is advised for the return value.
  106. */
  107. /**
  108. * ===========================================
  109. * obs_exec_ui
  110. * ===========================================
  111. * Requests modal UI to be displayed. Returns when user is complete.
  112. *
  113. * name: Name of the input/output/etc type that UI was requested for
  114. * task: Task of the user interface (usually "config")
  115. * target: Desired target (i.e. "qt", "wx", "gtk3", "win32", etc)
  116. * data: Pointer to the obs input/output/etc
  117. * ui_data: UI-specific data, usually a parent pointer/handle (if any)
  118. *
  119. * Return value: OBS_UI_SUCCESS if the UI was successful
  120. * OBS_UI_CANCEL if the UI was cancelled by the user
  121. * OBS_UI_NOTFOUND if the UI callback was not found
  122. */
  123. #define OBS_UI_SUCCESS 0
  124. #define OBS_UI_CANCEL -1
  125. #define OBS_UI_NOTFOUND -2
  126. EXPORT int obs_exec_ui(const char *name, const char *task, const char *target,
  127. void *data, void *ui_data);
  128. /**
  129. * ===========================================
  130. * obs_create_ui
  131. * ===========================================
  132. * Requests modeless UI to be created. Returns immediately.
  133. *
  134. * name: Name of the input/output/etc type that UI was requested for
  135. * task: Task of the user interface
  136. * target: Desired target (i.e. "qt", "wx", "gtk3", "win32", etc)
  137. * data: Pointer to the obs input/output/etc
  138. * ui_data: UI-specific data, usually a parent pointer/handle (if any)
  139. *
  140. * Return value: Pointer to the target-specific modeless object, or NULL if
  141. * not found or failed.
  142. */
  143. EXPORT void *obs_create_ui(const char *name, const char *task,
  144. const char *target, void *data, void *ui_data);
  145. #ifdef __cplusplus
  146. }
  147. #endif