hokusai-zero 0.2.6.pre.pinephone2 → 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.
data/ui/src/hokusai.rb CHANGED
@@ -13,35 +13,6 @@ require_relative './hokusai/event'
13
13
  require_relative './hokusai/painter'
14
14
  require_relative './hokusai/util/selection'
15
15
  require_relative './hokusai/util/piece_table'
16
- require_relative './hokusai/blocks/empty'
17
- require_relative './hokusai/blocks/vblock'
18
- require_relative './hokusai/blocks/hblock'
19
- require_relative './hokusai/blocks/label'
20
- require_relative './hokusai/blocks/rect'
21
- require_relative './hokusai/blocks/button'
22
- require_relative './hokusai/blocks/circle'
23
- require_relative './hokusai/blocks/checkbox'
24
- require_relative './hokusai/blocks/scissor_begin'
25
- require_relative './hokusai/blocks/scissor_end'
26
- require_relative './hokusai/blocks/clipped'
27
- require_relative './hokusai/blocks/cursor'
28
- require_relative './hokusai/blocks/image'
29
- require_relative './hokusai/blocks/svg'
30
- require_relative './hokusai/blocks/toggle'
31
- require_relative './hokusai/blocks/scrollbar'
32
- require_relative './hokusai/blocks/dynamic'
33
- require_relative './hokusai/blocks/panel'
34
- require_relative './hokusai/blocks/text'
35
- require_relative './hokusai/blocks/selectable'
36
- require_relative './hokusai/blocks/input'
37
- require_relative './hokusai/blocks/variable'
38
- require_relative './hokusai/blocks/titlebar/osx'
39
- require_relative './hokusai/blocks/modal'
40
- require_relative './hokusai/blocks/dropdown'
41
- require_relative './hokusai/blocks/shader_begin'
42
- require_relative './hokusai/blocks/shader_end'
43
- require_relative './hokusai/blocks/texture'
44
- require_relative './hokusai/blocks/color_picker'
45
16
 
46
17
  # A backend agnostic library for authoring
47
18
  # desktop applications
@@ -60,6 +31,10 @@ module Hokusai
60
31
  SHADER_UNIFORM_UIVEC3 = 10 # Shader uniform type: uivec3 (3 unsigned int)
61
32
  SHADER_UNIFORM_UIVEC4 = 11 # Shader uniform type: uivec4 (4 unsigned int)
62
33
 
34
+ def self.asset(path)
35
+ "#{ASSETS_FOLDER}/#{path}"
36
+ end
37
+
63
38
  # Access the font registry
64
39
  #
65
40
  # @return [Hokusai::FontRegistry]
@@ -161,4 +136,60 @@ module Hokusai
161
136
  def self.set_mouse_cursor(type)
162
137
  @on_set_mouse_cursor&.call(type)
163
138
  end
164
- end
139
+
140
+ # Mobile support
141
+ def self.on_show_keyboard(&block)
142
+ @on_show_keyboard = block
143
+ end
144
+
145
+ def self.show_keyboard
146
+ @on_show_keyboard&.call
147
+ end
148
+
149
+ def self.on_hide_keyboard(&block)
150
+ @on_hide_keyboard = block
151
+ end
152
+
153
+ def self.hide_keyboard
154
+ @on_hide_keyboard&.call
155
+ end
156
+
157
+ def self.on_keyboard_visible(&block)
158
+ @on_keyboard_visible = block
159
+ end
160
+
161
+ def self.keyboard_visible?
162
+ @on_keyboard_visible&.call
163
+ end
164
+ end
165
+
166
+ require_relative './hokusai/blocks/empty'
167
+ require_relative './hokusai/blocks/vblock'
168
+ require_relative './hokusai/blocks/hblock'
169
+ require_relative './hokusai/blocks/label'
170
+ require_relative './hokusai/blocks/rect'
171
+ require_relative './hokusai/blocks/button'
172
+ require_relative './hokusai/blocks/circle'
173
+ require_relative './hokusai/blocks/checkbox'
174
+ require_relative './hokusai/blocks/scissor_begin'
175
+ require_relative './hokusai/blocks/scissor_end'
176
+ require_relative './hokusai/blocks/clipped'
177
+ require_relative './hokusai/blocks/cursor'
178
+ require_relative './hokusai/blocks/image'
179
+ require_relative './hokusai/blocks/svg'
180
+ require_relative './hokusai/blocks/toggle'
181
+ require_relative './hokusai/blocks/scrollbar'
182
+ require_relative './hokusai/blocks/dynamic'
183
+ require_relative './hokusai/blocks/panel'
184
+ require_relative './hokusai/blocks/text'
185
+ require_relative './hokusai/blocks/selectable'
186
+ require_relative './hokusai/blocks/input'
187
+ require_relative './hokusai/blocks/variable'
188
+ require_relative './hokusai/blocks/titlebar/osx'
189
+ require_relative './hokusai/blocks/modal'
190
+ require_relative './hokusai/blocks/dropdown'
191
+ require_relative './hokusai/blocks/shader_begin'
192
+ require_relative './hokusai/blocks/shader_end'
193
+ require_relative './hokusai/blocks/texture'
194
+ require_relative './hokusai/blocks/color_picker'
195
+ require_relative './hokusai/blocks/keyboard'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hokusai-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6.pre.pinephone2
4
+ version: 0.2.6.pre.pinephone3
5
5
  platform: ruby
6
6
  authors:
7
7
  - skinnyjames
@@ -114,7 +114,6 @@ files:
114
114
  - ast/test/fixtures/test.ui
115
115
  - ast/test/greatest.h
116
116
  - ast/test/hokusai.c
117
- - ast/test/input.c
118
117
  - ast/test/parser.c
119
118
  - ast/test/text.c
120
119
  - docs.sh
@@ -175,6 +174,7 @@ files:
175
174
  - ui/examples/forum/music.rb
176
175
  - ui/examples/forum/post.rb
177
176
  - ui/examples/game.rb
177
+ - ui/examples/keyboard.rb
178
178
  - ui/examples/overlay.rb
179
179
  - ui/examples/provider.rb
180
180
  - ui/examples/shader.rb
@@ -193,6 +193,7 @@ files:
193
193
  - ui/spec/hokusai/diff_spec.rb
194
194
  - ui/spec/hokusai/directives_spec.rb
195
195
  - ui/spec/hokusai/e2e/client_spec.rb
196
+ - ui/spec/hokusai/e2e/keyboard_spec.rb
196
197
  - ui/spec/hokusai/e2e/meta_spec.rb
197
198
  - ui/spec/hokusai/providers_spec.rb
198
199
  - ui/spec/hokusai/publisher_spec.rb
@@ -205,6 +206,8 @@ files:
205
206
  - ui/src/hokusai/assets/arrow-down-wide-line.png
206
207
  - ui/src/hokusai/assets/arrow-drop-down-line.png
207
208
  - ui/src/hokusai/assets/close-large-line.png
209
+ - ui/src/hokusai/assets/icons/outline/arrow-big-up.svg
210
+ - ui/src/hokusai/assets/icons/outline/backspace.svg
208
211
  - ui/src/hokusai/ast.rb
209
212
  - ui/src/hokusai/automation.rb
210
213
  - ui/src/hokusai/automation/client.rb
@@ -221,10 +224,6 @@ files:
221
224
  - ui/src/hokusai/automation/keys_transcoder.rb
222
225
  - ui/src/hokusai/automation/selector.rb
223
226
  - ui/src/hokusai/automation/server.rb
224
- - ui/src/hokusai/backends/embedded.rb
225
- - ui/src/hokusai/backends/embedded/config.rb
226
- - ui/src/hokusai/backends/embedded/font.rb
227
- - ui/src/hokusai/backends/embedded/keys.rb
228
227
  - ui/src/hokusai/backends/raylib.rb
229
228
  - ui/src/hokusai/backends/raylib/config.rb
230
229
  - ui/src/hokusai/backends/raylib/font.rb
@@ -248,6 +247,7 @@ files:
248
247
  - ui/src/hokusai/blocks/hblock.rb
249
248
  - ui/src/hokusai/blocks/image.rb
250
249
  - ui/src/hokusai/blocks/input.rb
250
+ - ui/src/hokusai/blocks/keyboard.rb
251
251
  - ui/src/hokusai/blocks/label.rb
252
252
  - ui/src/hokusai/blocks/modal.rb
253
253
  - ui/src/hokusai/blocks/panel.rb
@@ -258,6 +258,7 @@ files:
258
258
  - ui/src/hokusai/blocks/selectable.rb
259
259
  - ui/src/hokusai/blocks/shader_begin.rb
260
260
  - ui/src/hokusai/blocks/shader_end.rb
261
+ - ui/src/hokusai/blocks/slider.rb
261
262
  - ui/src/hokusai/blocks/svg.rb
262
263
  - ui/src/hokusai/blocks/text.rb
263
264
  - ui/src/hokusai/blocks/texture.rb
@@ -294,6 +295,7 @@ files:
294
295
  - ui/src/hokusai/util/clamping_iterator.rb
295
296
  - ui/src/hokusai/util/piece_table.rb
296
297
  - ui/src/hokusai/util/selection.rb
298
+ - ui/src/hokusai/util/wrap_stream.rb
297
299
  - ui/vendor/.gitkeep
298
300
  - vendor/.gitkeep
299
301
  - xmake.lua
data/ast/test/input.c DELETED
@@ -1,44 +0,0 @@
1
- #include "../src/core/input.c"
2
- #include<unistd.h>
3
-
4
- TEST test_hoku_input_touch_basic()
5
- {
6
- hoku_input* input;
7
- int ret = hoku_input_init(&input);
8
- ASSERT_EQ_FMT(ret, 0, "%d");
9
-
10
- ret = hoku_input_attach_touch(input, 2);
11
- ASSERT_EQ_FMT(ret, 0, "%d");
12
-
13
- hoku_input_record_touch(input, 0, 1.0, 2.0);
14
- hoku_input_clear_touch(input, 0);
15
-
16
- bool tapped = hoku_input_touch_tapped(input);
17
- bool swiped = hoku_input_touch_swiped(input, 4);
18
-
19
- ASSERT_EQ_FMT(1, tapped, "%d");
20
- ASSERT_EQ_FMT(0, swiped, "%d");
21
-
22
- hoku_input_record_touch(input, 0, 1.0, 2.0);
23
- usleep(1000);
24
- hoku_input_record_touch(input, 0, 3.0, 1.0);
25
-
26
- bool longtapped = hoku_input_touch_longtapped(input, 4);
27
-
28
- hoku_input_clear_touch(input, 0);
29
- swiped = hoku_input_touch_swiped(input, 1.0);
30
-
31
- ASSERT_EQ_FMT(1, longtapped, "%d");
32
- ASSERT_EQ_FMT(1, swiped, "%d");
33
- // ASSERT_EQ_FMT(pinched, 0, "%d");
34
-
35
- hoku_input_free(input);
36
-
37
- PASS();
38
- }
39
-
40
-
41
- SUITE(hoku_input_suite)
42
- {
43
- RUN_TEST(test_hoku_input_touch_basic);
44
- }
@@ -1,48 +0,0 @@
1
- module Hokusai::Backends
2
- class EmbeddedBackend::ConfigError < StandardError; end
3
-
4
- class EmbeddedBackend::Config
5
- attr_accessor :width, :height, :fps,
6
- :title, :config_flags, :window_state_flags,
7
- :automation_driver, :background, :after_load_cb,
8
- :host, :port, :automated, :on_reload, :event_waiting, :max_touch_count
9
-
10
- def initialize
11
- @width = 500
12
- @height = 500
13
- @fps = 60
14
- @title = "(Unknown Title)"
15
- @config_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_VSYNC_HINT
16
- @window_state_flags = Raylib::FLAG_WINDOW_RESIZABLE
17
- @automation_driver = nil
18
- @background = Raylib::WHITE
19
- @after_load_cb = nil
20
- @host = "127.0.0.1"
21
- @port = 4333
22
- @automated = false
23
- @on_reload = ->(_){}
24
- @event_waiting = false
25
- @max_touch_count = 2
26
- end
27
-
28
- def start_automation_driver
29
- raise ConfigError.new("Need a Hokusai::Driver in order to automate") if automation_driver.nil?
30
-
31
- automation_driver.serve(host, port)
32
- end
33
-
34
- def automate(host, port)
35
- self.host = host
36
- self.port = port
37
- self.automated = true
38
- end
39
-
40
- def after_load(&block)
41
- self.after_load_cb = block
42
- end
43
-
44
- def on_reload(&block)
45
- @on_reload = block
46
- end
47
- end
48
- end
@@ -1,112 +0,0 @@
1
- module Hokusai
2
- module Backends
3
- class EmbeddedBackend
4
- class DataForCb < FFI::Struct
5
- layout :size, :int,
6
- :spacing, :int,
7
- :raw, :pointer
8
-
9
- def self.create(size, spacing, raw)
10
- obj = new.tap do |instance|
11
- instance[:size] = size
12
- instance[:spacing] = spacing
13
- instance[:raw] = raw
14
- end
15
-
16
- yield obj.to_ptr
17
- end
18
- end
19
-
20
- OnWidthCb = Proc.new do |char, ffi_pointer|
21
- data = DataForCb.new ffi_pointer
22
-
23
- Raylib.MeasureTextEx(data[:raw], "#{char.chr}", data[:size], data[:spacing]).x + 1.565#@ data[:spacing]
24
- end
25
-
26
- class Font < Hokusai::Font
27
- attr_reader :raw
28
-
29
- DEFAULT = "–—‘’“”…\r\n\t0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%%^&*(),.?/\"\\[]-_=+|~`{}<>;:'\0"
30
-
31
- def self.default
32
- font = Raylib.GetFontDefault
33
- Raylib.SetTextureFilter(font.texture, Raylib::TEXTURE_FILTER_BILINEAR)
34
- # Raylib.GenTextureMipmaps(font.texture)
35
-
36
- new(font)
37
- end
38
-
39
- def self.from(file)
40
- font = Raylib.LoadFont(file)
41
- Raylib.SetTextureFilter(font.texture, Raylib::TEXTURE_FILTER_BILINEAR)
42
- # Raylib.GenTextureMipmaps(font.texture)
43
-
44
- new(font)
45
- end
46
-
47
- def self.from_ext(file, font_size, codepoint_string = DEFAULT)
48
- ptr = FFI::MemoryPointer.new :int
49
- codepoints = Raylib.LoadCodepoints(codepoint_string, ptr)
50
- count = ptr.read_int
51
-
52
- raylib_font = Raylib.LoadFontEx(file, font_size, codepoints, count)
53
- # Raylib.GenTextureMipmaps(raylib_font.texture)
54
- Raylib.SetTextureFilter(raylib_font.texture, Raylib::TEXTURE_FILTER_BILINEAR)
55
-
56
- font = new(raylib_font)
57
- Raylib.UnloadCodepoints(codepoints)
58
-
59
- font
60
- end
61
-
62
- def initialize(raw, spacing = 1.0)
63
- @raw = raw
64
- @spacing = spacing
65
- end
66
-
67
- # returns the spacing for this font
68
- # based on the text size
69
- def spacing
70
- ssize = raw.baseSize || 1
71
- ssize = 10 if ssize < 10
72
-
73
- (ssize / (raw.baseSize.zero? ? 1 : raw.baseSize)).to_f
74
- end
75
-
76
- def measure(string, size)
77
- vec = Raylib.MeasureTextEx(raw, string, size, spacing)
78
-
79
- [vec.x, vec.y]
80
- end
81
-
82
- def height
83
- raw.baseSize
84
- end
85
-
86
- def clamp_markdown(text, size, width, initial_offset = 0.0)
87
- clamping_pointer = FFI::MemoryPointer.new :pointer
88
- RaylibBackend::DataForCb.create(size, spacing, raw) do |ptr|
89
- ret = LibHokusai.hoku_text_md_clamp(clamping_pointer, text, width, initial_offset, ptr, RaylibBackend::OnWidthCb)
90
- raise Hokusai::Error.new("Clamping failed") unless ret.zero?
91
- end
92
-
93
- clamping = LibHokusai::HokuClamping.new(FFI::AutoPointer.new(clamping_pointer.get_pointer(0), LibHokusai.method(:hoku_text_clamping_free)))
94
-
95
- Hokusai::Clamping.new(clamping, markdown: true)
96
- end
97
-
98
- def clamp(text, size, width, initial_offset = 0.0)
99
- clamping_pointer = FFI::MemoryPointer.new :pointer
100
- EmbeddedBackend::DataForCb.create(size, spacing, raw) do |ptr|
101
- ret = LibHokusai.hoku_text_clamp(clamping_pointer, text, width, initial_offset, ptr, EmbeddedBackend::OnWidthCb)
102
- raise Hokusai::Error.new("Clamping failed") unless ret.zero?
103
- end
104
-
105
- clamping = LibHokusai::HokuClamping.new(FFI::AutoPointer.new(clamping_pointer.get_pointer(0), LibHokusai.method(:hoku_text_clamping_free)))
106
-
107
- Hokusai::Clamping.new(clamping)
108
- end
109
- end
110
- end
111
- end
112
- end
@@ -1,124 +0,0 @@
1
- module Hokusai::Backends
2
- class EmbeddedBackend
3
- Keys = [
4
- [:null, Raylib::KEY_NULL],
5
- [:left_shift, Raylib::KEY_LEFT_SHIFT],
6
- [:left_control, Raylib::KEY_LEFT_CONTROL],
7
- [:left_alt, Raylib::KEY_LEFT_ALT],
8
- [:left_super, Raylib::KEY_LEFT_SUPER],
9
- [:right_shift, Raylib::KEY_RIGHT_SHIFT],
10
- [:right_control, Raylib::KEY_RIGHT_CONTROL],
11
- [:right_alt, Raylib::KEY_RIGHT_ALT],
12
- [:right_super, Raylib::KEY_RIGHT_SUPER],
13
- [:apostrophe, Raylib::KEY_APOSTROPHE],
14
- [:comma, Raylib::KEY_COMMA],
15
- [:minus, Raylib::KEY_MINUS],
16
- [:period, Raylib::KEY_PERIOD],
17
- [:slash, Raylib::KEY_SLASH],
18
- [:zero, Raylib::KEY_ZERO],
19
- [:one, Raylib::KEY_ONE],
20
- [:two, Raylib::KEY_TWO],
21
- [:three, Raylib::KEY_THREE],
22
- [:four, Raylib::KEY_FOUR],
23
- [:five, Raylib::KEY_FIVE],
24
- [:six, Raylib::KEY_SIX],
25
- [:seven, Raylib::KEY_SEVEN],
26
- [:eight, Raylib::KEY_EIGHT],
27
- [:nine, Raylib::KEY_NINE],
28
- [:semicolon, Raylib::KEY_SEMICOLON],
29
- [:equal, Raylib::KEY_EQUAL],
30
- [:a, Raylib::KEY_A],
31
- [:b, Raylib::KEY_B],
32
- [:c, Raylib::KEY_C],
33
- [:d, Raylib::KEY_D],
34
- [:e, Raylib::KEY_E],
35
- [:f, Raylib::KEY_F],
36
- [:g, Raylib::KEY_G],
37
- [:h, Raylib::KEY_H],
38
- [:i, Raylib::KEY_I],
39
- [:j, Raylib::KEY_J],
40
- [:k, Raylib::KEY_K],
41
- [:l, Raylib::KEY_L],
42
- [:m, Raylib::KEY_M],
43
- [:n, Raylib::KEY_N],
44
- [:o, Raylib::KEY_O],
45
- [:p, Raylib::KEY_P],
46
- [:q, Raylib::KEY_Q],
47
- [:r, Raylib::KEY_R],
48
- [:s, Raylib::KEY_S],
49
- [:t, Raylib::KEY_T],
50
- [:u, Raylib::KEY_U],
51
- [:v, Raylib::KEY_V],
52
- [:w, Raylib::KEY_W],
53
- [:x, Raylib::KEY_X],
54
- [:y, Raylib::KEY_Y],
55
- [:z, Raylib::KEY_Z],
56
- [:left_bracket, Raylib::KEY_LEFT_BRACKET],
57
- [:backslash, Raylib::KEY_BACKSLASH],
58
- [:right_bracket, Raylib::KEY_RIGHT_BRACKET],
59
- [:grave, Raylib::KEY_GRAVE],
60
- [:space, Raylib::KEY_SPACE],
61
- [:escape, Raylib::KEY_ESCAPE],
62
- [:enter, Raylib::KEY_ENTER],
63
- [:tab, Raylib::KEY_TAB],
64
- [:backspace, Raylib::KEY_BACKSPACE],
65
- [:insert, Raylib::KEY_INSERT],
66
- [:delete, Raylib::KEY_DELETE],
67
- [:right, Raylib::KEY_RIGHT],
68
- [:left, Raylib::KEY_LEFT],
69
- [:down, Raylib::KEY_DOWN],
70
- [:up, Raylib::KEY_UP],
71
- [:page_up, Raylib::KEY_PAGE_UP],
72
- [:page_down, Raylib::KEY_PAGE_DOWN],
73
- [:home, Raylib::KEY_HOME],
74
- [:end, Raylib::KEY_END],
75
- [:caps_lock, Raylib::KEY_CAPS_LOCK],
76
- [:scroll_lock, Raylib::KEY_SCROLL_LOCK],
77
- [:num_lock, Raylib::KEY_NUM_LOCK],
78
- [:print_screen, Raylib::KEY_PRINT_SCREEN],
79
- [:pause, Raylib::KEY_PAUSE],
80
- [:f1, Raylib::KEY_F1],
81
- [:f2, Raylib::KEY_F2],
82
- [:f3, Raylib::KEY_F3],
83
- [:f4, Raylib::KEY_F4],
84
- [:f5, Raylib::KEY_F5],
85
- [:f6, Raylib::KEY_F6],
86
- [:f7, Raylib::KEY_F7],
87
- [:f8, Raylib::KEY_F8],
88
- [:f9, Raylib::KEY_F9],
89
- [:f10, Raylib::KEY_F10],
90
- [:f11, Raylib::KEY_F11],
91
- [:f12, Raylib::KEY_F12],
92
- [:left_shift, Raylib::KEY_LEFT_SHIFT],
93
- [:left_control, Raylib::KEY_LEFT_CONTROL],
94
- [:left_alt, Raylib::KEY_LEFT_ALT],
95
- [:left_super, Raylib::KEY_LEFT_SUPER],
96
- [:right_shift, Raylib::KEY_RIGHT_SHIFT],
97
- [:right_control, Raylib::KEY_RIGHT_CONTROL],
98
- [:right_alt, Raylib::KEY_RIGHT_ALT],
99
- [:right_super, Raylib::KEY_RIGHT_SUPER],
100
- [:kb_menu, Raylib::KEY_KB_MENU],
101
- [:kp_0, Raylib::KEY_KP_0],
102
- [:kp_1, Raylib::KEY_KP_1],
103
- [:kp_2, Raylib::KEY_KP_2],
104
- [:kp_3, Raylib::KEY_KP_3],
105
- [:kp_4, Raylib::KEY_KP_4],
106
- [:kp_5, Raylib::KEY_KP_5],
107
- [:kp_6, Raylib::KEY_KP_6],
108
- [:kp_7, Raylib::KEY_KP_7],
109
- [:kp_8, Raylib::KEY_KP_8],
110
- [:kp_9, Raylib::KEY_KP_9],
111
- [:kp_decimal, Raylib::KEY_KP_DECIMAL],
112
- [:kp_divide, Raylib::KEY_KP_DIVIDE],
113
- [:kp_multiply, Raylib::KEY_KP_MULTIPLY],
114
- [:kp_subtract, Raylib::KEY_KP_SUBTRACT],
115
- [:kp_add, Raylib::KEY_KP_ADD],
116
- [:kp_enter, Raylib::KEY_KP_ENTER],
117
- [:kp_equal, Raylib::KEY_KP_EQUAL],
118
- [:back, Raylib::KEY_BACK],
119
- [:menu, Raylib::KEY_MENU],
120
- [:volume_up, Raylib::KEY_VOLUME_UP],
121
- [:volume_down, Raylib::KEY_VOLUME_DOWN]]
122
- end
123
- end
124
-