obs-ui.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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_ui_info {
  20. const char *name;
  21. const char *task;
  22. const char *target;
  23. };
  24. /*
  25. * ===========================================
  26. * Module UI calls
  27. * ===========================================
  28. *
  29. * Modules can specify custom user-interface-specific exports. UI exports
  30. * can be within the same library as the actual core logic, or separated in to
  31. * different modules to split up UI logic and core module logic.
  32. *
  33. * The reasoning for this is to allow for custom user interface of differing
  34. * toolkits or for automatically generated user interface, or to simply allow
  35. * separation of UI code from core code (which may often be in differing
  36. * languages)
  37. *
  38. * A module with UI calls needs to export this function:
  39. * + enum_ui
  40. *
  41. * The enum_ui function provides an obs_ui_info structure for each
  42. * input/output/etc. For example, to export Qt-specific configuration
  43. * functions, the exports might be something like:
  44. * + mysource_config_qt
  45. * + myoutput_config_qt
  46. * + myencoder_config_panel_qt
  47. *
  48. * ..And the values given to enum_ui would be something this:
  49. *
  50. * struct obs_ui_info ui_list[] = {
  51. * {"mysource", "config", "qt"},
  52. * {"myoutput", "config", "qt"},
  53. * {"myencoder", "config_panel", "qt"}
  54. * };
  55. *
  56. * 'qt' could be replaced with 'wx' or something similar if using wxWidgets,
  57. * or 'win32' if using bare windows API.
  58. *
  59. * ===========================================
  60. * Primary Exports
  61. * ===========================================
  62. * bool enum_ui(size_t idx, const struct obs_ui_info **ui_info);
  63. *
  64. * idx: index of the enumeration
  65. * ui_info: pointer to the ui data for this enumeration
  66. * Return value: false when no more available.
  67. *
  68. * ===========================================
  69. * Export Format
  70. * ===========================================
  71. * Although the 'export' variable specifies the full export name, each
  72. * export should be formatted as so:
  73. *
  74. * bool [name]_[task]_[target](void *data, void *ui_data);
  75. *
  76. * [name]: specifies the name of the input/output/encoder/etc.
  77. * [task]: specifies the task of the user interface, most often 'config',
  78. * or 'config_panel'
  79. * [target]: specifies the target or toolkit of the user interface, such as
  80. * but not limited to 'qt', 'wx', 'win32', 'cocoa', etc. If
  81. * a custom solution is desired, it can use a program-specific
  82. * name, such as 'myprogram'.
  83. *
  84. * The 'data' variable points to the input/output/encoder/etc. The 'ui_data'
  85. * varaible points to the UI parent or UI-specific data to be used with the
  86. * custom user interface.
  87. *
  88. * What 'ui_data' points to differs depending on the target, and you should
  89. * use discretion and consistency when using this variable to relay
  90. * information to the UI function. For example, it would be ideal to have
  91. * 'ui_data' point to a parent, QWidget for Qt, or a wxWindow for wxWidgets,
  92. * etc.
  93. *
  94. * For example, if I had a source called 'mysource', and I wanted to export
  95. * a function that handles the task 'config' with the Qt library, the export
  96. * would be:
  97. *
  98. * bool mysource_config_qt(void *data, void *ui_data);
  99. *
  100. * In this example, the ui_data variable should ideally be a pointer to the
  101. * QWidget parent, if any.
  102. */
  103. /**
  104. * ===========================================
  105. * obs_call_ui
  106. * ===========================================
  107. * Requests UI to be displayed
  108. *
  109. * This is typically used for things like creating dialogs/panels/etc for
  110. * specific toolkits.
  111. *
  112. * name: Name of the input/output/etc type that UI was requested for
  113. * task: Task of the user interface (i.e. "config", "config_panel")
  114. * target: Desired target (i.e. "qt", "wx", "gtk3", "win32", etc)
  115. * data: Pointer to the obs input/output/etc
  116. * ui_data: UI-specific data, usually a parent pointer/handle (if any)
  117. *
  118. * Return value: OBS_UI_SUCCESS if the UI was successful
  119. * OBS_UI_CANCEL if the UI was cancelled by the user
  120. * OBS_UI_NOTFOUND if the UI callback was not found
  121. */
  122. #define OBS_UI_SUCCESS 0
  123. #define OBS_UI_CANCEL -1
  124. #define OBS_UI_NOTFOUND -2
  125. EXPORT int obs_call_ui(const char *name, const char *task, const char *target,
  126. void *data, void *ui_data);
  127. #ifdef __cplusplus
  128. }
  129. #endif