From 9b19ea91bd5672280238f4132153c5ef16ba127d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 28 Dec 2022 12:18:06 -0500 Subject: node-2d: Fix width/height init args bug. --- catbird/node-2d.scm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'catbird') diff --git a/catbird/node-2d.scm b/catbird/node-2d.scm index a81e2a6..9199536 100644 --- a/catbird/node-2d.scm +++ b/catbird/node-2d.scm @@ -336,7 +336,6 @@ ;; transformation matrix into consideration. (size #:getter size #:init-thunk make-null-rect) (width #:accessor width - #:init-keyword #:width #:observe? #t #:allocation #:virtual #:slot-ref (lambda (node) (rect-width (size node))) @@ -344,7 +343,6 @@ (set-rect-width! (size node) w) (expire-local-bounding-box node))) (height #:accessor height - #:init-keyword #:height #:observe? #t #:allocation #:virtual #:slot-ref (lambda (node) (rect-height (size node))) @@ -378,10 +376,11 @@ (slot-set! node 'scale (vec2 s s)))) ;; If caller doesn't specify a custom width and height, let the node ;; pick a reasonable default size. - (when (= (width node) 0.0) - (set! (width node) (default-width node))) - (when (= (height node) 0.0) - (set! (height node) (default-height node))) + (let ((r (size node))) + (set-rect-width! r (or (get-keyword #:width args) + (default-width node))) + (set-rect-height! r (or (get-keyword #:height args) + (default-height node)))) ;; Build an initial bounding box. (vec2-copy! (position node) (render-position node)) ;; Set the initial last position to the same as the initial position -- cgit v1.2.3