aboutsummaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/menus.lisp55
1 files changed, 28 insertions, 27 deletions
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))