diff options
author | Colin Okay <colin@cicadas.surf> | 2022-07-27 07:41:38 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-07-27 07:41:38 -0500 |
commit | 38b33de4c2e03a6f706fced1b866d975a6296156 (patch) | |
tree | 69b18dde462d45447f52dd3a1f2b2d132d52b1ad /src/wheelwork.lisp | |
parent | b510307e505275fffcbd029f4ae437581bc916a9 (diff) |
[refactor] to reduce use of vec
Diffstat (limited to 'src/wheelwork.lisp')
-rw-r--r-- | src/wheelwork.lisp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/wheelwork.lisp b/src/wheelwork.lisp index 154adaa..8a534ed 100644 --- a/src/wheelwork.lisp +++ b/src/wheelwork.lisp @@ -84,13 +84,13 @@ TARGET is FOCUSABLEP" (sdl2:mod-keywords (sdl2:mod-value sdl-keysym))))))) -(defun region-contains-point-p (region pt) +(defun region-contains-point-p (region x y) (with-slots (left right bottom top) region - (and (<= left (vec:vx pt) right) - (<= bottom (vec:vy pt) top)))) + (and (<= left x right) + (<= bottom y top)))) -(defun unit-contains-point-p (unit pt) - (path-encloses-point-p (get-rect unit) pt)) +(defun unit-contains-point-p (unit x y) + (path-encloses-point-p (get-rect unit) x y)) (defun mouse-event-targets (app x y &optional bubblep) "Returns a list of one or more objects found under the x y @@ -101,26 +101,23 @@ position. The list always contains the app itself as the last element." (list app))) -(defun unit-visibly-contains-p (unit pt) +(defun unit-visibly-contains-p (unit x y) (and (unit-visiblep unit) - (region-contains-point-p (unit-region unit) pt) - (unit-contains-point-p unit pt))) + (region-contains-point-p (unit-region unit) x y) + (unit-contains-point-p unit x y))) (defun unit-under (app x y) "Finds the visible unit that contains the point x y, returns it as a single elemtn list, or nil if none found" - (let ((xy (vec:vec x y 0.0 1.0))) - (loop for u in (application-scene app) - when (unit-visibly-contains-p u xy) - return (list u)))) + (loop for u in (application-scene app) + when (unit-visibly-contains-p u x y) + return (list u))) (defun all-units-under (app x y) "Finds all units under the point x y" - (let ((xy - (vec:vec x y 0.0 1.0))) - (loop for u in (application-scene app) - when (unit-visibly-contains-p u xy) - collect u))) + (loop for u in (application-scene app) + when (unit-visibly-contains-p u x y) + collect u)) (defvar *event-still-bubbling-p* nil "Controls whether an event is bubbling") @@ -132,7 +129,8 @@ single elemtn list, or nil if none found" (defun screen-to-world (x y &optional (app *application*)) "Scales the screen point - the literal pixel position relative to the top corner of the application window - to reflect the -application's scaling factor." +application's scaling factor" + (declare (optimize (speed 3) (saftey 0))) (with-slots (height scale) app (list (/ x scale) (/ (- height y) scale)))) @@ -187,6 +185,7 @@ give focus to whatever was clicked." (funcall handler focus wx wy dir))))) (defun eventloop (app) + (declare (optimize (speed 3) (safety 0))) (sdl2:with-event-loop (:method :poll) (:mousebuttondown (:x x :y y :clicks clicks :button button) |