EQL5/examples/M-modules/quick/palindrome-2/palindrome.lisp

33 lines
1.1 KiB
Common Lisp

;;; palindrome
(qrequire :quick)
(require :properties "properties")
(require :utils "utils")
(use-package :qml)
;;; QSLEEP note: it's the same as SLEEP in CL, but continuing
;;; to process Qt events (using a temporary event loop)
(defun run-animation (&optional first)
(dolist (move-to (nthcdr (if first 1 0) *move-to-positions*))
(let ((target 0))
(dolist (xy move-to)
(incf target)
(let ((img (find-quick-item (format nil "img~D" target))))
(q> |x| img (* 31 (first xy)))
(q> |y| img (* 31 (second xy)))
(qsleep 0.03)))) ; delay between item start (in sec)
(qsleep 4)) ; duration of animation + pause (in sec)
(qsingle-shot 500 'run-animation)) ; pause (in msec)
(defun run ()
(setf qml:*quick-view* (qnew "QQuickView"))
(x:do-with qml:*quick-view*
(|setSource| (|fromLocalFile.QUrl| "qml/palindrome.qml"))
(|setResizeMode| |QQuickView.SizeRootObjectToView|)
(|show|))
(qlater (lambda () (run-animation t)))) ; QLATER: don't block REPL (for eql5 -qtpl)
(run)