This commit is contained in:
David Botton 2021-02-24 21:46:34 -05:00
parent 35008c3116
commit f925d720de
2 changed files with 42 additions and 0 deletions

View file

@ -68,6 +68,7 @@
(set-on-window-size-done generic-function)
"CLOG-GUI - Dialog Boxes"
(alert-toast function)
(alert-dialog function)
(input-dialog function)
(confirm-dialog function)
@ -1217,6 +1218,32 @@ interactions. Use window-end-modal to undo."))
;; Implementation - Dialog Boxes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun alert-toast (obj title content &key
(color-class "w3-red")
(time-out nil)
(html-id nil))
"Create an alert toast with option :TIME-OUT"
(unless html-id
(setf html-id (clog-connection:generate-id)))
(let* ((body (connection-data-item obj "clog-body"))
(win (create-child body
(format nil
" <div class='w3-panel ~A w3-animate-right w3-display-container'>~
<span id=~A-close class='w3-button w3-large w3-display-topright'>&times;</span>~
<h3>~A</h3>~
<p>~A</p>~
</div>"
color-class
html-id
title
content)))
(closer (attach-as-child body (format nil "~A-close" html-id))))
(set-on-click closer (lambda (obj)
(destroy win)))
(when time-out
(sleep time-out)
(destroy win))))
(defun alert-dialog (obj content &key (modal t)
(title "About")
(left nil) (top nil)

View file

@ -93,6 +93,17 @@
(alert-dialog obj results))
:height 550))
(defun on-toast-alert (obj)
(alert-toast obj "Stop!" "To get rid of me, click the X. I have no time-out"))
(defun on-toast-warn (obj)
(alert-toast obj "Warning!" "To get rid of me, click the X. I time-out in 5 seconds"
:color-class "w3-yellow" :time-out 5))
(defun on-toast-success (obj)
(alert-toast obj "Success!" "To get rid of me, click the X. I time-out in 2 seconds"
:color-class "w3-green" :time-out 2))
(defun on-help-about (obj)
(let* ((about (create-gui-window obj
:title "About"
@ -132,6 +143,10 @@
(tmp (create-gui-menu-item dlg :content "Confirm Dialog Box" :on-click #'on-dlg-confirm))
(tmp (create-gui-menu-item dlg :content "Form Dialog Box" :on-click #'on-dlg-form))
(tmp (create-gui-menu-item dlg :content "Server File Dialog Box" :on-click #'on-dlg-file))
(tst (create-gui-menu-drop-down menu :content "Toasts"))
(tmp (create-gui-menu-item tst :content "Alert Toast" :on-click #'on-toast-alert))
(tmp (create-gui-menu-item tst :content "Warning Toast" :on-click #'on-toast-warn))
(tmp (create-gui-menu-item tst :content "Success Toast" :on-click #'on-toast-success))
(help (create-gui-menu-drop-down menu :content "Help"))
(tmp (create-gui-menu-item help :content "About" :on-click #'on-help-about))
(tmp (create-gui-menu-full-screen menu)))