Skip to content

Commit

Permalink
Bla
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Jul 18, 2024
1 parent 2c0585e commit ce2cdf8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 4 additions & 3 deletions examples/toolkit.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
`(progn (defun ,name (,@(rest args))
(flet ((,thunk (,(first args))
,@body))
(unless *screen*
(setf *screen* (make-instance 'screen)))
(,thunk *screen*)))
(if (boundp '*screen*)
(,thunk *screen*)
(framebuffers:with-screen (*screen* 'screen)
(thunk *screen*)))))
(pushnew ',name *examples*))))
3 changes: 2 additions & 1 deletion renderers/framebuffers/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#:cursor
#:monitor
#:screen
#:window))
#:window
#:with-screen))

(push :alloy-framebuffers *features*)
15 changes: 13 additions & 2 deletions renderers/framebuffers/windowing.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,23 @@
(defmethod (setf alloy:cursor) (value (screen screen))
value)

(defmethod make-window ((screen screen) &rest args &key &allow-other-keys)
(defmethod window:make-window ((screen screen) &rest args &key &allow-other-keys)
(apply #'make-instance 'window :screen screen args))

(defmethod process-events ((screen screen) &key timeout)
(fb:process-events (windows screen) :timeout timeout)
(setf (windows screen) (remove-if #'fb:close-requested-p (windows screen)))
screen)

(defmacro with-screen ((screen &optional (type ''screen) &rest initargs) &body body)
(let ((thunk (gensym "THUNK")))
`(let ((,screen (make-instance ,type ,@initargs)))
(locally ,@body)
(loop while (windows ,screen)
do (dolist (window (windows ,screen))
(alloy:maybe-render ,screen window))
(process-events ,screen :timeout T)))))

(defclass cursor (window:cursor)
((native :initarg :native :accessor native)
(icon :initform :default :accessor icon :reader window:icon)))
Expand All @@ -46,7 +55,8 @@
(symbol icon)))
(setf (icon cursor) icon))

(defclass window (alloy:ui fb:event-handler
(defclass window (window:window
fb:event-handler
org.shirakumo.alloy.renderers.simple.presentations::default-look-and-feel)
((native :accessor native)
(screen :initarg :screen :reader window:screen)
Expand All @@ -55,6 +65,7 @@
(cursor :reader window:cursor)))

(defmethod initialize-instance :after ((window window) &key)
#++
(setf (slot-value window 'cursor) (make-instance 'cursor :window native)))

(defmethod alloy:render ((screen screen) (window window))
Expand Down

0 comments on commit ce2cdf8

Please sign in to comment.