aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/region.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-23 10:44:40 -0500
committerColin Okay <colin@cicadas.surf>2022-07-23 10:44:40 -0500
commit8fc1317f0c3c32e3d75b17260b9b0c3ed810fd76 (patch)
treeaae56cef22eb9e1b4a3e0a6a6ad159b355a7a8cc /src/region.lisp
parent00841605110612f6e7f3bbfc054ceff980bf25be (diff)
[add] menu basics and [example]
Diffstat (limited to 'src/region.lisp')
-rw-r--r--src/region.lisp32
1 files changed, 32 insertions, 0 deletions
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)))))