|
25 | 25 | (defmethod (setf alloy:cursor) (value (screen screen)) |
26 | 26 | value) |
27 | 27 |
|
28 | | -(defmethod make-window ((screen screen) &rest args &key &allow-other-keys) |
| 28 | +(defmethod window:make-window ((screen screen) &rest args &key &allow-other-keys) |
29 | 29 | (apply #'make-instance 'window :screen screen args)) |
30 | 30 |
|
31 | 31 | (defmethod process-events ((screen screen) &key timeout) |
32 | 32 | (fb:process-events (windows screen) :timeout timeout) |
33 | 33 | (setf (windows screen) (remove-if #'fb:close-requested-p (windows screen))) |
34 | 34 | screen) |
35 | 35 |
|
| 36 | +(defmacro with-screen ((screen &optional (type ''screen) &rest initargs) &body body) |
| 37 | + (let ((thunk (gensym "THUNK"))) |
| 38 | + `(let ((,screen (make-instance ,type ,@initargs))) |
| 39 | + (locally ,@body) |
| 40 | + (loop while (windows ,screen) |
| 41 | + do (dolist (window (windows ,screen)) |
| 42 | + (alloy:maybe-render ,screen window)) |
| 43 | + (process-events ,screen :timeout T))))) |
| 44 | + |
36 | 45 | (defclass cursor (window:cursor) |
37 | 46 | ((native :initarg :native :accessor native) |
38 | 47 | (icon :initform :default :accessor icon :reader window:icon))) |
|
46 | 55 | (symbol icon))) |
47 | 56 | (setf (icon cursor) icon)) |
48 | 57 |
|
49 | | -(defclass window (alloy:ui fb:event-handler |
| 58 | +(defclass window (window:window |
| 59 | + fb:event-handler |
50 | 60 | org.shirakumo.alloy.renderers.simple.presentations::default-look-and-feel) |
51 | 61 | ((native :accessor native) |
52 | 62 | (screen :initarg :screen :reader window:screen) |
|
55 | 65 | (cursor :reader window:cursor))) |
56 | 66 |
|
57 | 67 | (defmethod initialize-instance :after ((window window) &key) |
| 68 | + #++ |
58 | 69 | (setf (slot-value window 'cursor) (make-instance 'cursor :window native))) |
59 | 70 |
|
60 | 71 | (defmethod alloy:render ((screen screen) (window window)) |
|
0 commit comments