hokusai-zero 0.2.6.pre.pinephone6 → 0.2.6

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +2 -0
  4. data/README.md +1 -1
  5. data/ast/src/core/input.h +1 -0
  6. data/ast/src/core/util.c +23 -23
  7. data/ast/src/core/util.h +7 -7
  8. data/ext/extconf.rb +3 -3
  9. data/hokusai.gemspec +2 -1
  10. data/ui/examples/counter.rb +1 -2
  11. data/ui/examples/forum/file.rb +1 -1
  12. data/ui/examples/forum/post.rb +1 -0
  13. data/ui/examples/forum.rb +7 -7
  14. data/ui/examples/spreadsheet.rb +0 -1
  15. data/ui/examples/tic_tac_toe.rb +6 -6
  16. data/ui/lib/lib_hokusai.rb +24 -25
  17. data/ui/spec/spec_helper.rb +1 -1
  18. data/ui/src/hokusai/assets/chevron-down.svg +1 -0
  19. data/ui/src/hokusai/automation/driver_commands/base.rb +8 -2
  20. data/ui/src/hokusai/automation/driver_commands/trigger_keyboard.rb +6 -3
  21. data/ui/src/hokusai/automation/driver_commands/trigger_mouse.rb +5 -12
  22. data/ui/src/hokusai/automation/server.rb +3 -2
  23. data/ui/src/hokusai/backends/raylib/config.rb +1 -2
  24. data/ui/src/hokusai/backends/raylib/font.rb +3 -24
  25. data/ui/src/hokusai/backends/raylib.rb +36 -167
  26. data/ui/src/hokusai/backends/sdl2/config.rb +6 -9
  27. data/ui/src/hokusai/backends/sdl2/font.rb +1 -3
  28. data/ui/src/hokusai/backends/sdl2.rb +93 -188
  29. data/ui/src/hokusai/blocks/input.rb +2 -2
  30. data/ui/src/hokusai/commands/rect.rb +3 -12
  31. data/ui/src/hokusai/commands.rb +0 -22
  32. data/ui/src/hokusai/event.rb +1 -2
  33. data/ui/src/hokusai/events/keyboard.rb +18 -11
  34. data/ui/src/hokusai/events/mouse.rb +8 -10
  35. data/ui/src/hokusai/mounting/loop_entry.rb +1 -1
  36. data/ui/src/hokusai/painter.rb +8 -31
  37. data/ui/src/hokusai/types.rb +244 -20
  38. data/ui/src/hokusai.rb +35 -61
  39. data/xmake.lua +1 -1
  40. metadata +22 -32
  41. data/ui/examples/drag.rb +0 -154
  42. data/ui/examples/embedded.rb +0 -58
  43. data/ui/examples/game.rb +0 -143
  44. data/ui/examples/keyboard.rb +0 -47
  45. data/ui/examples/overlay.rb +0 -233
  46. data/ui/examples/provider.rb +0 -56
  47. data/ui/examples/shader/test.rb +0 -155
  48. data/ui/examples/shader.rb +0 -100
  49. data/ui/examples/wiki.rb +0 -82
  50. data/ui/spec/hokusai/e2e/keyboard_spec.rb +0 -52
  51. data/ui/src/hokusai/assets/arrow-down-line.png +0 -0
  52. data/ui/src/hokusai/assets/arrow-down-wide-line.png +0 -0
  53. data/ui/src/hokusai/assets/icons/outline/arrow-big-up.svg +0 -19
  54. data/ui/src/hokusai/assets/icons/outline/backspace.svg +0 -20
  55. data/ui/src/hokusai/blocks/color_picker.rb +0 -1080
  56. data/ui/src/hokusai/blocks/keyboard.rb +0 -249
  57. data/ui/src/hokusai/blocks/shader_begin.rb +0 -22
  58. data/ui/src/hokusai/blocks/shader_end.rb +0 -12
  59. data/ui/src/hokusai/blocks/slider.rb +0 -139
  60. data/ui/src/hokusai/blocks/texture.rb +0 -23
  61. data/ui/src/hokusai/commands/shader.rb +0 -33
  62. data/ui/src/hokusai/commands/texture.rb +0 -26
  63. data/ui/src/hokusai/events/touch.rb +0 -62
  64. data/ui/src/hokusai/types/display.rb +0 -151
  65. data/ui/src/hokusai/types/keyboard.rb +0 -168
  66. data/ui/src/hokusai/types/mouse.rb +0 -36
  67. data/ui/src/hokusai/types/primitives.rb +0 -56
  68. data/ui/src/hokusai/types/touch.rb +0 -181
  69. data/ui/src/hokusai/util/wrap_stream.rb +0 -193
@@ -1,193 +0,0 @@
1
- module Hokusai::Util
2
- class Wrapped
3
- attr_accessor :text, :x, :y, :extra
4
-
5
- def initialize(text, x, y, extra)
6
- @text = text
7
- @x = x
8
- @y = y
9
- @extra = extra
10
- end
11
- end
12
-
13
- class SelectionWrapper
14
- attr_accessor :x, :y, :width, :height
15
-
16
- def initialize(x, y, w, h)
17
- @x = x
18
- @y = y
19
- @width = w
20
- @height = h
21
- end
22
-
23
- def <<(w)
24
- @width += w
25
- end
26
- end
27
-
28
- class WrapStream
29
- attr_accessor :width, :current_width, :x, :y,
30
- :origin_x, :origin_y, :buffer, :stack
31
- attr_reader :on_text_cb, :on_text_selection_cb, :on_advancex_cb, :selector, :padding
32
-
33
- def initialize(width, &measure)
34
- @width = width
35
- @current_width = 0.0
36
-
37
- @origin_x = 0.0
38
- @origin_y = 0.0
39
- @x = @origin_x
40
- @y = @origin_y
41
-
42
- @stack = []
43
- @buffer = ""
44
-
45
- @measure_cb = measure
46
- end
47
-
48
- def on_advancex(&block)
49
- @on_advancex_cb = block
50
- end
51
-
52
- def on_text_selection(selector, padding, &block)
53
- @selector = selector
54
- @padding = padding || Hokusai::Padding.new(0.0, 0.0, 0.0, 0.0)
55
- @on_text_selection_cb = block
56
- end
57
-
58
- def on_text(&block)
59
- @on_text_cb = block
60
- end
61
-
62
- def measure(string, extra)
63
- @measure_cb.call(string, extra)
64
- end
65
-
66
- def flush
67
- sx = x + padding.left
68
- wrapper = nil
69
- stack.each do |(range, extra)|
70
- str = buffer[range]
71
- if selector
72
- str.split("").each do |char|
73
- nw, nh = measure(char, extra)
74
- ox = on_advancex_cb.call(char.codepoints.first)
75
-
76
- if selector.selected(sx, y + padding.top - selector.offset_y, nw, nh)
77
- wrapper ||= SelectionWrapper.new(sx, y + padding.top, 0.0, nh)
78
- wrapper << ox
79
- end
80
-
81
- sx += ox
82
- end
83
-
84
- on_text_selection_cb.call(wrapper) if wrapper
85
- wrapper = nil
86
- end
87
-
88
- nw, _ = measure(str, extra)
89
-
90
- # hard break on the buffer, split on character
91
- wrap_and_call(str, extra)
92
-
93
- self.x += nw
94
- end
95
-
96
- self.current_width = 0.0
97
- self.buffer = ""
98
- stack.clear
99
- self.x = origin_x
100
- end
101
-
102
- def wrap(text, extra)
103
- offset = 0
104
- size = text.size
105
-
106
- stack << [((buffer.size)..(text.size + buffer.size - 1)), extra]
107
-
108
- while offset < size
109
- char = text[offset]
110
- w, h = measure(char, extra)
111
-
112
- # if it's a newline we want to break
113
- if char =~ /\n|\r\n/
114
- flush
115
-
116
- stack << [(0...(text.size - offset - 1)), extra]
117
- self.y += h
118
- self.x = origin_x
119
- offset += 1
120
-
121
- next
122
- end
123
-
124
- # if adding this char extends beyond the boundary
125
- if current_width + w > width
126
- # find the last space
127
- idx = buffer.rindex(" ")
128
-
129
- # if there is a break in this line split the buffer
130
- # and render the current line
131
- unless idx.nil? || idx < (buffer.size / 2)
132
- cur = []
133
- nex = []
134
- found = false
135
-
136
- # We need to split up both the buffer, and the ranges
137
- while payload = stack.shift
138
- range, xtra = payload
139
- if range.include?(idx)
140
- # putting the space on this line
141
- cur << [(range.begin..idx), xtra]
142
- # pp [range, idx]
143
- nex << [(0..(range.end - idx - 1)), xtra] unless idx == range.end
144
-
145
- found = true
146
- elsif !found
147
- cur << payload
148
- else
149
- nex << [((range.begin - idx - 1)..(range.end - idx - 1)), xtra]
150
- end
151
- end
152
-
153
- scur = buffer[0..idx]
154
- snex = buffer[(idx + 1)..-1]
155
-
156
- cur.each do |(range, xtra)|
157
- str = scur[range]
158
-
159
- nw, _ = measure(str, xtra)
160
- wrap_and_call(str, xtra)
161
-
162
- self.x += nw
163
- end
164
-
165
- self.buffer = snex + char
166
- self.stack = nex
167
- self.y += h
168
- self.current_width = measure(buffer, extra).first
169
- self.x = origin_x
170
- else
171
- # break on this word
172
- flush
173
-
174
- self.y += h
175
- self.current_width = measure(char, extra).first
176
- self.buffer = char
177
- stack << [(0...(text.size - offset)), extra]
178
- end
179
- else
180
- self.current_width += w
181
- buffer << char
182
- end
183
-
184
- offset += 1
185
- end
186
-
187
- end
188
-
189
- private def wrap_and_call(text, extra)
190
- on_text_cb.call Wrapped.new(text, x, y, extra)
191
- end
192
- end
193
- end