Added has-pin option on title bar

This commit is contained in:
David Botton 2021-02-19 14:29:54 -05:00
parent 90aa969fd1
commit 19adb38982
2 changed files with 33 additions and 30 deletions

View file

@ -476,7 +476,8 @@ The on-window-change clog-obj received is the new window"))
:documentation "Window body clog-element")
(pinner
:accessor pinner
:documentation "Window pinner clog-element")
:initform nil
:documentation "Window pinner clog-element if created with has-pinner")
(closer
:accessor closer
:documentation "Window closer clog-element")
@ -499,10 +500,10 @@ The on-window-change clog-obj received is the new window"))
:accessor last-y
:initform nil
:documentation "Last y before maximize")
(pinned-p
:accessor pinned-p
(pinnedp
:accessor pinnedp
:initform nil
:documentation "Returns true if this window is pinned and false otherwise")
:documentation "True if this window is pinned and nil otherwise")
(keep-on-top
:accessor keep-on-top
:initform nil
@ -646,6 +647,7 @@ The on-window-change clog-obj received is the new window"))
content
left top width height
maximize
has-pinner
hidden
client-movement
html-id)
@ -662,6 +664,7 @@ on-window-resize-done at end of resize."))
(width 300)
(height 200)
(maximize nil)
(has-pinner nil)
(hidden nil)
(client-movement nil)
(html-id nil))
@ -693,9 +696,7 @@ on-window-resize-done at end of resize."))
<div id='~A-title-bar' class='w3-container w3-black'
style='flex-container;display:flex;align-items:stretch;'>
<span data-drag-obj='~A' data-drag-type='m' id='~A-title'
style='flex-grow:9;user-select:none;cursor:move;'>~A</span>
<span id='~A-pinner'
style='cursor:pointer;user-select:none;'>(Un)pin&nbsp;&nbsp;&nbsp;</span>
style='flex-grow:9;user-select:none;cursor:move;'>~A</span>~A
<span id='~A-closer'
style='cursor:pointer;user-select:none;'>&times;</span>
</div>
@ -707,7 +708,11 @@ on-window-resize-done at end of resize."))
top left width height (incf (last-z app)) ; outer div
html-id html-id html-id ; title bar
title ; title
html-id ; pinner
(if has-pinner ; pinner
(format nil "<span id='~A-pinner'
style='cursor:pointer;user-select:none;'>
(Un)pin&nbsp;&nbsp;&nbsp;</span>" html-id)
"")
html-id ; closer
html-id content ; body
html-id html-id) ; size
@ -717,7 +722,8 @@ on-window-resize-done at end of resize."))
(attach-as-child win (format nil "~A-title" html-id)))
(setf (title-bar win)
(attach-as-child win (format nil "~A-title-bar" html-id)))
(setf (pinner win) (attach-as-child win (format nil "~A-pinner" html-id)))
(when has-pinner
(setf (pinner win) (attach-as-child win (format nil "~A-pinner" html-id))))
(setf (closer win) (attach-as-child win (format nil "~A-closer" html-id)))
(setf (sizer win) (attach-as-child win (format nil "~A-sizer" html-id)))
(setf (content win) (attach-as-child win (format nil "~A-body" html-id)))
@ -734,9 +740,10 @@ on-window-resize-done at end of resize."))
(set-on-double-click (win-title win) (lambda (obj)
(declare (ignore obj))
(window-toggle-maximize win)))
(when has-pinner
(set-on-click (pinner win) (lambda (obj)
(declare (ignore obj))
(window-toggle-pin win)))
(window-toggle-pin win))))
(set-on-click (closer win) (lambda (obj)
(declare (ignore obj))
(when (fire-on-window-can-close win)
@ -904,17 +911,17 @@ cannot be moved, closed, resized, maximized or normalized. A new window is
always unpinned."))
(defmethod window-toggle-pin ((win clog-gui-window))
(if (pinned-p win)
(if (pinnedp win)
;; Toggle the pinned state of this window
(progn
(setf (pinned-p win) nil)
(setf (pinnedp win) nil)
(set-on-window-can-close win nil)
(set-on-window-can-size win nil)
(set-on-window-can-move win nil)
(set-on-window-can-maximize win nil)
(set-on-window-can-normalize win nil))
(flet ((no-op (obj) (declare (ignore obj))))
(setf (pinned-p win) t)
(setf (pinnedp win) t)
(set-on-window-can-close win #'no-op)
(set-on-window-can-size win #'no-op)
(set-on-window-can-move win #'no-op)

View file

@ -43,17 +43,13 @@
(setf (box-height movie) "100%")))
(defun on-file-pinned (obj)
(let ((win (create-gui-window obj :title "Pinned"
(let ((win (create-gui-window obj :title "Pin me!"
:has-pinner t
:top 200
:left 0
:width 100
:height 100)))
(flet ((can-not-do (obj)(declare (ignore obj))()))
(set-on-window-can-maximize win #'can-not-do)
(set-on-window-can-close win #'can-not-do)
(set-on-window-can-size win #'can-not-do))
(window-keep-on-top win)
(create-div win :content "I am pinned")))
:width 200
:height 200)))
(create-div win :content "I can be pinned. Just click the pin on window bar.")))
(defun on-dlg-alert (obj)
(alert-dialog obj "This is a modal alert box"))