From c99c0f2ef95a3f78ed1be83b9b38db6010d21981 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 14 Feb 2017 01:01:59 +0100 Subject: [PATCH] Write window declarations using a syntax --- examples/01-hello-world/01-hello-world.scm | 4 ++-- .../02-event-driven-programming.scm | 5 +++-- gacela/window.scm | 15 ++++++++++----- 3 files changed, 15 insertions(+), 9 deletions(-) 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) + ...))))))))) -- 2.39.2