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.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +1 -1
- data/ast/src/core/input.h +1 -0
- data/ast/src/core/util.c +23 -23
- data/ast/src/core/util.h +7 -7
- data/ext/extconf.rb +3 -3
- data/hokusai.gemspec +2 -1
- data/ui/examples/counter.rb +1 -2
- data/ui/examples/forum/file.rb +1 -1
- data/ui/examples/forum/post.rb +1 -0
- data/ui/examples/forum.rb +7 -7
- data/ui/examples/spreadsheet.rb +0 -1
- data/ui/examples/tic_tac_toe.rb +6 -6
- data/ui/lib/lib_hokusai.rb +24 -25
- data/ui/spec/spec_helper.rb +1 -1
- data/ui/src/hokusai/assets/chevron-down.svg +1 -0
- data/ui/src/hokusai/automation/driver_commands/base.rb +8 -2
- data/ui/src/hokusai/automation/driver_commands/trigger_keyboard.rb +6 -3
- data/ui/src/hokusai/automation/driver_commands/trigger_mouse.rb +5 -12
- data/ui/src/hokusai/automation/server.rb +3 -2
- data/ui/src/hokusai/backends/raylib/config.rb +1 -2
- data/ui/src/hokusai/backends/raylib/font.rb +3 -24
- data/ui/src/hokusai/backends/raylib.rb +36 -167
- data/ui/src/hokusai/backends/sdl2/config.rb +6 -9
- data/ui/src/hokusai/backends/sdl2/font.rb +1 -3
- data/ui/src/hokusai/backends/sdl2.rb +93 -188
- data/ui/src/hokusai/blocks/input.rb +2 -2
- data/ui/src/hokusai/commands/rect.rb +3 -12
- data/ui/src/hokusai/commands.rb +0 -22
- data/ui/src/hokusai/event.rb +1 -2
- data/ui/src/hokusai/events/keyboard.rb +18 -11
- data/ui/src/hokusai/events/mouse.rb +8 -10
- data/ui/src/hokusai/mounting/loop_entry.rb +1 -1
- data/ui/src/hokusai/painter.rb +8 -31
- data/ui/src/hokusai/types.rb +244 -20
- data/ui/src/hokusai.rb +35 -61
- data/xmake.lua +1 -1
- metadata +22 -32
- data/ui/examples/drag.rb +0 -154
- data/ui/examples/embedded.rb +0 -58
- data/ui/examples/game.rb +0 -143
- data/ui/examples/keyboard.rb +0 -47
- data/ui/examples/overlay.rb +0 -233
- data/ui/examples/provider.rb +0 -56
- data/ui/examples/shader/test.rb +0 -155
- data/ui/examples/shader.rb +0 -100
- data/ui/examples/wiki.rb +0 -82
- data/ui/spec/hokusai/e2e/keyboard_spec.rb +0 -52
- data/ui/src/hokusai/assets/arrow-down-line.png +0 -0
- data/ui/src/hokusai/assets/arrow-down-wide-line.png +0 -0
- data/ui/src/hokusai/assets/icons/outline/arrow-big-up.svg +0 -19
- data/ui/src/hokusai/assets/icons/outline/backspace.svg +0 -20
- data/ui/src/hokusai/blocks/color_picker.rb +0 -1080
- data/ui/src/hokusai/blocks/keyboard.rb +0 -249
- data/ui/src/hokusai/blocks/shader_begin.rb +0 -22
- data/ui/src/hokusai/blocks/shader_end.rb +0 -12
- data/ui/src/hokusai/blocks/slider.rb +0 -139
- data/ui/src/hokusai/blocks/texture.rb +0 -23
- data/ui/src/hokusai/commands/shader.rb +0 -33
- data/ui/src/hokusai/commands/texture.rb +0 -26
- data/ui/src/hokusai/events/touch.rb +0 -62
- data/ui/src/hokusai/types/display.rb +0 -151
- data/ui/src/hokusai/types/keyboard.rb +0 -168
- data/ui/src/hokusai/types/mouse.rb +0 -36
- data/ui/src/hokusai/types/primitives.rb +0 -56
- data/ui/src/hokusai/types/touch.rb +0 -181
- data/ui/src/hokusai/util/wrap_stream.rb +0 -193
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c28ec9cbfb0ad097992724a26e9304ff581f2becdb0c3edae24b953fecf6f69c
|
4
|
+
data.tar.gz: 7d78d50e110f70dd8af7095df76bd5b039d13c205336c31f42d58c9d503cceb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4c92faf605ff7a6b4f9e0c3489327a01886ee18b2a2700a502b10b984fabf49e365986fb17c37c24d7f474fa7689e36761709bc1e59fcc0cd238ccf29ca8011
|
7
|
+
data.tar.gz: a2b09402e3f899644cb30e398130111e2afd40542763e6e9377f9777b6c5facf56f54465451b26ee2296d3834cc3be1aed640c7856bb2a7839801c260f7ad9ac
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,6 +8,7 @@ GIT
|
|
8
8
|
GEM
|
9
9
|
remote: https://www.rubygems.org/
|
10
10
|
specs:
|
11
|
+
concurrent-ruby (1.3.5)
|
11
12
|
daemons (1.4.1)
|
12
13
|
diff-lcs (1.6.1)
|
13
14
|
domain_name (0.6.20240107)
|
@@ -76,6 +77,7 @@ PLATFORMS
|
|
76
77
|
x86_64-linux
|
77
78
|
|
78
79
|
DEPENDENCIES
|
80
|
+
concurrent-ruby
|
79
81
|
ffi!
|
80
82
|
memory_profiler
|
81
83
|
mini_portile2 (~> 2.0.0)
|
data/README.md
CHANGED
data/ast/src/core/input.h
CHANGED
data/ast/src/core/util.c
CHANGED
@@ -3,33 +3,33 @@
|
|
3
3
|
|
4
4
|
#include "util.h"
|
5
5
|
|
6
|
-
bool hoku_rect_includes_y(hoku_rect
|
6
|
+
bool hoku_rect_includes_y(hoku_rect rect, float y)
|
7
7
|
{
|
8
|
-
return y > rect
|
8
|
+
return y > rect.y && y <= (rect.y + rect.h);
|
9
9
|
}
|
10
10
|
|
11
|
-
bool hoku_rect_includes_x(hoku_rect
|
11
|
+
bool hoku_rect_includes_x(hoku_rect rect, float x)
|
12
12
|
{
|
13
|
-
return x > rect
|
13
|
+
return x > rect.x && x <= (rect.x + rect.w);
|
14
14
|
}
|
15
15
|
|
16
|
-
float hoku_rect_x_left(hoku_rect
|
16
|
+
float hoku_rect_x_left(hoku_rect rect, int times)
|
17
17
|
{
|
18
|
-
return (rect
|
18
|
+
return (rect.x - ((rect.w / 2) * times));
|
19
19
|
}
|
20
|
-
float hoku_rect_x_right(hoku_rect
|
20
|
+
float hoku_rect_x_right(hoku_rect rect, int times)
|
21
21
|
{
|
22
|
-
return (rect
|
22
|
+
return (rect.x + ((rect.w / 2) * times));
|
23
23
|
}
|
24
24
|
|
25
|
-
float hoku_rect_y_up(hoku_rect
|
25
|
+
float hoku_rect_y_up(hoku_rect rect, int times)
|
26
26
|
{
|
27
|
-
return (rect
|
27
|
+
return (rect.y - ((rect.h / 2) * times));
|
28
28
|
}
|
29
29
|
|
30
|
-
float hoku_rect_y_down(hoku_rect
|
30
|
+
float hoku_rect_y_down(hoku_rect rect, int times)
|
31
31
|
{
|
32
|
-
return (rect
|
32
|
+
return (rect.y + ((rect.h / 2) * times));
|
33
33
|
}
|
34
34
|
|
35
35
|
int hoku_selection_init(hoku_selection** selection)
|
@@ -68,28 +68,28 @@ bool hoku_selection_selected(hoku_selection* selection, float x, float y, float
|
|
68
68
|
bool right = selection->start_x <= selection->stop_x;
|
69
69
|
|
70
70
|
hoku_rect hit_box = (hoku_rect){.x=x, .y=y, .w=width, .h=height};
|
71
|
-
float x_shifted_right = hoku_rect_x_right(
|
72
|
-
float y_shifted_up = hoku_rect_y_up(
|
73
|
-
float y_shifted_down = hoku_rect_y_down(
|
71
|
+
float x_shifted_right = hoku_rect_x_right(hit_box, 1);
|
72
|
+
float y_shifted_up = hoku_rect_y_up(hit_box, 2);
|
73
|
+
float y_shifted_down = hoku_rect_y_down(hit_box, 2);
|
74
74
|
float end_y = y + height;
|
75
75
|
|
76
76
|
return (
|
77
77
|
(down &&
|
78
78
|
// first line of multiline selection
|
79
|
-
((x_shifted_right > sx && end_y < ey && hoku_rect_includes_y(
|
79
|
+
((x_shifted_right > sx && end_y < ey && hoku_rect_includes_y(hit_box, sy)) ||
|
80
80
|
// last line of multiline selection
|
81
81
|
(x_shifted_right <= ex && y_shifted_up + hit_box.h < ey && hit_box.y > sy) ||
|
82
82
|
// middle line (all selected)
|
83
83
|
(hit_box.y > sy && end_y < ey))) ||
|
84
84
|
(up &&
|
85
85
|
// first line of multiline selection
|
86
|
-
((x_shifted_right <= sx && hit_box.y > ey && hoku_rect_includes_y(
|
86
|
+
((x_shifted_right <= sx && hit_box.y > ey && hoku_rect_includes_y(hit_box, sy)) ||
|
87
87
|
// last line of multiline selection
|
88
88
|
(x_shifted_right >= ex && y_shifted_down > ey && end_y < sy) ||
|
89
89
|
// middle line (all selected)
|
90
90
|
(hit_box.y > ey && hit_box.y + hit_box.h < sy))) ||
|
91
91
|
// single line selection
|
92
|
-
((hoku_rect_includes_y(
|
92
|
+
((hoku_rect_includes_y(hit_box, sy) && hoku_rect_includes_y(hit_box, ey)) &&
|
93
93
|
((left && x_shifted_right < sx && x_shifted_right > ex) || (right && x_shifted_right > sx && x_shifted_right < ex)))
|
94
94
|
);
|
95
95
|
}
|
@@ -108,7 +108,7 @@ hoku_cursor_position hoku_selection_cursor_get(hoku_selection* selection)
|
|
108
108
|
return pos;
|
109
109
|
}
|
110
110
|
|
111
|
-
int hoku_selection_cursor_set(hoku_selection* selection, hoku_cursor_position
|
111
|
+
int hoku_selection_cursor_set(hoku_selection* selection, hoku_cursor_position cursor)
|
112
112
|
{
|
113
113
|
if (selection->cursor == NULL)
|
114
114
|
{
|
@@ -117,10 +117,10 @@ int hoku_selection_cursor_set(hoku_selection* selection, hoku_cursor_position* c
|
|
117
117
|
if (selection->cursor == NULL) return -1;
|
118
118
|
}
|
119
119
|
|
120
|
-
selection->cursor->x = cursor
|
121
|
-
selection->cursor->y = cursor
|
122
|
-
selection->cursor->w = cursor
|
123
|
-
selection->cursor->h = cursor
|
120
|
+
selection->cursor->x = cursor.x;
|
121
|
+
selection->cursor->y = cursor.y;
|
122
|
+
selection->cursor->w = cursor.w;
|
123
|
+
selection->cursor->h = cursor.h;
|
124
124
|
|
125
125
|
return 0;
|
126
126
|
}
|
data/ast/src/core/util.h
CHANGED
@@ -30,16 +30,16 @@ typedef struct HokuSelection
|
|
30
30
|
hoku_cursor_position* cursor;
|
31
31
|
} hoku_selection;
|
32
32
|
|
33
|
-
bool hoku_rect_includes_y(hoku_rect
|
34
|
-
bool hoku_rect_includes_x(hoku_rect
|
35
|
-
float hoku_rect_x_left(hoku_rect
|
36
|
-
float hoku_rect_x_right(hoku_rect
|
37
|
-
float hoku_rect_y_up(hoku_rect
|
38
|
-
float hoku_rect_y_down(hoku_rect
|
33
|
+
bool hoku_rect_includes_y(hoku_rect rect, float y);
|
34
|
+
bool hoku_rect_includes_x(hoku_rect rect, float x);
|
35
|
+
float hoku_rect_x_left(hoku_rect rect, int times);
|
36
|
+
float hoku_rect_x_right(hoku_rect rect, int times);
|
37
|
+
float hoku_rect_y_up(hoku_rect rect, int times);
|
38
|
+
float hoku_rect_y_down(hoku_rect rect, int times);
|
39
39
|
|
40
40
|
int hoku_selection_init(hoku_selection** selection);
|
41
41
|
bool hoku_selection_selected(hoku_selection* selection, float x, float y, float width, float height);
|
42
|
-
int hoku_selection_cursor_set(hoku_selection* selection, hoku_cursor_position
|
42
|
+
int hoku_selection_cursor_set(hoku_selection* selection, hoku_cursor_position cursor);
|
43
43
|
void hoku_selection_cursor_free(hoku_selection* selection);
|
44
44
|
void hoku_selection_free(hoku_selection* selection);
|
45
45
|
|
data/ext/extconf.rb
CHANGED
@@ -9,7 +9,7 @@ if MiniPortile.darwin?
|
|
9
9
|
elsif MiniPortile.linux?
|
10
10
|
suffix = "so"
|
11
11
|
ext = "tar.gz"
|
12
|
-
md4cext = "
|
12
|
+
md4cext = "so"
|
13
13
|
MDFLAGS = "-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
|
14
14
|
elsif MiniPortile.windows?
|
15
15
|
suffix = "dll"
|
@@ -45,7 +45,7 @@ md4c = MiniPortileCMake.new("md4c", "0.5.2")
|
|
45
45
|
md4c.files = ["https://github.com/mity/md4c/archive/refs/tags/release-0.5.2.#{ext}"]
|
46
46
|
|
47
47
|
def md4c.cmake_compile_flags
|
48
|
-
[*super, "-DBUILD_SHARED_LIBS=OFF
|
48
|
+
[*super, "-DBUILD_SHARED_LIBS=OFF #{MDFLAGS}"]
|
49
49
|
end
|
50
50
|
|
51
51
|
md4c.cook
|
@@ -89,4 +89,4 @@ File.open("Makefile", "w") do |io|
|
|
89
89
|
#{"\t"}rm -f #{File.expand_path("vendor/lib/libhokusai.*")}
|
90
90
|
#{"\t"}rm -f #{File.expand_path("vendor/lib/libmd4c.*")}
|
91
91
|
EOF
|
92
|
-
end
|
92
|
+
end
|
data/hokusai.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'hokusai-zero'
|
3
|
-
s.version = '0.2.6
|
3
|
+
s.version = '0.2.6'
|
4
4
|
s.licenses = ['MIT']
|
5
5
|
s.summary = "A Ruby library for writing GUI applications"
|
6
6
|
s.authors = ["skinnyjames"]
|
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.metadata = { "source_code_uri" => "https://codeberg.org/skinnyjames/hokusai" }
|
17
17
|
|
18
18
|
s.add_dependency "ffi", "~> 1.16"
|
19
|
+
s.add_dependency "concurrent-ruby", "~> 1.3.4"
|
19
20
|
s.add_dependency "raylib-bindings", "~> 0.7.9"
|
20
21
|
s.add_dependency "sdl2-bindings", "~> 0.2.3"
|
21
22
|
s.add_dependency "memory_profiler"
|
data/ui/examples/counter.rb
CHANGED
@@ -122,12 +122,11 @@ Hokusai::Backends::RaylibBackend.run(Demos::Counter) do |config|
|
|
122
122
|
# end
|
123
123
|
|
124
124
|
config.after_load do
|
125
|
-
font = Hokusai::Backends::RaylibBackend::Font.
|
125
|
+
font = Hokusai::Backends::RaylibBackend::Font.from_ext("#{__dir__}/assets/OpenSans-Regular.ttf", 160)
|
126
126
|
Hokusai.fonts.register "opensans", font
|
127
127
|
Hokusai.fonts.activate "opensans"
|
128
128
|
end
|
129
129
|
|
130
|
-
config.fps = 40
|
131
130
|
config.width = 500
|
132
131
|
config.height = 500
|
133
132
|
config.title = "Counter application"
|
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::RaylibBackend.run(Demos::Forum::App) do |config|
|
179
179
|
config.after_load do
|
180
|
-
font = Hokusai::Backends::
|
180
|
+
font = Hokusai::Backends::RaylibBackend::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::RaylibBackend::Font.from_ext("#{__dir__}/assets/Delius-Regular.ttf", 160)
|
185
185
|
Hokusai.fonts.register "dohyeon", font
|
186
186
|
end
|
187
187
|
|
@@ -190,10 +190,10 @@ Hokusai::Backends::SDLBackend.run(Demos::Forum::App) do |config|
|
|
190
190
|
config.height = 500
|
191
191
|
config.title = "Counter application"
|
192
192
|
|
193
|
-
config.window_config_flags = SDL::WINDOW_RESIZABLE
|
193
|
+
# config.window_config_flags = SDL::WINDOW_RESIZABLE | SDL::WINDOW_BORDERLESS
|
194
194
|
|
195
|
-
|
196
|
-
|
197
|
-
|
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
|
|
data/ui/examples/spreadsheet.rb
CHANGED
@@ -134,7 +134,6 @@ Hokusai::Backends::RaylibBackend.run(Demos::Spreadsheet::App) do |config|
|
|
134
134
|
config.height = 500
|
135
135
|
config.title = "Spreadsheet application"
|
136
136
|
|
137
|
-
|
138
137
|
config.config_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_VSYNC_HINT | Raylib::FLAG_WINDOW_TRANSPARENT
|
139
138
|
config.window_state_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_WINDOW_UNDECORATED | Raylib::FLAG_WINDOW_TRANSPARENT
|
140
139
|
config.background = Raylib::BLANK
|
data/ui/examples/tic_tac_toe.rb
CHANGED
@@ -240,9 +240,9 @@ module Demos
|
|
240
240
|
end
|
241
241
|
end
|
242
242
|
end
|
243
|
-
|
244
|
-
Hokusai::Backends::
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
end
|
243
|
+
#
|
244
|
+
# Hokusai::Backends::SDLBackend.run(TicTacToe::App) do |config|
|
245
|
+
# config.width = 500
|
246
|
+
# config.height = 500
|
247
|
+
# config.title = "Tic Tac Trollio"
|
248
|
+
# end
|
data/ui/lib/lib_hokusai.rb
CHANGED
@@ -122,7 +122,23 @@ module LibHokusai
|
|
122
122
|
:next_child, HmlAst.ptr
|
123
123
|
end
|
124
124
|
|
125
|
-
|
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, [
|
126
142
|
:null, :apostrophe, :comma, :minus,
|
127
143
|
:period, :slash, :zero, :one, :two,
|
128
144
|
:three, :four, :five, :six, :seven,
|
@@ -146,23 +162,6 @@ module LibHokusai
|
|
146
162
|
:max
|
147
163
|
]
|
148
164
|
|
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
|
-
|
166
165
|
enum :hml_input_select_type, [
|
167
166
|
:ACTIVE, 0x01,
|
168
167
|
:FROZEN, 0x02,
|
@@ -353,16 +352,16 @@ module LibHokusai
|
|
353
352
|
|
354
353
|
attach_function :hoku_selection_init, [:pointer], :int
|
355
354
|
attach_function :hoku_selection_selected, [HokuSelection.by_ref, :float, :float, :float, :float], :bool
|
356
|
-
attach_function :hoku_selection_cursor_set, [HokuSelection.by_ref, HokuCursorPosition.
|
355
|
+
attach_function :hoku_selection_cursor_set, [HokuSelection.by_ref, HokuCursorPosition.by_value], :int
|
357
356
|
attach_function :hoku_selection_cursor_free, [HokuSelection.by_ref], :void
|
358
357
|
attach_function :hoku_selection_free, [HokuSelection.by_ref], :void
|
359
358
|
|
360
|
-
attach_function :hoku_rect_includes_y, [HmlRect.
|
361
|
-
attach_function :hoku_rect_includes_x, [HmlRect.
|
362
|
-
attach_function :hoku_rect_x_left, [HmlRect.
|
363
|
-
attach_function :hoku_rect_x_right, [HmlRect.
|
364
|
-
attach_function :hoku_rect_y_up, [HmlRect.
|
365
|
-
attach_function :hoku_rect_y_down, [HmlRect.
|
359
|
+
attach_function :hoku_rect_includes_y, [HmlRect.by_value, :float], :bool
|
360
|
+
attach_function :hoku_rect_includes_x, [HmlRect.by_value, :float], :bool
|
361
|
+
attach_function :hoku_rect_x_left, [HmlRect.by_value, :int], :float
|
362
|
+
attach_function :hoku_rect_x_right, [HmlRect.by_value, :int], :float
|
363
|
+
attach_function :hoku_rect_y_up, [HmlRect.by_value, :int], :float
|
364
|
+
attach_function :hoku_rect_y_down, [HmlRect.by_value, :int], :float
|
366
365
|
|
367
366
|
class HokuChar < FFI::Struct
|
368
367
|
layout :offset, :int,
|
data/ui/spec/spec_helper.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><title>finite-icons</title><path d="M13.60851,6.08611L8.35425,11.339,3.06908,6.05389a0.5,0.5,0,0,1,0-.70711l0.539-.539a0.5,0.5,0,0,1,.70711,0l4.03907,4.039L12.36249,4.8399a0.5,0.5,0,0,1,.70705.00006l0.539,0.539A0.5,0.5,0,0,1,13.60851,6.08611Z" fill="#231f20"/></svg>
|
@@ -65,8 +65,14 @@ module Hokusai::Automation
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def mouse_move(x, y, input)
|
68
|
-
input
|
69
|
-
|
68
|
+
LibHokusai.hoku_input_set_mouse_position(input, vec2(x, y))
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
# Returns an HmlVec2 from {x,y}
|
74
|
+
def vec2(x, y)
|
75
|
+
LibHokusai::HmlVec2.create(x, y)
|
70
76
|
end
|
71
77
|
end
|
72
78
|
end
|
@@ -33,18 +33,21 @@ module Hokusai::Automation
|
|
33
33
|
decode_key = keys.shift
|
34
34
|
|
35
35
|
mouse_center(canvas, input)
|
36
|
-
|
36
|
+
state = LibHokusai::HmlInputMouseButton.create(clicked: true)
|
37
|
+
LibHokusai.hoku_input_mouse_set_button(input, state, 0)
|
37
38
|
|
38
39
|
begin
|
39
40
|
key_results = to_hml_keygroup(decode_key)
|
40
41
|
|
41
|
-
input
|
42
|
+
LibHokusai.hoku_input_keyboard_start(input)
|
42
43
|
|
43
44
|
key_results.each do |key|
|
44
45
|
Log.info { "populating #{key}"}
|
45
46
|
|
46
|
-
|
47
|
+
LibHokusai.hoku_input_keyboard_set_key(input, key, true)
|
47
48
|
end
|
49
|
+
|
50
|
+
LibHokusai.hoku_input_keyboard_stop(input)
|
48
51
|
rescue Automation::Error => ex
|
49
52
|
keys.clear
|
50
53
|
self.exeception = ex
|
@@ -2,9 +2,9 @@ module Hokusai::Automation
|
|
2
2
|
module DriverCommands
|
3
3
|
module MouseMethods
|
4
4
|
def trigger_mouse(input, **args)
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
state = LibHokusai::HmlInputMouseButton.create(**args)
|
6
|
+
|
7
|
+
LibHokusai.hoku_input_mouse_set_button(input, state, button)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -27,14 +27,6 @@ module Hokusai::Automation
|
|
27
27
|
state[:button]
|
28
28
|
end
|
29
29
|
|
30
|
-
def button_symbol
|
31
|
-
{
|
32
|
-
0 => :left,
|
33
|
-
1 => :middle,
|
34
|
-
2 => :right
|
35
|
-
}[button]
|
36
|
-
end
|
37
|
-
|
38
30
|
def on_complete
|
39
31
|
return value if done?
|
40
32
|
|
@@ -73,6 +65,7 @@ module Hokusai::Automation
|
|
73
65
|
class TriggerMouseClick < TriggerMouseBase
|
74
66
|
def execute(blocks, canvas, input)
|
75
67
|
if matches_blocks(blocks)
|
68
|
+
|
76
69
|
mouse_center(canvas, input)
|
77
70
|
trigger_mouse(input, clicked: true)
|
78
71
|
|
@@ -209,8 +202,8 @@ module Hokusai::Automation
|
|
209
202
|
def execute(blocks, canvas, input)
|
210
203
|
if matches_block(blocks[0])
|
211
204
|
mouse_center(canvas, input)
|
205
|
+
LibHokusai.hoku_input_mouse_set_scroll(input, scroll_amount)
|
212
206
|
|
213
|
-
input.mouse.scroll = scroll_amount
|
214
207
|
|
215
208
|
done!
|
216
209
|
end
|
@@ -99,14 +99,15 @@ module Hokusai
|
|
99
99
|
app = App.new(driver)
|
100
100
|
|
101
101
|
@socket = Thin::Server.new(*args, app)
|
102
|
-
|
103
|
-
Thread.new do
|
102
|
+
Hokusai::ThreadPool.post do
|
104
103
|
@socket.start
|
105
104
|
end
|
106
105
|
end
|
107
106
|
|
108
107
|
def self.stop
|
109
108
|
@socket.stop
|
109
|
+
|
110
|
+
Hokusai::ThreadPool.prune_pool
|
110
111
|
end
|
111
112
|
end
|
112
113
|
end
|
@@ -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
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@width = 500
|
@@ -22,7 +22,6 @@ module Hokusai::Backends
|
|
22
22
|
@automated = false
|
23
23
|
@on_reload = ->(_){}
|
24
24
|
@event_waiting = false
|
25
|
-
@touch = false
|
26
25
|
end
|
27
26
|
|
28
27
|
def start_automation_driver
|
@@ -24,7 +24,7 @@ module Hokusai
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Font < Hokusai::Font
|
27
|
-
attr_reader :raw
|
27
|
+
attr_reader :raw
|
28
28
|
|
29
29
|
DEFAULT = "–—‘’“”…\r\n\t0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%%^&*(),.?/\"\\[]-_=+|~`{}<>;:'\0"
|
30
30
|
|
@@ -51,7 +51,7 @@ module Hokusai
|
|
51
51
|
|
52
52
|
raylib_font = Raylib.LoadFontEx(file, font_size, codepoints, count)
|
53
53
|
Raylib.GenTextureMipmaps(raylib_font.texture)
|
54
|
-
Raylib.SetTextureFilter(raylib_font.texture, Raylib::
|
54
|
+
Raylib.SetTextureFilter(raylib_font.texture, Raylib::TEXTURE_FILTER_BILINEAR)
|
55
55
|
|
56
56
|
font = new(raylib_font)
|
57
57
|
Raylib.UnloadCodepoints(codepoints)
|
@@ -59,30 +59,9 @@ module Hokusai
|
|
59
59
|
font
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
63
|
-
ptr = FFI::MemoryPointer.new(:int)
|
64
|
-
data = Raylib.LoadFileData(file, ptr)
|
65
|
-
font = Raylib::Font.new
|
66
|
-
font.baseSize = size
|
67
|
-
font.glyphCount = 95
|
68
|
-
|
69
|
-
font.glyphs = Raylib.LoadFontData(data, ptr.read_int, size, nil, 0, Raylib::FONT_SDF)
|
70
|
-
buf = FFI::MemoryPointer.new(:pointer, 1)
|
71
|
-
atlas = Raylib.GenImageFontAtlas(font.glyphs, buf, 95, size, 4, 0)
|
72
|
-
font.recs = buf.read_pointer
|
73
|
-
font.texture = Raylib.LoadTextureFromImage(atlas)
|
74
|
-
Raylib.UnloadImage(atlas)
|
75
|
-
Raylib.UnloadFileData(data)
|
76
|
-
buf.free
|
77
|
-
ptr.free
|
78
|
-
|
79
|
-
new(font, sdf: true)
|
80
|
-
end
|
81
|
-
|
82
|
-
def initialize(raw, spacing = 1.0, sdf: false)
|
62
|
+
def initialize(raw, spacing = 1.0)
|
83
63
|
@raw = raw
|
84
64
|
@spacing = spacing
|
85
|
-
@sdf = sdf
|
86
65
|
end
|
87
66
|
|
88
67
|
# returns the spacing for this font
|