Skip to content

Commit ed06d84

Browse files
committed
Add RFC: Separate context bar code into UI and plugins
1 parent d767e24 commit ed06d84

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

text/0061-context-bar-in-plugins.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Summary
2+
3+
<!-- Simple explanation of feature/changes -->
4+
5+
Move the source-type specific implementation of the context-bar into plugins.
6+
7+
## Implementation in libobs
8+
9+
Add a new callback into `struct obs_source_info`.
10+
```c
11+
obs_properties_t *(*get_short_properties)(void *data, void *type_data);
12+
```
13+
This callback will return the property information of this source for the context bar.
14+
Unlike the existing callbacks `get_properties` and `get_properties2`,
15+
it is expected to return a few subset of the properties.
16+
17+
Add a new API `obs_source_short_properties` that returns the property list for the context bar.
18+
If `obs_source_info.get_short_properties` is not defined, the API will return NULL.
19+
The interface is the same as the existing API `obs_source_properties`.
20+
```c
21+
obs_properties_t *obs_source_properties(const obs_source_t *source);
22+
obs_properties_t *obs_source_short_properties(const obs_source_t *source);
23+
```
24+
25+
The context-bar version of `obs_get_source_properties` won't be implemented
26+
since the context-bar will be created only when there is an instance.
27+
```c
28+
obs_properties_t *obs_get_source_properties(const char *id);
29+
```
30+
31+
## Alternative implementation in libobs
32+
33+
Add new callbacks `obs_property_set_context_bar` and `obs_property_context_bar` as below.
34+
These callbacks will set and get each property that should be available for the context bar.
35+
```c
36+
void obs_property_set_context_bar(obs_property_t *p, bool enabled);
37+
bool obs_property_context_bar(obs_property_t *p);
38+
```
39+
40+
In the callback `get_properties` or `get_properties2` in the plugin should call `obs_property_set_context_bar` to indicate which properties should be shown in the context bar.
41+
42+
The drawback of this alternative implementation is that the properties of the context bar should be fully subset of the properties of the original properties.
43+
For example, though the browser source has a button `Refresh cache of current page` in the property dialog, the context bar has a short text on the button `Refresh`. This difference will be covered by a different description returned by `get_short_properties`.
44+
45+
46+
## Implementation in UI
47+
48+
The `class WidgetInfo` displays one property and handles its value and change.
49+
The class is currently expected to be instantiated from the `class OBSPropertiesView`.
50+
In the new implementation, the `class WidgetInfo` will be renamed to `class OBSPropertyWidget` and it will be generalized so that the class can be instantiated from the context bar.
51+
Major changes in the class will be changing direct access to the members of `class OBSPropertiesView` but will emit signals, which will be connected to slots on the parent instance.
52+
53+
For the filter properties, the undo and redo handler is pushed into the stack using a 500-millisecond timer.
54+
The timer will be moved into `class OBSPropertiesView`.
55+
Hopefully, this change will fix [the minor bug on the redo](https://github.com/obsproject/obs-studio/issues/10628).
56+
57+
## Implementation in plugins
58+
59+
All these plugins will implement the callback `get_short_properties`.
60+
61+
- `browser_source`
62+
- `wasapi_input_capture`, `wasapi_output_capture`, `wasapi_process_output_capture`
63+
- `coreaudio_input_capture`, `coreaudio_output_capture`
64+
- `pulse_input_capture`, `pulse_output_capture`
65+
- `alsa_input_capture`
66+
- `window_capture`
67+
- `xcomposite_input`
68+
- `monitor_capture`
69+
- `display_capture`
70+
- `xshm_input`
71+
- `dshow_input`
72+
- `game_capture`
73+
- `image_source`
74+
- `color_source`
75+
- `text_ft2_source`
76+
- `text_gdiplus`
77+
78+
# Motivation
79+
80+
<!-- What problem is this solving? What are the common use cases? -->
81+
82+
UI has the implementation of the context-bar for each source type.
83+
As a result, property names are hard-coded in both UI and plugins.
84+
In possible future modification, it might require to change both plugin and UI, which might lead to a potential bug.
85+
86+
It is a good implementation to separate the plugin-specific implementation from the UI.
87+
88+
This will also enable 3rd party plugins to have their context bar.
89+
90+
# Drawbacks
91+
92+
<!-- What is the potential detriment for adding this feature/change? -->
93+
94+
This makes it unable to have features that are not supported by `obs_property_t`.
95+
So far, I don't see any features on the context bar that cannot be covered by this RFC.
96+
97+
# Additional Information
98+
99+
<!-- Any additional information that may not be covered above that you feel is relevant. External links, references, examples, etc. -->
100+
101+
Preliminary implementation in libobs is as below.
102+
https://github.com/norihiro/obs-studio/commit/8ffc569f13993af317b2917bfade409cf6d02799

0 commit comments

Comments
 (0)