From 76fa9bbd852fdb2d47c8cf3d539da805bd2f9b53 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 6 Jul 2022 09:51:13 -0500 Subject: [bugfix] get-rect (container); [modify] contains-point-p modification to contains-point-p in order to handle events on objects in containers correctly; i.e. event doesn't fire if object is not being drawn. --- examples/07-renderarea.lisp | 4 ++-- src/core/container.lisp | 7 +++---- src/wheelwork.lisp | 6 ++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/examples/07-renderarea.lisp b/examples/07-renderarea.lisp index ead322f..78d116b 100644 --- a/examples/07-renderarea.lisp +++ b/examples/07-renderarea.lisp @@ -53,8 +53,7 @@ (ww::add-unit cube-container cube) (ww::add-unit app cube-container) - (describe cube-container) - )) + (describe cube-container))) (defun start () @@ -63,6 +62,7 @@ :fps 30 :width 800 :height 600 + :refocus-on-mousedown-p nil :title "A scrollable area." :asset-root (merge-pathnames "examples/" diff --git a/src/core/container.lisp b/src/core/container.lisp index 1410310..e5fe251 100644 --- a/src/core/container.lisp +++ b/src/core/container.lisp @@ -21,7 +21,7 @@ (with-slots (cached-rect left right top bottom) container (or cached-rect (setf cached-rect - (list* (vec:vec left bottom 0 1.0) + (list (vec:vec left bottom 0 1.0) (vec:vec left top 0 1.0) (vec:vec right top 0 1.0) (vec:vec right bottom 0 1.0) @@ -71,12 +71,11 @@ necessary." (gl:get* :scissor-box)) (scale (application-scale - (app-of-unit container)) - )) + (app-of-unit container)))) (with-slots (left right top bottom) container (gl:scissor (* left scale) (* scale bottom) (* scale (- right left)) (* scale (- top bottom))) (unwind-protect (dolist (u (container-units container)) - (when (visible-in-container-p u) + (if (visible-in-container-p u) (render u))) (gl:scissor (aref current 0) (aref current 1) (aref current 2) (aref current 3)))))) diff --git a/src/wheelwork.lisp b/src/wheelwork.lisp index cc70053..8efca4e 100644 --- a/src/wheelwork.lisp +++ b/src/wheelwork.lisp @@ -65,9 +65,6 @@ TARGET is FOCUSABLEP" (sdl2:scancode sdl-keysym) (sdl2:mod-keywords (sdl2:mod-value sdl-keysym))))))) - - - (defun contains-point-p (unit px py) (let* ((pt (vec:vec px py 0.0 1.0)) @@ -95,7 +92,8 @@ TARGET is FOCUSABLEP" (when (unit-visiblep thing) (etypecase thing (container - (find-if #'finder (container-units thing) :from-end t)) + (when (contains-point-p thing x y) + (find-if #'finder (container-units thing) :from-end t))) (unit (when (contains-point-p thing x y) (return-from unit-under thing))))))) -- cgit v1.2.3