Skip to content

How Graphics context seems to work in JSFX plugins

Trond Lossius edited this page Jan 23, 2022 · 1 revision

If a JSFX plugin with GUI has UI embedded in TCP or MCP, one is tempted to assume that the plugin has several views according to MVC thinking: The free-standing GUI in the FX window would be one view, the embedded UI in TCP another view, and the embedded UI in MCP a third view.

Having played around with how the plugin GUI actually behaves, this however does not seem to be the case. It appears that the plugin has one and only one instance of the GUI. First of all, UI can be embedded in one of TCP and MCP, but not both at the same time.

  • If ( UI is not embedded )
    • UI is drawn in the FX Window
  • If ( UI is embedded ) AND ( UI is not currently displayed in the FX window )
    • GUI draws only to its embedded slot
    • gfx_w and gfx_h will adjust accordingly (to relatively small values)
  • If ( UI is embedded ) AND ( UI is also displayed in FX Window)
    • GUI context is that of the FX window
    • The resulting UI as drawn in FX window is then copied across as a bit image to the embedded frame
    • The bit image is greyed out and a notice is posted on top of it: "PLUG UI IS OPEN"
    • Depending on GUI size the image as copied across to the embedded slot might be out of proportions

If the UI is to be adjusted and simplified when embedded (responsive), this need to be done by checking for the overall width and height of the UI, alternatively this can be combined with a test of the 1 flag in gfx_ext_flags - ref. the JSFX documentation. In the process of doing so, it is possible to use the Reaper JSFX editor to monitor values of parameters, including gfx_w and gfx_h. The UI then need to be simplified with smaller widgets when these two values reach a lower threshold.

I should be able to set a flag for this in determineGeometry(), as this method is called by all plugins with a GUI. This test needs to consider the value of gfx_ext_retina and compensate accordingly, as width and height will be 2x if retina.

Clone this wiki locally