clogframe and start on native apps with WebView.h

This commit is contained in:
David Botton 2022-09-02 15:23:41 -04:00
parent e6df0e5ab0
commit 92381b366a
8 changed files with 1727 additions and 2 deletions

8
NATIVE.md vendored
View file

@ -18,6 +18,7 @@ More advanced solutions:
4. Native iOS and Android using Cordova and ECL
5. Webview.h
## 1 Open app using chrome in app mode
@ -116,4 +117,9 @@ To package you applicaton use:
## 4 Native iOS and Android using Cordova and ECL
https://cordova.apache.org/
https://cordova.apache.org/
## 5 Webview.h
https://github.com/webview/webview

34
clogframe/README.md vendored Normal file
View file

@ -0,0 +1,34 @@
## CLOGFrame
CLOG Frame uses the native browser control on your platform to create
a simple app the displays a 640x480 frame ready to recieve your app.
clogframe[.exe] "Window Title" port
in the clogframe directory run:
On Mac (all requirements for build part of OS):
./make-mac
./make-snake
On Linux
Development: apt install libgtk-3-dev libwebkit2gtk-4.0-dev
Production: apt install libgtk-3-0 libwebkit2gtk-4.0-37
./make-linux
./make-snake
On Windows
to do (see https://github.com/webview/webview)
On All Platfroms:
This will create two executable clogframe and snake. clogframe
must be in the same directory and the sname executable. Then
run:
./snake

14
clogframe/clogframe.cpp vendored Normal file
View file

@ -0,0 +1,14 @@
#include <iostream>
#include <sstream>
#include <string>
#include "webview.h"
int main(int argc,char* argv[]) {
webview::webview w(true, nullptr);
w.set_title(argv[1]);
w.set_size(640, 480, WEBVIEW_HINT_NONE);
std::ostringstream o;
o << "http://127.0.0.1:" << argv[2];
w.navigate(o.str());
w.run();
return 0;
}

1
clogframe/make-linux vendored Normal file
View file

@ -0,0 +1 @@
g++ clogframe.cpp -std=c++11 -Ilibs/webview $(pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0) -o clogframe

1
clogframe/make-mac vendored Executable file
View file

@ -0,0 +1 @@
c++ clogframe.cpp -std=c++11 -framework WebKit -o clogframe

1
clogframe/make-snake vendored Executable file
View file

@ -0,0 +1 @@
sbcl --eval "(ql:quickload :clog)" --eval "(clog:load-demo 1)" --eval "(sb-ext:save-lisp-and-die #P\"snake\" :toplevel (lambda () (clog-demo-1:start-demo :port 0 :app t :start-browser nil :clogframe t) (loop (sleep 10))) :executable t :compression t)"

1666
clogframe/webview.h vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -182,13 +182,15 @@
(clog:shutdown)
(uiop:quit)))
(defun start-demo (&key (host "0.0.0.0") (port 8080) (start-browser t) app)
(defun start-demo (&key (host "0.0.0.0") (port 8080) (start-browser t) clogframe app)
"Start demo. If app is t, runs one game and shutsdown."
(when (eql port 0)
(setf port (clog-connection:random-port)))
(initialize 'on-new-window :host host :port port)
(when app
(setf *app-mode* app))
(when clogframe
(uiop:run-program (list "./clogframe" "CLOG Snake" (format nil "~A" port))))
(when start-browser
(format t "If browser does not start go to http://127.0.0.1:~A" port)
(open-browser :url (format nil "http://127.0.0.1:~A" port))))