(in-package :cube-modeller) (defvar *toolbox-frame* nil) ;;; works only for functions, not for macros ;;; ;;; (defmacro defun-with-cube-write (name lambda-list &rest body) ;;; `(defun ,name ,lambda-list ;;; (prog1 ;;; (progn ;;; ,@body) ;;; (write-cube-to-device)))) ;;; ;;; (defmacro wrap-defun-with-cube-write (new-symbol old-symbol) ;;; `(defun-with-cube-write ,new-symbol (&rest parameters) ;;; (apply ,old-symbol parameters))) ;;; ;;; (wrap-defun-with-cube-write move-cube #'led-cube:move-cube) ;;; (wrap-defun-with-cube-write goto-cube #'led-cube:goto-cube) ;;; (wrap-defun-with-cube-write empty-cube #'led-cube:empty-cube) ;;; (wrap-defun-with-cube-write delete-cube #'led-cube:delete-cube) ;;; (wrap-defun-with-cube-write delete-animation #'led-cube:delete-animation) ;;; (wrap-defun-with-cube-write undo #'led-cube:undo) (defmacro wrap-defun-with-cube-write (new-symbol old-symbol &optional more-stuff) `(defmacro ,new-symbol (&rest parameters) `(multiple-value-prog1 (,',old-symbol ,@parameters) (write-cube-to-device) (let ((*application-frame* (or *application-frame* *toolbox-frame*))) (when *application-frame* ,',more-stuff))))) (wrap-defun-with-cube-write load-animation-file led-cube:load-animation-file) (wrap-defun-with-cube-write move-cube led-cube:move-cube) (wrap-defun-with-cube-write goto-cube led-cube:goto-cube (set-cube-slider-value)) (wrap-defun-with-cube-write fill-cube led-cube:fill-cube) (wrap-defun-with-cube-write empty-cube led-cube:empty-cube) (wrap-defun-with-cube-write insert-cube-copy led-cube:insert-cube-copy ;; needs not to update the physical cube but the cube-slider (adjust-cube-slider-for-animation)) (wrap-defun-with-cube-write delete-cube led-cube:delete-cube (adjust-cube-slider-for-animation)) (wrap-defun-with-cube-write delete-animation led-cube:delete-animation (adjust-cube-slider-for-animation)) (wrap-defun-with-cube-write undo led-cube:undo (adjust-cube-slider-for-animation)) (defun set-current-intensity (intensity &key (update-color-selector t)) (prog1 (led-cube:set-current-intensity intensity) (when update-color-selector (let ((*application-frame* (or *application-frame* *toolbox-frame*))) (when *application-frame* (update-color-selector intensity)))))) (defun move-up () (move-cube :y 1)) (defun move-down () (move-cube :y -1)) (defun move-left () (move-cube :x -1)) (defun move-right () (move-cube :x 1)) (defun move-forward () (move-cube :z -1)) (defun move-backward () (move-cube :z 1)) (defun reset-perspective () (setf *alpha* *alpha-default* *beta* *beta-default*))