Add menu from clog-gui to tutorial 26

This commit is contained in:
David Botton 2021-03-17 12:16:21 -04:00
parent 43e51cc367
commit c95f8e1e3e
3 changed files with 23 additions and 7 deletions

View file

@ -165,7 +165,8 @@
(defun clog-gui-initialize (clog-body &key (w3-css-url "/css/w3.css") (defun clog-gui-initialize (clog-body &key (w3-css-url "/css/w3.css")
(jquery-ui-css "/css/jquery-ui.css") (jquery-ui-css "/css/jquery-ui.css")
(jquery-ui "/js/jquery-ui.js")) (jquery-ui "/js/jquery-ui.js"))
"Initializes clog-gui and installs a clog-gui object on connection." "Initializes clog-gui and installs a clog-gui object on connection.
If W3-CSS-URL has not been loaded before is installed unless is nil."
(create-clog-gui clog-body) (create-clog-gui clog-body)
(set-on-full-screen-change (html-document clog-body) (set-on-full-screen-change (html-document clog-body)
(lambda (obj) (lambda (obj)
@ -179,8 +180,10 @@
(when (window-maximized-p (current-window obj)) (when (window-maximized-p (current-window obj))
(window-normalize (current-window obj)) (window-normalize (current-window obj))
(window-maximize (current-window obj)))))) (window-maximize (current-window obj))))))
(when w3-css-url (unless (connection-data-item clog-body "w3-css")
(load-css (html-document clog-body) w3-css-url)) (when w3-css-url
(setf (connection-data-item clog-body "w3-css") t)
(load-css (html-document clog-body) w3-css-url)))
(when jquery-ui-css (when jquery-ui-css
(load-css (html-document clog-body) jquery-ui-css)) (load-css (html-document clog-body) jquery-ui-css))
(when jquery-ui (when jquery-ui

View file

@ -108,10 +108,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;
(defun clog-web-initialize (clog-body &key (w3-css-url "/css/w3.css")) (defun clog-web-initialize (clog-body &key (w3-css-url "/css/w3.css"))
"Initializes clog-web and installs a clog-web object on connection." "Initializes clog-web and installs a clog-web object on connection.
If W3-CSS-URL has not been loaded before is installed unless is nil."
(create-clog-web clog-body) (create-clog-web clog-body)
(when w3-css-url (unless (connection-data-item clog-body "w3-css")
(load-css (html-document clog-body) w3-css-url))) (when w3-css-url
(setf (connection-data-item clog-body "w3-css") t)
(load-css (html-document clog-body) w3-css-url))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set-maximum-page-width-in-pixels ;; ;; set-maximum-page-width-in-pixels ;;

View file

@ -9,14 +9,24 @@
(defpackage #:clog-user (defpackage #:clog-user
(:use #:cl #:clog #:clog-web) (:use #:cl #:clog #:clog-web #:clog-gui)
(:export start-tutorial)) (:export start-tutorial))
(in-package :clog-user) (in-package :clog-user)
(defun on-new-window (body) (defun on-new-window (body)
(clog-web-initialize body) (clog-web-initialize body)
(clog-gui-initialize body)
(setf (title (html-document body)) "Tutorial 26") (setf (title (html-document body)) "Tutorial 26")
;; Install a menu
(let* ((menu (create-gui-menu-bar body))
(tmp (create-gui-menu-icon menu :on-click (lambda (obj)
(setf (hash (location body)) "rung2"))))
(tmp (create-gui-menu-item menu :content "About"
:on-click (lambda (obj)
(setf (hash (location body)) "rung2"))))
(tmp (create-gui-menu-full-screen menu)))
(declare (ignore tmp)))
;; rung-1 ;; rung-1
(let* ((first-rung (create-web-compositor body :html-id "rung1")) (let* ((first-rung (create-web-compositor body :html-id "rung1"))
(image (create-img first-rung :url-src "/img/windmills.jpg" (image (create-img first-rung :url-src "/img/windmills.jpg"