|
| 1 | +# Summary |
| 2 | + |
| 3 | +API similar to browser panels API to expose the internal implementation of an OBS frontend editable canvas for re-use by developers. |
| 4 | + |
| 5 | +# Motivation |
| 6 | + |
| 7 | +This should enable consistency in plugins which create additional canvases in OBS, and prevent OBS code from being duplicated in this type of plugins. |
| 8 | + |
| 9 | +# Drawbacks |
| 10 | + |
| 11 | +The drawbacks are an additional API to maintain. |
| 12 | + |
| 13 | +# Additional Information |
| 14 | + |
| 15 | +## API interface |
| 16 | + |
| 17 | +```c++ |
| 18 | +class QOBSEditableCanvasView: public QWidget { |
| 19 | +public: |
| 20 | + // When currentScene == nullptr, no scene editing facilities are present |
| 21 | + // |
| 22 | + // The class will add a reference to the currentScene which is passed in, and |
| 23 | + // release previously held reference when switching to a different currentScene. |
| 24 | + // |
| 25 | + virtual void setOBSRenderCallbackAndEditableScene(render_callback_t* renderCallback, obs_scene_t* currentScene = nullptr) = 0; |
| 26 | + |
| 27 | + // Release references to canvas and scene. |
| 28 | + virtual void clearOBSRenderCallbackAndEditableScene() = 0; |
| 29 | +}; |
| 30 | + |
| 31 | +QOBSEditableCanvasView* obs_frontend_create_editable_canvas_view(render_callback_t* renderCallback, obs_scene_t* currentScene = nullptr); |
| 32 | +``` |
| 33 | +
|
| 34 | +## External render callback |
| 35 | +
|
| 36 | +We need an external render callback in order to support rendering different OBS objects to the canvas view surface (sources, canvases, views, etc.) |
| 37 | +
|
| 38 | +## Usage |
| 39 | +
|
| 40 | +When a component wishing to display an editable canvas initializes, it will call `obs_frontend_create_editable_canvas_view` |
| 41 | +to obtain an instance pointer of `QOBSEditableCanvasView`. |
| 42 | +
|
| 43 | +From that point on, it will interact with the QWidget-based class as with any other QWidget, with the addition of specialized |
| 44 | +methods for specifying current canvas & editable scene. |
| 45 | +
|
| 46 | +## Changes |
| 47 | +
|
| 48 | +This will require changes to `OBSProjector` (and maybe `OBSQTDisplay`) to support additional methods, and calling an external render callback. |
0 commit comments