From 8fc1317f0c3c32e3d75b17260b9b0c3ed810fd76 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sat, 23 Jul 2022 10:44:40 -0500 Subject: [add] menu basics and [example] --- src/region.lisp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/region.lisp') diff --git a/src/region.lisp b/src/region.lisp index 2355db6..4f22763 100644 --- a/src/region.lisp +++ b/src/region.lisp @@ -4,3 +4,35 @@ (defclass/std region () ((left bottom top right :with :std 0))) + +(defmethod width ((region region)) + (- (region-right region) (region-left region))) + +(defmethod (setf width) (newval (region region)) + (with-slots (left right) region + (setf right (+ left newval)))) + +(defmethod height ((region region)) + (- (region-top region) (region-bottom region))) + +(defmethod (setf height) (newval (region region)) + (with-slots (top bottom) region + (setf top (+ bottom newval)))) + +(defmethod x ((r region)) + (region-left r)) + +(defmethod (setf x) (newval (region region)) + (let ((width (width region))) ;;get before change + (with-slots (left right) + (setf left newval + right (+ newval width))))) + +(defmethod y ((r region)) + (region-bottom r)) + +(defmethod (setf y) (newval (region region)) + (let ((height (height region))) ;;get before change + (with-slots (top bottom) region + (setf bottom newval + top (+ newval height))))) -- cgit v1.2.3