From: Javier Sancho Date: Tue, 14 Feb 2017 00:01:59 +0000 (+0100) Subject: Write window declarations using a syntax X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=c99c0f2ef95a3f78ed1be83b9b38db6010d21981;p=gacela.git Write window declarations using a syntax --- diff --git a/examples/01-hello-world/01-hello-world.scm b/examples/01-hello-world/01-hello-world.scm index cc5e0f3..61263f1 100644 --- a/examples/01-hello-world/01-hello-world.scm +++ b/examples/01-hello-world/01-hello-world.scm @@ -20,5 +20,5 @@ (use-modules (gacela)) (display-scene - (window '(#:resolution (640 480)) - (bitmap "hello-world.bmp"))) + (window ((resolution '(640 480))) + (bitmap "hello-world.bmp"))) diff --git a/examples/02-event-driven-programming/02-event-driven-programming.scm b/examples/02-event-driven-programming/02-event-driven-programming.scm index 2fcd3ab..505f4b0 100644 --- a/examples/02-event-driven-programming/02-event-driven-programming.scm +++ b/examples/02-event-driven-programming/02-event-driven-programming.scm @@ -20,5 +20,6 @@ (use-modules (gacela)) (display-scene - (window '(#:resolution (640 480)) - (bitmap "x.bmp"))) + (window ((resolution '(640 480)) + (when-quit (lambda () (format #t "Quit clicked!!~%")))) + (bitmap "x.bmp"))) diff --git a/gacela/window.scm b/gacela/window.scm index eeed32d..6d43ce6 100644 --- a/gacela/window.scm +++ b/gacela/window.scm @@ -20,8 +20,13 @@ #:export (window)) -(define* (window window-properties #:optional scene) - (make-scene - "window" - (lambda () - (apply run-scene (cons scene window-properties))))) +(define-syntax window + (lambda (x) + (syntax-case x () + ((_ ((property-name property-value) ...) scene) + #'(make-scene + "window" + (lambda () + (apply run-scene (cons scene + (append (list (symbol->keyword 'property-name) property-value) + ...)))))))))