-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement webview for windows, custom choc fork
Signed-off-by: falkTX <[email protected]>
- Loading branch information
Showing
14 changed files
with
8,734 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* DISTRHO Plugin Framework (DPF) | ||
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | ||
* or without fee is hereby granted, provided that the above copyright notice and this | ||
* permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | ||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | ||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | ||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | ||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
// Include CHOC separately because it requires C++17 | ||
|
||
#include "DistrhoDetails.hpp" | ||
#include "src/DistrhoPluginChecks.h" | ||
#include "src/DistrhoDefines.h" | ||
|
||
#if DISTRHO_UI_WEB_VIEW | ||
# define DISTRHO_WEB_VIEW_INCLUDE_IMPLEMENTATION | ||
# include "extra/WebView.hpp" | ||
# include "extra/WebViewWin32.hpp" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* DISTRHO Plugin Framework (DPF) | ||
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | ||
* or without fee is hereby granted, provided that the above copyright notice and this | ||
* permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | ||
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | ||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | ||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | ||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#if !defined(DISTRHO_WEB_VIEW_HPP_INCLUDED) && !defined(DGL_WEB_VIEW_HPP_INCLUDED) | ||
# define DISTRHO_WEB_VIEW_INCLUDE_IMPLEMENTATION | ||
# include "WebView.hpp" | ||
#endif | ||
|
||
// -------------------------------------------------------------------------------------------------------------------- | ||
// Web View stuff | ||
|
||
START_NAMESPACE_DISTRHO | ||
|
||
struct WebView; | ||
|
||
WebView* webview_choc_create(const WebViewOptions& opts); | ||
void webview_choc_destroy(WebView*); | ||
void* webview_choc_handle(WebView*); | ||
void webview_choc_eval(WebView*, const char* js); | ||
void webview_choc_navigate(WebView*, const char* url); | ||
|
||
END_NAMESPACE_DISTRHO | ||
|
||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
#ifdef DISTRHO_WEB_VIEW_INCLUDE_IMPLEMENTATION | ||
|
||
# define WC_ERR_INVALID_CHARS 0 | ||
# include "choc/choc_WebView.h" | ||
|
||
START_NAMESPACE_DISTRHO | ||
|
||
WebView* webview_choc_create(const WebViewOptions& opts) | ||
{ | ||
WebView::Options wopts; | ||
wopts.acceptsFirstMouseClick = true; | ||
wopts.enableDebugMode = true; | ||
|
||
std::unique_ptr<WebView> webview = std::make_unique<WebView>(wopts); | ||
DISTRHO_SAFE_ASSERT_RETURN(webview->loadedOK(), nullptr); | ||
|
||
if (const WebViewMessageCallback callback = opts.callback) | ||
{ | ||
webview->addInitScript("function postMessage(m){window.chrome.webview.postMessage(m);}"); | ||
|
||
void* const callbackPtr = opts.callbackPtr; | ||
webview->bind([callback, callbackPtr](const std::string& value) { | ||
char* const data = strdup(value.data()); | ||
callback(callbackPtr, data); | ||
std::free(data); | ||
}); | ||
} | ||
else | ||
{ | ||
webview->addInitScript("function postMessage(m){}"); | ||
} | ||
|
||
if (opts.initialJS != nullptr) | ||
webview->addInitScript(opts.initialJS); | ||
|
||
return webview.release(); | ||
} | ||
|
||
void webview_choc_destroy(WebView* const webview) | ||
{ | ||
delete webview; | ||
} | ||
|
||
void* webview_choc_handle(WebView* const webview) | ||
{ | ||
return webview->getViewHandle(); | ||
} | ||
|
||
void webview_choc_eval(WebView* const webview, const char* const js) | ||
{ | ||
webview->evaluateJavascript(js); | ||
} | ||
|
||
void webview_choc_navigate(WebView* const webview, const char* const url) | ||
{ | ||
webview->navigate(url); | ||
} | ||
|
||
END_NAMESPACE_DISTRHO | ||
|
||
#endif // DISTRHO_WEB_VIEW_INCLUDE_IMPLEMENTATION | ||
|
||
// -------------------------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## CHOC: licensing | ||
|
||
I'd like anyone to feel able to use this library code without worrying about the legal implications, so it's released under the permissive ISC license: | ||
|
||
---- | ||
|
||
**Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.** | ||
|
||
**THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.** | ||
|
||
https://en.wikipedia.org/wiki/ISC_license | ||
|
||
---- | ||
|
||
Note that if you use the `choc::ui::WebView` class on Windows, it embeds some Microsoft redistributable code which has its own (permissive) license that you should be aware of. See inside the file `choc_WebView.h` for more details. |
Oops, something went wrong.