diff options
author | Colin Okay <colin@cicadas.surf> | 2022-07-23 10:44:40 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-07-23 10:44:40 -0500 |
commit | 8fc1317f0c3c32e3d75b17260b9b0c3ed810fd76 (patch) | |
tree | aae56cef22eb9e1b4a3e0a6a6ad159b355a7a8cc /examples | |
parent | 00841605110612f6e7f3bbfc054ceff980bf25be (diff) |
[add] menu basics and [example]
Diffstat (limited to 'examples')
-rw-r--r-- | examples/13-menus.lisp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/13-menus.lisp b/examples/13-menus.lisp new file mode 100644 index 0000000..66d455c --- /dev/null +++ b/examples/13-menus.lisp @@ -0,0 +1,47 @@ +;;;; menus.lisp + +(defpackage #:ww.examples/13 + (:use #:cl) + (:export #:start)) + +(in-package :ww.examples/13) + +(defclass menus-demo (ww::application) ()) + +(defclass numbered-image (ww::image) + ((n :initarg :num :reader num))) + +(ww:defhandler option-clicked + (ww::on-mousedown (img) + (format t "~a was clicked~%" (num img)))) + +(defmethod ww::boot ((app menus-demo)) + (let ((vscroller + (make-instance 'ww::vscroller + :scroll-speed 10 + :region (make-instance 'ww::region + :left 0 :right 100 + :top 250 :bottom 0)))) + (loop for i to 10 + for img = (make-instance 'numbered-image + :num i + :texture (ww:get-asset "Fezghoul.png")) + do + (ww::add-handler img #'option-clicked) + (ww::add-menu-option vscroller img)) + (ww:add-unit vscroller) + (ww:refocus-on vscroller))) + + +(defun start (&optional (scale 1.0) (side 500)) + (ww:start + (make-instance + 'menus-demo + :fps 30 + :width (round (* scale side)) + :height (round (* scale side)) + :scale scale + :title "Canvas demo" + :asset-root (merge-pathnames + "examples/" + (asdf:system-source-directory :wheelwork))))) |