-
Notifications
You must be signed in to change notification settings - Fork 2
/
miogui.ss
117 lines (86 loc) · 2.93 KB
/
miogui.ss
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
;; * MIOGUI *
;;
;; Copyright 2016 Aldo Nicolas Bruno
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
#!chezscheme
(debug-level 3)
(optimize-level 0)
(sdl-library-init)
(cairo-library-init)
(print-record #f)
(run-cp0 (lambda (cp0 x) x))
(import (chezscheme)
(sdl2)
(cairo))
(define mi-window (make-parameter #f))
(define mi-renderer (make-parameter #f))
(define mi-window-width (make-parameter 640))
(define mi-window-height (make-parameter 480))
(define mi-sdl-texture (make-parameter #f))
(define (init-sdl window-title)
(assert (= 0 (sdl-init (sdl-initialization 'video))))
(mi-window (sdl-create-window window-title 100 100
(mi-window-width) (mi-window-height)
(sdl-window-flags 'shown 'resizable)))
(assert (not (ftype-pointer-null? (mi-window))))
(mi-renderer (sdl-create-renderer (mi-window) -1
(sdl-renderer-flags 'accelerated 'presentvsync)))
(assert (not (ftype-pointer-null? (mi-renderer))))
(mi-sdl-texture (sdl-create-texture (mi-renderer) (sdl-pixelformat 'argb-8888)
(sdl-texture-access 'streaming)
(mi-window-width) (mi-window-height))))
(define (fini-sdl)
(sdl-destroy-window (mi-window)))
(define mi-mouse-x (make-parameter 0))
(define mi-mouse-y (make-parameter 0))
(define mi-mouse-down? (make-parameter #f))
(define mi-hot-item (make-parameter #f))
(define mi-active-item (make-parameter #f))
(define mi-active-window 'none)
(define mi-last-activable (make-parameter #f))
(define mi-kbd-item (make-parameter #f))
;; (define mi-keys (make-parameter '()))
;; (define (mi-keys-add k)
;; (mi-keys (append (mi-keys) (list k))))
;; (define (mi-keys-rm k)
;; (mi-keys (remove k (mi-keys))))
;; (define (mi-keys-available)
;; (pair? (mi-keys)))
;; (define (mi-keys-pop)
;; (if (pair? (mi-keys))
;; (let ([k (car (mi-keys))])
;; (mi-keys (cdr (mi-keys)))
;; k)
;; #f))
(define mi-key (make-parameter #f))
(define mi-keymod (make-parameter '()))
(define mi-txt (make-parameter #f))
(define mi-cr (make-parameter #f))
(define mi-cairo-surface (make-parameter #f))
(define fps (make-parameter 25))
(define mi-frame-number (make-parameter 0))
(import (srfi s26 cut))
(import (matchable))
(include "utils.ss")
(include "css-color.ss")
(include "draw.ss")
(include "css.ss")
(include "layout.ss")
(include "transition.ss")
(include "element.ss")
(include "css-element.ss")
(include "widgets.ss")
(include "render.ss")
(include "repl.ss")
(include "event-loop.ss")