aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-07-23 14:09:27 -0500
committerColin Okay <okay@toyful.space>2022-07-23 14:09:27 -0500
commitc32f78283706c3249ddb73577eff5297cd14390e (patch)
tree764633a30c1ab1e6ac2b6eda10cad3150b6e5e55
parentc82d6751e9414d5c17aca7f8a1138086bd4f9c1d (diff)
[change] option->item in menu
-rw-r--r--examples/13-menus.lisp6
-rw-r--r--gui/menus.lisp55
-rw-r--r--src/package.lisp2
3 files changed, 32 insertions, 31 deletions
diff --git a/examples/13-menus.lisp b/examples/13-menus.lisp
index 66d455c..d1c5668 100644
--- a/examples/13-menus.lisp
+++ b/examples/13-menus.lisp
@@ -11,7 +11,7 @@
(defclass numbered-image (ww::image)
((n :initarg :num :reader num)))
-(ww:defhandler option-clicked
+(ww:defhandler item-clicked
(ww::on-mousedown (img)
(format t "~a was clicked~%" (num img))))
@@ -27,8 +27,8 @@
:num i
:texture (ww:get-asset "Fezghoul.png"))
do
- (ww::add-handler img #'option-clicked)
- (ww::add-menu-option vscroller img))
+ (ww::add-handler img #'item-clicked)
+ (ww::add-menu-item vscroller img))
(ww:add-unit vscroller)
(ww:refocus-on vscroller)))
diff --git a/gui/menus.lisp b/gui/menus.lisp
index f758d51..6c3e5b8 100644
--- a/gui/menus.lisp
+++ b/gui/menus.lisp
@@ -3,10 +3,10 @@
(in-package :wheelwork)
(defclass/std menu (unit interactive)
- ((options :with :std nil
+ ((items :with :std nil
:doc "A list of interactive units")
(focus :with :std nil
- :doc "The option that is focused in this menu, if any.")
+ :doc "The item that is focused in this menu, if any.")
(region :std (error "Menus require an explicit region"))))
(defmethod initialize-instance :after ((menu menu) &key)
@@ -42,67 +42,68 @@
`(defmethod (setf ,name) (newval (menu menu))
(let ((diff (- newval (,name menu))))
(setf (,name (unit-region menu)) newval)
- (dolist (o (menu-options menu))
+ (dolist (o (menu-items menu))
(incf (,name o) diff)))))))
`(progn ,@defs))))
(def-menu-accessors x y width height))
(defmethod add-unit :after ((menu menu))
- (dolist (o (menu-options menu))
+ (dolist (o (menu-items menu))
(add-unit o)))
(defmethod drop-unit :before ((menu menu))
- (dolist (o (menu-options menu))
+ (dolist (o (menu-items menu))
(drop-unit o)))
-(defgeneric add-menu-option (menu option))
-(defmethod add-menu-option ((menu menu) option)
- (setf (unit-region option) (unit-region menu))
- (setf (menu-options menu)
- (nconc (menu-options menu) (list option)))
+(defgeneric add-menu-item (menu item))
+(defmethod add-menu-item ((menu menu) item)
+ (setf (unit-region item) (unit-region menu)
+ (focusablep item) nil)
+ (setf (menu-items menu)
+ (nconc (menu-items menu) (list item)))
(when (unit-in-scene-p menu)
- (add-unit option)))
+ (add-unit item)))
-(defun remove-menu-option (menu option)
- (when (member option (menu-options menu))
- (setf (unit-region option) *application*)
- (setf (menu-options menu)
- (delete option (menu-options menu)))
- (drop-unit option)))
+(defun remove-menu-item (menu item)
+ (when (member item (menu-items menu))
+ (setf (unit-region item) *application*)
+ (setf (menu-items menu)
+ (delete item (menu-items menu)))
+ (drop-unit item)))
(defmethod render ((menu menu))
- (dolist (o (menu-options menu))
+ (dolist (o (menu-items menu))
(render o)))
(defclass/std vscroller (menu)
((scroll-speed :std 1)
(vert-scroll :std 0
- :doc "Vertical distance options have been displaced.")))
+ :doc "Vertical distance items have been displaced.")))
(defmethod (setf vert-scroll) :after (val (vs vscroller))
(loop
- for o in (menu-options vs)
+ for o in (menu-items vs)
for y = (+ (y vs) (height vs) val) then (- y (height o))
do (setf (y o) y)))
(defhandler vscroller-scroll
(on-mousewheel (vs horiz vert)
- (let ((oh (vscroller-options-height vs))
+ (let ((oh (vscroller-items-height vs))
(h (height vs)))
(setf (vert-scroll vs)
(clamp 0
(+ (vert-scroll vs) (* vert (scroll-speed vs)))
(- oh h))))))
-(defun vscroller-options-height (vs)
- (loop for o in (menu-options vs) summing (height o)))
+(defun vscroller-items-height (vs)
+ (loop for o in (menu-items vs) summing (height o)))
-(defmethod add-menu-option :before ((vs vscroller) option)
- (setf (x option) (x vs)
- (y option) (- (+ (y vs) (height vs) (vert-scroll vs))
- (vscroller-options-height vs))))
+(defmethod add-menu-item :before ((vs vscroller) item)
+ (setf (x item) (x vs)
+ (y item) (- (+ (y vs) (height vs) (vert-scroll vs))
+ (vscroller-items-height vs))))
(defmethod initialize-instance :after ((vscroller vscroller) &key)
(add-handler vscroller #'vscroller-scroll))
diff --git a/src/package.lisp b/src/package.lisp
index a93c8fc..7a07726 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -77,7 +77,7 @@
;; Generic and APIs
#:unit-visbilep
- #:unit-in-scene-
+ #:unit-in-scene-p
;; Specific Unit Classes and APIs
#:image