From 424681f151f798b896cdef67ec57efefe3baec3d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 30 Apr 2023 10:47:29 -0400 Subject: Be more responsive to nested container resizing. --- catbird/ui.scm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/catbird/ui.scm b/catbird/ui.scm index 7809226..326924c 100644 --- a/catbird/ui.scm +++ b/catbird/ui.scm @@ -139,12 +139,17 @@ (define-class () (needs-layout? #:accessor needs-layout? #:init-value #t)) +(define-method (needs-layout? (node )) #f) + (define-method (initialize (container ) initargs) (next-method) (layout container)) (define-method (layout (container )) - #t) + (for-each-child (lambda (child) + (when (needs-layout? child) + (layout child))) + container)) (define-method (on-attach (container ) child) (set! (needs-layout? container) #t)) @@ -152,6 +157,9 @@ (define-method (on-detach (container ) child) (set! (needs-layout? container) #t)) +(define-method (on-child-resize (container ) child) + (set! (needs-layout? container) #t)) + (define-method (update (container ) dt) (when (needs-layout? container) (layout container) @@ -203,10 +211,8 @@ (slot-set! container 'margin-top m) (set! (needs-layout? container) #t)) -(define-method (on-child-resize (container ) child) - (set! (needs-layout? container) #t)) - (define-method (layout (container )) + (next-method) (for-each-child (lambda (child) (place-at child (margin-left container) @@ -224,6 +230,7 @@ (padding #:accessor padding #:init-keyword #:padding #:init-value 0.0)) (define-method (layout (container )) + (next-method) (let ((p (padding container))) (let loop ((kids (children container)) (prev #f)) @@ -241,6 +248,7 @@ (padding #:accessor padding #:init-keyword #:padding #:init-value 0.0)) (define-method (layout (container )) + (next-method) (let ((p (padding container))) (let loop ((kids (children container)) (prev #f)) -- cgit v1.2.3