;;;; region.lisp (in-package :wheelwork) (def:class region () (left bottom top right :prefix :initform 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)))))