-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathui.lisp
53 lines (32 loc) · 1.6 KB
/
ui.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(cl:in-package :cl-bodge.ui)
(declaim (special *rendering-output*))
(defclass ui (disposable)
((renderer :initarg :renderer :reader %renderer-of)
(handle :initarg :handle :reader %handle-of)))
(define-destructor ui (renderer handle)
(dispose handle)
(run (for-graphics :disposing t ()
(dispose renderer))))
(define-system-function make-ui graphics-system (width height &key (pixel-ratio 1f0)
input-source
(antialiased t))
(let ((renderer (make-ui-canvas-renderer width height :antialiased antialiased
:pixel-ratio pixel-ratio)))
(make-instance 'ui :handle (bodge-ui:make-ui renderer :input-source input-source)
:renderer renderer)))
(defun compose-ui (ui &optional (rendering-output t))
(let ((*rendering-output* rendering-output))
(bodge-ui:compose-ui (%handle-of ui))))
(defmacro with-ui-access ((ui) &body body)
`(bodge-ui:with-ui-access ((%handle-of ,ui))
,@body))
(defun add-panel (ui window-class &rest initargs &key &allow-other-keys)
(apply #'bodge-ui:add-panel (%handle-of ui) window-class initargs))
(defun remove-panel (ui window)
(bodge-ui:remove-panel (%handle-of ui) window))
(defun remove-all-panels (ui)
(bodge-ui:remove-all-panels (%handle-of ui)))
(defun update-ui-size (ui width height)
(update-renderer-canvas-size (%renderer-of ui) width height))
(defun update-ui-pixel-ratio (ui pixel-ratio)
(update-renderer-canvas-pixel-ratio (%renderer-of ui) pixel-ratio))