maximize on create option

This commit is contained in:
David Botton 2021-02-14 00:42:17 -05:00
parent 19b8581ed5
commit 2ab508458d

View file

@ -384,6 +384,7 @@ The on-window-change clog-obj received is the new window"))
(defgeneric create-gui-window (clog-obj &key title
content
left top width height
maximize
client-movement
html-id)
(:documentation "Create a clog-gui-window. If client-movement is t then
@ -398,6 +399,7 @@ on-window-resize-done at end of resize."))
(top 60)
(width 400)
(height 300)
(maximize nil)
(client-movement nil)
(html-id nil))
(unless html-id
@ -435,23 +437,26 @@ on-window-resize-done at end of resize."))
(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)))
(set-on-double-click (win-title win)
(lambda (obj)
(cond ((last-width win)
(setf (width win) (last-width win))
(setf (height win) (last-height win))
(setf (top win) (last-y win))
(setf (left win) (last-x win))
(setf (last-width win) nil))
(t
(setf (last-x win) (left win))
(setf (last-y win) (top win))
(setf (last-height win) (height win))
(setf (last-width win) (width win))
(setf (top win) (unit :px 35))
(setf (left win) (unit :px 0))
(setf (width win) (unit :vw 100))
(setf (height win) (- (inner-height (window (body app))) 30))))))
(flet ((maximize-window (obj)
(cond ((last-width win)
(setf (width win) (last-width win))
(setf (height win) (last-height win))
(setf (top win) (last-y win))
(setf (left win) (last-x win))
(setf (last-width win) nil))
(t
(setf (last-x win) (left win))
(setf (last-y win) (top win))
(setf (last-height win) (height win))
(setf (last-width win) (width win))
(setf (top win) (unit :px 35))
(setf (left win) (unit :px 0))
(setf (width win) (unit :vw 100))
(setf (height win)
(- (inner-height (window (body app))) 30))))))
(set-on-double-click (win-title win) #'maximize-window)
(when maximize
(maximize-window win)))
(set-on-click (closer win) (lambda (obj)
(declare (ignore obj))
(when (fire-on-window-can-close win)