hokusai-zero 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Gemfile.lock +4 -0
- data/README.md +33 -83
- data/ast/src/core/hml.c +9 -9
- data/ast/src/core/text.c +21 -3
- data/ast/test/text.c +3 -3
- data/docs.sh +29 -0
- data/ext/extconf.rb +69 -14
- data/grammar/corpus/1_document.txt +24 -0
- data/grammar/corpus/6_styles.txt +23 -0
- data/grammar/grammar.js +4 -4
- data/grammar/src/grammar.json +19 -19
- data/grammar/src/parser.c +1904 -1956
- data/grammar/test.nml +10 -8
- data/hokusai.gemspec +3 -1
- data/ui/examples/assets/Delius-Regular.ttf +0 -0
- data/ui/examples/assets/DoHyeon.ttf +0 -0
- data/ui/examples/assets/Inter-Regular.ttf +0 -0
- data/ui/examples/assets/ernest.gif +0 -0
- data/ui/examples/assets/icons/audio-x-generic.png +0 -0
- data/ui/examples/assets/icons/image-x-generic.png +0 -0
- data/ui/examples/assets/icons/media-playback-pause.png +0 -0
- data/ui/examples/assets/icons/media-playback-start.png +0 -0
- data/ui/examples/assets/icons/media-playback-stop.png +0 -0
- data/ui/examples/assets/icons/package-x-generic.png +0 -0
- data/ui/examples/assets/icons/text-x-generic.png +0 -0
- data/ui/examples/assets/icons/video-x-generic.png +0 -0
- data/ui/examples/buddy.rb +16 -14
- data/ui/examples/clock.rb +38 -36
- data/ui/examples/counter.rb +100 -98
- data/ui/examples/dynamic.rb +115 -113
- data/ui/examples/foobar.rb +189 -187
- data/ui/examples/forum/file.rb +54 -0
- data/ui/examples/forum/music.rb +76 -0
- data/ui/examples/forum/post.rb +146 -0
- data/ui/examples/forum.rb +198 -0
- data/ui/examples/spreadsheet/csv.rb +261 -0
- data/ui/examples/spreadsheet.rb +138 -0
- data/ui/examples/stock.rb +86 -92
- data/ui/examples/stock_decider/option.rb +1 -1
- data/ui/examples/tic_tac_toe.rb +193 -191
- data/ui/lib/lib_hokusai.rb +2 -1
- data/ui/src/hokusai/assets/arrow-drop-down-line.png +0 -0
- data/ui/src/hokusai/assets/chevron-down.svg +1 -0
- data/ui/src/hokusai/assets/close-large-line.png +0 -0
- data/ui/src/hokusai/ast.rb +42 -43
- data/ui/src/hokusai/backends/raylib/font.rb +1 -2
- data/ui/src/hokusai/backends/raylib.rb +29 -17
- data/ui/src/hokusai/backends/sdl2/font.rb +13 -9
- data/ui/src/hokusai/backends/sdl2.rb +32 -5
- data/ui/src/hokusai/block.rb +14 -7
- data/ui/src/hokusai/blocks/dropdown.rb +205 -0
- data/ui/src/hokusai/blocks/hblock.rb +2 -2
- data/ui/src/hokusai/blocks/image.rb +6 -1
- data/ui/src/hokusai/blocks/input.rb +17 -0
- data/ui/src/hokusai/blocks/label.rb +5 -2
- data/ui/src/hokusai/blocks/modal.rb +62 -0
- data/ui/src/hokusai/blocks/panel.rb +2 -2
- data/ui/src/hokusai/blocks/scrollbar.rb +0 -2
- data/ui/src/hokusai/blocks/text.rb +12 -6
- data/ui/src/hokusai/blocks/titlebar/osx.rb +4 -4
- data/ui/src/hokusai/blocks/variable.rb +33 -0
- data/ui/src/hokusai/blocks/vblock.rb +1 -1
- data/ui/src/hokusai/commands/rect.rb +4 -4
- data/ui/src/hokusai/commands.rb +46 -29
- data/ui/src/hokusai/diff.rb +11 -0
- data/ui/src/hokusai/event.rb +19 -5
- data/ui/src/hokusai/events/mouse.rb +9 -1
- data/ui/src/hokusai/font.rb +60 -0
- data/ui/src/hokusai/meta.rb +11 -24
- data/ui/src/hokusai/node.rb +1 -1
- data/ui/src/hokusai/painter.rb +66 -8
- data/ui/src/hokusai/util/clamping_iterator.rb +5 -6
- data/ui/src/hokusai.rb +53 -4
- metadata +56 -3
data/ui/src/hokusai.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
ASSETS_FOLDER = "#{__dir__}/hokusai/assets"
|
2
|
+
|
1
3
|
require_relative '../lib/lib_hokusai'
|
2
4
|
require_relative './hokusai/error'
|
3
5
|
require_relative './hokusai/types'
|
@@ -32,10 +34,16 @@ require_relative './hokusai/blocks/panel'
|
|
32
34
|
require_relative './hokusai/blocks/text'
|
33
35
|
require_relative './hokusai/blocks/selectable'
|
34
36
|
require_relative './hokusai/blocks/input'
|
37
|
+
require_relative './hokusai/blocks/variable'
|
35
38
|
require_relative './hokusai/blocks/titlebar/osx'
|
39
|
+
require_relative './hokusai/blocks/modal'
|
40
|
+
require_relative './hokusai/blocks/dropdown'
|
36
41
|
|
37
42
|
require "concurrent"
|
38
43
|
|
44
|
+
# A backend agnostic library for authoring
|
45
|
+
# desktop applications
|
46
|
+
# @author skinnyjames
|
39
47
|
module Hokusai
|
40
48
|
ThreadPool = Concurrent::ThreadPoolExecutor.new(
|
41
49
|
min_threads: 5,
|
@@ -44,60 +52,96 @@ module Hokusai
|
|
44
52
|
fallback_policy: :caller_runs
|
45
53
|
)
|
46
54
|
|
55
|
+
SHADER_UNIFORM_FLOAT = 0 # Shader uniform type: float
|
56
|
+
SHADER_UNIFORM_VEC2 = 1 # Shader uniform type: vec2 (2 float)
|
57
|
+
SHADER_UNIFORM_VEC3 = 2 # Shader uniform type: vec3 (3 float)
|
58
|
+
SHADER_UNIFORM_VEC4 = 3 # Shader uniform type: vec4 (4 float)
|
59
|
+
SHADER_UNIFORM_INT = 4 # Shader uniform type: int
|
60
|
+
SHADER_UNIFORM_IVEC2 = 5 # Shader uniform type: ivec2 (2 int)
|
61
|
+
SHADER_UNIFORM_IVEC3 = 6 # Shader uniform type: ivec3 (3 int)
|
62
|
+
SHADER_UNIFORM_IVEC4 = 7 # Shader uniform type: ivec4 (4 int)
|
63
|
+
SHADER_UNIFORM_UINT = 8 # Shader uniform type: unsigned int
|
64
|
+
SHADER_UNIFORM_UIVEC2 = 9 # Shader uniform type: uivec2 (2 unsigned int)
|
65
|
+
SHADER_UNIFORM_UIVEC3 = 10 # Shader uniform type: uivec3 (3 unsigned int)
|
66
|
+
SHADER_UNIFORM_UIVEC4 = 11 # Shader uniform type: uivec4 (4 unsigned int)
|
67
|
+
|
68
|
+
# Access the font registry
|
69
|
+
#
|
70
|
+
# @return [Hokusai::FontRegistry]
|
47
71
|
def self.fonts
|
48
72
|
@fonts ||= FontRegistry.new
|
49
73
|
end
|
50
74
|
|
75
|
+
# Close the current window
|
76
|
+
#
|
77
|
+
# @return [void]
|
51
78
|
def self.close_window
|
52
79
|
@on_close_window&.call
|
53
80
|
end
|
54
81
|
|
82
|
+
# **Backend:** Provides the window close callback
|
55
83
|
def self.on_close_window(&block)
|
56
84
|
@on_close_window = block
|
57
85
|
end
|
58
86
|
|
87
|
+
# **Backend:** Provides the window restore callback
|
59
88
|
def self.on_restore_window(&block)
|
60
89
|
@on_restore_window = block
|
61
90
|
end
|
62
91
|
|
92
|
+
# Restores the current window
|
93
|
+
#
|
94
|
+
# @return [void]
|
63
95
|
def self.restore_window
|
64
96
|
@on_restore_window&.call
|
65
97
|
end
|
66
98
|
|
99
|
+
# Minimizes the current window
|
100
|
+
#
|
101
|
+
# @return [void]
|
67
102
|
def self.minimize_window
|
68
103
|
@on_minimize_window&.call
|
69
104
|
end
|
70
105
|
|
106
|
+
# **Backend** Provides the minimize window callback
|
71
107
|
def self.on_minimize_window(&block)
|
72
108
|
@on_minimize_window = block
|
73
109
|
end
|
74
110
|
|
111
|
+
# Maxmizes the current window
|
112
|
+
#
|
113
|
+
# @return [void]
|
75
114
|
def self.maximize_window
|
76
115
|
@on_maximize_window&.call
|
77
116
|
end
|
78
117
|
|
118
|
+
# **Backend** Provides the maximize window callback
|
79
119
|
def self.on_maximize_window(&block)
|
80
120
|
@on_maximize_window = block
|
81
121
|
end
|
82
122
|
|
83
123
|
# Sets the window position on the screen
|
84
124
|
#
|
85
|
-
#
|
125
|
+
# @param [Array<Float, Float>]
|
126
|
+
# @return [void]
|
86
127
|
def self.set_window_position(mouse)
|
87
128
|
@on_set_window_position&.call(mouse)
|
88
129
|
end
|
89
130
|
|
131
|
+
# **Backend:** Provides the window position callback
|
90
132
|
def self.on_set_window_position(&block)
|
91
133
|
@on_set_window_position = block
|
92
134
|
end
|
93
135
|
|
94
|
-
#
|
95
|
-
#
|
96
|
-
# NOTE the implementation is backend specific
|
136
|
+
# **Backend:** Provides the mouse position callback
|
97
137
|
def self.on_set_mouse_position(&block)
|
98
138
|
@on_set_mouse_position = block
|
99
139
|
end
|
100
140
|
|
141
|
+
# Sets the window position on the screen
|
142
|
+
#
|
143
|
+
# @param [Array<Float, Float>]
|
144
|
+
# @return [void]
|
101
145
|
def self.set_mouse_position(mouse)
|
102
146
|
@on_set_mouse_position&.call(mouse)
|
103
147
|
end
|
@@ -106,6 +150,11 @@ module Hokusai
|
|
106
150
|
@on_renderable = block
|
107
151
|
end
|
108
152
|
|
153
|
+
# Tells if a canvas is renderable
|
154
|
+
# Useful for pruning unneeded renders
|
155
|
+
#
|
156
|
+
# @param [Hokusai::Canvas]
|
157
|
+
# @return [Bool]
|
109
158
|
def self.can_render(canvas)
|
110
159
|
@on_renderable&.call(canvas)
|
111
160
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hokusai-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- skinnyjames
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: concurrent-ruby
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 0.2.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: memory_profiler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description:
|
70
98
|
email: zero@skinnyjames.net
|
71
99
|
executables: []
|
@@ -104,6 +132,7 @@ files:
|
|
104
132
|
- ast/test/hokusai.c
|
105
133
|
- ast/test/parser.c
|
106
134
|
- ast/test/text.c
|
135
|
+
- docs.sh
|
107
136
|
- ext/extconf.rb
|
108
137
|
- grammar/Cargo.lock
|
109
138
|
- grammar/Cargo.toml
|
@@ -129,19 +158,37 @@ files:
|
|
129
158
|
- grammar/src/tree_sitter/scanner.h
|
130
159
|
- grammar/test.nml
|
131
160
|
- hokusai.gemspec
|
161
|
+
- ui/examples/assets/Delius-Regular.ttf
|
132
162
|
- ui/examples/assets/DigitalDisplay.ttf
|
163
|
+
- ui/examples/assets/DoHyeon.ttf
|
164
|
+
- ui/examples/assets/Inter-Regular.ttf
|
133
165
|
- ui/examples/assets/OpenSans-Regular.ttf
|
134
166
|
- ui/examples/assets/addy.png
|
135
167
|
- ui/examples/assets/baby_sean.png
|
168
|
+
- ui/examples/assets/ernest.gif
|
136
169
|
- ui/examples/assets/football-troll.png
|
137
170
|
- ui/examples/assets/gear.png
|
138
171
|
- ui/examples/assets/icecold.ttf
|
172
|
+
- ui/examples/assets/icons/audio-x-generic.png
|
173
|
+
- ui/examples/assets/icons/image-x-generic.png
|
174
|
+
- ui/examples/assets/icons/media-playback-pause.png
|
175
|
+
- ui/examples/assets/icons/media-playback-start.png
|
176
|
+
- ui/examples/assets/icons/media-playback-stop.png
|
177
|
+
- ui/examples/assets/icons/package-x-generic.png
|
178
|
+
- ui/examples/assets/icons/text-x-generic.png
|
179
|
+
- ui/examples/assets/icons/video-x-generic.png
|
139
180
|
- ui/examples/assets/science-troll.png
|
140
181
|
- ui/examples/buddy.rb
|
141
182
|
- ui/examples/clock.rb
|
142
183
|
- ui/examples/counter.rb
|
143
184
|
- ui/examples/dynamic.rb
|
144
185
|
- ui/examples/foobar.rb
|
186
|
+
- ui/examples/forum.rb
|
187
|
+
- ui/examples/forum/file.rb
|
188
|
+
- ui/examples/forum/music.rb
|
189
|
+
- ui/examples/forum/post.rb
|
190
|
+
- ui/examples/spreadsheet.rb
|
191
|
+
- ui/examples/spreadsheet/csv.rb
|
145
192
|
- ui/examples/stock.rb
|
146
193
|
- ui/examples/stock_decider/option.rb
|
147
194
|
- ui/examples/tic_tac_toe.rb
|
@@ -159,6 +206,9 @@ files:
|
|
159
206
|
- ui/spec/hokusai_spec.rb
|
160
207
|
- ui/spec/spec_helper.rb
|
161
208
|
- ui/src/hokusai.rb
|
209
|
+
- ui/src/hokusai/assets/arrow-drop-down-line.png
|
210
|
+
- ui/src/hokusai/assets/chevron-down.svg
|
211
|
+
- ui/src/hokusai/assets/close-large-line.png
|
162
212
|
- ui/src/hokusai/ast.rb
|
163
213
|
- ui/src/hokusai/automation.rb
|
164
214
|
- ui/src/hokusai/automation/client.rb
|
@@ -191,12 +241,14 @@ files:
|
|
191
241
|
- ui/src/hokusai/blocks/circle.rb
|
192
242
|
- ui/src/hokusai/blocks/clipped.rb
|
193
243
|
- ui/src/hokusai/blocks/cursor.rb
|
244
|
+
- ui/src/hokusai/blocks/dropdown.rb
|
194
245
|
- ui/src/hokusai/blocks/dynamic.rb
|
195
246
|
- ui/src/hokusai/blocks/empty.rb
|
196
247
|
- ui/src/hokusai/blocks/hblock.rb
|
197
248
|
- ui/src/hokusai/blocks/image.rb
|
198
249
|
- ui/src/hokusai/blocks/input.rb
|
199
250
|
- ui/src/hokusai/blocks/label.rb
|
251
|
+
- ui/src/hokusai/blocks/modal.rb
|
200
252
|
- ui/src/hokusai/blocks/panel.rb
|
201
253
|
- ui/src/hokusai/blocks/rect.rb
|
202
254
|
- ui/src/hokusai/blocks/scissor_begin.rb
|
@@ -207,6 +259,7 @@ files:
|
|
207
259
|
- ui/src/hokusai/blocks/text.rb
|
208
260
|
- ui/src/hokusai/blocks/titlebar/osx.rb
|
209
261
|
- ui/src/hokusai/blocks/toggle.rb
|
262
|
+
- ui/src/hokusai/blocks/variable.rb
|
210
263
|
- ui/src/hokusai/blocks/vblock.rb
|
211
264
|
- ui/src/hokusai/commands.rb
|
212
265
|
- ui/src/hokusai/commands/base.rb
|
@@ -257,7 +310,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
310
|
- !ruby/object:Gem::Version
|
258
311
|
version: '0'
|
259
312
|
requirements: []
|
260
|
-
rubygems_version: 3.5.
|
313
|
+
rubygems_version: 3.5.18
|
261
314
|
signing_key:
|
262
315
|
specification_version: 4
|
263
316
|
summary: A Ruby library for writing GUI applications
|