hokusai-zero 0.2.6.pre.pinephone → 0.2.6.pre.pinephone3
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/ast/src/core/input.c +0 -85
- data/ast/src/core/input.h +0 -32
- data/hokusai.gemspec +1 -1
- data/ui/examples/embedded.rb +0 -1
- data/ui/examples/forum/file.rb +1 -1
- data/ui/examples/forum/post.rb +0 -1
- data/ui/examples/forum.rb +7 -7
- data/ui/examples/keyboard.rb +47 -0
- data/ui/examples/shader/test.rb +28 -18
- data/ui/examples/spreadsheet.rb +12 -11
- data/ui/lib/lib_hokusai.rb +19 -39
- data/ui/spec/hokusai/e2e/keyboard_spec.rb +52 -0
- data/ui/src/hokusai/assets/icons/outline/arrow-big-up.svg +19 -0
- data/ui/src/hokusai/assets/icons/outline/backspace.svg +20 -0
- data/ui/src/hokusai/backends/raylib.rb +7 -5
- data/ui/src/hokusai/backends/sdl2/config.rb +9 -6
- data/ui/src/hokusai/backends/sdl2/font.rb +3 -1
- data/ui/src/hokusai/backends/sdl2.rb +164 -65
- data/ui/src/hokusai/blocks/input.rb +1 -1
- data/ui/src/hokusai/blocks/keyboard.rb +234 -0
- data/ui/src/hokusai/blocks/slider.rb +139 -0
- data/ui/src/hokusai/commands/rect.rb +2 -2
- data/ui/src/hokusai/event.rb +1 -1
- data/ui/src/hokusai/events/{embedded.rb → touch.rb} +12 -18
- data/ui/src/hokusai/painter.rb +5 -5
- data/ui/src/hokusai/types.rb +180 -17
- data/ui/src/hokusai/util/wrap_stream.rb +197 -0
- data/ui/src/hokusai.rb +61 -30
- data/xmake.lua +1 -1
- metadata +9 -6
- data/ui/src/hokusai/backends/embedded/config.rb +0 -47
- data/ui/src/hokusai/backends/embedded/font.rb +0 -112
- data/ui/src/hokusai/backends/embedded/keys.rb +0 -124
- data/ui/src/hokusai/backends/embedded.rb +0 -564
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2b53ce8769964539f51ad894c33476cecb01095b7b5ce851355cbf7df17a707
|
4
|
+
data.tar.gz: 430de1cd6a0ffae61fdf9ca547b15aa61e0065769f94472962047c0205df83ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d571179fb72b52671eafceed834e76c7154e205faaff5bb67a95d7d1eb801c86d34f6e5525ade0247db57e48c3019098744dbef7d704630fc4ea7b7577854ab4
|
7
|
+
data.tar.gz: '082837551a6b0ff70eda1779c4bde8232efe3108dad48359a05f597023895250faa07812878367229da734075bb0fb1c5c2ab180820b06e4040f7569fdb87306'
|
data/ast/src/core/input.c
CHANGED
@@ -4,84 +4,6 @@
|
|
4
4
|
#include "input.h"
|
5
5
|
#include <stdio.h>
|
6
6
|
|
7
|
-
int hoku_input_embedded_init(hoku_input_embedded** embedded)
|
8
|
-
{
|
9
|
-
hoku_input_embedded* out = malloc(sizeof(hoku_input_embedded));
|
10
|
-
if (!out) return -1;
|
11
|
-
|
12
|
-
out->drag_pos = malloc(sizeof(hoku_vec2));
|
13
|
-
if (out->drag_pos == NULL)
|
14
|
-
{
|
15
|
-
free(out);
|
16
|
-
return -1;
|
17
|
-
}
|
18
|
-
|
19
|
-
out->pinch_pos = malloc(sizeof(hoku_vec2));
|
20
|
-
if (out->pinch_pos == NULL)
|
21
|
-
{
|
22
|
-
free(out->drag_pos);
|
23
|
-
free(out);
|
24
|
-
return -1;
|
25
|
-
}
|
26
|
-
|
27
|
-
out->drag_pos->x = 0.0;
|
28
|
-
out->drag_pos->y = 0.0;
|
29
|
-
out->pinch_pos->x = 0.0;
|
30
|
-
out->pinch_pos->y = 0.0;
|
31
|
-
out->hold = false;
|
32
|
-
out->drag = false;
|
33
|
-
out->pinch = false;
|
34
|
-
out->drag_direction = HOKU_DRAG_UP;
|
35
|
-
out->pinch_direction = HOKU_PINCH_IN;
|
36
|
-
out->hold_duration = 0;
|
37
|
-
out->drag_angle = 0.0;
|
38
|
-
out->pinch_angle = 0.0;
|
39
|
-
|
40
|
-
*embedded = out;
|
41
|
-
return 0;
|
42
|
-
}
|
43
|
-
|
44
|
-
void hoku_input_embedded_set_hold(hoku_input* input, bool hold, int hold_duration)
|
45
|
-
{
|
46
|
-
input->embedded->hold = hold;
|
47
|
-
input->embedded->hold_duration = hold_duration;
|
48
|
-
}
|
49
|
-
|
50
|
-
void hoku_input_embedded_set_drag(hoku_input* input, bool drag, hoku_drag_direction drag_direction, float drag_x, float drag_y, float drag_angle)
|
51
|
-
{
|
52
|
-
input->embedded->drag = drag;
|
53
|
-
input->embedded->drag_direction = drag_direction;
|
54
|
-
input->embedded->drag_pos->x = drag_x;
|
55
|
-
input->embedded->drag_pos->y = drag_y;
|
56
|
-
input->embedded->drag_angle = drag_angle;
|
57
|
-
}
|
58
|
-
|
59
|
-
void hoku_input_embedded_set_pinch(hoku_input* input, bool pinch, hoku_pinch_direction pinch_direction, float pinch_x, float pinch_y, float pinch_angle)
|
60
|
-
{
|
61
|
-
input->embedded->pinch = pinch;
|
62
|
-
input->embedded->pinch_direction = pinch_direction;
|
63
|
-
input->embedded->pinch_pos->x = pinch_x;
|
64
|
-
input->embedded->pinch_pos->y = pinch_y;
|
65
|
-
input->embedded->pinch_angle = pinch_angle;
|
66
|
-
}
|
67
|
-
|
68
|
-
int hoku_input_attach_embedded(hoku_input* input)
|
69
|
-
{
|
70
|
-
hoku_input_embedded* embedded;
|
71
|
-
if (hoku_input_embedded_init(&embedded) == -1) return -1;
|
72
|
-
input->embedded = embedded;
|
73
|
-
|
74
|
-
return 0;
|
75
|
-
}
|
76
|
-
|
77
|
-
void hoku_input_embedded_free(hoku_input_embedded* embedded)
|
78
|
-
{
|
79
|
-
free(embedded->drag_pos);
|
80
|
-
free(embedded->pinch_pos);
|
81
|
-
free(embedded);
|
82
|
-
}
|
83
|
-
|
84
|
-
|
85
7
|
static int hoku_keycodes[HOKU_KEY_MAX] = {
|
86
8
|
0,39,44,45,46,47,48,49,50,51,52,53,54,55,56,57,59,61,65,66,67,68,69,
|
87
9
|
70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,
|
@@ -351,12 +273,6 @@ void hoku_input_free(hoku_input* input)
|
|
351
273
|
{
|
352
274
|
hoku_input_keyboard_free(input->keyboard);
|
353
275
|
hoku_input_mouse_free(input->mouse);
|
354
|
-
|
355
|
-
if (input->embedded)
|
356
|
-
{
|
357
|
-
hoku_input_embedded_free(input->embedded);
|
358
|
-
}
|
359
|
-
|
360
276
|
free(input);
|
361
277
|
}
|
362
278
|
|
@@ -382,7 +298,6 @@ int hoku_input_init(hoku_input** input)
|
|
382
298
|
return -1;
|
383
299
|
}
|
384
300
|
init->keyboard = keyboard;
|
385
|
-
init->embedded = NULL;
|
386
301
|
|
387
302
|
*input = init;
|
388
303
|
return 0;
|
data/ast/src/core/input.h
CHANGED
@@ -87,44 +87,12 @@ typedef struct HmlInputKeyboard
|
|
87
87
|
bool collecting;
|
88
88
|
} hoku_input_keyboard;
|
89
89
|
|
90
|
-
typedef enum HmlDragDirection {
|
91
|
-
HOKU_DRAG_UP,
|
92
|
-
HOKU_DRAG_DOWN,
|
93
|
-
HOKU_DRAG_LEFT,
|
94
|
-
HOKU_DRAG_RIGHT
|
95
|
-
} hoku_drag_direction;
|
96
|
-
|
97
|
-
typedef enum HmlPinchDirection {
|
98
|
-
HOKU_PINCH_IN,
|
99
|
-
HOKU_PINCH_OUT
|
100
|
-
} hoku_pinch_direction;
|
101
|
-
|
102
|
-
typedef struct HmlInputEmbedded
|
103
|
-
{
|
104
|
-
bool hold;
|
105
|
-
int hold_duration;
|
106
|
-
bool drag;
|
107
|
-
hoku_drag_direction drag_direction;
|
108
|
-
hoku_vec2* drag_pos;
|
109
|
-
float drag_angle;
|
110
|
-
bool pinch;
|
111
|
-
hoku_pinch_direction pinch_direction;
|
112
|
-
hoku_vec2* pinch_pos;
|
113
|
-
float pinch_angle;
|
114
|
-
} hoku_input_embedded;
|
115
|
-
|
116
90
|
typedef struct HmlInput
|
117
91
|
{
|
118
92
|
hoku_input_keyboard* keyboard;
|
119
93
|
hoku_input_mouse* mouse;
|
120
|
-
hoku_input_embedded* embedded;
|
121
94
|
} hoku_input;
|
122
95
|
|
123
|
-
void hoku_input_embedded_set_hold(hoku_input* input, bool hold, int hold_duration);
|
124
|
-
void hoku_input_embedded_set_drag(hoku_input* input, bool drag, hoku_drag_direction drag_direction, float drag_x, float drag_y, float drag_angle);
|
125
|
-
void hoku_input_embedded_set_pinch(hoku_input* input, bool pinch, hoku_pinch_direction pinch_direction, float pinch_x, float pinch_y, float pinch_angle);
|
126
|
-
int hoku_input_attach_embedded(hoku_input* input);
|
127
|
-
|
128
96
|
int hoku_input_keyboard_init(hoku_input_keyboard** keyboard);
|
129
97
|
int hoku_input_mouse_init(hoku_input_mouse** mouse);
|
130
98
|
int hoku_input_init(hoku_input** input);
|
data/hokusai.gemspec
CHANGED
data/ui/examples/embedded.rb
CHANGED
data/ui/examples/forum/file.rb
CHANGED
data/ui/examples/forum/post.rb
CHANGED
data/ui/examples/forum.rb
CHANGED
@@ -175,13 +175,13 @@ module Demos
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
Hokusai::Backends::
|
178
|
+
Hokusai::Backends::SDLBackend.run(Demos::Forum::App) do |config|
|
179
179
|
config.after_load do
|
180
|
-
font = Hokusai::Backends::
|
180
|
+
font = Hokusai::Backends::SDLBackend::Font.from("#{__dir__}/assets/Inter-Regular.ttf")
|
181
181
|
Hokusai.fonts.register "inter", font
|
182
182
|
Hokusai.fonts.activate "inter"
|
183
183
|
|
184
|
-
font = Hokusai::Backends::
|
184
|
+
font = Hokusai::Backends::SDLBackend::Font.from("#{__dir__}/assets/Delius-Regular.ttf")
|
185
185
|
Hokusai.fonts.register "dohyeon", font
|
186
186
|
end
|
187
187
|
|
@@ -190,10 +190,10 @@ Hokusai::Backends::RaylibBackend.run(Demos::Forum::App) do |config|
|
|
190
190
|
config.height = 500
|
191
191
|
config.title = "Counter application"
|
192
192
|
|
193
|
-
|
193
|
+
config.window_config_flags = SDL::WINDOW_RESIZABLE #| SDL::WINDOW_BORDERLESS
|
194
194
|
|
195
|
-
config.config_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_VSYNC_HINT | Raylib::FLAG_WINDOW_TRANSPARENT
|
196
|
-
config.window_state_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_WINDOW_UNDECORATED | Raylib::FLAG_WINDOW_TRANSPARENT
|
197
|
-
config.background = Raylib::BLANK
|
195
|
+
# config.config_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_VSYNC_HINT | Raylib::FLAG_WINDOW_TRANSPARENT
|
196
|
+
# config.window_state_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_WINDOW_UNDECORATED | Raylib::FLAG_WINDOW_TRANSPARENT
|
197
|
+
# config.background = Raylib::BLANK
|
198
198
|
end
|
199
199
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative "../src/hokusai"
|
2
|
+
require_relative "../src/hokusai/backends/sdl2"
|
3
|
+
require_relative "../src/hokusai/backends/raylib"
|
4
|
+
|
5
|
+
class KeyboardExample < Hokusai::Block
|
6
|
+
style <<~EOF
|
7
|
+
[style]
|
8
|
+
example {
|
9
|
+
background: rgb(225,255,255);
|
10
|
+
reverse: true
|
11
|
+
}
|
12
|
+
input {
|
13
|
+
size: 20;
|
14
|
+
color: rgb(0, 0, 0);
|
15
|
+
}
|
16
|
+
EOF
|
17
|
+
|
18
|
+
template <<~EOF
|
19
|
+
[template]
|
20
|
+
vblock { ...example }
|
21
|
+
keyboard
|
22
|
+
vblock
|
23
|
+
input {
|
24
|
+
...input
|
25
|
+
}
|
26
|
+
EOF
|
27
|
+
|
28
|
+
uses(
|
29
|
+
input: Hokusai::Blocks::Input,
|
30
|
+
vblock: Hokusai::Blocks::Vblock,
|
31
|
+
text: Hokusai::Blocks::Text,
|
32
|
+
keyboard: Hokusai::Blocks::Keyboard
|
33
|
+
)
|
34
|
+
|
35
|
+
attr_accessor :content
|
36
|
+
|
37
|
+
def initialize(**args)
|
38
|
+
super
|
39
|
+
@content = ""
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Hokusai::Backends::SDLBackend.run(KeyboardExample) do |config|
|
44
|
+
config.width = 370
|
45
|
+
config.height = 680
|
46
|
+
config.title = "keyboard example"
|
47
|
+
end
|
data/ui/examples/shader/test.rb
CHANGED
@@ -97,24 +97,28 @@ class ShaderTest < Hokusai::Block
|
|
97
97
|
|
98
98
|
template <<~EOF
|
99
99
|
[template]
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
100
|
+
vblock
|
101
|
+
[if="pickered"]
|
102
|
+
picker
|
103
|
+
[else]
|
104
|
+
vblock
|
105
|
+
hblock { @click="set_pickered" }
|
106
|
+
empty
|
107
|
+
hblock
|
108
|
+
hblock
|
109
|
+
empty
|
110
|
+
hblock
|
111
|
+
wrapper
|
112
|
+
image { :source="addy_png" :width="500" :height="400" }
|
113
|
+
text { ...textStyle }
|
114
|
+
circle {
|
115
|
+
:radius="50.0"
|
116
|
+
...circleStyle
|
117
|
+
}
|
118
|
+
hblock
|
119
|
+
empty
|
120
|
+
hblock
|
121
|
+
empty
|
118
122
|
EOF
|
119
123
|
|
120
124
|
uses(
|
@@ -128,6 +132,12 @@ class ShaderTest < Hokusai::Block
|
|
128
132
|
empty: Hokusai::Blocks::Empty
|
129
133
|
)
|
130
134
|
|
135
|
+
attr_accessor :pickered
|
136
|
+
|
137
|
+
def set_pickered(event)
|
138
|
+
self.pickered = true
|
139
|
+
end
|
140
|
+
|
131
141
|
def addy_png
|
132
142
|
"#{__dir__}/../assets/addy.png"
|
133
143
|
end
|
data/ui/examples/spreadsheet.rb
CHANGED
@@ -119,22 +119,23 @@ module Demos
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
Hokusai::Backends::
|
123
|
-
config.after_load do
|
124
|
-
|
125
|
-
|
126
|
-
|
122
|
+
Hokusai::Backends::SDLBackend.run(Demos::Spreadsheet::App) do |config|
|
123
|
+
# config.after_load do
|
124
|
+
# font = Hokusai::Backends::RaylibBackend::Font.from("#{__dir__}/assets/Inter-Regular.ttf")
|
125
|
+
# Hokusai.fonts.register "inter", font
|
126
|
+
# Hokusai.fonts.activate "inter"
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
end
|
128
|
+
# font = Hokusai::Backends::RaylibBackend::Font.from_ext("#{__dir__}/assets/Delius-Regular.ttf", 160)
|
129
|
+
# Hokusai.fonts.register "dohyeon", font
|
130
|
+
# end
|
131
131
|
|
132
132
|
config.fps = 60
|
133
133
|
config.width = 800
|
134
134
|
config.height = 500
|
135
135
|
config.title = "Spreadsheet application"
|
136
136
|
|
137
|
-
|
138
|
-
config.
|
139
|
-
config.
|
137
|
+
|
138
|
+
# config.config_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_VSYNC_HINT | Raylib::FLAG_WINDOW_TRANSPARENT
|
139
|
+
# config.window_state_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_WINDOW_UNDECORATED | Raylib::FLAG_WINDOW_TRANSPARENT
|
140
|
+
# config.background = Raylib::BLANK
|
140
141
|
end
|
data/ui/lib/lib_hokusai.rb
CHANGED
@@ -122,23 +122,7 @@ module LibHokusai
|
|
122
122
|
:next_child, HmlAst.ptr
|
123
123
|
end
|
124
124
|
|
125
|
-
|
126
|
-
# fun hashmap_iter(map : Hashmap, i : LibC::SizeT*, item : Void**) : Bool
|
127
|
-
# ast methods
|
128
|
-
attach_function :hoku_ast_prop_init, [:pointer, :string], :int
|
129
|
-
attach_function :hoku_ast_class_list_includes, [:pointer, :string], :int
|
130
|
-
attach_function :hoku_ast_get_prop, [HmlAst.by_ref, HmlAstProp.by_ref], HmlAstProp.by_ref
|
131
|
-
attach_function :hoku_ast_get_event, [:pointer, :pointer], HmlAstEvent.by_ref
|
132
|
-
attach_function :hashmap_iter, [:hashmap, :pointer, :pointer], :bool
|
133
|
-
attach_function :hashmap_count, [:hashmap], :int
|
134
|
-
attach_function :hoku_ast_free, [:pointer], :void
|
135
|
-
attach_function :hoku_errored_ast, [HmlAst.by_ref], HmlAst.by_ref
|
136
|
-
attach_function :hoku_ast_from_template, [:pointer, :string, :string], :int
|
137
|
-
attach_function :hoku_style_from_template, [:pointer, :string], :int
|
138
|
-
attach_function :hoku_style_free, [:pointer], :void
|
139
|
-
attach_function :hoku_dump, [:pointer, :int], :void
|
140
|
-
|
141
|
-
enum :hml_input_key, [
|
125
|
+
HOKUSAI_KEYS = [
|
142
126
|
:null, :apostrophe, :comma, :minus,
|
143
127
|
:period, :slash, :zero, :one, :two,
|
144
128
|
:three, :four, :five, :six, :seven,
|
@@ -162,6 +146,23 @@ module LibHokusai
|
|
162
146
|
:max
|
163
147
|
]
|
164
148
|
|
149
|
+
# fun hashmap_iter(map : Hashmap, i : LibC::SizeT*, item : Void**) : Bool
|
150
|
+
# ast methods
|
151
|
+
attach_function :hoku_ast_prop_init, [:pointer, :string], :int
|
152
|
+
attach_function :hoku_ast_class_list_includes, [:pointer, :string], :int
|
153
|
+
attach_function :hoku_ast_get_prop, [HmlAst.by_ref, HmlAstProp.by_ref], HmlAstProp.by_ref
|
154
|
+
attach_function :hoku_ast_get_event, [:pointer, :pointer], HmlAstEvent.by_ref
|
155
|
+
attach_function :hashmap_iter, [:hashmap, :pointer, :pointer], :bool
|
156
|
+
attach_function :hashmap_count, [:hashmap], :int
|
157
|
+
attach_function :hoku_ast_free, [:pointer], :void
|
158
|
+
attach_function :hoku_errored_ast, [HmlAst.by_ref], HmlAst.by_ref
|
159
|
+
attach_function :hoku_ast_from_template, [:pointer, :string, :string], :int
|
160
|
+
attach_function :hoku_style_from_template, [:pointer, :string], :int
|
161
|
+
attach_function :hoku_style_free, [:pointer], :void
|
162
|
+
attach_function :hoku_dump, [:pointer, :int], :void
|
163
|
+
|
164
|
+
enum :hml_input_key, HOKUSAI_KEYS
|
165
|
+
|
165
166
|
enum :hml_input_select_type, [
|
166
167
|
:ACTIVE, 0x01,
|
167
168
|
:FROZEN, 0x02,
|
@@ -245,22 +246,6 @@ module LibHokusai
|
|
245
246
|
:collecting, :bool
|
246
247
|
end
|
247
248
|
|
248
|
-
enum :hml_drag_direction, [:up, :down, :left, :right]
|
249
|
-
enum :hml_pinch_direction, [:in, :out]
|
250
|
-
|
251
|
-
class HmlInputEmbedded < FFI::Struct
|
252
|
-
layout :hold, :bool,
|
253
|
-
:hold_duration, :int,
|
254
|
-
:drag, :bool,
|
255
|
-
:drag_direction, :hml_drag_direction,
|
256
|
-
:drag_pos, HmlVec2.ptr,
|
257
|
-
:drag_angle, :float,
|
258
|
-
:pinch, :bool,
|
259
|
-
:pinch_direction, :hml_pinch_direction,
|
260
|
-
:pinch_pos, HmlVec2.ptr,
|
261
|
-
:pinch_angle, :float
|
262
|
-
end
|
263
|
-
|
264
249
|
class HmlInputMouseButton < FFI::Struct
|
265
250
|
layout :down, :bool,
|
266
251
|
:up, :bool,
|
@@ -309,8 +294,7 @@ module LibHokusai
|
|
309
294
|
|
310
295
|
class HmlInput < FFI::Struct
|
311
296
|
layout :keyboard, HmlInputKeyboard.ptr,
|
312
|
-
:mouse, HmlInputMouse.ptr
|
313
|
-
:embedded, HmlInputEmbedded.ptr
|
297
|
+
:mouse, HmlInputMouse.ptr
|
314
298
|
end
|
315
299
|
|
316
300
|
def LibHokusai.const_missing( sym )
|
@@ -325,10 +309,6 @@ module LibHokusai
|
|
325
309
|
attach_function :hoku_input_set_mouse_position, [HmlInput.by_ref, HmlVec2.by_ref], :void
|
326
310
|
attach_function :hoku_input_mouse_set_scroll, [HmlInput.by_ref, :float], :void
|
327
311
|
attach_function :hoku_input_mouse_set_button, [HmlInput.by_ref, HmlInputMouseButton.by_ref, :int], :void
|
328
|
-
attach_function :hoku_input_embedded_set_hold, [HmlInput.by_ref, :bool, :int], :void
|
329
|
-
attach_function :hoku_input_embedded_set_drag, [HmlInput.by_ref, :bool, :hml_drag_direction, :float, :float, :float], :void
|
330
|
-
attach_function :hoku_input_embedded_set_pinch, [HmlInput.by_ref, :bool, :hml_pinch_direction, :float, :float, :float], :void
|
331
|
-
attach_function :hoku_input_attach_embedded, [HmlInput.by_ref], :int
|
332
312
|
|
333
313
|
attach_function :hoku_input_is_clicked, [HmlInput.by_ref, HmlRect.by_ref], :bool
|
334
314
|
attach_function :hoku_input_is_hovered, [HmlInput.by_ref, HmlRect.by_ref], :bool
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# describe Hokusai::Automation::Client do
|
2
|
+
# let(:keyboard) do
|
3
|
+
# klass = Class.new(Hokusai::Block) do
|
4
|
+
# template <<~EOF
|
5
|
+
# [template]
|
6
|
+
# vblock
|
7
|
+
# text#display {
|
8
|
+
# @keypress="update_content"
|
9
|
+
# :content="content" size="90"
|
10
|
+
# }
|
11
|
+
# keyboard{ :automatic="true" }
|
12
|
+
# EOF
|
13
|
+
|
14
|
+
# uses(
|
15
|
+
# text: Hokusai::Blocks::Text,
|
16
|
+
# keyboard: Hokusai::Blocks::Keyboard
|
17
|
+
# )
|
18
|
+
|
19
|
+
# attr_accessor :content
|
20
|
+
|
21
|
+
# def update_content(event)
|
22
|
+
# self.content << event.char
|
23
|
+
# end
|
24
|
+
|
25
|
+
# def initialize(**args)
|
26
|
+
# @content = ""
|
27
|
+
|
28
|
+
# super(**args)
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
|
32
|
+
# klass
|
33
|
+
# end
|
34
|
+
|
35
|
+
# def click_key(client, key)
|
36
|
+
# client.block("keyboard.#{key}").click
|
37
|
+
# end
|
38
|
+
|
39
|
+
# it "client works" do
|
40
|
+
# with_app(keyboard) do |client, app|
|
41
|
+
# display = client.block("#display")
|
42
|
+
|
43
|
+
# expect(display.prop("content")).to eq("")
|
44
|
+
|
45
|
+
# "hello world".split("").each do |key|
|
46
|
+
# click_key(client, key)
|
47
|
+
# end
|
48
|
+
|
49
|
+
# expect(display.prop("content")).to eq("hello world")
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
# end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!--
|
2
|
+
tags: [direction, north]
|
3
|
+
category: Arrows
|
4
|
+
version: "1.37"
|
5
|
+
unicode: "eddd"
|
6
|
+
-->
|
7
|
+
<svg
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
9
|
+
width="24"
|
10
|
+
height="24"
|
11
|
+
viewBox="0 0 24 24"
|
12
|
+
fill="none"
|
13
|
+
stroke="white"
|
14
|
+
stroke-width="2"
|
15
|
+
stroke-linecap="round"
|
16
|
+
stroke-linejoin="round"
|
17
|
+
>
|
18
|
+
<path d="M9 20v-8h-3.586a1 1 0 0 1 -.707 -1.707l6.586 -6.586a1 1 0 0 1 1.414 0l6.586 6.586a1 1 0 0 1 -.707 1.707h-3.586v8a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z" />
|
19
|
+
</svg>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!--
|
2
|
+
category: Text
|
3
|
+
tags: [delete, remove, eliminate]
|
4
|
+
version: "1.0"
|
5
|
+
unicode: "ea2d"
|
6
|
+
-->
|
7
|
+
<svg
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
9
|
+
width="24"
|
10
|
+
height="24"
|
11
|
+
viewBox="0 0 24 24"
|
12
|
+
fill="none"
|
13
|
+
stroke="white"
|
14
|
+
stroke-width="2"
|
15
|
+
stroke-linecap="round"
|
16
|
+
stroke-linejoin="round"
|
17
|
+
>
|
18
|
+
<path d="M20 6a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-11l-5 -5a1.5 1.5 0 0 1 0 -2l5 -5z" />
|
19
|
+
<path d="M12 10l4 4m0 -4l-4 4" />
|
20
|
+
</svg>
|
@@ -131,13 +131,15 @@ module Hokusai::Backends
|
|
131
131
|
LibHokusai.hoku_input_mouse_set_button(input.raw, button, button_id)
|
132
132
|
end
|
133
133
|
|
134
|
-
|
134
|
+
if !input.keyboard_override
|
135
|
+
LibHokusai.hoku_input_keyboard_start(input.raw)
|
135
136
|
|
136
|
-
|
137
|
-
|
138
|
-
|
137
|
+
Keys.each do |(hoku_key, raylib_key)|
|
138
|
+
LibHokusai.hoku_input_keyboard_set_key(input.raw, hoku_key, Raylib.IsKeyDown(raylib_key))
|
139
|
+
end
|
139
140
|
|
140
|
-
|
141
|
+
LibHokusai.hoku_input_keyboard_stop(input.raw)
|
142
|
+
end
|
141
143
|
end
|
142
144
|
|
143
145
|
def self.run(app)
|
@@ -3,8 +3,8 @@ module Hokusai::Backends
|
|
3
3
|
class Config
|
4
4
|
attr_accessor :width, :height, :fps, :init_flags,
|
5
5
|
:title, :background, :automation_driver,
|
6
|
-
:after_load_cb, :host, :port, :automated,
|
7
|
-
:window_config_flags
|
6
|
+
:after_load_cb, :host, :port, :automated, :mobile,
|
7
|
+
:window_config_flags, :touch
|
8
8
|
|
9
9
|
def after_load(&block)
|
10
10
|
self.after_load_cb = block
|
@@ -14,16 +14,19 @@ module Hokusai::Backends
|
|
14
14
|
@width = 500
|
15
15
|
@height = 500
|
16
16
|
@fps = 60
|
17
|
+
@touch = false
|
17
18
|
|
18
19
|
@init_flags = ::SDL::INIT_VIDEO | ::SDL::INIT_EVENTS
|
19
|
-
@window_config_flags = SDL::WINDOW_RESIZABLE
|
20
|
+
@window_config_flags = SDL::WINDOW_RESIZABLE | SDL::WINDOW_ALLOW_HIGHDPI
|
20
21
|
@title = "(Unknown Title)"
|
21
22
|
@background = SDLBackend.color(255,255,255, 0)
|
22
23
|
|
23
24
|
after_load do
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
if Hokusai.fonts.get("default").nil?
|
26
|
+
font = Hokusai::Backends::SDLBackend::Font.from "#{__dir__}/Monaco.ttf"
|
27
|
+
Hokusai.fonts.register "default", font
|
28
|
+
Hokusai.fonts.activate "default"
|
29
|
+
end
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
@@ -21,7 +21,7 @@ module Hokusai::Backends
|
|
21
21
|
end
|
22
22
|
|
23
23
|
class Font < Hokusai::Font
|
24
|
-
def self.from(file = "#{__dir__}/Monaco.ttf", size=
|
24
|
+
def self.from(file = "#{__dir__}/Monaco.ttf", size=60)
|
25
25
|
raw = SDL.TTF_OpenFont(file, size)
|
26
26
|
|
27
27
|
raise Hokusai::Error.new("Cannot open font from #{file}: #{ttf_error}") if raw.null?
|
@@ -51,6 +51,8 @@ module Hokusai::Backends
|
|
51
51
|
set_style(**args)
|
52
52
|
|
53
53
|
render_color = SDLBackend.color(color.r, color.g, color.b, color.a)
|
54
|
+
# bg = SDLBackend.color(0, 0, 0, 0)
|
55
|
+
|
54
56
|
SDL.TTF_RenderUTF8_Blended(raw, text, render_color)
|
55
57
|
end
|
56
58
|
|