reflexion 0.6.0 → 0.7.0

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.
Files changed (275) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +37 -6
  3. data/.doc/ext/reflex/capture_event.cpp +1 -1
  4. data/.doc/ext/reflex/chase_constraint.cpp +1 -1
  5. data/.doc/ext/reflex/clipboard.cpp +1 -1
  6. data/.doc/ext/reflex/color_event.cpp +76 -0
  7. data/.doc/ext/reflex/color_picker.cpp +113 -0
  8. data/.doc/ext/reflex/constraint.cpp +1 -1
  9. data/.doc/ext/reflex/contact_event.cpp +1 -1
  10. data/.doc/ext/reflex/control_change_event.cpp +1 -1
  11. data/.doc/ext/reflex/device.cpp +1 -1
  12. data/.doc/ext/reflex/device_event.cpp +1 -1
  13. data/.doc/ext/reflex/draw_event.cpp +1 -1
  14. data/.doc/ext/reflex/ellipse_shape.cpp +1 -1
  15. data/.doc/ext/reflex/event.cpp +1 -1
  16. data/.doc/ext/reflex/file_dialog.cpp +181 -0
  17. data/.doc/ext/reflex/file_event.cpp +103 -0
  18. data/.doc/ext/reflex/filter.cpp +1 -1
  19. data/.doc/ext/reflex/focus_event.cpp +1 -1
  20. data/.doc/ext/reflex/frame_event.cpp +1 -1
  21. data/.doc/ext/reflex/gamepad.cpp +48 -0
  22. data/.doc/ext/reflex/image_view.cpp +1 -1
  23. data/.doc/ext/reflex/key_event.cpp +1 -274
  24. data/.doc/ext/reflex/line_shape.cpp +1 -1
  25. data/.doc/ext/reflex/link_constraint.cpp +1 -1
  26. data/.doc/ext/reflex/menu.cpp +6 -5
  27. data/.doc/ext/reflex/midi.cpp +9 -2
  28. data/.doc/ext/reflex/midi_event.cpp +1 -1
  29. data/.doc/ext/reflex/motion_event.cpp +1 -1
  30. data/.doc/ext/reflex/native.cpp +18 -6
  31. data/.doc/ext/reflex/note_event.cpp +1 -1
  32. data/.doc/ext/reflex/pin.cpp +1 -1
  33. data/.doc/ext/reflex/pointer.cpp +1 -1
  34. data/.doc/ext/reflex/pointer_event.cpp +2 -2
  35. data/.doc/ext/reflex/polygon_shape.cpp +1 -1
  36. data/.doc/ext/reflex/rect_shape.cpp +1 -1
  37. data/.doc/ext/reflex/reflex.cpp +566 -232
  38. data/.doc/ext/reflex/screen.cpp +27 -1
  39. data/.doc/ext/reflex/scroll_event.cpp +1 -1
  40. data/.doc/ext/reflex/selector.cpp +1 -1
  41. data/.doc/ext/reflex/shape.cpp +1 -1
  42. data/.doc/ext/reflex/snap_constraint.cpp +1 -1
  43. data/.doc/ext/reflex/style.cpp +1 -1
  44. data/.doc/ext/reflex/style_length.cpp +1 -1
  45. data/.doc/ext/reflex/text_event.cpp +104 -0
  46. data/.doc/ext/reflex/timer.cpp +1 -1
  47. data/.doc/ext/reflex/timer_event.cpp +1 -1
  48. data/.doc/ext/reflex/update_event.cpp +1 -1
  49. data/.doc/ext/reflex/view.cpp +110 -56
  50. data/.doc/ext/reflex/wheel_constraint.cpp +1 -1
  51. data/.doc/ext/reflex/wheel_event.cpp +1 -1
  52. data/.doc/ext/reflex/window.cpp +226 -17
  53. data/.github/workflows/release-gem.yml +2 -49
  54. data/.github/workflows/tag.yml +5 -28
  55. data/.github/workflows/test.yml +1 -37
  56. data/ChangeLog.md +54 -0
  57. data/Gemfile.lock +13 -8
  58. data/Rakefile +13 -2
  59. data/Reflex.podspec +2 -2
  60. data/VERSION +1 -1
  61. data/ext/reflex/application.cpp +41 -6
  62. data/ext/reflex/capture_event.cpp +1 -1
  63. data/ext/reflex/chase_constraint.cpp +1 -1
  64. data/ext/reflex/clipboard.cpp +1 -1
  65. data/ext/reflex/color_event.cpp +80 -0
  66. data/ext/reflex/color_picker.cpp +121 -0
  67. data/ext/reflex/constraint.cpp +1 -1
  68. data/ext/reflex/contact_event.cpp +1 -1
  69. data/ext/reflex/control_change_event.cpp +1 -1
  70. data/ext/reflex/device.cpp +1 -1
  71. data/ext/reflex/device_event.cpp +1 -1
  72. data/ext/reflex/draw_event.cpp +1 -1
  73. data/ext/reflex/ellipse_shape.cpp +1 -1
  74. data/ext/reflex/event.cpp +1 -1
  75. data/ext/reflex/extconf.rb +4 -2
  76. data/ext/reflex/file_dialog.cpp +194 -0
  77. data/ext/reflex/file_event.cpp +108 -0
  78. data/ext/reflex/filter.cpp +1 -1
  79. data/ext/reflex/focus_event.cpp +1 -1
  80. data/ext/reflex/frame_event.cpp +1 -1
  81. data/ext/reflex/gamepad.cpp +50 -0
  82. data/ext/reflex/image_view.cpp +1 -1
  83. data/ext/reflex/key_event.cpp +1 -275
  84. data/ext/reflex/line_shape.cpp +1 -1
  85. data/ext/reflex/link_constraint.cpp +1 -1
  86. data/ext/reflex/menu.cpp +8 -7
  87. data/ext/reflex/midi.cpp +11 -3
  88. data/ext/reflex/midi_event.cpp +1 -1
  89. data/ext/reflex/motion_event.cpp +1 -1
  90. data/ext/reflex/native.cpp +18 -6
  91. data/ext/reflex/note_event.cpp +1 -1
  92. data/ext/reflex/pin.cpp +1 -1
  93. data/ext/reflex/pointer.cpp +1 -1
  94. data/ext/reflex/pointer_event.cpp +2 -2
  95. data/ext/reflex/polygon_shape.cpp +1 -1
  96. data/ext/reflex/rect_shape.cpp +1 -1
  97. data/ext/reflex/reflex.cpp +568 -232
  98. data/ext/reflex/screen.cpp +31 -2
  99. data/ext/reflex/scroll_event.cpp +1 -1
  100. data/ext/reflex/selector.cpp +1 -1
  101. data/ext/reflex/selector.h +9 -9
  102. data/ext/reflex/shape.cpp +1 -1
  103. data/ext/reflex/snap_constraint.cpp +1 -1
  104. data/ext/reflex/style.cpp +1 -1
  105. data/ext/reflex/style_length.cpp +1 -1
  106. data/ext/reflex/text_event.cpp +111 -0
  107. data/ext/reflex/timer.cpp +1 -1
  108. data/ext/reflex/timer_event.cpp +1 -1
  109. data/ext/reflex/update_event.cpp +1 -1
  110. data/ext/reflex/view.cpp +121 -61
  111. data/ext/reflex/wheel_constraint.cpp +1 -1
  112. data/ext/reflex/wheel_event.cpp +1 -1
  113. data/ext/reflex/window.cpp +256 -25
  114. data/include/reflex/application.h +10 -0
  115. data/include/reflex/color_picker.h +65 -0
  116. data/include/reflex/event.h +178 -88
  117. data/include/reflex/file_dialog.h +73 -0
  118. data/include/reflex/gamepad.h +3 -0
  119. data/include/reflex/menu.h +3 -3
  120. data/include/reflex/midi.h +3 -0
  121. data/include/reflex/reflex.h +2 -0
  122. data/include/reflex/ruby/application.h +6 -1
  123. data/include/reflex/ruby/color_picker.h +89 -0
  124. data/include/reflex/ruby/event.h +62 -29
  125. data/include/reflex/ruby/file_dialog.h +89 -0
  126. data/include/reflex/ruby/gamepad.h +46 -0
  127. data/include/reflex/ruby/reflex.h +3 -0
  128. data/include/reflex/ruby/view.h +92 -44
  129. data/include/reflex/ruby/window.h +60 -1
  130. data/include/reflex/ruby.h +3 -0
  131. data/include/reflex/screen.h +11 -2
  132. data/include/reflex/view.h +28 -16
  133. data/include/reflex/window.h +40 -8
  134. data/include/reflex.h +3 -0
  135. data/lib/reflex/application.rb +5 -5
  136. data/lib/reflex/autoinit.rb +3 -1
  137. data/lib/reflex/button.rb +3 -3
  138. data/lib/reflex/color_event.rb +16 -0
  139. data/lib/reflex/color_picker.rb +45 -0
  140. data/lib/reflex/control_change_event.rb +17 -0
  141. data/lib/reflex/file_dialog.rb +70 -0
  142. data/lib/reflex/file_event.rb +37 -0
  143. data/lib/reflex/helper.rb +58 -7
  144. data/lib/reflex/key_event.rb +9 -4
  145. data/lib/reflex/menu.rb +17 -1
  146. data/lib/reflex/model.rb +19 -19
  147. data/lib/reflex/note_event.rb +1 -1
  148. data/lib/reflex/pointer.rb +14 -3
  149. data/lib/reflex/pointer_event.rb +12 -1
  150. data/lib/reflex/reflex.rb +5 -0
  151. data/lib/reflex/shape.rb +14 -14
  152. data/lib/reflex/style.rb +16 -16
  153. data/lib/reflex/text_event.rb +40 -0
  154. data/lib/reflex/timer.rb +3 -3
  155. data/lib/reflex/view.rb +29 -14
  156. data/lib/reflex/wheel_event.rb +12 -3
  157. data/lib/reflex/window.rb +25 -13
  158. data/lib/reflex.rb +8 -2
  159. data/reflex.gemspec +4 -4
  160. data/samples/ime.rb +100 -0
  161. data/samples/ios/hello/hello.xcodeproj/project.pbxproj +236 -224
  162. data/samples/menu.rb +4 -1
  163. data/samples/model.rb +3 -3
  164. data/samples/test/alert.rb +93 -0
  165. data/samples/test/always_on.rb +76 -0
  166. data/samples/test/app_background.rb +51 -0
  167. data/samples/test/boundary.rb +75 -0
  168. data/samples/test/callback_exception.rb +101 -0
  169. data/samples/test/cancel.rb +53 -0
  170. data/samples/test/color_picker.rb +63 -0
  171. data/samples/test/file_dialog.rb +102 -0
  172. data/samples/window_style.rb +156 -0
  173. data/src/application.cpp +159 -18
  174. data/src/application.h +92 -7
  175. data/src/color_picker.cpp +113 -0
  176. data/src/color_picker.h +36 -0
  177. data/src/event.cpp +410 -252
  178. data/src/event.h +12 -0
  179. data/src/file_dialog.cpp +163 -0
  180. data/src/file_dialog.h +52 -0
  181. data/src/gamepad.cpp +42 -5
  182. data/src/gamepad.h +4 -0
  183. data/src/ios/app_delegate.mm +5 -3
  184. data/src/ios/application.mm +24 -0
  185. data/src/ios/color_picker.mm +19 -0
  186. data/src/ios/file_dialog.mm +21 -0
  187. data/src/ios/gamepad.mm +4 -4
  188. data/src/ios/menu.mm +5 -0
  189. data/src/ios/reflex.mm +8 -0
  190. data/src/ios/screen.mm +26 -0
  191. data/src/ios/view_controller.mm +2 -30
  192. data/src/ios/window.mm +38 -9
  193. data/src/menu.cpp +66 -4
  194. data/src/menu.h +17 -1
  195. data/src/midi.cpp +61 -31
  196. data/src/osx/app_delegate.h +4 -0
  197. data/src/osx/app_delegate.mm +102 -22
  198. data/src/osx/application.mm +88 -6
  199. data/src/osx/color_picker.mm +112 -0
  200. data/src/osx/event.h +10 -0
  201. data/src/osx/event.mm +84 -30
  202. data/src/osx/file_dialog.mm +168 -0
  203. data/src/osx/gamepad.mm +2 -2
  204. data/src/osx/gamepad_hid.mm +1 -1
  205. data/src/osx/menu.mm +177 -33
  206. data/src/osx/native_window.h +16 -2
  207. data/src/osx/native_window.mm +114 -57
  208. data/src/osx/opengl_view.h +2 -1
  209. data/src/osx/opengl_view.mm +184 -43
  210. data/src/osx/reflex.mm +38 -0
  211. data/src/osx/screen.mm +36 -0
  212. data/src/osx/window.mm +106 -24
  213. data/src/pointer.cpp +13 -4
  214. data/src/pointer.h +4 -0
  215. data/src/rays.h +46 -0
  216. data/src/sdl/application.cpp +68 -8
  217. data/src/sdl/color_picker.cpp +18 -0
  218. data/src/sdl/event.cpp +24 -3
  219. data/src/sdl/event.h +12 -0
  220. data/src/sdl/file_dialog.cpp +20 -0
  221. data/src/sdl/gamepad.cpp +3 -7
  222. data/src/sdl/menu.cpp +5 -0
  223. data/src/sdl/reflex.cpp +20 -0
  224. data/src/sdl/screen.cpp +36 -0
  225. data/src/sdl/window.cpp +142 -29
  226. data/src/shape.cpp +15 -10
  227. data/src/view.cpp +287 -198
  228. data/src/view.h +4 -2
  229. data/src/vk.h +416 -0
  230. data/src/win32/application.cpp +162 -12
  231. data/src/win32/application.h +20 -0
  232. data/src/win32/color_picker.cpp +82 -0
  233. data/src/win32/event.cpp +114 -12
  234. data/src/win32/event.h +21 -4
  235. data/src/win32/file_dialog.cpp +226 -0
  236. data/src/win32/gamepad.cpp +9 -2
  237. data/src/win32/menu.cpp +191 -53
  238. data/src/win32/menu.h +9 -1
  239. data/src/win32/opengl.cpp +2 -9
  240. data/src/win32/reflex.cpp +44 -3
  241. data/src/win32/screen.cpp +164 -3
  242. data/src/win32/screen.h +8 -0
  243. data/src/win32/tray.cpp +191 -0
  244. data/src/win32/tray.h +22 -0
  245. data/src/win32/vk.cpp +11 -0
  246. data/src/win32/window.cpp +809 -148
  247. data/src/win32/window.h +6 -0
  248. data/src/window.cpp +718 -185
  249. data/src/window.h +66 -33
  250. data/src/world.cpp +9 -1
  251. data/test/helper.rb +17 -0
  252. data/test/test_application.rb +90 -1
  253. data/test/test_chase_constraint.rb +1 -3
  254. data/test/test_color_event.rb +36 -0
  255. data/test/test_color_picker.rb +62 -0
  256. data/test/test_constraint.rb +2 -4
  257. data/test/test_event.rb +1 -1
  258. data/test/test_file_dialog.rb +48 -0
  259. data/test/test_file_event.rb +43 -0
  260. data/test/test_has_text_preedit.rb +54 -0
  261. data/test/test_key_event.rb +20 -5
  262. data/test/test_link_constraint.rb +1 -3
  263. data/test/test_menu.rb +40 -10
  264. data/test/test_pointer.rb +33 -23
  265. data/test/test_pointer_event.rb +24 -9
  266. data/test/test_reflex.rb +36 -0
  267. data/test/test_screen.rb +24 -2
  268. data/test/test_snap_constraint.rb +1 -3
  269. data/test/test_text_event.rb +54 -0
  270. data/test/test_view.rb +41 -4
  271. data/test/test_wheel_constraint.rb +1 -3
  272. data/test/test_wheel_event.rb +13 -5
  273. data/test/test_window.rb +196 -44
  274. metadata +80 -10
  275. data/.github/workflows/utils.rb +0 -127
data/lib/reflex/reflex.rb CHANGED
@@ -19,6 +19,11 @@ module Reflex
19
19
  Window.new(*args, &block).tap {|w| w.show}
20
20
  end
21
21
 
22
+ def alert(message, title: nil)
23
+ utf8 = -> s {s.to_s.encode Encoding::UTF_8, invalid: :replace, undef: :replace}
24
+ alert! utf8[message], title&.then(&utf8)
25
+ end
26
+
22
27
  self
23
28
 
24
29
  end# ClassMethods
data/lib/reflex/shape.rb CHANGED
@@ -39,20 +39,20 @@ module Reflex
39
39
 
40
40
  private
41
41
 
42
- def on_contact!(*args)
43
- call_contact!(*args)
44
- owner&.delay {on_contact(*args)}# delay to avoid physics world lock
45
- end
46
-
47
- def on_contact_begin!(*args)
48
- call_contact_begin!(*args)
49
- owner&.delay {on_contact_begin(*args)}
50
- end
51
-
52
- def on_contact_end!(*args)
53
- call_contact_end!(*args)
54
- owner&.delay {on_contact_end(*args)}
55
- end
42
+ def on_contact!(*args)
43
+ call_contact!(*args)
44
+ owner&.delay {on_contact(*args)}# delay to avoid physics world lock
45
+ end
46
+
47
+ def on_contact_begin!(*args)
48
+ call_contact_begin!(*args)
49
+ owner&.delay {on_contact_begin(*args)}
50
+ end
51
+
52
+ def on_contact_end!(*args)
53
+ call_contact_end!(*args)
54
+ owner&.delay {on_contact_end(*args)}
55
+ end
56
56
 
57
57
  end# Shape
58
58
 
data/lib/reflex/style.rb CHANGED
@@ -110,23 +110,23 @@ module Reflex
110
110
 
111
111
  private
112
112
 
113
- SYM2FLOW = {
114
- none: FLOW_NONE,
115
- down: FLOW_DOWN,
116
- right: FLOW_RIGHT,
117
- up: FLOW_UP,
118
- left: FLOW_LEFT,
119
- }
120
-
121
- FLOW2SYM = SYM2FLOW.inject({}) {|h, (k, v)| h[v] = k; h}
122
-
123
- def sym2flow(sym)
124
- SYM2FLOW[sym] || FLOW_NONE
125
- end
113
+ SYM2FLOW = {
114
+ none: FLOW_NONE,
115
+ down: FLOW_DOWN,
116
+ right: FLOW_RIGHT,
117
+ up: FLOW_UP,
118
+ left: FLOW_LEFT,
119
+ }
120
+
121
+ FLOW2SYM = SYM2FLOW.inject({}) {|h, (k, v)| h[v] = k; h}
122
+
123
+ def sym2flow(sym)
124
+ SYM2FLOW[sym] || FLOW_NONE
125
+ end
126
126
 
127
- def flow2sym(flow)
128
- FLOW2SYM[flow] || :none
129
- end
127
+ def flow2sym(flow)
128
+ FLOW2SYM[flow] || :none
129
+ end
130
130
 
131
131
  end# Style
132
132
 
@@ -0,0 +1,40 @@
1
+ require 'xot/const_symbol_accessor'
2
+ require 'reflex/ext'
3
+
4
+
5
+ module Reflex
6
+
7
+
8
+ class TextEvent < Event
9
+
10
+ alias get_action action
11
+
12
+ const_symbol_reader :action, **{
13
+ none: ACTION_NONE,
14
+ preedit: PREEDIT,
15
+ commit: COMMIT
16
+ }
17
+
18
+ def preedit?()
19
+ get_action == PREEDIT
20
+ end
21
+
22
+ def commit?()
23
+ get_action == COMMIT
24
+ end
25
+
26
+ def selection()
27
+ offset = selection_offset!
28
+ return nil if offset < 0
29
+ offset...(offset + selection_size!)
30
+ end
31
+
32
+ def inspect()
33
+ "#<Reflex::TextEvent action:%s text:'%s' selection:%s>" %
34
+ [action, text, selection || :nil]
35
+ end
36
+
37
+ end# TextEvent
38
+
39
+
40
+ end# Reflex
data/lib/reflex/timer.rb CHANGED
@@ -17,9 +17,9 @@ module Reflex
17
17
 
18
18
  private
19
19
 
20
- def call_timer_block()
21
- @block.call self if @block
22
- end
20
+ def call_timer_block()
21
+ @block.call self if @block
22
+ end
23
23
 
24
24
  end# Timer
25
25
 
data/lib/reflex/view.rb CHANGED
@@ -162,6 +162,21 @@ module Reflex
162
162
  end
163
163
  end
164
164
 
165
+ # true or false to force, nil to decide by the presence of an on_text handler.
166
+ def text_input=(state)
167
+ @text_input = state
168
+ set_text_input_flag! !!state
169
+ end
170
+
171
+ attr_reader :text_input
172
+
173
+ def accepts_text_input?()
174
+ return false if hidden?
175
+ return text_input_flag! unless @text_input.nil?
176
+ %i[on_text on_text_preedit on_text_commit]
177
+ .any? {|name| method(name).owner != Reflex::View}
178
+ end
179
+
165
180
  def on_contact(e)
166
181
  end
167
182
 
@@ -172,12 +187,12 @@ module Reflex
172
187
  end
173
188
 
174
189
  universal_accessor :shape, :name, :selector,
175
- :frame, :angle, :pivot, :zoom, :capture,
190
+ :frame, :angle, :pivot, :zoom, :capture, :text_input,
176
191
  :density, :friction, :restitution,
177
192
  :linear_velocity, :angular_velocity, :gravity_scale,
178
193
  :gravity, :time_scale,
179
194
  clip: {reader: :clip?},
180
- cache: {reader: :cache?},
195
+ draw_cache: {reader: :draw_cache?},
181
196
  resize_to_fit: {reader: :resize_to_fit?},
182
197
  scroll_to_fit: {reader: :scroll_to_fit?},
183
198
  fix_angle: {reader: :fix_angle?},
@@ -202,20 +217,20 @@ module Reflex
202
217
 
203
218
  private
204
219
 
205
- def on_contact!(*args)
206
- call_contact!(*args)
207
- delay {on_contact(*args)}# delay to avoid physics world lock
208
- end
220
+ def on_contact!(*args)
221
+ call_contact!(*args)
222
+ delay {on_contact(*args)}# delay to avoid physics world lock
223
+ end
209
224
 
210
- def on_contact_begin!(*args)
211
- call_contact_begin!(*args)
212
- delay {on_contact_begin(*args)}
213
- end
225
+ def on_contact_begin!(*args)
226
+ call_contact_begin!(*args)
227
+ delay {on_contact_begin(*args)}
228
+ end
214
229
 
215
- def on_contact_end!(*args)
216
- call_contact_end!(*args)
217
- delay {on_contact_end(*args)}
218
- end
230
+ def on_contact_end!(*args)
231
+ call_contact_end!(*args)
232
+ delay {on_contact_end(*args)}
233
+ end
219
234
 
220
235
  end# View
221
236
 
@@ -11,12 +11,21 @@ module Reflex
11
11
  bit_flag_reader :modifiers, **MODIFIER_SYMBOLS
12
12
  private alias_method :get_modifiers!, :modifiers
13
13
 
14
- def modifiers(locks: true)
15
- locks ? get_modifiers! : (get_modifiers! - LOCK_MODIFIER_SYMBOLS.keys)
14
+ def modifiers(all: false)
15
+ all ? get_modifiers! : (get_modifiers!.select {SHORTCUT_MODIFIER_SYMBOLS.key? _1})
16
16
  end
17
17
 
18
18
  def inspect()
19
- "#<Reflex::WheelEvent x:#{x} y:#{y} z:#{z} dx:#{dx} dy:#{dy} dz:#{dz} mod:#{modifiers}>"
19
+ "#<Reflex::WheelEvent x:%p y:%p z:%p dx:%p dy:%p dz:%p mod:%p>" %
20
+ [
21
+ x.round(2),
22
+ y.round(2),
23
+ z.round(2),
24
+ dx.round(2),
25
+ dy.round(2),
26
+ dz.round(2),
27
+ modifiers(all: true)
28
+ ]
20
29
  end
21
30
 
22
31
  end# WheelEvent
data/lib/reflex/window.rb CHANGED
@@ -21,6 +21,11 @@ module Reflex
21
21
 
22
22
  extend Forwardable
23
23
 
24
+ bit_flag_accessor :titlebar do
25
+ flag :buttons, TITLEBAR_BUTTONS
26
+ flag :background, TITLEBAR_BACKGROUND
27
+ end
28
+
24
29
  bit_flag_accessor :orientations do
25
30
  flag :portrait, ORIENTATION_PORTRAIT
26
31
  flag :landscape, ORIENTATION_LANDSCAPE
@@ -35,11 +40,11 @@ module Reflex
35
40
  :timeout, :delay, :interval,
36
41
  :meter2pixel, :meter, :wall,
37
42
  :zoom=, :zoom,
38
- :clip=, :clip, :clip?,
39
- :cache=, :cache, :cache?,
43
+ :clip=, :clip, :clip?,
44
+ :draw_cache=, :draw_cache, :draw_cache?,
40
45
  :gravity=, :gravity,
41
46
  :time_scale=, :time_scale,
42
- :debug=, :debug, :debug?
47
+ :debug=, :debug, :debug?
43
48
 
44
49
  def_delegators :style,
45
50
  :flow=, :flow,
@@ -68,11 +73,18 @@ module Reflex
68
73
  :friction=, :friction,
69
74
  :restitution=, :restitution
70
75
 
71
- universal_accessor :title, :frame,
72
- closable: {reader: :closable?},
73
- minimizable: {reader: :minimizable?},
74
- resizable: {reader: :resizable?},
75
- fullscreen: {reader: :fullscreen?}
76
+ universal_accessor :title, :frame, :titlebar,
77
+ :pointer_through_alpha, :orientations,
78
+ closable: {reader: :closable?},
79
+ minimizable: {reader: :minimizable?},
80
+ resizable: {reader: :resizable?},
81
+ unlisted: {reader: :unlisted?},
82
+ shadow: {reader: :shadow?},
83
+ transparent: {reader: :transparent?},
84
+ fullscreen: {reader: :fullscreen?},
85
+ always_on_top: {reader: :always_on_top?},
86
+ always_on_bottom: {reader: :always_on_bottom?},
87
+ pointer_through: {reader: :pointer_through?}
76
88
 
77
89
  def initialize(options = nil, &block)
78
90
  super()
@@ -90,11 +102,11 @@ module Reflex
90
102
 
91
103
  private
92
104
 
93
- def call_show_block()
94
- return unless @show_block
95
- Xot::BlockUtil.instance_eval_or_block_call self, &@show_block
96
- @show_block = nil
97
- end
105
+ def call_show_block()
106
+ return unless @show_block
107
+ Xot::BlockUtil.instance_eval_or_block_call self, &@show_block
108
+ @show_block = nil
109
+ end
98
110
 
99
111
  end# Window
100
112
 
data/lib/reflex.rb CHANGED
@@ -31,13 +31,17 @@ require 'reflex/frame_event'
31
31
  require 'reflex/scroll_event'
32
32
  require 'reflex/focus_event'
33
33
  require 'reflex/key_event'
34
+ require 'reflex/text_event'
34
35
  require 'reflex/pointer_event'
35
36
  require 'reflex/wheel_event'
36
- require 'reflex/midi_event'
37
- require 'reflex/note_event'
38
37
  require 'reflex/capture_event'
39
38
  require 'reflex/timer_event'
40
39
  require 'reflex/contact_event'
40
+ require 'reflex/file_event'
41
+ require 'reflex/color_event'
42
+ require 'reflex/midi_event'
43
+ require 'reflex/note_event'
44
+ require 'reflex/control_change_event'
41
45
 
42
46
  require 'reflex/shape'
43
47
  require 'reflex/polygon_shape'
@@ -61,6 +65,8 @@ require 'reflex/view'
61
65
  require 'reflex/menu'
62
66
  require 'reflex/screen'
63
67
  require 'reflex/clipboard'
68
+ require 'reflex/file_dialog'
69
+ require 'reflex/color_picker'
64
70
 
65
71
  require 'reflex/button'
66
72
  require 'reflex/text_view'
data/reflex.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
 
12
12
  ext = Reflex::Extension
13
13
  name = ext.name true
14
- rdocs = glob.call *%w[README .doc/ext/**/*.cpp]
14
+ rdocs = glob.call(*%w[README .doc/ext/**/*.cpp])
15
15
 
16
16
  s.name = "#{name}ion"
17
17
  s.version = ext.version
@@ -25,9 +25,9 @@ Gem::Specification.new do |s|
25
25
  s.platform = Gem::Platform::RUBY
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
- s.add_dependency 'xot', '~> 0.4.0'
29
- s.add_dependency 'rucy', '~> 0.4.0'
30
- s.add_dependency 'rays', '~> 0.4.0'
28
+ s.add_dependency 'xot', '~> 0.5.0'
29
+ s.add_dependency 'rucy', '~> 0.5.0'
30
+ s.add_dependency 'rays', '~> 0.5.0'
31
31
 
32
32
  s.files = `git ls-files`.split $/
33
33
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
data/samples/ime.rb ADDED
@@ -0,0 +1,100 @@
1
+ %w[xot rays reflex]
2
+ .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
+
5
+ require 'reflex'
6
+
7
+ include Reflex
8
+
9
+
10
+ MARGIN = 20
11
+
12
+
13
+ # text input is enabled automatically because the text handlers are defined.
14
+ class InputView < View
15
+
16
+ def initialize(*args, &block)
17
+ @text = @preedit = ''
18
+ @selection = nil
19
+ super
20
+ end
21
+
22
+ def on_text_preedit(e)
23
+ @preedit, @selection = e.text, e.selection
24
+ redraw
25
+ end
26
+
27
+ def on_text_commit(e)
28
+ @text += e.text
29
+ @preedit, @selection = '', nil
30
+ redraw
31
+ end
32
+
33
+ # tells the input method where to put the candidate window.
34
+ def text_input_bounds()
35
+ f = font
36
+ [MARGIN + f.width(@text), MARGIN, f.width(@preedit), f.height]
37
+ end
38
+
39
+ def on_draw(e)
40
+ f, p = font, e.painter
41
+ x, y = MARGIN, MARGIN
42
+
43
+ p.fill 1
44
+ p.text @text, x, y
45
+ x += f.width(@text)
46
+
47
+ unless @preedit.empty?
48
+ # keep the underlines just below the baseline, or the candidate window
49
+ # (which opens at the bottom of text_input_bounds) hides them.
50
+ uy = y + f.ascent + 2
51
+
52
+ p.text @preedit, x, y
53
+ underline p, x, uy, f.width(@preedit)
54
+
55
+ if @selection
56
+ # emphasize the clause being converted.
57
+ sx = x + f.width(@preedit[0...@selection.begin] || '')
58
+ underline p, sx, uy + 3, f.width(@preedit[@selection] || '')
59
+ end
60
+ end
61
+
62
+ p.text "|", caret_x(f, x), y
63
+ end
64
+
65
+ private
66
+
67
+ def font()
68
+ window.painter.font
69
+ end
70
+
71
+ # the caret follows the clause being converted, or the end of the preedit.
72
+ def caret_x(font, preedit_x)
73
+ return preedit_x if @preedit.empty?
74
+
75
+ count = @selection ? @selection.end : @preedit.size
76
+ preedit_x + font.width(@preedit[0...count] || '')
77
+ end
78
+
79
+ def underline(painter, x, y, width)
80
+ painter.push stroke: 1 do
81
+ painter.line x, y, x + width, y
82
+ end
83
+ end
84
+
85
+ end# InputView
86
+
87
+
88
+ win = Window.new do
89
+ set title: 'Reflex IME Sample', frame: [100, 100, 600, 200]
90
+ painter.background 0.1
91
+ painter.font = Font.new nil, 24
92
+
93
+ add input = InputView.new(name: :input)
94
+ input.focus
95
+ end
96
+
97
+
98
+ Reflex.start do
99
+ win.show
100
+ end