Skip to content

Commit

Permalink
Add set-position generic function
Browse files Browse the repository at this point in the history
Add single function to set both the x and y coordinate so of an object
and use it.
  • Loading branch information
sdilts committed Oct 20, 2024
1 parent 88ab22d commit 0b47042
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions lisp/interfaces/view-interface.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
(print-unreadable-object (object stream :type t)
(with-slots (x y) object
(format stream ":x ~S :y ~S" x y))))

(defgeneric set-position (object x y)
(:documentation "Set the x-y position of the object"))
13 changes: 7 additions & 6 deletions lisp/tree/frame.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@
(tmp-y (frame-y frame1))
(tmp-width (frame-width frame1))
(tmp-height (frame-height frame1)))
(setf (frame-x frame1) (frame-x frame2)
(frame-y frame1) (frame-y frame2))
(set-position frame1 (frame-x frame2) (frame-y frame2))
(set-dimensions frame1 (frame-width frame2) (frame-height frame2))

(setf (frame-x frame2) tmp-x
(frame-y frame2) tmp-y)
(set-position frame2 tmp-x tmp-y)
(set-dimensions frame2 tmp-width tmp-height))

(let ((frame1-parent (frame-parent frame1))
Expand Down Expand Up @@ -101,6 +99,10 @@
(setf (frame-width frame) width
(frame-height frame) height))

(defmethod set-position ((frame frame) x y)
(setf (frame-x frame) x
(frame-y frame) y))

(defmethod split-frame-h :before ((frame frame) &key ratio direction)
(declare (ignore frame direction))
(when ratio
Expand Down Expand Up @@ -141,8 +143,7 @@ of FRAME to those of ROOT."
(setf (frame-parent frame) (frame-parent root))
;; don't bother with an if-statement to see which values to change:
(set-dimensions frame (frame-width root) (frame-height root))
(setf (frame-x frame) (frame-x root)
(frame-y frame) (frame-y root)))
(set-position frame (frame-x root) (frame-y root)))

(defun binary-split-h (frame ratio direction parent-type)
"Split a frame in two, with the resulting parent frame of type parent-frame.
Expand Down

0 comments on commit 0b47042

Please sign in to comment.