Skip to content

Commit

Permalink
Maitain a collection of "hidden" views
Browse files Browse the repository at this point in the history
Put the non-visible views in the new ring-list data structure so we
can pull them out in the correct order. Use this to restore the most
recently hidden view when a view is removed / closed.
  • Loading branch information
sdilts committed Nov 6, 2024
1 parent 3d3f078 commit 2b5a127
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lisp/group.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,31 @@ to match."
(declare (type mahogany-group group)
(type hrt:view view))
(with-accessors ((views mahogany-group-views)
(outputs mahogany-group-output-map))
(outputs mahogany-group-output-map)
(hidden mahogany-group-hidden-views))
group
(push view (mahogany-group-views group))
(alexandria:when-let ((current-frame (mahogany-group-current-frame group)))
(alexandria:when-let ((view (tree:frame-view current-frame)))
(ring-list:add-item hidden view))
(setf (tree:frame-view current-frame) view))))

(defun group-remove-view (group view)
(declare (type mahogany-group group))
(with-accessors ((view-list mahogany-group-views)
(output-map mahogany-group-output-map))
(output-map mahogany-group-output-map)
(hidden mahogany-group-hidden-views))
group
(maphash (lambda (key container)
(declare (ignore key))
;; OPTIMIZE ME: get-pouplated frames builds a list, we could use an iterator instead.
(dolist (f (mahogany/tree:get-populated-frames (mahogany/tree:root-tree container)))
(when (equalp (tree:frame-view f) view)
(log-string :trace "Removing view from frame")
(setf (tree:frame-view f) nil))))
(setf (tree:frame-view f) nil)
(alexandria:when-let ((new-view (ring-list:pop-item hidden)))
(setf (tree:frame-view f) new-view)))))
output-map)
(ring-list:remove-item hidden view)
(setf view-list (remove view view-list :test #'equalp))))

(defmethod tree:find-empty-frame ((group mahogany-group))
Expand Down
1 change: 1 addition & 0 deletions lisp/objects.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
(number 1 :type fixnum :read-only t)
(output-map (make-hash-table :test 'equal) :type hash-table :read-only t)
(current-frame nil :type (or tree:frame null))
(hidden-views (ring-list:make-ring-list) :type ring-list:ring-list)
(views nil :type list))

(defclass mahogany-state ()
Expand Down
2 changes: 1 addition & 1 deletion mahogany.asd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
(:file "frame" :depends-on ("tree-interface"))
(:file "view" :depends-on ("tree-interface"))))
(:file "package")
(:file "objects" :depends-on ("package"))
(:file "objects" :depends-on ("package" "ring-list"))
(:file "group" :depends-on ("objects" "bindings"))
(:file "state" :depends-on ("objects" "keyboard"))
(:file "globals" :depends-on ("state" "objects" "system"))
Expand Down

0 comments on commit 2b5a127

Please sign in to comment.