DISTRHO / DPF

DISTRHO Plugin Framework
ISC License
672 stars 97 forks source link

[Question] file browser for ExternalWindow? #329

Open lucianoiam opened 3 years ago

lucianoiam commented 3 years ago

Currently we have Window::openFileBrowser() which is part of DGL. Does it make sense to take it out of DGL and make it available to custom UIs like ExternalWindow?

Not sure this is trivial or overly complex, I guess that depends on how much the file browser relies on DGL/Pugl.

falkTX commented 3 years ago

It used to depend on pugl, but not anymore. So indeed it could be made to work for external windows too.

Note that LV2 hosts already provide ways to get a file browser without the UI needing to do it (ie, host-side file browser).

Best would be to have some example plugins that use external ui, like your html variant. Might be a bit of work now, but do you think you can create a repo of example plugins using html uis? Not sure if it fits the repo that contains the actual html uis or not, doesnt matter. It will be extremely useful on the long-term to have easy to build + ready to run plugin examples that we can tweak and test. Then everytime we need a new feature like this, we can just add in something in the examples and verify that all works.

lucianoiam commented 3 years ago

Nice touch from LV2 didn't know that.

The DPF+HTML project comes with some HTML UI examples, the canonical gain and a trivial synth drum. There is a third one here but it is based on DGL.

These examples are there mostly for 1) showing how to organize project files and 2) showing how UI and DSP are completely decoupled so the 4 combinations of Web/C++ UI/DSP are possible.

The goal is different to the DPF mini-examples which are focused on a single framework function.

Do you mean having some mini-examples akin to DPF, but with a HTML interface? I agree that sounds useful.

falkTX commented 3 years ago

Do you mean having some mini-examples akin to DPF, but with a HTML interface? I agree that sounds useful.

I mean a repository/project purposefully meant for examples. But I see you set up your hiphop similar to DPF, where it has implementation and a few examples too. So that works well enough.

Just create a branch and add some stubs for this, assuming the API will go through the DPF UI class just like what is already in place there. Then ping me from time to time if I forget to check on this. I am focused on trying some VST3 stuff at the moment, want to keep at it for the time being for a few days now.

lucianoiam commented 3 years ago

I saw some VST3 related commits, good stuff. Ok on the examples branch, will add a skeleton project for the file browser. JavaScript call will match C++'s as done for previous features. I find the DPF API good and simple so mirroring it is one of the project goals.

lucianoiam commented 3 years ago

FYI there is a new mini-example here . Once the file chooser can be called from ExternalWindow I will update the new example accordingly.

falkTX commented 3 years ago

If you want some quick advancements, you can hack around the code to allow the UI method to request a state file, but then only pass it through the host and not through DGL Window methods. Since LV2 has this and Carla implements it, that part should already work and can work as proof of concept. The platform independent code can be added later on.

falkTX commented 3 years ago

I mean, test this new plugin as LV2 in Carla. It should allow you to get a native carla-provided file picker dialog. From your code I see you already setup "state file" as needed for this, so it ought to just work with some hacking around.

PS: the parameter implementation (initParameter etc) are not required anymore if you do not have any. They are no longer pure virtual methods on the Plugin class, though still pure virtual on UI for now.

lucianoiam commented 3 years ago

That worked, thanks a lot!. Also removed the parameter calls.

falkTX commented 3 years ago

Just pushed 29709cbe4e1f5d97b7630fd1664e2eb1210bb82f which has the needed pieces for this. I did not implement the external-ui support, but the file dialog stuff is now separate from pugl/dgl so we should be able to get this to work now.

PRs welcome :)

PS: there is a saving mode now too, and linux can use freedesktop portal dbus to get native file dialogs.

falkTX commented 2 years ago

FYI there is a new mini-example here . Once the file chooser can be called from ExternalWindow I will update the new example accordingly.

is this example still somewhere I can find it? I have an idea for having the dialogs working directly from the UI which will ask the host and fallback to the extra file dialog implementation I added couple months ago.

That 2nd part is still missing though, I can more easily finish that if there was some kind of official example.

lucianoiam commented 2 years ago

That example was removed because there is a more complete example that also includes a file chooser.

Finally this was handed over to the web views rather than trying to extend DPF, because half of them already provide the file chooser functionality. Custom code was added only where needed:

macOS: use class NSOpenPanel

Linux X11: Use SOFD, like DPF.

Linux GTK: this web view already handles file dialogs without extra code.

[Windows]: also handles file chooser on its own but cannot find the docs.