Skip to content

Commit 312f858

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

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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_context_bar_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_context_bar_properties` that returns the property list for the context bar.
18+
If `obs_source_info.get_context_bar_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_context_bar_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`.
34+
These callbacks will set and get each property that should be available for the context bar.
35+
36+
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.
37+
38+
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.
39+
For example, though the browser source has a button `Refresh cache of current page` in the property dialog, the context bar has a short button `Refresh`. This difference will be covered by a different description returned by `get_context_bar_properties`.
40+
41+
42+
## Implementation in UI
43+
44+
The `class WidgetInfo` displays one property and handles its value and change.
45+
The class is currently expected to be instantiated from the `class OBSPropertiesView`.
46+
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.
47+
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.
48+
49+
For the filter properties, the undo and redo handler is pushed into the stack using a 500-millisecond timer.
50+
The timer will be moved into `class OBSPropertiesView`.
51+
Hopefully, this change will fix [the minor bug on the redo](https://github.com/obsproject/obs-studio/issues/10628).
52+
53+
## Implementation in plugins
54+
55+
All these plugins will implement the callback `get_context_bar_properties`.
56+
57+
- `browser_source`
58+
- `wasapi_input_capture`, `wasapi_output_capture`, `wasapi_process_output_capture`
59+
- `coreaudio_input_capture`, `coreaudio_output_capture`
60+
- `pulse_input_capture`, `pulse_output_capture`
61+
- `alsa_input_capture`
62+
- `window_capture`
63+
- `xcomposite_input`
64+
- `monitor_capture`
65+
- `display_capture`
66+
- `xshm_input`
67+
- `dshow_input`
68+
- `game_capture`
69+
- `image_source`
70+
- `color_source`
71+
- `text_ft2_source`
72+
- `text_gdiplus`
73+
74+
# Motivation
75+
76+
<!-- What problem is this solving? What are the common use cases? -->
77+
78+
UI has the implementation of the context-bar for each source type.
79+
As a result, property names are hard-coded in both UI and plugins.
80+
In possible future modification, it might require to change both plugin and UI, which might lead to a potential bug.
81+
82+
It is a good implementation to separate the plugin-specific implementation from the UI.
83+
84+
This will also enable 3rd party plugins to have their context bar.
85+
86+
# Drawbacks
87+
88+
<!-- What is the potential detriment for adding this feature/change? -->
89+
90+
This makes it unable to have features that are not supported by `obs_property_t`.
91+
So far, I don't see any features on the context bar that cannot be covered by this RFC.
92+
93+
# Additional Information
94+
95+
<!-- Any additional information that may not be covered above that you feel is relevant. External links, references, examples, etc. -->
96+
97+
Preliminary implementation in libobs is as below.
98+
https://github.com/norihiro/obs-studio/commit/dbbb706f32ed5de73aabda4a788d7460ecec033f

0 commit comments

Comments
 (0)