reflexion 0.5.3 → 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 (309) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +56 -7
  3. data/.doc/ext/reflex/capture_event.cpp +1 -1
  4. data/.doc/ext/reflex/chase_constraint.cpp +84 -0
  5. data/.doc/ext/reflex/clipboard.cpp +65 -0
  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 +135 -0
  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 +178 -0
  26. data/.doc/ext/reflex/menu.cpp +303 -0
  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 +40 -10
  31. data/.doc/ext/reflex/note_event.cpp +1 -1
  32. data/.doc/ext/reflex/pin.cpp +156 -0
  33. data/.doc/ext/reflex/pointer.cpp +3 -1
  34. data/.doc/ext/reflex/pointer_event.cpp +3 -3
  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 +606 -237
  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 +5 -5
  41. data/.doc/ext/reflex/shape.cpp +1 -1
  42. data/.doc/ext/reflex/snap_constraint.cpp +125 -0
  43. data/.doc/ext/reflex/style.cpp +1 -1
  44. data/.doc/ext/reflex/style_length.cpp +4 -3
  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 +206 -79
  50. data/.doc/ext/reflex/wheel_constraint.cpp +142 -0
  51. data/.doc/ext/reflex/wheel_event.cpp +1 -1
  52. data/.doc/ext/reflex/window.cpp +282 -31
  53. data/.github/workflows/release-gem.yml +2 -40
  54. data/.github/workflows/tag.yml +5 -28
  55. data/.github/workflows/test.yml +1 -28
  56. data/ChangeLog.md +79 -0
  57. data/Gemfile.lock +13 -8
  58. data/README.md +1 -0
  59. data/Rakefile +13 -2
  60. data/Reflex.podspec +2 -2
  61. data/VERSION +1 -1
  62. data/ext/reflex/application.cpp +62 -7
  63. data/ext/reflex/capture_event.cpp +1 -1
  64. data/ext/reflex/chase_constraint.cpp +89 -0
  65. data/ext/reflex/clipboard.cpp +69 -0
  66. data/ext/reflex/color_event.cpp +80 -0
  67. data/ext/reflex/color_picker.cpp +121 -0
  68. data/ext/reflex/constraint.cpp +146 -0
  69. data/ext/reflex/contact_event.cpp +1 -1
  70. data/ext/reflex/control_change_event.cpp +1 -1
  71. data/ext/reflex/device.cpp +1 -1
  72. data/ext/reflex/device_event.cpp +1 -1
  73. data/ext/reflex/draw_event.cpp +1 -1
  74. data/ext/reflex/ellipse_shape.cpp +1 -1
  75. data/ext/reflex/event.cpp +1 -1
  76. data/ext/reflex/extconf.rb +4 -2
  77. data/ext/reflex/file_dialog.cpp +194 -0
  78. data/ext/reflex/file_event.cpp +108 -0
  79. data/ext/reflex/filter.cpp +1 -1
  80. data/ext/reflex/focus_event.cpp +1 -1
  81. data/ext/reflex/frame_event.cpp +1 -1
  82. data/ext/reflex/gamepad.cpp +50 -0
  83. data/ext/reflex/image_view.cpp +1 -1
  84. data/ext/reflex/key_event.cpp +1 -275
  85. data/ext/reflex/line_shape.cpp +1 -1
  86. data/ext/reflex/link_constraint.cpp +194 -0
  87. data/ext/reflex/menu.cpp +331 -0
  88. data/ext/reflex/midi.cpp +11 -3
  89. data/ext/reflex/midi_event.cpp +1 -1
  90. data/ext/reflex/motion_event.cpp +1 -1
  91. data/ext/reflex/native.cpp +40 -10
  92. data/ext/reflex/note_event.cpp +1 -1
  93. data/ext/reflex/pin.cpp +165 -0
  94. data/ext/reflex/pointer.cpp +3 -1
  95. data/ext/reflex/pointer_event.cpp +3 -3
  96. data/ext/reflex/polygon_shape.cpp +1 -1
  97. data/ext/reflex/rect_shape.cpp +1 -1
  98. data/ext/reflex/reflex.cpp +608 -237
  99. data/ext/reflex/screen.cpp +31 -2
  100. data/ext/reflex/scroll_event.cpp +1 -1
  101. data/ext/reflex/selector.cpp +5 -5
  102. data/ext/reflex/selector.h +10 -10
  103. data/ext/reflex/shape.cpp +1 -1
  104. data/ext/reflex/snap_constraint.cpp +135 -0
  105. data/ext/reflex/style.cpp +1 -1
  106. data/ext/reflex/style_length.cpp +4 -3
  107. data/ext/reflex/text_event.cpp +111 -0
  108. data/ext/reflex/timer.cpp +1 -1
  109. data/ext/reflex/timer_event.cpp +1 -1
  110. data/ext/reflex/update_event.cpp +1 -1
  111. data/ext/reflex/view.cpp +236 -96
  112. data/ext/reflex/wheel_constraint.cpp +154 -0
  113. data/ext/reflex/wheel_event.cpp +1 -1
  114. data/ext/reflex/window.cpp +318 -40
  115. data/include/reflex/application.h +19 -0
  116. data/include/reflex/clipboard.h +53 -0
  117. data/include/reflex/color_picker.h +65 -0
  118. data/include/reflex/constraint.h +275 -0
  119. data/include/reflex/defs.h +204 -195
  120. data/include/reflex/event.h +180 -88
  121. data/include/reflex/file_dialog.h +73 -0
  122. data/include/reflex/gamepad.h +3 -0
  123. data/include/reflex/menu.h +120 -0
  124. data/include/reflex/midi.h +3 -0
  125. data/include/reflex/pin.h +68 -0
  126. data/include/reflex/pointer.h +4 -0
  127. data/include/reflex/reflex.h +2 -0
  128. data/include/reflex/ruby/application.h +6 -1
  129. data/include/reflex/ruby/clipboard.h +23 -0
  130. data/include/reflex/ruby/color_picker.h +89 -0
  131. data/include/reflex/ruby/constraint.h +94 -0
  132. data/include/reflex/ruby/event.h +62 -29
  133. data/include/reflex/ruby/file_dialog.h +89 -0
  134. data/include/reflex/ruby/gamepad.h +46 -0
  135. data/include/reflex/ruby/menu.h +103 -0
  136. data/include/reflex/ruby/pin.h +40 -0
  137. data/include/reflex/ruby/reflex.h +3 -0
  138. data/include/reflex/ruby/view.h +123 -39
  139. data/include/reflex/ruby/window.h +96 -19
  140. data/include/reflex/ruby.h +3 -0
  141. data/include/reflex/screen.h +11 -2
  142. data/include/reflex/view.h +66 -27
  143. data/include/reflex/window.h +57 -12
  144. data/include/reflex.h +8 -0
  145. data/lib/reflex/application.rb +5 -5
  146. data/lib/reflex/autoinit.rb +3 -1
  147. data/lib/reflex/button.rb +3 -3
  148. data/lib/reflex/chase_constraint.rb +15 -0
  149. data/lib/reflex/clipboard.rb +19 -0
  150. data/lib/reflex/color_event.rb +16 -0
  151. data/lib/reflex/color_picker.rb +45 -0
  152. data/lib/reflex/constraint.rb +29 -0
  153. data/lib/reflex/control_change_event.rb +17 -0
  154. data/lib/reflex/extension.rb +1 -1
  155. data/lib/reflex/file_dialog.rb +70 -0
  156. data/lib/reflex/file_event.rb +37 -0
  157. data/lib/reflex/helper.rb +79 -0
  158. data/lib/reflex/key_event.rb +14 -14
  159. data/lib/reflex/link_constraint.rb +31 -0
  160. data/lib/reflex/menu.rb +92 -0
  161. data/lib/reflex/model.rb +19 -19
  162. data/lib/reflex/note_event.rb +1 -1
  163. data/lib/reflex/pin.rb +39 -0
  164. data/lib/reflex/pointer.rb +30 -1
  165. data/lib/reflex/pointer_event.rb +13 -2
  166. data/lib/reflex/reflex.rb +5 -0
  167. data/lib/reflex/shape.rb +14 -14
  168. data/lib/reflex/snap_constraint.rb +28 -0
  169. data/lib/reflex/style.rb +16 -16
  170. data/lib/reflex/text_event.rb +40 -0
  171. data/lib/reflex/timer.rb +3 -3
  172. data/lib/reflex/view.rb +85 -18
  173. data/lib/reflex/wheel_constraint.rb +28 -0
  174. data/lib/reflex/wheel_event.rb +19 -1
  175. data/lib/reflex/window.rb +25 -13
  176. data/lib/reflex.rb +23 -8
  177. data/pod.rake +1 -1
  178. data/reflex.gemspec +4 -4
  179. data/samples/constraint.rb +152 -0
  180. data/samples/ime.rb +100 -0
  181. data/samples/ios/hello/hello.xcodeproj/project.pbxproj +236 -224
  182. data/samples/menu.rb +32 -0
  183. data/samples/model.rb +3 -3
  184. data/samples/test/alert.rb +93 -0
  185. data/samples/test/always_on.rb +76 -0
  186. data/samples/test/app_background.rb +51 -0
  187. data/samples/test/boundary.rb +75 -0
  188. data/samples/test/callback_exception.rb +101 -0
  189. data/samples/test/cancel.rb +53 -0
  190. data/samples/test/color_picker.rb +63 -0
  191. data/samples/test/file_dialog.rb +102 -0
  192. data/samples/window_style.rb +156 -0
  193. data/src/application.cpp +180 -20
  194. data/src/application.h +95 -5
  195. data/src/clipboard.cpp +81 -0
  196. data/src/color_picker.cpp +113 -0
  197. data/src/color_picker.h +36 -0
  198. data/src/constraint.cpp +1662 -0
  199. data/src/constraint.h +64 -0
  200. data/src/event.cpp +416 -252
  201. data/src/event.h +13 -2
  202. data/src/file_dialog.cpp +163 -0
  203. data/src/file_dialog.h +52 -0
  204. data/src/gamepad.cpp +42 -5
  205. data/src/gamepad.h +4 -0
  206. data/src/ios/app_delegate.mm +5 -3
  207. data/src/ios/application.mm +29 -0
  208. data/src/ios/clipboard.mm +44 -0
  209. data/src/ios/color_picker.mm +19 -0
  210. data/src/ios/event.h +6 -2
  211. data/src/ios/event.mm +31 -12
  212. data/src/ios/file_dialog.mm +21 -0
  213. data/src/ios/gamepad.mm +4 -4
  214. data/src/ios/menu.mm +41 -0
  215. data/src/ios/reflex.mm +8 -0
  216. data/src/ios/screen.mm +26 -0
  217. data/src/ios/view_controller.mm +47 -42
  218. data/src/ios/window.mm +44 -9
  219. data/src/menu.cpp +387 -0
  220. data/src/menu.h +81 -0
  221. data/src/midi.cpp +61 -31
  222. data/src/osx/app_delegate.h +4 -0
  223. data/src/osx/app_delegate.mm +168 -139
  224. data/src/osx/application.mm +103 -5
  225. data/src/osx/clipboard.mm +45 -0
  226. data/src/osx/color_picker.mm +112 -0
  227. data/src/osx/event.h +10 -0
  228. data/src/osx/event.mm +114 -30
  229. data/src/osx/file_dialog.mm +168 -0
  230. data/src/osx/gamepad.mm +2 -2
  231. data/src/osx/gamepad_hid.mm +1 -1
  232. data/src/osx/menu.h +25 -0
  233. data/src/osx/menu.mm +516 -0
  234. data/src/osx/native_window.h +16 -2
  235. data/src/osx/native_window.mm +141 -57
  236. data/src/osx/opengl_view.h +2 -1
  237. data/src/osx/opengl_view.mm +229 -37
  238. data/src/osx/reflex.mm +38 -0
  239. data/src/osx/screen.mm +36 -0
  240. data/src/osx/window.mm +117 -24
  241. data/src/pin.cpp +137 -0
  242. data/src/pointer.cpp +36 -16
  243. data/src/pointer.h +10 -0
  244. data/src/rays.h +46 -0
  245. data/src/sdl/application.cpp +73 -8
  246. data/src/sdl/clipboard.cpp +39 -0
  247. data/src/sdl/color_picker.cpp +18 -0
  248. data/src/sdl/event.cpp +44 -6
  249. data/src/sdl/event.h +18 -3
  250. data/src/sdl/file_dialog.cpp +20 -0
  251. data/src/sdl/gamepad.cpp +3 -7
  252. data/src/sdl/menu.cpp +40 -0
  253. data/src/sdl/reflex.cpp +20 -0
  254. data/src/sdl/screen.cpp +36 -0
  255. data/src/sdl/window.cpp +168 -37
  256. data/src/shape.cpp +15 -10
  257. data/src/view.cpp +583 -233
  258. data/src/view.h +22 -4
  259. data/src/vk.h +416 -0
  260. data/src/win32/application.cpp +167 -12
  261. data/src/win32/application.h +20 -0
  262. data/src/win32/clipboard.cpp +210 -0
  263. data/src/win32/color_picker.cpp +82 -0
  264. data/src/win32/event.cpp +123 -11
  265. data/src/win32/event.h +22 -3
  266. data/src/win32/file_dialog.cpp +226 -0
  267. data/src/win32/gamepad.cpp +9 -2
  268. data/src/win32/menu.cpp +490 -0
  269. data/src/win32/menu.h +35 -0
  270. data/src/win32/opengl.cpp +2 -9
  271. data/src/win32/reflex.cpp +44 -3
  272. data/src/win32/screen.cpp +164 -3
  273. data/src/win32/screen.h +8 -0
  274. data/src/win32/tray.cpp +191 -0
  275. data/src/win32/tray.h +22 -0
  276. data/src/win32/vk.cpp +11 -0
  277. data/src/win32/window.cpp +858 -135
  278. data/src/win32/window.h +9 -0
  279. data/src/window.cpp +929 -183
  280. data/src/window.h +77 -33
  281. data/src/world.cpp +86 -15
  282. data/src/world.h +9 -2
  283. data/test/helper.rb +24 -0
  284. data/test/test_application.rb +101 -1
  285. data/test/test_chase_constraint.rb +122 -0
  286. data/test/test_clipboard.rb +54 -0
  287. data/test/test_color_event.rb +36 -0
  288. data/test/test_color_picker.rb +62 -0
  289. data/test/test_constraint.rb +184 -0
  290. data/test/test_event.rb +1 -1
  291. data/test/test_file_dialog.rb +48 -0
  292. data/test/test_file_event.rb +43 -0
  293. data/test/test_has_text_preedit.rb +54 -0
  294. data/test/test_key_event.rb +23 -2
  295. data/test/test_link_constraint.rb +237 -0
  296. data/test/test_menu.rb +237 -0
  297. data/test/test_pin.rb +65 -0
  298. data/test/test_pointer.rb +50 -26
  299. data/test/test_pointer_event.rb +25 -10
  300. data/test/test_reflex.rb +36 -0
  301. data/test/test_screen.rb +24 -2
  302. data/test/test_snap_constraint.rb +140 -0
  303. data/test/test_text_event.rb +54 -0
  304. data/test/test_view.rb +152 -25
  305. data/test/test_wheel_constraint.rb +125 -0
  306. data/test/test_wheel_event.rb +24 -10
  307. data/test/test_window.rb +205 -43
  308. metadata +154 -10
  309. data/.github/workflows/utils.rb +0 -127
data/src/ios/screen.mm CHANGED
@@ -37,6 +37,15 @@ namespace Reflex
37
37
  {
38
38
  }
39
39
 
40
+ String
41
+ Screen::name () const
42
+ {
43
+ if (!*this)
44
+ invalid_state_error(__FILE__, __LINE__);
45
+
46
+ return "";
47
+ }
48
+
40
49
  Bounds
41
50
  Screen::frame () const
42
51
  {
@@ -47,6 +56,15 @@ namespace Reflex
47
56
  return Bounds(b.origin.x, b.origin.y, b.size.width, b.size.height);
48
57
  }
49
58
 
59
+ float
60
+ Screen::pixel_density () const
61
+ {
62
+ if (!*this)
63
+ invalid_state_error(__FILE__, __LINE__);
64
+
65
+ return self->screen.nativeScale;
66
+ }
67
+
50
68
  Screen::operator bool () const
51
69
  {
52
70
  return self->screen;
@@ -58,5 +76,13 @@ namespace Reflex
58
76
  return !operator bool();
59
77
  }
60
78
 
79
+ Screen::List
80
+ Screen::all ()
81
+ {
82
+ Screen s;
83
+ Screen_initialize(&s, UIScreen.mainScreen);
84
+ return {s};
85
+ }
86
+
61
87
 
62
88
  }// Reflex
@@ -151,6 +151,7 @@ ReflexViewController_get_show_fun ()
151
151
  int update_count;
152
152
  int touching_count;
153
153
  int repeating_key_count;
154
+ bool pen;
154
155
  }
155
156
 
156
157
  - (id) init
@@ -163,6 +164,7 @@ ReflexViewController_get_show_fun ()
163
164
  update_count = 0;
164
165
  touching_count = 0;
165
166
  repeating_key_count = 0;
167
+ pen = false;
166
168
 
167
169
  return self;
168
170
  }
@@ -426,11 +428,8 @@ ReflexViewController_get_show_fun ()
426
428
 
427
429
  Window_call_update_event(win);
428
430
 
429
- if (win->self->redraw)
430
- {
431
+ if (Xot::check_and_remove_flag(&win->self->flags, Reflex::Window::Data::REDRAW))
431
432
  [self.reflexView setNeedsDisplay];
432
- win->self->redraw = false;
433
- }
434
433
  }
435
434
 
436
435
  - (void) glkView: (GLKView*) view drawInRect: (CGRect) rect
@@ -461,32 +460,7 @@ ReflexViewController_get_show_fun ()
461
460
 
462
461
  - (void) viewDidResize
463
462
  {
464
- Reflex::Window* win = self.window;
465
- if (!win) return;
466
-
467
- Rays::Bounds b = win->frame();
468
- Rays::Point dpos = b.position() - win->self->prev_position;
469
- Rays::Point dsize = b.size() - win->self->prev_size;
470
- win->self->prev_position = b.position();
471
- win->self->prev_size = b.size();
472
-
473
- if (dpos == 0 && dsize == 0) return;
474
-
475
- Reflex::FrameEvent e(b, dpos.x, dpos.y, 0, dsize.x, dsize.y, 0);
476
- if (dpos != 0) win->on_move(&e);
477
- if (dsize != 0)
478
- {
479
- Rays::Bounds b = win->frame();
480
- b.move_to(0, 0);
481
-
482
- if (win->painter())
483
- win->painter()->canvas(b, win->painter()->pixel_density());
484
-
485
- if (win->root())
486
- View_set_frame(win->root(), b);
487
-
488
- win->on_resize(&e);
489
- }
463
+ Window_call_frame_event(self.window);
490
464
  }
491
465
 
492
466
  #if 0
@@ -529,10 +503,12 @@ ReflexViewController_get_show_fun ()
529
503
  Reflex::Window* win = self.window;
530
504
  if (!win) return;
531
505
 
532
- Reflex::NativePointerEvent e(touches, event, self.reflexView);
506
+ Reflex::NativePointerEvent e(self.reflexView, self.hoverRecognizer, touches, event);
507
+
508
+ int count = (int) e.size();
533
509
  Window_call_pointer_event(win, &e);
534
510
 
535
- touching_count += e.size();
511
+ touching_count += count;
536
512
  }
537
513
 
538
514
  - (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event
@@ -540,12 +516,19 @@ ReflexViewController_get_show_fun ()
540
516
  Reflex::Window* win = self.window;
541
517
  if (!win) return;
542
518
 
543
- Reflex::NativePointerEvent e(touches, event, self.reflexView);
519
+ Reflex::NativePointerEvent e(self.reflexView, self.hoverRecognizer, touches, event);
520
+
521
+ int count = (int) e.size();
544
522
  Window_call_pointer_event(win, &e);
545
523
 
546
- touching_count -= e.size();
524
+ touching_count -= count;
547
525
  if (touching_count == 0)
548
- win->self->prev_pointers.clear();
526
+ {
527
+ win->self->prev_pointers.remove_if([](const Reflex::Pointer& p)
528
+ {
529
+ return !Reflex::Pointer_is_floatable(p);
530
+ });
531
+ }
549
532
  else if (touching_count < 0)
550
533
  Reflex::invalid_state_error(__FILE__, __LINE__);
551
534
  }
@@ -560,7 +543,7 @@ ReflexViewController_get_show_fun ()
560
543
  Reflex::Window* win = self.window;
561
544
  if (!win) return;
562
545
 
563
- Reflex::NativePointerEvent e(touches, event, self.reflexView);
546
+ Reflex::NativePointerEvent e(self.reflexView, self.hoverRecognizer, touches, event);
564
547
  Window_call_pointer_event(win, &e);
565
548
  }
566
549
 
@@ -570,16 +553,38 @@ ReflexViewController_get_show_fun ()
570
553
  Reflex::Window* win = self.window;
571
554
  if (!win) return;
572
555
 
573
- if (touching_count > 0) return;
556
+ if (recognizer.state == UIGestureRecognizerStateBegan)
557
+ pen = false;
574
558
 
575
- if (
576
- recognizer.state != UIGestureRecognizerStateBegan &&
577
- recognizer.state != UIGestureRecognizerStateChanged)
559
+ Reflex::Pointer::Action action;
560
+ switch (recognizer.state)
578
561
  {
579
- return;
562
+ case UIGestureRecognizerStateBegan:
563
+ case UIGestureRecognizerStateChanged:
564
+ // suppress hover moves while a touch is active
565
+ if (touching_count > 0) return;
566
+ action = recognizer.state == UIGestureRecognizerStateBegan
567
+ ? Reflex::Pointer::ENTER
568
+ : Reflex::Pointer::MOVE;
569
+ if (@available(iOS 16.1, *))
570
+ {
571
+ // zOffset drops to 0 on the Ended state, so latch the pen-ness
572
+ // here and reuse it until the leave.
573
+ if (recognizer.zOffset > 0) pen = true;
574
+ }
575
+ break;
576
+
577
+ case UIGestureRecognizerStateEnded:
578
+ case UIGestureRecognizerStateCancelled:
579
+ case UIGestureRecognizerStateFailed:
580
+ action = Reflex::Pointer::LEAVE;
581
+ break;
582
+
583
+ default:
584
+ return;
580
585
  }
581
586
 
582
- Reflex::NativePointerEvent e(recognizer, self.reflexView);
587
+ Reflex::NativePointerEvent e(self.reflexView, recognizer, action, pen);
583
588
  if (e.size() > 0)
584
589
  Window_call_pointer_event(win, &e);
585
590
  }
data/src/ios/window.mm CHANGED
@@ -142,6 +142,12 @@ namespace Reflex
142
142
  return Bounds(b.origin.x, b.origin.y, b.size.width, b.size.height);
143
143
  }
144
144
 
145
+ void
146
+ Window_set_menu (Window* window, Menu* menu)
147
+ {
148
+ not_implemented_error(__FILE__, __LINE__);
149
+ }
150
+
145
151
  static UIScreen*
146
152
  get_screen (const Window& window)
147
153
  {
@@ -218,8 +224,8 @@ namespace Reflex
218
224
  }
219
225
  }
220
226
 
221
- void
222
- Window_set_orientation_mask (UIViewController* vc, UIInterfaceOrientationMask mask)
227
+ static void
228
+ set_orientation_mask (UIViewController* vc, UIInterfaceOrientationMask mask)
223
229
  {
224
230
  if (mask == g_orientation_mask) return;
225
231
 
@@ -227,12 +233,6 @@ namespace Reflex
227
233
  update_orientation_mask(vc, mask);
228
234
  }
229
235
 
230
- UIInterfaceOrientationMask
231
- Window_get_orientation_mask ()
232
- {
233
- return g_orientation_mask;
234
- }
235
-
236
236
  static UIInterfaceOrientationMask
237
237
  flags_to_orientation_mask (uint flags)
238
238
  {
@@ -260,7 +260,31 @@ namespace Reflex
260
260
  if (Xot::has_flag(flags, Window::FLAG_MINIMIZABLE))
261
261
  argument_error(__FILE__, __LINE__, "FLAG_MINIMIZABLE is not supported");
262
262
 
263
- Window_set_orientation_mask(
263
+ if (Xot::has_flag(flags, Window::FLAG_TITLEBAR_BUTTONS))
264
+ argument_error(__FILE__, __LINE__, "FLAG_TITLEBAR_BUTTONS is not supported");
265
+
266
+ if (Xot::has_flag(flags, Window::FLAG_TITLEBAR_BACKGROUND))
267
+ argument_error(__FILE__, __LINE__, "FLAG_TITLEBAR_BACKGROUND is not supported");
268
+
269
+ if (Xot::has_flag(flags, Window::FLAG_UNLISTED))
270
+ argument_error(__FILE__, __LINE__, "FLAG_UNLISTED is not supported");
271
+
272
+ if (Xot::has_flag(flags, Window::FLAG_SHADOW))
273
+ argument_error(__FILE__, __LINE__, "FLAG_SHADOW is not supported");
274
+
275
+ if (Xot::has_flag(flags, Window::FLAG_TRANSPARENT))
276
+ argument_error(__FILE__, __LINE__, "FLAG_TRANSPARENT is not supported");
277
+
278
+ if (Xot::has_flag(flags, Window::FLAG_ALWAYS_ON_TOP))
279
+ argument_error(__FILE__, __LINE__, "FLAG_ALWAYS_ON_TOP is not supported");
280
+
281
+ if (Xot::has_flag(flags, Window::FLAG_ALWAYS_ON_BOTTOM))
282
+ argument_error(__FILE__, __LINE__, "FLAG_ALWAYS_ON_BOTTOM is not supported");
283
+
284
+ if (Xot::has_flag(flags, Window::FLAG_POINTER_THROUGH))
285
+ argument_error(__FILE__, __LINE__, "FLAG_POINTER_THROUGH is not supported");
286
+
287
+ set_orientation_mask(
264
288
  get_vc(window),
265
289
  flags_to_orientation_mask(flags & (Window::FLAG_PORTRAIT | Window::FLAG_LANDSCAPE)));
266
290
  }
@@ -271,5 +295,16 @@ namespace Reflex
271
295
  return UIScreen.mainScreen.nativeScale;
272
296
  }
273
297
 
298
+ void
299
+ Window_set_pointer_through (Window* window, bool through)
300
+ {
301
+ }
302
+
303
+ bool
304
+ Window_is_pointer_over_and_uncovered (Point* position, const Window& window)
305
+ {
306
+ return false;
307
+ }
308
+
274
309
 
275
310
  }// Reflex
data/src/menu.cpp ADDED
@@ -0,0 +1,387 @@
1
+ #include "menu.h"
2
+
3
+
4
+ #include <algorithm>
5
+ #include <rays/point.h>
6
+ #include "reflex/exception.h"
7
+ #include "application.h"
8
+ #include "view.h"
9
+ #include "window.h"
10
+
11
+
12
+ namespace Reflex
13
+ {
14
+
15
+
16
+ void
17
+ Menu_cancel_active_pointers_for_popup (View* view)
18
+ {
19
+ Window* window = view ? view->window() : Window_get_active();
20
+ if (!window) return;
21
+
22
+ // popup runs a modal event loop that swallows every event until the
23
+ // menu is dismissed, so pointers being pressed would never see their
24
+ // up; canceling them first keeps every pointer stream closed.
25
+ Window_cancel_active_pointers(window);
26
+ }
27
+
28
+ void
29
+ Menu_call_click_event (Menu* menu, Event* event)
30
+ {
31
+ Application_guard([&]()
32
+ {
33
+ menu->on_click(event);
34
+ });
35
+ }
36
+
37
+ void
38
+ Menu_call_show_event (Menu* menu, Event* event)
39
+ {
40
+ Application_guard([&]()
41
+ {
42
+ menu->on_show(event);
43
+ });
44
+ }
45
+
46
+ void
47
+ Menu_call_hide_event (Menu* menu, Event* event)
48
+ {
49
+ Application_guard([&]()
50
+ {
51
+ menu->on_hide(event);
52
+ });
53
+ }
54
+
55
+ void
56
+ Menu_call_open_submenu_event (Menu* menu, Event* event)
57
+ {
58
+ Application_guard([&]()
59
+ {
60
+ menu->on_open_submenu(event);
61
+ });
62
+ }
63
+
64
+ void
65
+ Menu_call_close_submenu_event (Menu* menu, Event* event)
66
+ {
67
+ Application_guard([&]()
68
+ {
69
+ menu->on_close_submenu(event);
70
+ });
71
+ }
72
+
73
+
74
+ Menu::Data::Data ()
75
+ {
76
+ }
77
+
78
+ Menu::Data::~Data ()
79
+ {
80
+ }
81
+
82
+
83
+ Menu::Menu (const char* label)
84
+ : self(Menu_create_data())
85
+ {
86
+ if (label) set_label(label);
87
+ }
88
+
89
+ Menu::~Menu ()
90
+ {
91
+ }
92
+
93
+ void
94
+ Menu::popup (coord x, coord y)
95
+ {
96
+ Menu_popup(this, NULL, x, y);
97
+ }
98
+
99
+ void
100
+ Menu::popup (const Point& position)
101
+ {
102
+ Menu_popup(this, NULL, position.x, position.y);
103
+ }
104
+
105
+ void
106
+ Menu::popup (View* view, coord x, coord y)
107
+ {
108
+ Menu_popup(this, view, x, y);
109
+ }
110
+
111
+ void
112
+ Menu::popup (View* view, const Point& position)
113
+ {
114
+ Menu_popup(this, view, position.x, position.y);
115
+ }
116
+
117
+ void
118
+ Menu::add_child (Menu* child, int index)
119
+ {
120
+ if (!child)
121
+ argument_error(__FILE__, __LINE__);
122
+
123
+ if (child->parent() == this)
124
+ return;
125
+
126
+ if (child->parent())
127
+ argument_error(__FILE__, __LINE__);
128
+
129
+ ChildList* children = self->children();
130
+ if (index < 0 || (int) children->size() < index)
131
+ index = (int) children->size();
132
+
133
+ children->insert(children->begin() + (size_t) index, child);
134
+
135
+ child->self->parent.reset(this);
136
+
137
+ Menu_child_added(this, child, index);
138
+ }
139
+
140
+ void
141
+ Menu::remove_child (Menu* child)
142
+ {
143
+ if (!child || child->parent() != this)
144
+ return;
145
+
146
+ auto* children = self->pchildren.get();
147
+ if (!children) return;
148
+
149
+ auto it = std::find(children->begin(), children->end(), child);
150
+ if (it == children->end()) return;
151
+
152
+ children->erase(it);
153
+ if (children->empty())
154
+ self->pchildren.reset();
155
+
156
+ child->self->parent.reset();
157
+
158
+ Menu_child_removed(this, child);
159
+ }
160
+
161
+ void
162
+ Menu::clear_children ()
163
+ {
164
+ while (self->pchildren && !self->pchildren->empty())
165
+ remove_child(self->pchildren->back().get());
166
+ }
167
+
168
+ static void
169
+ find_all_children (
170
+ Menu::ChildList* result, const Menu* menu, const Selector& selector,
171
+ bool recursive)
172
+ {
173
+ auto* children = menu->self->pchildren.get();
174
+ if (!children) return;
175
+
176
+ for (auto& child : *children)
177
+ {
178
+ if (!child)
179
+ invalid_state_error(__FILE__, __LINE__);
180
+
181
+ if (child->selector().contains(selector))
182
+ result->push_back(child);
183
+
184
+ if (recursive)
185
+ find_all_children(result, child.get(), selector, true);
186
+ }
187
+ }
188
+
189
+ Menu::ChildList
190
+ Menu::find_children (const Selector& selector, bool recursive) const
191
+ {
192
+ ChildList result;
193
+ find_all_children(&result, this, selector, recursive);
194
+ return result;
195
+ }
196
+
197
+ static bool
198
+ is_separator_label (const char* s)
199
+ {
200
+ if (!s || !*s) return false;
201
+ for (const char* p = s; *p; ++p)
202
+ if (*p != '-') return false;
203
+ return true;
204
+ }
205
+
206
+ void
207
+ Menu::set_label (const char* label)
208
+ {
209
+ if (!label) label = "";
210
+ if (label == self->label)
211
+ return;
212
+
213
+ self->label = label;
214
+ self->separator = is_separator_label(label);
215
+
216
+ Menu_update(this);
217
+ }
218
+
219
+ const char*
220
+ Menu::label () const
221
+ {
222
+ return self->label.c_str();
223
+ }
224
+
225
+ void
226
+ Menu::enable (bool state)
227
+ {
228
+ if (state == self->enabled)
229
+ return;
230
+
231
+ self->enabled = state;
232
+ Menu_update(this);
233
+ }
234
+
235
+ bool
236
+ Menu::is_enabled () const
237
+ {
238
+ return self->enabled;
239
+ }
240
+
241
+ void
242
+ Menu::check (bool state)
243
+ {
244
+ if (state == self->checked)
245
+ return;
246
+
247
+ self->checked = state;
248
+ Menu_update(this);
249
+ }
250
+
251
+ bool
252
+ Menu::is_checked () const
253
+ {
254
+ return self->checked;
255
+ }
256
+
257
+ void
258
+ Menu::set_shortcut (KeyCode key, uint modifiers)
259
+ {
260
+ Menu_validate_shortcut_modifiers(modifiers);
261
+
262
+ if (key == self->key && modifiers == self->modifiers)
263
+ return;
264
+
265
+ self->key = key;
266
+ self->modifiers = modifiers;
267
+ Menu_update(this);
268
+ }
269
+
270
+ KeyCode
271
+ Menu::shortcut_key () const
272
+ {
273
+ return self->key;
274
+ }
275
+
276
+ uint
277
+ Menu::shortcut_modifiers () const
278
+ {
279
+ return self->modifiers;
280
+ }
281
+
282
+ void
283
+ Menu::set_image (const Image& image)
284
+ {
285
+ self->image = image;
286
+ Menu_update(this);
287
+ }
288
+
289
+ const Image&
290
+ Menu::image () const
291
+ {
292
+ return self->image;
293
+ }
294
+
295
+ bool
296
+ Menu::is_separator () const
297
+ {
298
+ return self->separator;
299
+ }
300
+
301
+ Menu*
302
+ Menu::parent ()
303
+ {
304
+ return self->parent;
305
+ }
306
+
307
+ const Menu*
308
+ Menu::parent () const
309
+ {
310
+ return const_cast<Menu*>(this)->parent();
311
+ }
312
+
313
+ size_t
314
+ Menu::size () const
315
+ {
316
+ return self->pchildren ? self->pchildren->size() : 0;
317
+ }
318
+
319
+ bool
320
+ Menu::empty () const
321
+ {
322
+ return self->pchildren ? self->pchildren->empty() : true;
323
+ }
324
+
325
+ static Menu::ChildList empty_children;
326
+
327
+ Menu::iterator
328
+ Menu::begin ()
329
+ {
330
+ if (!self->pchildren) return empty_children.begin();
331
+ return self->pchildren->begin();
332
+ }
333
+
334
+ Menu::const_iterator
335
+ Menu::begin () const
336
+ {
337
+ if (!self->pchildren) return empty_children.begin();
338
+ return self->pchildren->begin();
339
+ }
340
+
341
+ Menu::iterator
342
+ Menu::end ()
343
+ {
344
+ if (!self->pchildren) return empty_children.end();
345
+ return self->pchildren->end();
346
+ }
347
+
348
+ Menu::const_iterator
349
+ Menu::end () const
350
+ {
351
+ if (!self->pchildren) return empty_children.end();
352
+ return self->pchildren->end();
353
+ }
354
+
355
+ void
356
+ Menu::on_show (Event* e)
357
+ {
358
+ }
359
+
360
+ void
361
+ Menu::on_hide (Event* e)
362
+ {
363
+ }
364
+
365
+ void
366
+ Menu::on_open_submenu (Event* e)
367
+ {
368
+ }
369
+
370
+ void
371
+ Menu::on_close_submenu (Event* e)
372
+ {
373
+ }
374
+
375
+ void
376
+ Menu::on_click (Event* e)
377
+ {
378
+ }
379
+
380
+ SelectorPtr*
381
+ Menu::get_selector_ptr ()
382
+ {
383
+ return &self->pselector;
384
+ }
385
+
386
+
387
+ }// Reflex