From 543704f0f54cbb1de78754ad8a323c482ab6829c Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 14 Dec 2024 12:29:29 -0800 Subject: Loop style nits --- src/wheelwork.lisp | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'src/wheelwork.lisp') diff --git a/src/wheelwork.lisp b/src/wheelwork.lisp index 506ba9b..88ea772 100644 --- a/src/wheelwork.lisp +++ b/src/wheelwork.lisp @@ -115,19 +115,19 @@ position. The list always contains the app itself as the last element." single elemtn list, or nil if none found" (with-slots (scene) app (loop - for idx from (1- (length scene)) downto 0 - for u = (elt scene idx) - when (unit-visibly-contains-p u x y) - return (list u)))) + :for idx :from (1- (length scene)) :downto 0 + :for u := (elt scene idx) + :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" (with-slots (scene) app (loop - for idx from (1- (length scene)) downto 0 - for u = (elt scene idx) - when (unit-visibly-contains-p u x y) - collect u))) + :for idx :from (1- (length scene)) :downto 0 + :for u := (elt scene idx) + :when (unit-visibly-contains-p u x y) + :collect u))) (defvar *event-still-bubbling-p* nil "Controls whether an event is bubbling") @@ -140,7 +140,7 @@ single elemtn list, or nil if none found" "Scales the screen point - the literal pixel position relative to the top corner of the application window - to reflect the application's scaling factor" - (declare (optimize (speed 3) (saftey 0))) + (declare (optimize (speed 3) (safety 0))) (with-slots (height scale) app (list (/ x scale) (/ (- height y) scale)))) @@ -156,24 +156,21 @@ give focus to whatever was clicked." (when (and (refocus-on-mousedown-p app) (focusablep (first candidate-targets))) (refocus-on (first candidate-targets))) - (let ((*event-still-bubbling-p* - (mouse-button-events-bubble-p app))) - (loop for target in candidate-targets - do - (dolist (handler (get-handlers-for target 'mousedown)) - (funcall handler target x y clicks button wx wy)) - while *event-still-bubbling-p*))))) + (let ((*event-still-bubbling-p* (mouse-button-events-bubble-p app))) + (loop :for target :in candidate-targets :do + (dolist (handler (get-handlers-for target 'mousedown)) + (funcall handler target x y clicks button wx wy)) + :while *event-still-bubbling-p*))))) (defun eventloop-mousebuttonup (app wx wy clicks button) (when (should-listen-for-p 'mouseup app) (destructuring-bind (x y) (screen-to-world wx wy) (let ((*event-still-bubbling-p* (mouse-button-events-bubble-p app))) - (loop for target in (mouse-event-targets app x y (mouse-button-events-bubble-p app)) - do - (dolist (handler (get-handlers-for target 'mouseup)) - (funcall handler target x y clicks button wx wy)) - while *event-still-bubbling-p*))))) + (loop :for target :in (mouse-event-targets app x y (mouse-button-events-bubble-p app)) :do + (dolist (handler (get-handlers-for target 'mouseup)) + (funcall handler target x y clicks button wx wy)) + :while *event-still-bubbling-p*))))) (defun eventloop-mousemotion (app wx wy wxrel wyrel state) (when (should-listen-for-p 'mousemotion app) @@ -183,11 +180,10 @@ give focus to whatever was clicked." (yrel (* -1 (/ wyrel scale)))) (let ((*event-still-bubbling-p* (mouse-motion-events-bubble-p app))) - (loop for target in (mouse-event-targets app x y (mouse-motion-events-bubble-p app)) - do - (dolist (handler (get-handlers-for target 'mousemotion)) - (funcall handler target x y xrel yrel state wx wy wxrel wyrel)) - while *event-still-bubbling-p*)))))) + (loop :for target :in (mouse-event-targets app x y (mouse-motion-events-bubble-p app)) :do + (dolist (handler (get-handlers-for target 'mousemotion)) + (funcall handler target x y xrel yrel state wx wy wxrel wyrel)) + :while *event-still-bubbling-p*)))))) (defun eventloop-mousewheel (app wx wy dir) (when (should-listen-for-p 'mousewheel app) -- cgit v1.2.3