Drop the custom boot file and use the new clog-gui

This commit is contained in:
David Botton 2021-02-10 00:48:30 -05:00
parent 33b9344734
commit 420bc31015
6 changed files with 55 additions and 78 deletions

View file

@ -66,18 +66,18 @@ clog-body."))
(defgeneric create-gui-menu-item (clog-gui-menu-drop-down
&key content
on-click-handler
on-click
class
html-id)
(:documentation "Attached a menu item to a CLOG-GUI-MENU-DROP-DOWN"))
(defmethod create-gui-menu-item ((obj clog-obj)
&key (content "")
(on-click-handler nil)
(on-click nil)
(class "w3-bar-item w3-button")
(html-id nil))
(let ((span (create-span obj :content content :class class :html-id html-id)))
(set-on-click span on-click-handler)
(set-on-click span on-click)
(change-class span 'clog-gui-menu-item)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -103,14 +103,14 @@ icon ⤢ and full screen mode."))
;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgeneric create-gui-menu-icon (clog-gui-menu-bar &key image-url
on-click-handler
on-click
class
html-id)
(:documentation "Add icon as menu bar item."))
(defmethod create-gui-menu-icon ((obj clog-gui-menu-bar)
&key (image-url "/img/clogwicon.png")
(on-click-handler nil)
(on-click nil)
(class "w3-button w3-bar-item")
(html-id nil))
(set-on-click
@ -121,4 +121,4 @@ icon ⤢ and full screen mode."))
image-url)
:html-id html-id
:clog-type 'clog-gui-menu-item)
on-click-handler))
on-click))

View file

@ -1,6 +1,4 @@
;;; As this demo uses eval do not run over the internet.
;;; See the accompanying boot file at
;;; https://github.com/rabbibotton/clog/blob/main/static-files/demo/frame.html
(defpackage #:clog-user
(:use #:cl #:clog)
@ -251,7 +249,7 @@
(let* ((app (connection-data-item obj "app-data"))
(about (create-window (body app) "About"
:content "<div class='w3-black'>
<center><img src='/demo/clogwicon.png'></center>
<center><img src='/img/clogwicon.png'></center>
<center>CLOG</center>
<center>The Common Lisp Omnificent GUI</center></div>
<div><p><center>Demo 3</center>
@ -264,20 +262,29 @@
(defun on-new-window (body)
(let ((app (make-instance 'app-data)))
(setf (connection-data-item body "app-data") app)
(setf (body app) body)
(set-on-click (attach-as-child body "ide-logo") #'do-ide-help-about)
(set-on-click (attach-as-child body "ide-file-new") #'do-ide-file-new)
(set-on-click (attach-as-child body "ide-file-open") #'do-ide-file-open)
(set-on-click (attach-as-child body "ide-file-save") #'do-ide-file-save)
(set-on-click (attach-as-child body "ide-file-save-as") #'do-ide-file-save-as)
(set-on-click (attach-as-child body "ide-edit-copy") #'do-ide-edit-copy)
(set-on-click (attach-as-child body "ide-edit-cut") #'do-ide-edit-cut)
(set-on-click (attach-as-child body "ide-edit-paste") #'do-ide-edit-paste)
(set-on-click (attach-as-child body "ide-lisp-eval-file") #'do-ide-lisp-eval-file)
(set-on-click (attach-as-child body "ide-help-about") #'do-ide-help-about)
(run body)))
(setf (body app) body))
(clog-gui-initialize body)
(load-script (html-document body) "https://pagecdn.io/lib/ace/1.4.12/ace.js")
(add-class body "w3-teal")
(let* ((menu (create-gui-menu-bar body))
(icon (create-gui-menu-icon menu :on-click #'do-ide-help-about))
(file (create-gui-menu-drop-down menu :content "File"))
(edit (create-gui-menu-drop-down menu :content "Edit"))
(lisp (create-gui-menu-drop-down menu :content "Lisp"))
(help (create-gui-menu-drop-down menu :content "Help")))
(create-gui-menu-item file :content "New" :on-click #'do-ide-file-new)
(create-gui-menu-item file :content "Open" :on-click #'do-ide-file-open)
(create-gui-menu-item file :content "Save" :on-click #'do-ide-file-save)
(create-gui-menu-item file :content "Save As" :on-click #'do-ide-file-save-as)
(create-gui-menu-item edit :content "Copy" :on-click #'do-ide-edit-copy)
(create-gui-menu-item edit :content "Cut" :on-click #'do-ide-edit-cut)
(create-gui-menu-item edit :content "Paste" :on-click #'do-ide-edit-paste)
(create-gui-menu-item lisp :content "Eval File" :on-click #'do-ide-lisp-eval-file)
(create-gui-menu-item help :content "About" :on-click #'do-ide-help-about)
(create-gui-menu-full-screen menu))
(run body))
(defun start-demo ()
"Start demo."
(initialize #'on-new-window :boot-file "/demo/frame.html")
(initialize #'on-new-window)
(open-browser))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -1,56 +0,0 @@
<!doctype HTML>
<HTML>
<HEAD>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script>var clog_debug = true;</script>
<script src="/js/boot.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="https://pagecdn.io/lib/ace/1.4.12/ace.js" type="text/javascript" charset="utf-8"></script>
</HEAD>
<BODY class="w3-teal">
<div id='ide-menu' class="w3-bar w3-black w3-card-4">
<button id='ide-logo' class="w3-button w3-bar-item">
<img height=22 src="/demo/clogwicon.png"></button>
<div class="w3-dropdown-hover">
<button class="w3-button">File</button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
<span id='ide-file-new' class="w3-bar-item w3-button">New</span>
<span id='ide-file-open' class="w3-bar-item w3-button">Open...</span>
<span id='ide-file-save' class="w3-bar-item w3-button">Save</span>
<span id='ide-file-save-as' class="w3-bar-item w3-button">Save as...</span>
</div>
</div>
<div class="w3-dropdown-hover">
<button class="w3-button">Edit</button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
<span id="ide-edit-copy" class="w3-bar-item w3-button">Copy</span>
<span id="ide-edit-cut" class="w3-bar-item w3-button">Cut</span>
<span id="ide-edit-paste" class="w3-bar-item w3-button">Paste</span>
</div>
</div>
<div class="w3-dropdown-hover">
<button class="w3-button">Lisp</button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
<span id="ide-lisp-eval-file" class="w3-bar-item w3-button">Eval Current File</span>
</div>
</div>
<div class="w3-dropdown-hover">
<button class="w3-button">Help</button>
<div class="w3-dropdown-content w3-bar-block w3-card-4">
<span id="ide-help-about" class="w3-bar-item w3-button">About CLOG Demo 3</span>
</div>
</div>
<span class="w3-bar-item w3-right" style='user-select:none;'
onClick="if (document.fullscreenElement==null) {
documentElement.requestFullscreen()
} else {document.exitFullscreen();}">⤢</span>
</div>
</BODY>
</HTML>

26
tutorial/22-tutorial.lisp Normal file
View file

@ -0,0 +1,26 @@
(defpackage #:clog-user
(:use #:cl #:clog)
(:export start-tutorial))
(in-package :clog-user)
(defun on-new-window (body)
(clog-gui-initialize body)
(add-class body "w3-teal")
(let* ((menu (create-gui-menu-bar body))
(icon (create-gui-menu-icon menu))
(file (create-gui-menu-drop-down menu :content "File"))
(new (create-gui-menu-item file :content "New"))
(open (create-gui-menu-item file :content "Open"))
(save (create-gui-menu-item file :content "Save"))
(help (create-gui-menu-drop-down menu :content "Help"))
(about (create-gui-menu-item help :content "About"))
(fs (create-gui-menu-full-screen menu))))
(run body))
(defun start-tutorial ()
"Start turtorial."
(initialize #'on-new-window)
(open-browser))