add more stuff to dub

This commit is contained in:
Adam D. Ruppe 2021-12-09 22:23:41 -05:00
parent 4d5f6dabf8
commit 12bb6d7f4d
5 changed files with 76 additions and 11 deletions

View File

@ -69,6 +69,40 @@
"importPaths": ["."], "importPaths": ["."],
"sourceFiles": ["minigui_addons/nanovega.d"] "sourceFiles": ["minigui_addons/nanovega.d"]
}, },
{
"name": "minigui-terminal_emulator_widget",
"description": "Terminal emulator widget add-on for minigui. New to dub in v10.5.",
"targetType": "library",
"dflags": ["-mv=arsd.minigui_addons.terminal_emulator_widget=minigui_addons/terminal_emulator_widget.d"],
"dependencies": {
"arsd-official:minigui":"*",
"arsd-official:terminalemulator":"*"
},
"importPaths": ["."],
"sourceFiles": ["minigui_addons/terminal_emulator_widget.d"]
},
{
"name": "minigui-color_dialog",
"description": "Color picker dialog add-on for minigui. New to dub in v10.5.",
"targetType": "library",
"dflags": ["-mv=arsd.minigui_addons.color_dialog=minigui_addons/color_dialog.d"],
"dependencies": {
"arsd-official:minigui":"*"
},
"importPaths": ["."],
"sourceFiles": ["minigui_addons/color_dialog.d"]
},
{
"name": "minigui-webview",
"description": "Webview widget add-on for minigui. New to dub in v10.5 but NOT STABLE in that release and it will break at random without notice until I say it is stable.",
"targetType": "library",
"dflags": ["-mv=arsd.minigui_addons.webview=minigui_addons/webview.d", "-mv=arsd.webview=webview.d"],
"dependencies": {
"arsd-official:minigui":"*"
},
"importPaths": ["."],
"sourceFiles": ["minigui_addons/webview.d", "webview.d"]
},
{ {
"name": "gamehelpers", "name": "gamehelpers",
"description": "Assorted game-related structs and algorithms", "description": "Assorted game-related structs and algorithms",

View File

@ -1,5 +1,10 @@
/++ /++
Displays a color-picker dialog box. Displays a color-picker dialog box. On Windows, uses the standard system dialog you know from Paint. On X, uses a custom one with hsla and rgba support.
History:
Written April 2017.
Added to dub on December 9, 2021.
+/ +/
module arsd.minigui_addons.color_dialog; module arsd.minigui_addons.color_dialog;

View File

@ -1,10 +1,30 @@
/++ /++
A webview (based on [arsd.webview]) for minigui. A webview (based on [arsd.webview]) for minigui.
For now at least, to use this, you MUST have a CefApp in scope in main for the duration of your gui application. For now at least, to use this, you MUST have a [WebViewApp] in scope in main for the duration of your gui application.
Warning: CEF spams the current directory with a bunch of files and directories. You might want to run your program in a dedicated location.
History: History:
Added November 5, 2021. NOT YET STABLE. Added November 5, 2021. NOT YET STABLE.
Examples:
---
/+ dub.sdl:
name "web"
dependency "arsd-official:minigui-webview" version="*"
+/
import arsd.minigui;
import arsd.minigui_addons.webview;
void main() {
auto app = WebViewApp(null);
auto window = new Window;
auto webview = new WebViewWidget("http://dlang.org/", window);
window.loop;
}
---
+/ +/
module minigui_addons.webview; module minigui_addons.webview;
@ -23,11 +43,13 @@ version(Windows)
import arsd.minigui; import arsd.minigui;
import arsd.webview; import arsd.webview;
version(wv2) version(wv2) {
alias WebViewWidget = WebViewWidget_WV2; alias WebViewWidget = WebViewWidget_WV2;
else version(cef) alias WebViewApp = Wv2App;
} else version(cef) {
alias WebViewWidget = WebViewWidget_CEF; alias WebViewWidget = WebViewWidget_CEF;
else static assert(0, "no webview available"); alias WebViewApp = CefApp;
} else static assert(0, "no webview available");
class WebViewWidgetBase : NestedChildWindowWidget { class WebViewWidgetBase : NestedChildWindowWidget {
protected SimpleWindow containerWindow; protected SimpleWindow containerWindow;
@ -84,7 +106,7 @@ class WebViewWidget_WV2 : WebViewWidgetBase {
private bool initialized; private bool initialized;
this(Widget parent) { this(string url, Widget parent) {
super(parent); super(parent);
// that ctor sets containerWindow // that ctor sets containerWindow
@ -122,10 +144,13 @@ class WebViewWidget_WV2 : WebViewWidgetBase {
RECT bounds; RECT bounds;
GetClientRect(containerWindow.impl.hwnd, &bounds); GetClientRect(containerWindow.impl.hwnd, &bounds);
controller.Bounds = bounds; controller.Bounds = bounds;
error = webview_window.Navigate("http://arsdnet.net/test.html"w.ptr); //error = webview_window.Navigate("http://arsdnet.net/test.html"w.ptr);
//error = webview_window.NavigateToString("<html><body>Hello</body></html>"w.ptr); //error = webview_window.NavigateToString("<html><body>Hello</body></html>"w.ptr);
//error = webview_window.Navigate("http://192.168.1.10/"w.ptr); //error = webview_window.Navigate("http://192.168.1.10/"w.ptr);
WCharzBuffer bfr = WCharzBuffer(url);
webview_window.Navigate(bfr.ptr);
controller.IsVisible = true; controller.IsVisible = true;
initialized = true; initialized = true;
@ -183,7 +208,7 @@ class WebViewWidget_WV2 : WebViewWidgetBase {
version(cef) version(cef)
class WebViewWidget_CEF : WebViewWidgetBase { class WebViewWidget_CEF : WebViewWidgetBase {
this(Widget parent) { this(string url, Widget parent) {
//semaphore = new Semaphore; //semaphore = new Semaphore;
assert(CefApp.active); assert(CefApp.active);
@ -196,7 +221,7 @@ class WebViewWidget_CEF : WebViewWidgetBase {
cef_window_info_t window_info; cef_window_info_t window_info;
window_info.parent_window = containerWindow.nativeWindowHandle; window_info.parent_window = containerWindow.nativeWindowHandle;
cef_string_t cef_url = cef_string_t("http://arsdnet.net/test.html"); cef_string_t cef_url = cef_string_t(url);//"http://arsdnet.net/test.html");
cef_browser_settings_t browser_settings; cef_browser_settings_t browser_settings;
browser_settings.size = cef_browser_settings_t.sizeof; browser_settings.size = cef_browser_settings_t.sizeof;

View File

@ -3620,7 +3620,8 @@ static struct GenericCursor {
/++ /++
If you want to get more control over the event loop, you can use this. If you want to get more control over the event loop, you can use this.
Typically though, you can just call [SimpleWindow.eventLoop]. Typically though, you can just call [SimpleWindow.eventLoop] which forwards
to `EventLoop.get.run`.
+/ +/
struct EventLoop { struct EventLoop {
@disable this(); @disable this();

View File

@ -562,12 +562,12 @@ void main() {
} }
version(linux_gtk) version(linux_gtk)
enum activeEngine = WebviewEngine.webkit_gtk; enum activeEngine = WebviewEngine.webkit_gtk;
/++ /++
+/ +/
version(linux_gtk)
class WebView : browser_engine { class WebView : browser_engine {
/++ /++