Skip to content

Commit 3e126ea

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

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

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

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 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 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 diffrent description returned by `get_context_bar_properties`.
40+
41+
42+
## Implementation in UI
43+
44+
The `class WidgetInfo` displays one property and handles it's 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+
<!-- TODO: Also fix the bug on the timer -->
49+
50+
For the filter properties, the undo and redo handler is pushed into the stack using a 500-millisecond timer.
51+
The timer will be moved into `class OBSPropertiesView`.
52+
Hopefully, this change will fix a minor bug on the redo.
53+
54+
## Implementation in plugins
55+
56+
All these plugins will implement the callback `get_context_bar_properties`.
57+
58+
- `browser_source`
59+
- `wasapi_input_capture`, `wasapi_output_capture`, `wasapi_process_output_capture`
60+
- `coreaudio_input_capture`, `coreaudio_output_capture`
61+
- `pulse_input_capture`, `pulse_output_capture`
62+
- `alsa_input_capture`
63+
- `window_capture`
64+
- `xcomposite_input`
65+
- `monitor_capture`
66+
- `display_capture`
67+
- `xshm_input`
68+
- `dshow_input`
69+
- `game_capture`
70+
- `image_source`
71+
- `color_source`
72+
- `text_ft2_source`
73+
- `text_gdiplus`
74+
75+
# Motivation
76+
77+
<!-- What problem is this solving? What are the common use cases? -->
78+
79+
UI has the implementation of the context-bar for each source type.
80+
As the result, property names are hard-coded in both UI and plugins.
81+
In possible future modification, it might require to change both plugin and UI, which might lead a potential bug.
82+
83+
It is a good implementation to separate the plugin-specific implementation from the UI.
84+
85+
This will also enable 3rd party plugins to have their context bar.
86+
87+
# Drawbacks
88+
89+
<!-- What is the potential detriment for adding this feature/change? -->
90+
91+
This makes unable to have features that are not supported by `obs_property_t`.
92+
So far, I don't see any features on the context bar that cannot cover by this RFC.
93+
94+
# Additional Information
95+
96+
<!-- Any additional information that may not be covered above that you feel is relevant. External links, references, examples, etc. -->

0 commit comments

Comments
 (0)