hokusai-zero 0.2.6.pre.pinephone3 → 0.2.6.pre.pinephone4
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/hokusai.gemspec +1 -1
- data/ui/examples/keyboard.rb +1 -1
- data/ui/src/hokusai/backends/raylib/config.rb +2 -1
- data/ui/src/hokusai/backends/raylib.rb +47 -15
- data/ui/src/hokusai/backends/sdl2.rb +1 -1
- data/ui/src/hokusai/blocks/keyboard.rb +52 -37
- data/ui/src/hokusai/mounting/loop_entry.rb +1 -1
- data/ui/src/hokusai/painter.rb +5 -1
- data/ui/src/hokusai/types.rb +10 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b672dfc60bcfe8368484d46925bd4a01fe373e7208695ef1941a2dff41f8c2aa
|
4
|
+
data.tar.gz: 78f62f3189c1f7d505d301edd6a70d4b51fdbb15a7d71d95813f703c9e208dc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3a9eb97dac2c0331d8dcaca03fb520b182177ebfab0b48867e033df39d169ccd2dc4be6afe3395acf5b78d480caa3ed867ff5a3073994d781d9e568fd276198
|
7
|
+
data.tar.gz: fa827b5ee76853a7b2f8220f852dad1b4aad362908639e2117f138493011f2a98320441eaca88cd6c2ed6c80661e197ac965e4bd3056924214acd39e338ae304
|
data/hokusai.gemspec
CHANGED
data/ui/examples/keyboard.rb
CHANGED
@@ -40,7 +40,7 @@ class KeyboardExample < Hokusai::Block
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
Hokusai::Backends::
|
43
|
+
Hokusai::Backends::RaylibBackend.run(KeyboardExample) do |config|
|
44
44
|
config.width = 370
|
45
45
|
config.height = 680
|
46
46
|
config.title = "keyboard example"
|
@@ -5,7 +5,7 @@ module Hokusai::Backends
|
|
5
5
|
attr_accessor :width, :height, :fps,
|
6
6
|
:title, :config_flags, :window_state_flags,
|
7
7
|
:automation_driver, :background, :after_load_cb,
|
8
|
-
:host, :port, :automated, :on_reload, :event_waiting
|
8
|
+
:host, :port, :automated, :on_reload, :event_waiting, :touch
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@width = 500
|
@@ -22,6 +22,7 @@ module Hokusai::Backends
|
|
22
22
|
@automated = false
|
23
23
|
@on_reload = ->(_){}
|
24
24
|
@event_waiting = false
|
25
|
+
@touch = false
|
25
26
|
end
|
26
27
|
|
27
28
|
def start_automation_driver
|
@@ -113,22 +113,53 @@ module Hokusai::Backends
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def process_input(input)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
if !config.touch
|
117
|
+
raylib_mouse_pos = Raylib.GetMousePosition
|
118
|
+
raylib_mouse_delta = Raylib.GetMouseDelta
|
119
|
+
LibHokusai.hoku_input_mouse_set_scroll(input.raw, Raylib.GetMouseWheelMove)
|
120
|
+
LibHokusai.hoku_input_set_mouse_position(input.raw, hml_vec2(raylib_mouse_pos.x, raylib_mouse_pos.y))
|
121
|
+
|
122
|
+
input.raw[:mouse][:delta][:x] = raylib_mouse_delta.x
|
123
|
+
input.raw[:mouse][:delta][:y] = raylib_mouse_delta.y
|
124
|
+
end
|
125
|
+
|
126
|
+
if config.touch
|
127
|
+
count = Raylib.GetTouchPointCount
|
128
|
+
if count > 0
|
129
|
+
vec = Raylib.GetTouchPosition(0)
|
130
|
+
unless vec.x.zero? && vec.y.zero?
|
131
|
+
input.touch.record(0, vec.x, vec.y)
|
132
|
+
end
|
133
|
+
else
|
134
|
+
input.touch.clear
|
135
|
+
end
|
136
|
+
else
|
137
|
+
[0,1,2].each do |button_id|
|
138
|
+
clicked = Raylib.IsMouseButtonPressed(button_id)
|
139
|
+
down = Raylib.IsMouseButtonDown(button_id)
|
140
|
+
released = Raylib.IsMouseButtonReleased(button_id)
|
141
|
+
up = Raylib.IsMouseButtonUp(button_id)
|
142
|
+
|
143
|
+
button = mouse_button(clicked: clicked, down: down, released: released, up: up)
|
144
|
+
LibHokusai.hoku_input_mouse_set_button(input.raw, button, button_id)
|
145
|
+
end
|
146
|
+
end
|
120
147
|
|
121
|
-
|
122
|
-
|
148
|
+
if config.touch
|
149
|
+
if input.touch.touching?
|
150
|
+
token = input.touch.token
|
123
151
|
|
124
|
-
|
125
|
-
|
126
|
-
down = Raylib.IsMouseButtonDown(button_id)
|
127
|
-
released = Raylib.IsMouseButtonReleased(button_id)
|
128
|
-
up = Raylib.IsMouseButtonUp(button_id)
|
152
|
+
LibHokusai.hoku_input_set_mouse_position(input.raw, hml_vec2(token[:x], token[:y]))
|
153
|
+
end
|
129
154
|
|
130
|
-
|
131
|
-
|
155
|
+
# translate taps to clicks
|
156
|
+
if input.touch.tapped?
|
157
|
+
button = mouse_button(clicked: true, down: true, released: false, up: false)
|
158
|
+
LibHokusai.hoku_input_mouse_set_button(input.raw, button, 0)
|
159
|
+
else
|
160
|
+
button = mouse_button(clicked: false, down: false, released: true, up: true)
|
161
|
+
LibHokusai.hoku_input_mouse_set_button(input.raw, button, 0)
|
162
|
+
end
|
132
163
|
end
|
133
164
|
|
134
165
|
if !input.keyboard_override
|
@@ -155,7 +186,6 @@ module Hokusai::Backends
|
|
155
186
|
self.class.reset
|
156
187
|
|
157
188
|
Raylib.load_lib(RAYLIB_PATH)
|
158
|
-
|
159
189
|
resize = false
|
160
190
|
initial = true
|
161
191
|
width = config.width
|
@@ -168,6 +198,7 @@ module Hokusai::Backends
|
|
168
198
|
raw = LibHokusai::HmlInput.new(ptr.get_pointer(0))
|
169
199
|
input = Hokusai::Input.new(raw)
|
170
200
|
ptr.free
|
201
|
+
input.support_touch! if config.touch
|
171
202
|
|
172
203
|
Raylib.SetConfigFlags(config.config_flags)
|
173
204
|
Raylib.InitWindow(config.width, config.height, config.title)
|
@@ -221,7 +252,7 @@ module Hokusai::Backends
|
|
221
252
|
block.update
|
222
253
|
block.public_send(:after_updated) if block.respond_to?(:after_updated)
|
223
254
|
|
224
|
-
canvas.reset(
|
255
|
+
canvas.reset(0.0, 0.0, width.to_f, height.to_f)
|
225
256
|
|
226
257
|
Raylib.BeginDrawing
|
227
258
|
Raylib.ClearBackground(config.background)
|
@@ -245,6 +276,7 @@ module Hokusai::Backends
|
|
245
276
|
Raylib.DrawFPS(10, 10) if ENV["PROFILE"] || ENV["FPS"]
|
246
277
|
Raylib.EndDrawing
|
247
278
|
|
279
|
+
GC.start
|
248
280
|
|
249
281
|
break if self.class.stopped?
|
250
282
|
end
|
@@ -162,7 +162,7 @@ module Hokusai::Backends
|
|
162
162
|
SDL.SetRenderDrawBlendMode(renderer, SDL::BLENDMODE_BLEND)
|
163
163
|
SDL.SetRenderDrawColor(renderer, config.background[:r], config.background[:g], config.background[:b], config.background[:a])
|
164
164
|
SDL.RenderClear(renderer)
|
165
|
-
canvas.reset(
|
165
|
+
canvas.reset(0.0, 0.0, render_width.to_f, render_height.to_f)
|
166
166
|
painter = Hokusai::Painter.new(block, input)
|
167
167
|
painter.render(canvas, resize)
|
168
168
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Hokusai::Blocks
|
2
4
|
class Key < Hokusai::Block
|
3
5
|
template <<~EOF
|
@@ -12,17 +14,21 @@ module Hokusai::Blocks
|
|
12
14
|
uses(empty: Hokusai::Blocks::Empty)
|
13
15
|
|
14
16
|
computed! :value
|
15
|
-
computed! :icons
|
16
17
|
computed :size, default: 24, convert: proc(&:to_i)
|
17
18
|
computed :background, default: Hokusai::Color.new(70, 70, 70), convert: Hokusai::Color
|
18
19
|
computed :color, default: Hokusai::Color.new(244, 244, 244), convert: Hokusai::Color
|
19
20
|
computed :background_down, default: Hokusai::Color.new(33,33,33), convert: Hokusai::Color
|
20
21
|
computed :margin, default: Hokusai::Padding.new(3.0, 2.5, 3.0, 2.5), convert: Hokusai::Padding
|
21
22
|
|
22
|
-
|
23
|
+
inject :keyboard_icons
|
24
|
+
|
25
|
+
attr_accessor :down, :last_commands, :last_canvas, :last_value
|
23
26
|
|
24
27
|
def initialize(**args)
|
25
28
|
@down = false
|
29
|
+
@last_commands = []
|
30
|
+
@last_canvas = nil
|
31
|
+
@last_value = nil
|
26
32
|
|
27
33
|
super
|
28
34
|
end
|
@@ -47,25 +53,44 @@ module Hokusai::Blocks
|
|
47
53
|
vpad = (canvas.height - margin.height - size) / 2
|
48
54
|
|
49
55
|
draw do
|
50
|
-
if
|
51
|
-
|
52
|
-
|
53
|
-
command.round = 6.0
|
54
|
-
end
|
56
|
+
if last_canvas != canvas && last_value != value
|
57
|
+
self.last_value = value
|
58
|
+
self.last_canvas = canvas
|
55
59
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
if icon = keyboard_icons[value[0]]
|
61
|
+
if icon[:width]
|
62
|
+
node.meta.set_prop(:width, icon[:width])
|
63
|
+
end
|
64
|
+
|
65
|
+
rect(canvas.x + margin.left, canvas.y + margin.top, canvas.width - margin.width, canvas.height - margin.height) do |command|
|
66
|
+
command.color = icon[:background]# down ? background_down : background
|
67
|
+
command.round = 0.2
|
68
|
+
|
69
|
+
last_commands << command
|
70
|
+
end
|
71
|
+
|
72
|
+
svg(icon[:file], canvas.x + icon[:size] / 3, canvas.y + icon[:size] / 3, icon[:size], icon[:size]) do |command|
|
73
|
+
command.color = icon[:color]
|
74
|
+
|
75
|
+
last_commands << command
|
76
|
+
end
|
77
|
+
else
|
78
|
+
rect(canvas.x + margin.left, canvas.y + margin.top, canvas.width - margin.width, canvas.height - margin.height) do |command|
|
79
|
+
command.color = down ? background_down : background
|
80
|
+
command.round = 0.2
|
64
81
|
|
65
|
-
|
66
|
-
|
67
|
-
|
82
|
+
last_commands << command
|
83
|
+
end
|
84
|
+
|
85
|
+
text(value[1].to_s, canvas.x + hpad + margin.width, canvas.y + margin.height) do |command|
|
86
|
+
command.color = color
|
87
|
+
command.size = size
|
88
|
+
|
89
|
+
last_commands << command
|
90
|
+
end
|
68
91
|
end
|
92
|
+
else
|
93
|
+
queue.concat(last_commands)
|
69
94
|
end
|
70
95
|
end
|
71
96
|
|
@@ -92,9 +117,7 @@ module Hokusai::Blocks
|
|
92
117
|
[for="number in keys"]
|
93
118
|
key {
|
94
119
|
...keyStyle
|
95
|
-
:
|
96
|
-
:icons="icons"
|
97
|
-
:key="loop_key(number)"
|
120
|
+
:key="index"
|
98
121
|
:value="number"
|
99
122
|
@clicked="emit_key"
|
100
123
|
@released="emit_released"
|
@@ -108,20 +131,12 @@ module Hokusai::Blocks
|
|
108
131
|
)
|
109
132
|
|
110
133
|
computed! :keys
|
111
|
-
computed! :icons
|
112
134
|
|
113
|
-
|
114
|
-
# node.meta.set_prop(:height, 48.0)
|
115
|
-
# end
|
116
|
-
|
117
|
-
def width(key)
|
118
|
-
if icon = icons[key[0]]
|
119
|
-
icon[:width]
|
120
|
-
end
|
121
|
-
end
|
135
|
+
inject :keyboard_icons
|
122
136
|
|
123
137
|
def loop_key(value)
|
124
|
-
|
138
|
+
@keys ||= {}
|
139
|
+
@keys[value] ||= "key-#{value}".freeze
|
125
140
|
end
|
126
141
|
|
127
142
|
def emit_key(key, event)
|
@@ -160,8 +175,7 @@ module Hokusai::Blocks
|
|
160
175
|
row: KeyboardRow
|
161
176
|
)
|
162
177
|
|
163
|
-
|
164
|
-
def self.icons
|
178
|
+
def icons
|
165
179
|
{
|
166
180
|
:shift => {
|
167
181
|
file: Hokusai.asset("icons/outline/arrow-big-up.svg"),
|
@@ -180,9 +194,10 @@ module Hokusai::Blocks
|
|
180
194
|
}
|
181
195
|
end
|
182
196
|
|
183
|
-
computed :icons, default: icons
|
184
197
|
computed :row_height, default: 48.0, convert: proc(&:to_f)
|
185
198
|
|
199
|
+
provide :keyboard_icons, :icons
|
200
|
+
|
186
201
|
def on_mounted
|
187
202
|
node.meta.set_prop(:height, row_height * 5.0 + 20)
|
188
203
|
end
|
@@ -210,8 +225,8 @@ module Hokusai::Blocks
|
|
210
225
|
@zxcv_keys ||= begin
|
211
226
|
keys = %w[z x c v b n m]
|
212
227
|
middle = keys.zip(keys)
|
213
|
-
middle << [:backspace, :backspace]
|
214
|
-
middle.unshift([:shift, :shift])
|
228
|
+
# middle << [:backspace, :backspace]
|
229
|
+
# middle.unshift([:shift, :shift])
|
215
230
|
middle
|
216
231
|
end
|
217
232
|
end
|
@@ -65,7 +65,7 @@ module Hokusai
|
|
65
65
|
|
66
66
|
portal = Node.new(ast)
|
67
67
|
node = child_block_class.compile(ast.type, portal)
|
68
|
-
child_block = child_block_class.new(node: node)
|
68
|
+
child_block = child_block_class.new(node: node, providers: mount_providers)
|
69
69
|
child_block.node.add_styles(target.class)
|
70
70
|
child_block.node.add_props_from_block(target, context: ctx)
|
71
71
|
child_block.node.meta.set_prop(ast.loop.var.to_sym, value)
|
data/ui/src/hokusai/painter.rb
CHANGED
@@ -110,7 +110,6 @@ module Hokusai
|
|
110
110
|
while group = group_children.shift
|
111
111
|
z = group.block.node.meta.get_prop(:z)&.to_i || 0
|
112
112
|
ztarget = group.block.node.meta.get_prop(:ztarget)
|
113
|
-
entry = PainterEntry.new(group.block, group.x, group.y, group.w, group.h)
|
114
113
|
|
115
114
|
if (zindex_counter > 0 || z > 0)
|
116
115
|
case ztarget
|
@@ -118,9 +117,14 @@ module Hokusai
|
|
118
117
|
entry = PainterEntry.new(group.block, zroot_x || 0.0, zroot_y || 0.0, zroot_w, zroot_h).freeze
|
119
118
|
when ZTARGET_PARENT
|
120
119
|
entry = PainterEntry.new(group.block, group_parent.x || 0.0, group_parent.y || 0.0, group_parent.w, group_parent.h).freeze
|
120
|
+
else
|
121
|
+
entry = PainterEntry.new(group.block, group.x, group.y, group.w, group.h).freeze
|
121
122
|
end
|
123
|
+
else
|
124
|
+
entry = PainterEntry.new(group.block, group.x, group.y, group.w, group.h).freeze
|
122
125
|
end
|
123
126
|
|
127
|
+
|
124
128
|
canvas.reset(entry.x, entry.y, entry.w, entry.h)
|
125
129
|
|
126
130
|
before_render&.call([group.block, group.parent], canvas, input.raw)
|
data/ui/src/hokusai/types.rb
CHANGED
@@ -137,6 +137,7 @@ module Hokusai
|
|
137
137
|
@y = y
|
138
138
|
@vertical = vertical
|
139
139
|
@reverse = reverse
|
140
|
+
@hoku_rect = LibHokusai::HmlRect.create(x, y, width, height)
|
140
141
|
end
|
141
142
|
|
142
143
|
def reset(x, y, width, height, vertical: true, reverse: false)
|
@@ -146,6 +147,10 @@ module Hokusai
|
|
146
147
|
self.height = height
|
147
148
|
self.vertical = vertical
|
148
149
|
self.reverse = reverse
|
150
|
+
@hoku_rect[:x] = x
|
151
|
+
@hoku_rect[:y] = y
|
152
|
+
@hoku_rect[:w] = width
|
153
|
+
@hoku_rect[:h] = height
|
149
154
|
end
|
150
155
|
|
151
156
|
def to_bounds
|
@@ -157,7 +162,7 @@ module Hokusai
|
|
157
162
|
end
|
158
163
|
|
159
164
|
def to_hoku_rect
|
160
|
-
|
165
|
+
@hoku_rect
|
161
166
|
end
|
162
167
|
end
|
163
168
|
|
@@ -358,12 +363,14 @@ module Hokusai
|
|
358
363
|
end
|
359
364
|
|
360
365
|
def clear
|
361
|
-
log("clearing")
|
366
|
+
# log("clearing")
|
362
367
|
if type == :move
|
363
368
|
log("elapsed: #{elapsed(token)}")
|
364
|
-
if elapsed(token) >
|
369
|
+
if elapsed(token) > 300 && within(10.0)
|
365
370
|
@longtapped = true
|
366
371
|
log('longtap')
|
372
|
+
elsif within(10.0)
|
373
|
+
@tapped = true
|
367
374
|
else
|
368
375
|
@swiped = true
|
369
376
|
log('swipe')
|