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.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/application.cpp +37 -6
- data/.doc/ext/reflex/capture_event.cpp +1 -1
- data/.doc/ext/reflex/chase_constraint.cpp +1 -1
- data/.doc/ext/reflex/clipboard.cpp +1 -1
- data/.doc/ext/reflex/color_event.cpp +76 -0
- data/.doc/ext/reflex/color_picker.cpp +113 -0
- data/.doc/ext/reflex/constraint.cpp +1 -1
- data/.doc/ext/reflex/contact_event.cpp +1 -1
- data/.doc/ext/reflex/control_change_event.cpp +1 -1
- data/.doc/ext/reflex/device.cpp +1 -1
- data/.doc/ext/reflex/device_event.cpp +1 -1
- data/.doc/ext/reflex/draw_event.cpp +1 -1
- data/.doc/ext/reflex/ellipse_shape.cpp +1 -1
- data/.doc/ext/reflex/event.cpp +1 -1
- data/.doc/ext/reflex/file_dialog.cpp +181 -0
- data/.doc/ext/reflex/file_event.cpp +103 -0
- data/.doc/ext/reflex/filter.cpp +1 -1
- data/.doc/ext/reflex/focus_event.cpp +1 -1
- data/.doc/ext/reflex/frame_event.cpp +1 -1
- data/.doc/ext/reflex/gamepad.cpp +48 -0
- data/.doc/ext/reflex/image_view.cpp +1 -1
- data/.doc/ext/reflex/key_event.cpp +1 -274
- data/.doc/ext/reflex/line_shape.cpp +1 -1
- data/.doc/ext/reflex/link_constraint.cpp +1 -1
- data/.doc/ext/reflex/menu.cpp +6 -5
- data/.doc/ext/reflex/midi.cpp +9 -2
- data/.doc/ext/reflex/midi_event.cpp +1 -1
- data/.doc/ext/reflex/motion_event.cpp +1 -1
- data/.doc/ext/reflex/native.cpp +18 -6
- data/.doc/ext/reflex/note_event.cpp +1 -1
- data/.doc/ext/reflex/pin.cpp +1 -1
- data/.doc/ext/reflex/pointer.cpp +1 -1
- data/.doc/ext/reflex/pointer_event.cpp +2 -2
- data/.doc/ext/reflex/polygon_shape.cpp +1 -1
- data/.doc/ext/reflex/rect_shape.cpp +1 -1
- data/.doc/ext/reflex/reflex.cpp +566 -232
- data/.doc/ext/reflex/screen.cpp +27 -1
- data/.doc/ext/reflex/scroll_event.cpp +1 -1
- data/.doc/ext/reflex/selector.cpp +1 -1
- data/.doc/ext/reflex/shape.cpp +1 -1
- data/.doc/ext/reflex/snap_constraint.cpp +1 -1
- data/.doc/ext/reflex/style.cpp +1 -1
- data/.doc/ext/reflex/style_length.cpp +1 -1
- data/.doc/ext/reflex/text_event.cpp +104 -0
- data/.doc/ext/reflex/timer.cpp +1 -1
- data/.doc/ext/reflex/timer_event.cpp +1 -1
- data/.doc/ext/reflex/update_event.cpp +1 -1
- data/.doc/ext/reflex/view.cpp +110 -56
- data/.doc/ext/reflex/wheel_constraint.cpp +1 -1
- data/.doc/ext/reflex/wheel_event.cpp +1 -1
- data/.doc/ext/reflex/window.cpp +226 -17
- data/.github/workflows/release-gem.yml +2 -49
- data/.github/workflows/tag.yml +5 -28
- data/.github/workflows/test.yml +1 -37
- data/ChangeLog.md +54 -0
- data/Gemfile.lock +13 -8
- data/Rakefile +13 -2
- data/Reflex.podspec +2 -2
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +41 -6
- data/ext/reflex/capture_event.cpp +1 -1
- data/ext/reflex/chase_constraint.cpp +1 -1
- data/ext/reflex/clipboard.cpp +1 -1
- data/ext/reflex/color_event.cpp +80 -0
- data/ext/reflex/color_picker.cpp +121 -0
- data/ext/reflex/constraint.cpp +1 -1
- data/ext/reflex/contact_event.cpp +1 -1
- data/ext/reflex/control_change_event.cpp +1 -1
- data/ext/reflex/device.cpp +1 -1
- data/ext/reflex/device_event.cpp +1 -1
- data/ext/reflex/draw_event.cpp +1 -1
- data/ext/reflex/ellipse_shape.cpp +1 -1
- data/ext/reflex/event.cpp +1 -1
- data/ext/reflex/extconf.rb +4 -2
- data/ext/reflex/file_dialog.cpp +194 -0
- data/ext/reflex/file_event.cpp +108 -0
- data/ext/reflex/filter.cpp +1 -1
- data/ext/reflex/focus_event.cpp +1 -1
- data/ext/reflex/frame_event.cpp +1 -1
- data/ext/reflex/gamepad.cpp +50 -0
- data/ext/reflex/image_view.cpp +1 -1
- data/ext/reflex/key_event.cpp +1 -275
- data/ext/reflex/line_shape.cpp +1 -1
- data/ext/reflex/link_constraint.cpp +1 -1
- data/ext/reflex/menu.cpp +8 -7
- data/ext/reflex/midi.cpp +11 -3
- data/ext/reflex/midi_event.cpp +1 -1
- data/ext/reflex/motion_event.cpp +1 -1
- data/ext/reflex/native.cpp +18 -6
- data/ext/reflex/note_event.cpp +1 -1
- data/ext/reflex/pin.cpp +1 -1
- data/ext/reflex/pointer.cpp +1 -1
- data/ext/reflex/pointer_event.cpp +2 -2
- data/ext/reflex/polygon_shape.cpp +1 -1
- data/ext/reflex/rect_shape.cpp +1 -1
- data/ext/reflex/reflex.cpp +568 -232
- data/ext/reflex/screen.cpp +31 -2
- data/ext/reflex/scroll_event.cpp +1 -1
- data/ext/reflex/selector.cpp +1 -1
- data/ext/reflex/selector.h +9 -9
- data/ext/reflex/shape.cpp +1 -1
- data/ext/reflex/snap_constraint.cpp +1 -1
- data/ext/reflex/style.cpp +1 -1
- data/ext/reflex/style_length.cpp +1 -1
- data/ext/reflex/text_event.cpp +111 -0
- data/ext/reflex/timer.cpp +1 -1
- data/ext/reflex/timer_event.cpp +1 -1
- data/ext/reflex/update_event.cpp +1 -1
- data/ext/reflex/view.cpp +121 -61
- data/ext/reflex/wheel_constraint.cpp +1 -1
- data/ext/reflex/wheel_event.cpp +1 -1
- data/ext/reflex/window.cpp +256 -25
- data/include/reflex/application.h +10 -0
- data/include/reflex/color_picker.h +65 -0
- data/include/reflex/event.h +178 -88
- data/include/reflex/file_dialog.h +73 -0
- data/include/reflex/gamepad.h +3 -0
- data/include/reflex/menu.h +3 -3
- data/include/reflex/midi.h +3 -0
- data/include/reflex/reflex.h +2 -0
- data/include/reflex/ruby/application.h +6 -1
- data/include/reflex/ruby/color_picker.h +89 -0
- data/include/reflex/ruby/event.h +62 -29
- data/include/reflex/ruby/file_dialog.h +89 -0
- data/include/reflex/ruby/gamepad.h +46 -0
- data/include/reflex/ruby/reflex.h +3 -0
- data/include/reflex/ruby/view.h +92 -44
- data/include/reflex/ruby/window.h +60 -1
- data/include/reflex/ruby.h +3 -0
- data/include/reflex/screen.h +11 -2
- data/include/reflex/view.h +28 -16
- data/include/reflex/window.h +40 -8
- data/include/reflex.h +3 -0
- data/lib/reflex/application.rb +5 -5
- data/lib/reflex/autoinit.rb +3 -1
- data/lib/reflex/button.rb +3 -3
- data/lib/reflex/color_event.rb +16 -0
- data/lib/reflex/color_picker.rb +45 -0
- data/lib/reflex/control_change_event.rb +17 -0
- data/lib/reflex/file_dialog.rb +70 -0
- data/lib/reflex/file_event.rb +37 -0
- data/lib/reflex/helper.rb +58 -7
- data/lib/reflex/key_event.rb +9 -4
- data/lib/reflex/menu.rb +17 -1
- data/lib/reflex/model.rb +19 -19
- data/lib/reflex/note_event.rb +1 -1
- data/lib/reflex/pointer.rb +14 -3
- data/lib/reflex/pointer_event.rb +12 -1
- data/lib/reflex/reflex.rb +5 -0
- data/lib/reflex/shape.rb +14 -14
- data/lib/reflex/style.rb +16 -16
- data/lib/reflex/text_event.rb +40 -0
- data/lib/reflex/timer.rb +3 -3
- data/lib/reflex/view.rb +29 -14
- data/lib/reflex/wheel_event.rb +12 -3
- data/lib/reflex/window.rb +25 -13
- data/lib/reflex.rb +8 -2
- data/reflex.gemspec +4 -4
- data/samples/ime.rb +100 -0
- data/samples/ios/hello/hello.xcodeproj/project.pbxproj +236 -224
- data/samples/menu.rb +4 -1
- data/samples/model.rb +3 -3
- data/samples/test/alert.rb +93 -0
- data/samples/test/always_on.rb +76 -0
- data/samples/test/app_background.rb +51 -0
- data/samples/test/boundary.rb +75 -0
- data/samples/test/callback_exception.rb +101 -0
- data/samples/test/cancel.rb +53 -0
- data/samples/test/color_picker.rb +63 -0
- data/samples/test/file_dialog.rb +102 -0
- data/samples/window_style.rb +156 -0
- data/src/application.cpp +159 -18
- data/src/application.h +92 -7
- data/src/color_picker.cpp +113 -0
- data/src/color_picker.h +36 -0
- data/src/event.cpp +410 -252
- data/src/event.h +12 -0
- data/src/file_dialog.cpp +163 -0
- data/src/file_dialog.h +52 -0
- data/src/gamepad.cpp +42 -5
- data/src/gamepad.h +4 -0
- data/src/ios/app_delegate.mm +5 -3
- data/src/ios/application.mm +24 -0
- data/src/ios/color_picker.mm +19 -0
- data/src/ios/file_dialog.mm +21 -0
- data/src/ios/gamepad.mm +4 -4
- data/src/ios/menu.mm +5 -0
- data/src/ios/reflex.mm +8 -0
- data/src/ios/screen.mm +26 -0
- data/src/ios/view_controller.mm +2 -30
- data/src/ios/window.mm +38 -9
- data/src/menu.cpp +66 -4
- data/src/menu.h +17 -1
- data/src/midi.cpp +61 -31
- data/src/osx/app_delegate.h +4 -0
- data/src/osx/app_delegate.mm +102 -22
- data/src/osx/application.mm +88 -6
- data/src/osx/color_picker.mm +112 -0
- data/src/osx/event.h +10 -0
- data/src/osx/event.mm +84 -30
- data/src/osx/file_dialog.mm +168 -0
- data/src/osx/gamepad.mm +2 -2
- data/src/osx/gamepad_hid.mm +1 -1
- data/src/osx/menu.mm +177 -33
- data/src/osx/native_window.h +16 -2
- data/src/osx/native_window.mm +114 -57
- data/src/osx/opengl_view.h +2 -1
- data/src/osx/opengl_view.mm +184 -43
- data/src/osx/reflex.mm +38 -0
- data/src/osx/screen.mm +36 -0
- data/src/osx/window.mm +106 -24
- data/src/pointer.cpp +13 -4
- data/src/pointer.h +4 -0
- data/src/rays.h +46 -0
- data/src/sdl/application.cpp +68 -8
- data/src/sdl/color_picker.cpp +18 -0
- data/src/sdl/event.cpp +24 -3
- data/src/sdl/event.h +12 -0
- data/src/sdl/file_dialog.cpp +20 -0
- data/src/sdl/gamepad.cpp +3 -7
- data/src/sdl/menu.cpp +5 -0
- data/src/sdl/reflex.cpp +20 -0
- data/src/sdl/screen.cpp +36 -0
- data/src/sdl/window.cpp +142 -29
- data/src/shape.cpp +15 -10
- data/src/view.cpp +287 -198
- data/src/view.h +4 -2
- data/src/vk.h +416 -0
- data/src/win32/application.cpp +162 -12
- data/src/win32/application.h +20 -0
- data/src/win32/color_picker.cpp +82 -0
- data/src/win32/event.cpp +114 -12
- data/src/win32/event.h +21 -4
- data/src/win32/file_dialog.cpp +226 -0
- data/src/win32/gamepad.cpp +9 -2
- data/src/win32/menu.cpp +191 -53
- data/src/win32/menu.h +9 -1
- data/src/win32/opengl.cpp +2 -9
- data/src/win32/reflex.cpp +44 -3
- data/src/win32/screen.cpp +164 -3
- data/src/win32/screen.h +8 -0
- data/src/win32/tray.cpp +191 -0
- data/src/win32/tray.h +22 -0
- data/src/win32/vk.cpp +11 -0
- data/src/win32/window.cpp +809 -148
- data/src/win32/window.h +6 -0
- data/src/window.cpp +718 -185
- data/src/window.h +66 -33
- data/src/world.cpp +9 -1
- data/test/helper.rb +17 -0
- data/test/test_application.rb +90 -1
- data/test/test_chase_constraint.rb +1 -3
- data/test/test_color_event.rb +36 -0
- data/test/test_color_picker.rb +62 -0
- data/test/test_constraint.rb +2 -4
- data/test/test_event.rb +1 -1
- data/test/test_file_dialog.rb +48 -0
- data/test/test_file_event.rb +43 -0
- data/test/test_has_text_preedit.rb +54 -0
- data/test/test_key_event.rb +20 -5
- data/test/test_link_constraint.rb +1 -3
- data/test/test_menu.rb +40 -10
- data/test/test_pointer.rb +33 -23
- data/test/test_pointer_event.rb +24 -9
- data/test/test_reflex.rb +36 -0
- data/test/test_screen.rb +24 -2
- data/test/test_snap_constraint.rb +1 -3
- data/test/test_text_event.rb +54 -0
- data/test/test_view.rb +41 -4
- data/test/test_wheel_constraint.rb +1 -3
- data/test/test_wheel_event.rb +13 -5
- data/test/test_window.rb +196 -44
- metadata +80 -10
- 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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
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
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
225
|
+
def on_contact_begin!(*args)
|
|
226
|
+
call_contact_begin!(*args)
|
|
227
|
+
delay {on_contact_begin(*args)}
|
|
228
|
+
end
|
|
214
229
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
|
data/lib/reflex/wheel_event.rb
CHANGED
|
@@ -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(
|
|
15
|
-
|
|
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
|
|
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,
|
|
39
|
-
:
|
|
43
|
+
:clip=, :clip, :clip?,
|
|
44
|
+
:draw_cache=, :draw_cache, :draw_cache?,
|
|
40
45
|
:gravity=, :gravity,
|
|
41
46
|
:time_scale=, :time_scale,
|
|
42
|
-
: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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
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.
|
|
29
|
-
s.add_dependency 'rucy', '~> 0.
|
|
30
|
-
s.add_dependency 'rays', '~> 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
|