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/event.h CHANGED
@@ -12,6 +12,18 @@ namespace Reflex
12
12
  {
13
13
 
14
14
 
15
+ enum
16
+ {
17
+
18
+ WHEEL_PIXELS_PER_LINE = 16,
19
+
20
+ WHEEL_LINES_PER_NOTCH = 3,
21
+
22
+ WHEEL_PIXELS_PER_NOTCH = WHEEL_PIXELS_PER_LINE * WHEEL_LINES_PER_NOTCH
23
+
24
+ };
25
+
26
+
15
27
  void DrawEvent_set_view (DrawEvent* pthis, View* view);
16
28
 
17
29
  void DrawEvent_set_painter (DrawEvent* pthis, Painter* painter);
@@ -42,8 +54,7 @@ namespace Reflex
42
54
  void PointerEvent_update_for_child_view (
43
55
  PointerEvent* pthis, const View* view);
44
56
 
45
- void PointerEvent_update_for_capturing_view (
46
- PointerEvent* pthis, const View* view);
57
+ void PointerEvent_to_view_coord (PointerEvent* pthis, const View* view);
47
58
 
48
59
 
49
60
  void WheelEvent_set_position (WheelEvent* pthis, const Point& position);
@@ -0,0 +1,163 @@
1
+ #include "file_dialog.h"
2
+
3
+
4
+ #include "reflex/exception.h"
5
+ #include "application.h"
6
+ #include "window.h"
7
+
8
+
9
+ namespace Reflex
10
+ {
11
+
12
+
13
+ void
14
+ FileDialog_call_file_event (FileDialog* dialog, FileEvent* event)
15
+ {
16
+ if (!dialog)
17
+ argument_error(__FILE__, __LINE__);
18
+ if (!event)
19
+ argument_error(__FILE__, __LINE__);
20
+
21
+ Application_guard([&]()
22
+ {
23
+ dialog->on_file(event);
24
+ if (event->is_blocked()) return;
25
+
26
+ if (dialog->owner())
27
+ Window_call_file_event(dialog->owner(), event);
28
+ });
29
+ }
30
+
31
+ void
32
+ FileDialog_call_cancel_event (FileDialog* dialog, Event* event)
33
+ {
34
+ if (!dialog)
35
+ argument_error(__FILE__, __LINE__);
36
+ if (!event)
37
+ argument_error(__FILE__, __LINE__);
38
+
39
+ Application_guard([&]()
40
+ {
41
+ dialog->on_cancel(event);
42
+ });
43
+ }
44
+
45
+
46
+ FileDialog::FileDialog ()
47
+ {
48
+ }
49
+
50
+ FileDialog::~FileDialog ()
51
+ {
52
+ }
53
+
54
+ void
55
+ FileDialog::open_file (const char* dir)
56
+ {
57
+ FileDialog_show(this, Data::OPEN_FILE, dir, NULL);
58
+ }
59
+
60
+ void
61
+ FileDialog::open_files (const char* dir)
62
+ {
63
+ FileDialog_show(this, Data::OPEN_FILES, dir, NULL);
64
+ }
65
+
66
+ void
67
+ FileDialog::open_directory (const char* dir)
68
+ {
69
+ FileDialog_show(this, Data::OPEN_DIRECTORY, dir, NULL);
70
+ }
71
+
72
+ void
73
+ FileDialog::save_file (const char* dir, const char* name)
74
+ {
75
+ FileDialog_show(this, Data::SAVE_FILE, dir, name);
76
+ }
77
+
78
+ void
79
+ FileDialog::set_owner (Window* window)
80
+ {
81
+ self->owner = window;
82
+ }
83
+
84
+ Window*
85
+ FileDialog::owner ()
86
+ {
87
+ return self->owner;
88
+ }
89
+
90
+ const Window*
91
+ FileDialog::owner () const
92
+ {
93
+ return const_cast<FileDialog*>(this)->owner();
94
+ }
95
+
96
+ void
97
+ FileDialog::set_title (const char* title)
98
+ {
99
+ if (!title)
100
+ argument_error(__FILE__, __LINE__);
101
+
102
+ self->title = title;
103
+ }
104
+
105
+ const char*
106
+ FileDialog::title () const
107
+ {
108
+ return self->title;
109
+ }
110
+
111
+ static String
112
+ to_extension (const String& extension)
113
+ {
114
+ size_t start = extension.find_first_not_of('.');
115
+ if (start == String::npos)
116
+ argument_error(__FILE__, __LINE__);
117
+
118
+ String result = extension.substr(start);
119
+ if (result.find_first_of("*?[]/\\;") != String::npos)
120
+ argument_error(__FILE__, __LINE__);
121
+
122
+ return result;
123
+ }
124
+
125
+ void
126
+ FileDialog::set_extensions (const StringList& extensions)
127
+ {
128
+ StringList list;
129
+ for (const auto& extension : extensions)
130
+ list.emplace_back(to_extension(extension));
131
+
132
+ self->extensions = list;
133
+ }
134
+
135
+ const StringList&
136
+ FileDialog::extensions () const
137
+ {
138
+ return self->extensions;
139
+ }
140
+
141
+ void
142
+ FileDialog::on_file (FileEvent* e)
143
+ {
144
+ }
145
+
146
+ void
147
+ FileDialog::on_cancel (Event* e)
148
+ {
149
+ }
150
+
151
+ FileDialog::operator bool () const
152
+ {
153
+ return true;
154
+ }
155
+
156
+ bool
157
+ FileDialog::operator ! () const
158
+ {
159
+ return !operator bool();
160
+ }
161
+
162
+
163
+ }// Reflex
data/src/file_dialog.h ADDED
@@ -0,0 +1,52 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_SRC_FILE_DIALOG_H__
4
+ #define __REFLEX_SRC_FILE_DIALOG_H__
5
+
6
+
7
+ #include "reflex/file_dialog.h"
8
+ #include "reflex/window.h"
9
+
10
+
11
+ namespace Reflex
12
+ {
13
+
14
+
15
+ struct FileDialog::Data
16
+ {
17
+
18
+ enum Mode
19
+ {
20
+
21
+ OPEN_FILE = 0,
22
+
23
+ OPEN_FILES,
24
+
25
+ OPEN_DIRECTORY,
26
+
27
+ SAVE_FILE
28
+
29
+ };// Mode
30
+
31
+ Xot::WeakRef<Window> owner;
32
+
33
+ String title;
34
+
35
+ StringList extensions;
36
+
37
+ };// FileDialog::Data
38
+
39
+
40
+ void FileDialog_show (
41
+ FileDialog* dialog, FileDialog::Data::Mode mode,
42
+ const char* dir, const char* name);
43
+
44
+ void FileDialog_call_file_event (FileDialog* dialog, FileEvent* event);
45
+
46
+ void FileDialog_call_cancel_event (FileDialog* dialog, Event* event);
47
+
48
+
49
+ }// Reflex
50
+
51
+
52
+ #endif//EOH
data/src/gamepad.cpp CHANGED
@@ -40,6 +40,32 @@ namespace Reflex
40
40
  }
41
41
 
42
42
 
43
+ static bool initialized = false;
44
+
45
+ void
46
+ Gamepad_init (Application* app)
47
+ {
48
+ if (!app)
49
+ argument_error(__FILE__, __LINE__);
50
+
51
+ if (initialized) return;
52
+
53
+ initialized = true;
54
+ Gamepad_init_native(app);
55
+ }
56
+
57
+ void
58
+ Gamepad_fin (Application* app)
59
+ {
60
+ if (!app)
61
+ argument_error(__FILE__, __LINE__);
62
+
63
+ if (!initialized) return;
64
+
65
+ Gamepad_fin_native(app);
66
+ initialized = false;
67
+ }
68
+
43
69
  static Gamepad::List gamepads;
44
70
 
45
71
  void
@@ -50,7 +76,7 @@ namespace Reflex
50
76
 
51
77
  gamepads.emplace_back(gamepad);
52
78
 
53
- Application_call_device_connect(app, gamepad);
79
+ Application_call_device_connect_event(app, gamepad);
54
80
  }
55
81
 
56
82
  void
@@ -61,16 +87,17 @@ namespace Reflex
61
87
  auto it = std::find(gamepads.begin(), gamepads.end(), gamepad);
62
88
  if (it == gamepads.end()) return;
63
89
 
64
- Application_call_device_disconnect(app, gamepad);
65
-
90
+ Gamepad::Ref ref = *it;
66
91
  gamepads.erase(it);
92
+
93
+ Application_call_device_disconnect_event(app, ref);
67
94
  }
68
95
 
69
96
  void
70
97
  Gamepad_remove_all (Application* app)
71
98
  {
72
- for (auto& gamepad : gamepads)
73
- Gamepad_remove(app, gamepad);
99
+ while (!gamepads.empty())
100
+ Gamepad_remove(app, gamepads.back());
74
101
  }
75
102
 
76
103
  Gamepad*
@@ -123,6 +150,16 @@ namespace Reflex
123
150
  return gamepad_create_fun ? gamepad_create_fun() : new Gamepad();
124
151
  }
125
152
 
153
+ void
154
+ enable_gamepad ()
155
+ {
156
+ Application* app_ = app();
157
+ if (!app_)
158
+ invalid_state_error(__FILE__, __LINE__);
159
+
160
+ Gamepad_init(app_);
161
+ }
162
+
126
163
 
127
164
  Gamepad::Gamepad ()
128
165
  {
data/src/gamepad.h CHANGED
@@ -69,6 +69,10 @@ namespace Reflex
69
69
 
70
70
  Gamepad* Gamepad_create ();
71
71
 
72
+ void Gamepad_init_native (Application* app);
73
+
74
+ void Gamepad_fin_native (Application* app);
75
+
72
76
 
73
77
  }// Reflex
74
78
 
@@ -76,7 +76,7 @@
76
76
  return YES;
77
77
 
78
78
  Reflex::Event e;
79
- Application_call_start(application, &e);
79
+ Application_call_start_event(application, &e);
80
80
  started = true;
81
81
 
82
82
  return !e.is_blocked();
@@ -109,7 +109,7 @@
109
109
 
110
110
  Reflex::MotionEvent e(
111
111
  Reflex::Point(motion.gravity.x, -motion.gravity.y, motion.gravity.z));
112
- application->on_motion(&e);
112
+ Application_call_motion_event(application, &e);
113
113
  }
114
114
  ];
115
115
 
@@ -147,12 +147,14 @@
147
147
  if (self->application)
148
148
  {
149
149
  Reflex::Event e;
150
- Application_call_quit(self->application, &e);
150
+ Application_call_quit_event(self->application, &e);
151
151
  if (e.is_blocked())
152
152
  {
153
153
  Reflex::not_implemented_error(
154
154
  __FILE__, __LINE__, "blocking to quit is not supported.");
155
155
  }
156
+
157
+ Application_cleanup(self->application);
156
158
  }
157
159
 
158
160
  [self unbind];
@@ -28,6 +28,35 @@ namespace Reflex
28
28
  return new ApplicationData();
29
29
  }
30
30
 
31
+ String
32
+ Application_get_default_name ()
33
+ {
34
+ NSBundle* bundle = NSBundle.mainBundle;
35
+ NSString* name = [bundle objectForInfoDictionaryKey: @"CFBundleDisplayName"];
36
+ if (!name) name = [bundle objectForInfoDictionaryKey: @"CFBundleName"];
37
+ return name ? name.UTF8String : "";
38
+ }
39
+
40
+ void
41
+ Application_stop (Application* app)
42
+ {
43
+ }
44
+
45
+ void
46
+ Application_set_menu (Application* app, Menu* menu)
47
+ {
48
+ }
49
+
50
+ void
51
+ Application_set_background (Application* app, bool state)
52
+ {
53
+ }
54
+
55
+ void
56
+ Application_set_background_menu (Application* app, Menu* menu)
57
+ {
58
+ }
59
+
31
60
  ApplicationData&
32
61
  Application_get_data (Application* app)
33
62
  {
@@ -0,0 +1,44 @@
1
+ // -*- objc -*-
2
+ #include "reflex/clipboard.h"
3
+
4
+
5
+ #import <UIKit/UIKit.h>
6
+ #include "reflex/exception.h"
7
+
8
+
9
+ namespace Reflex
10
+ {
11
+
12
+
13
+ void
14
+ set_clipboard (const Clipboard& clipboard)
15
+ {
16
+ const char* text = clipboard.text();
17
+ NSString* nstext = nil;
18
+ if (text)
19
+ {
20
+ nstext = [NSString stringWithUTF8String: text];
21
+ if (!nstext)
22
+ argument_error(__FILE__, __LINE__);
23
+ }
24
+
25
+ UIPasteboard* pasteboard = UIPasteboard.generalPasteboard;
26
+ pasteboard.items = @[];
27
+
28
+ if (nstext) pasteboard.string = nstext;
29
+ }
30
+
31
+ Clipboard
32
+ get_clipboard ()
33
+ {
34
+ Clipboard clipboard;
35
+
36
+ NSString* nstext = UIPasteboard.generalPasteboard.string;
37
+ const char* text = nstext ? nstext.UTF8String : NULL;
38
+ if (text) clipboard.set_text(text);
39
+
40
+ return clipboard;
41
+ }
42
+
43
+
44
+ }// Reflex
@@ -0,0 +1,19 @@
1
+ // -*- objc -*-
2
+ #include "../color_picker.h"
3
+
4
+
5
+ #include "reflex/exception.h"
6
+
7
+
8
+ namespace Reflex
9
+ {
10
+
11
+
12
+ void
13
+ ColorPicker_show (ColorPicker* picker, const Color* initial)
14
+ {
15
+ not_implemented_error(__FILE__, __LINE__);
16
+ }
17
+
18
+
19
+ }// Reflex
data/src/ios/event.h CHANGED
@@ -28,9 +28,13 @@ namespace Reflex
28
28
 
29
29
  public:
30
30
 
31
- NativePointerEvent (NSSet* touches, UIEvent* event, UIView* view);
31
+ NativePointerEvent (
32
+ UIView* view, UIHoverGestureRecognizer* recognizer,
33
+ NSSet* touches, UIEvent* event);
32
34
 
33
- NativePointerEvent (UIHoverGestureRecognizer* recognizer, UIView* view);
35
+ NativePointerEvent (
36
+ UIView* view, UIHoverGestureRecognizer* recognizer,
37
+ Pointer::Action action, bool pen);
34
38
 
35
39
  };// NativePointerEvent
36
40
 
data/src/ios/event.mm CHANGED
@@ -79,12 +79,12 @@ namespace Reflex
79
79
  to_modifiers (NSInteger flags)
80
80
  {
81
81
  return
82
- (flags & UIKeyModifierAlphaShift) ? MOD_CAPS : 0 |
83
- (flags & UIKeyModifierShift) ? MOD_SHIFT : 0 |
84
- (flags & UIKeyModifierControl) ? MOD_CONTROL : 0 |
85
- (flags & UIKeyModifierAlternate) ? MOD_ALT : 0 |
86
- (flags & UIKeyModifierCommand) ? MOD_COMMAND : 0 |
87
- (flags & UIKeyModifierNumericPad) ? MOD_NUMPAD : 0;
82
+ (flags & UIKeyModifierAlphaShift ? MOD_CAPS : 0) |
83
+ (flags & UIKeyModifierShift ? MOD_SHIFT : 0) |
84
+ (flags & UIKeyModifierControl ? MOD_CONTROL : 0) |
85
+ (flags & UIKeyModifierAlternate ? MOD_ALT : 0) |
86
+ (flags & UIKeyModifierCommand ? MOD_COMMAND : 0) |
87
+ (flags & UIKeyModifierNumericPad ? MOD_NUMPAD : 0);
88
88
  }
89
89
 
90
90
  static uint
@@ -124,8 +124,11 @@ namespace Reflex
124
124
 
125
125
 
126
126
  NativePointerEvent::NativePointerEvent (
127
- NSSet* touches, UIEvent* event, UIView* view)
127
+ UIView* view, UIHoverGestureRecognizer* recognizer,
128
+ NSSet* touches, UIEvent* event)
128
129
  {
130
+ assert(view && recognizer);
131
+
129
132
  for (UITouch* touch in touches)
130
133
  {
131
134
  Pointer::Action action = get_action(touch);
@@ -141,7 +144,14 @@ namespace Reflex
141
144
  action == Pointer::MOVE,
142
145
  touch.timestamp);
143
146
 
144
- if (!(type & Pointer::MOUSE))
147
+ if ((type & Pointer::PEN))
148
+ {
149
+ // keying the pencil's touch on the hover recognizer unifies it with
150
+ // its hover pointer, so they act as one pointer across the
151
+ // hover <-> touch transitions.
152
+ Pointer_set_system_id(&pointer, (Pointer::ID) recognizer);
153
+ }
154
+ else if (!(type & Pointer::MOUSE))
145
155
  Pointer_set_system_id(&pointer, (Pointer::ID) touch);
146
156
 
147
157
  if (action != Pointer::DOWN)
@@ -156,20 +166,29 @@ namespace Reflex
156
166
  }
157
167
 
158
168
  NativePointerEvent::NativePointerEvent (
159
- UIHoverGestureRecognizer* recognizer, UIView* view)
169
+ UIView* view, UIHoverGestureRecognizer* recognizer,
170
+ Pointer::Action action, bool pen)
160
171
  {
161
- assert(recognizer && view);
172
+ assert(view && recognizer);
173
+
174
+ uint type = pen ? Pointer::PEN : Pointer::MOUSE;
162
175
 
163
176
  Pointer pointer(
164
177
  0,
165
- Pointer::MOUSE,
166
- Pointer::MOVE,
178
+ type,
179
+ action,
167
180
  to_point([recognizer locationInView: view]),
168
181
  get_modifiers(nil),
169
182
  0,
170
183
  false,
171
184
  Xot::time());
172
185
 
186
+ if (type & Pointer::PEN)
187
+ {
188
+ Pointer_set_system_id(&pointer, (Pointer::ID) recognizer);
189
+ Pointer_set_floatable(&pointer, true);
190
+ }
191
+
173
192
  if (pointer)
174
193
  PointerEvent_add_pointer(this, pointer);
175
194
  }
@@ -0,0 +1,21 @@
1
+ // -*- objc -*-
2
+ #include "../file_dialog.h"
3
+
4
+
5
+ #include "reflex/exception.h"
6
+
7
+
8
+ namespace Reflex
9
+ {
10
+
11
+
12
+ void
13
+ FileDialog_show (
14
+ FileDialog* dialog, FileDialog::Data::Mode mode,
15
+ const char* dir, const char* name)
16
+ {
17
+ not_implemented_error(__FILE__, __LINE__);
18
+ }
19
+
20
+
21
+ }// Reflex
data/src/ios/gamepad.mm CHANGED
@@ -258,7 +258,7 @@ namespace Reflex
258
258
 
259
259
  static id disconnect_observer = nil;
260
260
 
261
- void
261
+ static void
262
262
  init_gamepad (Application* app)
263
263
  {
264
264
  if (connect_observer || disconnect_observer)
@@ -280,7 +280,7 @@ namespace Reflex
280
280
  add_gamepad(app, c);
281
281
  }
282
282
 
283
- void
283
+ static void
284
284
  fin_gamepad (Application* app)
285
285
  {
286
286
  if (!connect_observer || !disconnect_observer)
@@ -297,13 +297,13 @@ namespace Reflex
297
297
  }
298
298
 
299
299
  void
300
- Gamepad_init (Application* app)
300
+ Gamepad_init_native (Application* app)
301
301
  {
302
302
  init_gamepad(app);
303
303
  }
304
304
 
305
305
  void
306
- Gamepad_fin (Application* app)
306
+ Gamepad_fin_native (Application* app)
307
307
  {
308
308
  fin_gamepad(app);
309
309
 
data/src/ios/menu.mm ADDED
@@ -0,0 +1,41 @@
1
+ // -*- objc -*-
2
+ #include "../menu.h"
3
+
4
+
5
+ namespace Reflex
6
+ {
7
+
8
+
9
+ Menu::Data*
10
+ Menu_create_data ()
11
+ {
12
+ return new Menu::Data();
13
+ }
14
+
15
+ void
16
+ Menu_validate_shortcut_modifiers (uint modifiers)
17
+ {
18
+ }
19
+
20
+ void
21
+ Menu_update (Menu* menu)
22
+ {
23
+ }
24
+
25
+ void
26
+ Menu_popup (Menu* menu, View* view, coord x, coord y)
27
+ {
28
+ }
29
+
30
+ void
31
+ Menu_child_added (Menu* parent, Menu* child, int index)
32
+ {
33
+ }
34
+
35
+ void
36
+ Menu_child_removed (Menu* parent, Menu* child)
37
+ {
38
+ }
39
+
40
+
41
+ }// Reflex
data/src/ios/reflex.mm CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
 
5
5
  #include "reflex/exception.h"
6
+ #include "../vk.h"
6
7
 
7
8
 
8
9
  namespace Reflex
@@ -36,5 +37,12 @@ namespace Reflex
36
37
  global::pool = nil;
37
38
  }
38
39
 
40
+ void
41
+ alert (const char* message, const char* title)
42
+ {
43
+ // UIAlertController only presents asynchronously
44
+ not_implemented_error(__FILE__, __LINE__);
45
+ }
46
+
39
47
 
40
48
  }// Reflex