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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6b346169398fdc8ace4e949627b34928b44230de71c120dc1b7ec2e3cb377c5
4
- data.tar.gz: 444a5c3581cc74ca1537f2682cd0a1fd3859164f92a773af738a3fea434d579f
3
+ metadata.gz: f2b53ce8769964539f51ad894c33476cecb01095b7b5ce851355cbf7df17a707
4
+ data.tar.gz: 430de1cd6a0ffae61fdf9ca547b15aa61e0065769f94472962047c0205df83ff
5
5
  SHA512:
6
- metadata.gz: a9e491ff21f1ed5532ae4b265c2084f3599a1c242f68cd14974d9ccd2f0b9cc8d39897ff38795183460641aea0b62984fcf3cdcaea1432bc076b0bf4844e12c7
7
- data.tar.gz: 80a602eff3310633a24f4edc99b7191d2d367a1a826e0f591ac4bece88119088551566cf82779f138f757c5fcd8c651efae8be1188b0c77c2131725aa016de87
6
+ metadata.gz: d571179fb72b52671eafceed834e76c7154e205faaff5bb67a95d7d1eb801c86d34f6e5525ade0247db57e48c3019098744dbef7d704630fc4ea7b7577854ab4
7
+ data.tar.gz: '082837551a6b0ff70eda1779c4bde8232efe3108dad48359a05f597023895250faa07812878367229da734075bb0fb1c5c2ab180820b06e4040f7569fdb87306'
data/ast/src/core/input.c CHANGED
@@ -4,134 +4,6 @@
4
4
  #include "input.h"
5
5
  #include <stdio.h>
6
6
 
7
- #define NANO_TO_MILLISECONDS 1000000
8
-
9
- int hoku_input_touch_init(hoku_input_touch** embedded, int max_touch_positions)
10
- {
11
- hoku_input_touch* out = malloc(sizeof(hoku_input_touch));
12
- if (!out) return -1;
13
-
14
- out->last_touch_positions = malloc(sizeof(hoku_dvec2*) * max_touch_positions);
15
- if (out->last_touch_positions == NULL) return -1;
16
-
17
- out->touch_positions = malloc(sizeof(hoku_dvec2*) * max_touch_positions);
18
- if (out->touch_positions == NULL) return -1;
19
-
20
- for (int i=0; i < max_touch_positions; i++)
21
- {
22
- out->last_touch_positions[i] = malloc(sizeof(hoku_dvec2));
23
- if (out->last_touch_positions[i] == NULL) return -1;
24
- out->last_touch_positions[i]->x = -1.0;
25
- out->last_touch_positions[i]->y = -1.0;
26
-
27
-
28
- out->touch_positions[i] = malloc(sizeof(hoku_dvec2));
29
- if (out->touch_positions[i] == NULL) return -1;
30
- out->touch_positions[i]->x = -1.0;
31
- out->touch_positions[i]->y = -1.0;
32
- }
33
-
34
- out->touch_len = max_touch_positions;
35
- out->touch_count = 0;
36
- out->touching_now = false;
37
- out->timer = 0;
38
-
39
- *embedded = out;
40
- return 0;
41
- }
42
-
43
- long hoku_input_touch_duration(hoku_input* input)
44
- {
45
- return input->touch->timer * NANO_TO_MILLISECONDS;
46
- }
47
-
48
- bool hoku_input_touch_tapped(hoku_input* input)
49
- {
50
- if (input->touch->touching_now == false && input->touch->last_touch_positions[0] != NULL) return true;
51
-
52
- return false;
53
- }
54
-
55
- bool hoku_input_touch_swiped(hoku_input* input, float threshold)
56
- {
57
- if (input->touch->touching_now == false)
58
- {
59
- hoku_dvec2* last = input->touch->last_touch_positions[0];
60
- hoku_dvec2* now = input->touch->touch_positions[0];
61
-
62
- if (last->x == -1.0 || last->y == -1.0) return false;
63
- if (last == NULL || now == NULL) return false;
64
-
65
- return (abs((int)(now->x - last->x)) >= threshold || abs((int)(now->y - last->y)) >= threshold);
66
- }
67
-
68
- return false;
69
- }
70
-
71
- bool hoku_input_touch_pinched(hoku_input* input)
72
- {
73
- return false;
74
- }
75
-
76
- bool hoku_input_touch_longtapped(hoku_input* input, int threshold)
77
- {
78
- if (input->touch->touching_now && input->touch->timer > 0l)
79
- {
80
- hoku_dvec2* last = input->touch->last_touch_positions[0];
81
- hoku_dvec2* now = input->touch->touch_positions[0];
82
-
83
- return (abs((int)(now->x - last->x)) < threshold && abs((int)(now->y - last->y)) < threshold);
84
- }
85
-
86
- return false;
87
- }
88
-
89
- void hoku_input_clear_touch(hoku_input* input, int index)
90
- {
91
- input->touch->touching_now = false;
92
- input->touch->timer = 0l;
93
- }
94
-
95
- int hoku_input_record_touch(hoku_input* input, int index, float x, float y)
96
- {
97
- struct timespec start;
98
- if (clock_gettime(CLOCK_MONOTONIC, &start) == -1) return -1;
99
-
100
- if (!(input->touch->touching_now))
101
- {
102
- input->touch->last_touch_positions[index]->x = input->touch->touch_positions[index]->x;
103
- input->touch->last_touch_positions[index]->y = input->touch->touch_positions[index]->y;
104
-
105
- input->touch->timer = start.tv_nsec;
106
- }
107
- else
108
- {
109
- input->touch->timer = start.tv_nsec - input->touch->timer;
110
- }
111
-
112
- input->touch->touch_positions[index]->x = x;
113
- input->touch->touch_positions[index]->y = y;
114
- input->touch->touching_now = true;
115
-
116
- return 0;
117
- }
118
-
119
- int hoku_input_attach_touch(hoku_input* input, int max_touch_count)
120
- {
121
- hoku_input_touch* touch;
122
- if (hoku_input_touch_init(&touch, max_touch_count) == -1) return -1;
123
- input->touch = touch;
124
-
125
- return 0;
126
- }
127
-
128
- void hoku_input_touch_free(hoku_input_touch* embedded)
129
- {
130
- free(embedded->touch_positions);
131
- free(embedded->last_touch_positions);
132
- free(embedded);
133
- }
134
-
135
7
  static int hoku_keycodes[HOKU_KEY_MAX] = {
136
8
  0,39,44,45,46,47,48,49,50,51,52,53,54,55,56,57,59,61,65,66,67,68,69,
137
9
  70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,
@@ -401,12 +273,6 @@ void hoku_input_free(hoku_input* input)
401
273
  {
402
274
  hoku_input_keyboard_free(input->keyboard);
403
275
  hoku_input_mouse_free(input->mouse);
404
-
405
- if (input->touch)
406
- {
407
- hoku_input_touch_free(input->touch);
408
- }
409
-
410
276
  free(input);
411
277
  }
412
278
 
@@ -432,7 +298,6 @@ int hoku_input_init(hoku_input** input)
432
298
  return -1;
433
299
  }
434
300
  init->keyboard = keyboard;
435
- init->touch = NULL;
436
301
 
437
302
  *input = init;
438
303
  return 0;
data/ast/src/core/input.h CHANGED
@@ -4,7 +4,6 @@
4
4
  #include "common.h"
5
5
  #include <stdbool.h>
6
6
  #include <stdlib.h>
7
- #include <time.h>
8
7
 
9
8
  typedef struct HmlInputMouseButton
10
9
  {
@@ -88,44 +87,12 @@ typedef struct HmlInputKeyboard
88
87
  bool collecting;
89
88
  } hoku_input_keyboard;
90
89
 
91
- typedef enum HmlDragDirection {
92
- HOKU_DRAG_UP,
93
- HOKU_DRAG_DOWN,
94
- HOKU_DRAG_LEFT,
95
- HOKU_DRAG_RIGHT
96
- } hoku_drag_direction;
97
-
98
- typedef enum HmlPinchDirection {
99
- HOKU_PINCH_IN,
100
- HOKU_PINCH_OUT
101
- } hoku_pinch_direction;
102
-
103
- typedef struct HmlInputTouch
104
- {
105
- int touch_len;
106
- int touch_count;
107
- bool touching_now;
108
- long timer;
109
- hoku_dvec2** last_touch_positions;
110
- hoku_dvec2** touch_positions;
111
- } hoku_input_touch;
112
-
113
90
  typedef struct HmlInput
114
91
  {
115
92
  hoku_input_keyboard* keyboard;
116
93
  hoku_input_mouse* mouse;
117
- hoku_input_touch* touch;
118
94
  } hoku_input;
119
95
 
120
-
121
- long hoku_input_touch_duration(hoku_input* input);
122
- bool hoku_input_touch_tapped(hoku_input* input);
123
- bool hoku_input_touch_swiped(hoku_input* input, float threshold);
124
- bool hoku_input_touch_longtapped(hoku_input* input, int threshold);
125
- void hoku_input_clear_touch(hoku_input* input, int index);
126
- int hoku_input_record_touch(hoku_input* input, int index, float x, float y);
127
- int hoku_input_attach_touch(hoku_input* input, int max_touch_count);
128
-
129
96
  int hoku_input_keyboard_init(hoku_input_keyboard** keyboard);
130
97
  int hoku_input_mouse_init(hoku_input_mouse** mouse);
131
98
  int hoku_input_init(hoku_input** input);
data/ast/test/hokusai.c CHANGED
@@ -1,7 +1,6 @@
1
1
  #include "greatest.h"
2
2
  #include "parser.c"
3
3
  #include "text.c"
4
- #include "input.c"
5
4
 
6
5
  GREATEST_MAIN_DEFS();
7
6
 
@@ -10,7 +9,6 @@ int main(int argc, char** argv) {
10
9
 
11
10
  RUN_SUITE(hoku_parser_suite);
12
11
  RUN_SUITE(hoku_text_suite);
13
- RUN_SUITE(hoku_input_suite);
14
12
 
15
13
  GREATEST_MAIN_END();
16
14
  }
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-pinephone2'
3
+ s.version = '0.2.6-pinephone3'
4
4
  s.licenses = ['MIT']
5
5
  s.summary = "A Ruby library for writing GUI applications"
6
6
  s.authors = ["skinnyjames"]
@@ -36,7 +36,7 @@ module Demos
36
36
  )
37
37
 
38
38
  def compute_background
39
- index.odd? ? nil : Hokusai::Color.new(255, 255, 255,20)
39
+ index.odd? ? nil : Hokusai::Color.new(44, 44, 44, 20)
40
40
  end
41
41
 
42
42
  def item_image
@@ -107,7 +107,6 @@ module Demos
107
107
 
108
108
  uses(
109
109
  vblock: Hokusai::Blocks::Vblock,
110
- hblock: Hokusai::Blocks::Hblock,
111
110
  text: Hokusai::Blocks::Text,
112
111
  image: Hokusai::Blocks::Image,
113
112
  label: Hokusai::Blocks::Label,
data/ui/examples/forum.rb CHANGED
@@ -175,13 +175,13 @@ module Demos
175
175
  end
176
176
  end
177
177
 
178
- Hokusai::Backends::RaylibBackend.run(Demos::Forum::App) do |config|
178
+ Hokusai::Backends::SDLBackend.run(Demos::Forum::App) do |config|
179
179
  config.after_load do
180
- font = Hokusai::Backends::RaylibBackend::Font.from("#{__dir__}/assets/Inter-Regular.ttf")
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::RaylibBackend::Font.from_ext("#{__dir__}/assets/Delius-Regular.ttf", 160)
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
- # config.window_config_flags = SDL::WINDOW_RESIZABLE | SDL::WINDOW_BORDERLESS
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
@@ -97,24 +97,28 @@ class ShaderTest < Hokusai::Block
97
97
 
98
98
  template <<~EOF
99
99
  [template]
100
- hblock
101
- empty
102
- hblock
103
- hblock
104
- empty
105
- hblock
106
- wrapper
107
- image { :source="addy_png" :width="500" :height="400" }
108
- text { ...textStyle }
109
- circle {
110
- :radius="50.0"
111
- ...circleStyle
112
- }
113
- hblock
114
- empty
115
- hblock
116
- empty
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
@@ -119,22 +119,23 @@ module Demos
119
119
  end
120
120
  end
121
121
 
122
- Hokusai::Backends::RaylibBackend.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"
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
- font = Hokusai::Backends::RaylibBackend::Font.from_ext("#{__dir__}/assets/Delius-Regular.ttf", 160)
129
- Hokusai.fonts.register "dohyeon", font
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
- config.config_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_VSYNC_HINT | Raylib::FLAG_WINDOW_TRANSPARENT
138
- config.window_state_flags = Raylib::FLAG_WINDOW_RESIZABLE | Raylib::FLAG_WINDOW_UNDECORATED | Raylib::FLAG_WINDOW_TRANSPARENT
139
- config.background = Raylib::BLANK
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
@@ -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,15 +246,6 @@ module LibHokusai
245
246
  :collecting, :bool
246
247
  end
247
248
 
248
- class HmlInputTouch < FFI::Struct
249
- layout :touch_len, :int,
250
- :touch_count, :int,
251
- :touching_now, :bool,
252
- :timer, :long,
253
- :last_touch_positions, :pointer,
254
- :touch_positions, :pointer
255
- end
256
-
257
249
  class HmlInputMouseButton < FFI::Struct
258
250
  layout :down, :bool,
259
251
  :up, :bool,
@@ -302,8 +294,7 @@ module LibHokusai
302
294
 
303
295
  class HmlInput < FFI::Struct
304
296
  layout :keyboard, HmlInputKeyboard.ptr,
305
- :mouse, HmlInputMouse.ptr,
306
- :touch, HmlInputTouch.ptr
297
+ :mouse, HmlInputMouse.ptr
307
298
  end
308
299
 
309
300
  def LibHokusai.const_missing( sym )
@@ -318,15 +309,6 @@ module LibHokusai
318
309
  attach_function :hoku_input_set_mouse_position, [HmlInput.by_ref, HmlVec2.by_ref], :void
319
310
  attach_function :hoku_input_mouse_set_scroll, [HmlInput.by_ref, :float], :void
320
311
  attach_function :hoku_input_mouse_set_button, [HmlInput.by_ref, HmlInputMouseButton.by_ref, :int], :void
321
- # touch functions
322
- attach_function :hoku_input_attach_touch, [HmlInput.by_ref, :int], :int
323
- attach_function :hoku_input_record_touch, [HmlInput.by_ref, :int, :float, :float], :int
324
- attach_function :hoku_input_clear_touch, [HmlInput.by_ref, :int], :void
325
-
326
- attach_function :hoku_input_touch_duration, [HmlInput.by_ref], :long
327
- attach_function :hoku_input_touch_tapped, [HmlInput.by_ref], :bool
328
- attach_function :hoku_input_touch_swiped, [HmlInput.by_ref], :bool
329
- attach_function :hoku_input_touch_longtapped, [HmlInput.by_ref], :bool
330
312
 
331
313
  attach_function :hoku_input_is_clicked, [HmlInput.by_ref, HmlRect.by_ref], :bool
332
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
- LibHokusai.hoku_input_keyboard_start(input.raw)
134
+ if !input.keyboard_override
135
+ LibHokusai.hoku_input_keyboard_start(input.raw)
135
136
 
136
- Keys.each do |(hoku_key, raylib_key)|
137
- LibHokusai.hoku_input_keyboard_set_key(input.raw, hoku_key, Raylib.IsKeyDown(raylib_key))
138
- end
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
- LibHokusai.hoku_input_keyboard_stop(input.raw)
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
- font = Hokusai::Backends::SDLBackend::Font.from "#{__dir__}/Monaco.ttf"
25
- Hokusai.fonts.register "default", font
26
- Hokusai.fonts.activate "default"
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