1 ; Copyright 2022 Frank Duncan (frank@consxy.com) under AGPL3. See distributed LICENSE.txt.
2 (in-package #:clnl-gltk)
4 (defgeneric render (item)
10 ITEM: item to be rendered
15 RENDER is the entry point for rendering different items in the
18 RENDER will return the opengl world to the way it found it after
19 finishing, usually via just popping the matrix."))
21 (defgeneric resize (item width height)
23 "RESIZE ITEM WIDTH HEIGHT => RESULT
27 ITEM: item to be rendered
34 RESIZE is the general purpose resizing entry point for all widgets.
36 WIDTH and HEIGHT are contextual to the actual item being resized, and
37 may be even be ignored."))
39 (defgeneric reposition (item x y)
41 "REPOSITION ITEM X Y => RESULT
45 ITEM: item to be rendered
52 REPOSITION is the general purpose resizing entry point for all widgets.
54 X and Y are contextual to the actual item being repositioned, and
55 may be even be ignored."))
57 (defgeneric mousemove (item x y)
59 "MOUSEMOVE ITEM X Y => RESULT
63 ITEM: item handling event
70 MOUSEMOVE is the general purpose mousemove entry point for all widgets. It
71 is used to alert widgets to movements of the mouse, regardless of button state.
73 X and Y are absolute coordinates, and assumed to be opengl coordinates,
74 not window coordinates (meaning they match the render and setup functions
77 A catchall method that does nothing is also defined so that mouse functions
78 can loop over all available widgets and let them decide what they want to do."))
80 (defmethod mousemove (item x y))
82 (defgeneric mousedown (item x y)
84 "MOUSEDOWN ITEM X Y => RESULT
88 ITEM: item handling event
95 MOUSEDOWN is the general purpose mousedown entry point for all widgets. It
96 is used to alert widgets that a mouse button has been pressed, and where.
97 There's no information on which button has been pressed.
99 X and Y are absolute coordinates, and assumed to be opengl coordinates,
100 not window coordinates (meaning they match the render and setup functions
103 A catchall method that does nothing is also defined so that mouse functions
104 can loop over all available widgets and let them decide what they want to do."))
106 (defmethod mousedown (item x y))
108 (defgeneric mouseup (item x y)
110 "MOUSEUP ITEM X Y => RESULT
112 ARGUMENTS AND VALUES:
114 ITEM: item handling event
121 MOUSEUP is the general purpose mouseup entry point for all widgets. It
122 is used to alert widgets to that a mouse button has been released, and where.
123 There's no information on which button has been released, and it is
124 up to the widget to decide if a click was triggered.
126 X and Y are absolute coordinates, and assumed to be opengl coordinates,
127 not window coordinates (meaning they match the render and setup functions
130 A catchall method that does nothing is also defined so that mouse functions
131 can loop over all available widgets and let them decide what they want to do."))
133 (defmethod mouseup (item x y))
135 (defgeneric toggle (item &optional state)
137 "TOGGLE ITEM &optional STATE => NEW-STATE
139 ARGUMENTS AND VALUES:
142 STATE: a boolean, the state to set to
143 NEW-STATE: a boolean, the state after being set
147 TOGGLE toggles an ITEM.
149 Inverts the current toggle status of the ITEM if no STATE
150 passed in, otherwise sets to STATE."))
152 ; Stick utilities here for now
153 (defun draw-border (x1 y1 x2 y2 &optional (line-width 1f0))
155 ((offset (/ (1- line-width) 2)))
156 (gl:line-width line-width)
159 (gl:vertex (+ x2 offset) y1)
161 (gl:vertex x2 (+ y2 offset))
163 (gl:vertex (- x1 offset) y2)
165 (gl:vertex x1 (- y1 offset))