diff options
author | Colin Okay <colin@cicadas.surf> | 2022-07-19 06:45:16 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-07-19 06:45:16 -0500 |
commit | 3c1df8b7807f772887dc3d85725059c4dbe75cca (patch) | |
tree | 9a02be7dff5b9e3e10c13b4f08f5fb487aca0d2c /examples/01-click-and-drag-image.lisp | |
parent | 3e5fb0e5ceb14475164b2a97187c0164ad465cc3 (diff) |
[rename] bitmap/image
Diffstat (limited to 'examples/01-click-and-drag-image.lisp')
-rw-r--r-- | examples/01-click-and-drag-image.lisp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/examples/01-click-and-drag-image.lisp b/examples/01-click-and-drag-image.lisp new file mode 100644 index 0000000..d13bce3 --- /dev/null +++ b/examples/01-click-and-drag-image.lisp @@ -0,0 +1,51 @@ +;;; 01-image-display.lisp + +(defpackage #:ww.examples/1 + (:use #:cl) + (:export #:start)) + +(in-package :ww.examples/1) + +(defclass image-display (ww::application ) ()) + +(ww::defhandler dragging-unit + (ww::on-mousemotion (app x y) + (let ((unit + (first (ww:container-units app)))) + (setf (ww:x unit) x + (ww:y unit) y)))) + +(ww:defhandler start-drag + (ww:on-mousedown (target) + (ww::add-handler + (ww::unit-container target) + #'dragging-unit))) + +(ww:defhandler stop-drag + (ww::on-mouseup (app) + (ww::remove-handler app #'dragging-unit))) + + +(defmethod ww::boot ((app image-display)) + (let ((bm + (make-instance 'ww::image + :texture (ww::get-asset "Fezghoul.png")))) + (describe (ww::model-matrix bm)) + (describe bm) + (describe app) + (ww::add-unit app bm) + (ww::add-handler bm #'start-drag) + (ww::add-handler app #'stop-drag) + (format t "CLICK AND DRAG THE GHOUL~%") + )) + + +(defun start () + (ww::start + (make-instance + 'image-display + :mouse-button-events-bubble-p t + :mouse-motion-events-bubble-p t + :asset-root (merge-pathnames + "examples/" + (asdf:system-source-directory :wheelwork))))) |