Boscop / web-view

Rust bindings for webview, a tiny cross-platform library to render web-based GUIs for desktop applications
MIT License
1.92k stars 175 forks source link

Attach to a parent window? #283

Open adam-hanna opened 3 years ago

adam-hanna commented 3 years ago

In the audio production world, developers can build VST plugins. These plugins can have GUI's but need to attach the GUI to an externally managed window.

Is it possible to add a feature to this library to allow such functionality?

For example, here's a rust crate for vst gui's that opens a web view and attaches it to a parent window: https://github.com/vanderlokken/rust-vst-gui/blob/c71ca8df17bbfb2b109aa72ffc05bbf56e3aeadd/src/lib.rs#L56

Here's the maintaners thoughts on using this library for cross-browser support: https://github.com/vanderlokken/rust-vst-gui/issues/8#issuecomment-832985277

EDIT ACK! This has already been mentioned in the Readme! So Sorry!

Boscop commented 3 years ago

I'm reopening this because we don't have a ticket for this yet.. It's probably possible but I'm not sure how. @vanderlokken: Would it be possible the same way as in https://github.com/vanderlokken/rust-vst-gui?

pythoneer commented 3 years ago

Just to add on usecases. I have an "old" application in Qt with two QtWebViews managed by that application – its basically just a convenience for managing two browser windows for the user for managing multiple accounts etc. But maintaining and deploying this application for Linux/macOS/Win is quite labor intense(Qt by itself and the Webview with openssl dependencies etc.) and i would love to replace it with something like fltk-rs and two embedded web-views. Would love if this could work like the embedded VLC example as an additional inspiration.

adam-hanna commented 3 years ago

Also adding @mikesoylu to the thread who may be able to provide comment (he forked @vanderlokken's code to work with MacOS).

https://github.com/mikesoylu/rust-vst-gui

pythoneer commented 3 years ago

If i am not fully mistaken the underlying c-lib should already support that, no?

https://raw.githubusercontent.com/zserge/webview/master/webview.h

// Creates a new webview instance. If debug is non-zero - developer tools will
// be enabled (if the platform supports them). Window parameter can be a
// pointer to the native window handle. If it's non-null - then child WebView
// is embedded into the given parent window. Otherwise a new window is created.
// Depending on the platform, a GtkWindow, NSWindow or HWND pointer can be
// passed here.
WEBVIEW_API webview_t webview_create(int debug, void *window);

i tried digging through the code a little bit with webview_sys and wondering why this is so different from webview.h different version or handmade wrapper?

EDIT:
oh ... is https://github.com/Boscop/web-view/tree/master/webview-sys a fork/reimplementation of https://github.com/webview/webview and not a "generated" binding that tracks webview and the implementations have diverged?

EDIT2:
yeah its say in the Readme:
This library provides a Rust binding to the original implementation of webview, ...

and this https://github.com/webview/webview/blob/0.1.0/webview.h looks quite similar to the current implementation of webview_sys that does not have the same API as the example i showed above. There was a major refactoring it looks like.

mikesoylu commented 3 years ago

Hi was able to do it with cocoa(just for some apple specific stuff) and webview-sys. Relevant code can be found here in the fork: https://github.com/mikesoylu/rust-vst-gui/pull/1/commits/3b56730f190e1907b60a2f41d4c9a968f228fcad#diff-7ea3d8f419ddb71f86b7e524c1c7025cf92f1b46ad6457e505795209408f67f1

lucianoiam commented 3 years ago

I've done this but for a C++ plugins framework here. I don't know Rust but it should be possible to extract the webview classes and write a wrapper. The classes were written from scratch with all the plugin specifics in mind: no statics, no link to GUI toolkits, etc.

This reverb plugin has a webview based UI.

SkyLeite commented 1 month ago

Hi! Any updates on this? It would be extremely helpful for writing UI in games :)