fixed current window issues

This commit is contained in:
David Botton 2021-02-11 19:01:21 -05:00
parent 36642642f0
commit fbbab97b39
4 changed files with 98 additions and 45 deletions

View file

@ -1267,7 +1267,7 @@ Note: z-index only works on Elements with Position Type of absolute,
relative and fixed."))
(defmethod z-index ((obj clog-element))
(style obj "z-index"))
(parse-integer (style obj "z-index") :junk-allowed t))
(defgeneric set-z-index (clog-element value)
(:documentation "Set z-index VALUE for CLOG-ELEMENT"))

View file

@ -45,7 +45,11 @@
:documentation "Location of the left side or width relative to pointer during drag")
(drag-y
:accessor drag-y
:documentation "Location of the top or height relative to pointer during drag")))
:documentation "Location of the top or height relative to pointer during drag")
(on-window-change
:accessor on-window-change
:initform nil
:documentation "Fired when foreground window changed.")))
;;;;;;;;;;;;;;;;;;;;;
;; create-clog-gui ;;
@ -179,7 +183,49 @@ icon ⤢ and full screen mode."))
on-click))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - Windows
;; Implementation - Window System
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;
;; current-window ;;
;;;;;;;;;;;;;;;;;;;;
(defgeneric current-window (clog-obj)
(:documentation "Get the current selected clog-gui-window"))
(defmethod current-window ((obj clog-obj))
(let ((app (connection-data-item obj "clog-gui")))
(current-win app)))
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set-on-window-change ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
(defgeneric set-on-window-change (clog-obj handler)
(:documentation "Set the on-window-change HANDLER.
The on-window-change clog-obj received is the new window"))
(defmethod set-on-window-change ((obj clog-obj) handler)
(let ((app (connection-data-item obj "clog-gui")))
(setf (on-window-change app) handler)))
(defmethod fire-on-window-change (obj app)
"Fire handler if set. Change the value of current-win to clog-obj (Private)"
(unless obj
(let (new-order
(order -9999))
(maphash (lambda (key value)
(setf new-order (z-index value))
(when (>= new-order order)
(setf order new-order)
(setf obj value)))
(windows app))))
(setf (current-win app) obj)
(when (on-window-change app)
(funcall (on-window-change app) obj)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - Individual Windows
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass clog-gui-window (clog-element)
@ -261,7 +307,7 @@ icon ⤢ and full screen mode."))
(t
(format t "Warning - invalid data-drag-type attribute")))
(setf (z-index (drag-obj app)) (incf (last-z app)))
(setf (current-win app) (drag-obj app))
(fire-on-window-change (drag-obj app) app)
(setf (drag-y app) (- pointer-y obj-top))
(setf (drag-x app) (- pointer-x obj-left)))
(cond (perform-drag
@ -366,22 +412,12 @@ icon ⤢ and full screen mode."))
(when (fire-on-window-can-close win)
(remhash (format nil "~A" html-id) (windows app))
(remove-from-dom win)
(fire-on-window-change nil app)
(fire-on-window-close win))))
(setf (gethash (format nil "~A" html-id) (windows app)) win)
(setf (current-win app) win)
(fire-on-window-change win app)
win))
;;;;;;;;;;;;;;;;;;;;
;; current-window ;;
;;;;;;;;;;;;;;;;;;;;
(defgeneric current-window (clog-obj)
(:documentation "Get the current selected clog-gui-window"))
(defmethod current-window ((obj clog-obj))
(let ((app (connection-data-item obj "clog-gui")))
(current-win app)))
;;;;;;;;;;;;;;;;;;
;; window-title ;;
;;;;;;;;;;;;;;;;;;

View file

@ -665,8 +665,11 @@ embedded in a native template application.)"
(create-gui-menu-full-screen generic-function)
(create-gui-menu-icon generic-function)
"CLOG-GUI - Windows"
"CLOG-GUI - Window System"
(current-window generic-function)
(set-on-window-change generic-function)
"CLOG-GUI - Individual Windows"
(clog-gui-window class)
(create-gui-window generic-function)
(window-title generic-function)

View file

@ -89,46 +89,60 @@
(defun do-ide-file-save (obj)
(if (equalp (window-title (current-window obj)) "New Window")
(do-ide-file-save-as obj)
(let* ((cw (current-window obj))
(fname (window-title cw)))
(write-file (js-query obj (format nil "editor_~A.getValue()"
(html-id (current-window obj))))
(window-title (current-window obj)))))
(html-id cw)))
fname)
(setf (window-title cw) "SAVED")
(sleep 2)
(setf (window-title cw) fname))))
(defun do-ide-file-save-as (obj)
(let ((cw (current-window obj)))
(when cw
(get-file-name obj "Save As.."
(lambda (fname)
(setf (window-title cw) fname)
(write-file (js-query obj (format nil "editor_~A.getValue()"
(html-id cw)))
fname)))))
fname))))))
(defun do-ide-edit-copy (obj)
(let ((cw (current-window obj)))
(when cw
(let* ((app (connection-data-item obj "app-data")))
(setf (copy-buf app) (js-query obj (format nil "editor_~A.getCopyText();"
(html-id (current-window obj)))))))
(html-id cw))))))))
(defun do-ide-edit-cut (obj)
(let ((cw (current-window obj)))
(when cw
(do-ide-edit-copy obj)
(js-execute obj (format nil "editor_~A.execCommand('cut')"
(html-id (current-window obj)))))
(html-id cw))))))
(defun do-ide-edit-paste (obj)
(let* ((app (connection-data-item obj "app-data")))
(let ((cw (current-window obj)))
(when cw
(let ((app (connection-data-item obj "app-data")))
(js-execute obj (format nil "editor_~A.execCommand('paste', '~A')"
(html-id (current-window obj))
(escape-string (copy-buf app))))))
(html-id cw)
(escape-string (copy-buf app))))))))
(defun do-ide-lisp-eval-file (obj)
(let ((cw (current-window obj)))
(when cw
(let* ((form-string (js-query obj (format nil "editor_~A.getValue()"
(html-id (current-window obj)))))
(result (capture-eval form-string)))
(do-ide-file-new obj)
(js-execute obj (format nil "editor_~A.setValue('~A');editor_~A.moveCursorTo(0,0);"
(html-id (current-window obj))
(html-id cw)
(escape-string result)
(html-id (current-window obj))))))
(html-id cw)))))))
(defun do-ide-help-about (obj)
(let* ((app (connection-data-item obj "app-data"))