AtlatestRepositorysigil-wm

sigil-wm / tree / examplesstacking.sgl

1(import (sigil ffi) (sigil async) (sigil wm model) (sigil wm scene)
2 (sigil wm host) (sigil wm input) (sigil wm repl) (sigil process) (sigil wm examples support))
3
4(define (stacking root box snapshot trigger)
5 (let loop ((ids (container-children root)) (index 0) (result '()))
6 (if (null? ids)
7 (let ((placements (reverse result)))
8 (append (filter (lambda (item) (not (placement-activated? item))) placements)
9 (filter placement-activated? placements)))
10 (let ((offset (* index 64)))
11 (loop (cdr ids) (+ index 1)
12 (cons (placement window: (car ids)
13 box: (rect x: (+ (rect-x box) 48 offset) y: (+ (rect-y box) 64 offset)
14 width: 480 height: 320)
15 activated?: (= (car ids) (container-data root)))
16 result))))))
18(define example (make-example stacking #f))
19(define host (example-host example))
20(with-async
21 (let ((repl (and (getenv "SIGIL_WM_REPL")
22 (start-repl! host (getenv "SIGIL_WM_REPL") (interaction-environment)))))
23 (run-host! host)
24 (when repl (stop-repl! repl))))
25(unless (and (= (host-statistic host 1) 0)
26 (= (host-statistic host 2) 0)
27 (= (host-statistic host 4) 0))
28 (error "native objects or copied buffers survived shutdown"))