reflexion 0.1.21 → 0.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/capture_event.cpp +6 -5
- data/.doc/ext/reflex/contact_event.cpp +18 -16
- data/.doc/ext/reflex/draw_event.cpp +10 -8
- data/.doc/ext/reflex/event.cpp +10 -10
- data/.doc/ext/reflex/focus_event.cpp +18 -17
- data/.doc/ext/reflex/frame_event.cpp +17 -17
- data/.doc/ext/reflex/key_event.cpp +227 -28
- data/.doc/ext/reflex/native.cpp +2 -0
- data/.doc/ext/reflex/pointer.cpp +158 -0
- data/.doc/ext/reflex/pointer_event.cpp +32 -91
- data/.doc/ext/reflex/scroll_event.cpp +14 -17
- data/.doc/ext/reflex/selector.cpp +8 -0
- data/.doc/ext/reflex/timer.cpp +9 -1
- data/.doc/ext/reflex/timer_event.cpp +4 -13
- data/.doc/ext/reflex/update_event.cpp +6 -5
- data/.doc/ext/reflex/view.cpp +57 -0
- data/.doc/ext/reflex/wheel_event.cpp +39 -22
- data/.doc/ext/reflex/window.cpp +24 -0
- data/VERSION +1 -1
- data/ext/reflex/capture_event.cpp +6 -5
- data/ext/reflex/contact_event.cpp +18 -16
- data/ext/reflex/draw_event.cpp +9 -7
- data/ext/reflex/event.cpp +11 -11
- data/ext/reflex/focus_event.cpp +18 -17
- data/ext/reflex/frame_event.cpp +16 -16
- data/ext/reflex/key_event.cpp +228 -28
- data/ext/reflex/native.cpp +2 -0
- data/ext/reflex/pointer.cpp +170 -0
- data/ext/reflex/pointer_event.cpp +31 -96
- data/ext/reflex/scroll_event.cpp +15 -18
- data/ext/reflex/selector.cpp +9 -0
- data/ext/reflex/timer.cpp +15 -6
- data/ext/reflex/timer_event.cpp +9 -19
- data/ext/reflex/update_event.cpp +6 -5
- data/ext/reflex/view.cpp +67 -3
- data/ext/reflex/wheel_event.cpp +40 -21
- data/ext/reflex/window.cpp +30 -3
- data/include/reflex/defs.h +140 -106
- data/include/reflex/event.h +232 -124
- data/include/reflex/pointer.h +107 -0
- data/include/reflex/ruby/pointer.h +41 -0
- data/include/reflex/ruby/view.h +9 -0
- data/include/reflex/ruby/window.h +9 -0
- data/include/reflex/selector.h +1 -1
- data/include/reflex/shape.h +2 -2
- data/include/reflex/view.h +6 -4
- data/include/reflex/window.h +10 -8
- data/lib/reflex/application.rb +3 -3
- data/lib/reflex/autoinit.rb +1 -1
- data/lib/reflex/button.rb +7 -7
- data/lib/reflex/capture_event.rb +7 -7
- data/lib/reflex/contact_event.rb +10 -10
- data/lib/reflex/draw_event.rb +2 -2
- data/lib/reflex/ellipse_shape.rb +2 -2
- data/lib/reflex/focus_event.rb +11 -11
- data/lib/reflex/frame_event.rb +5 -5
- data/lib/reflex/helper.rb +20 -20
- data/lib/reflex/image_view.rb +2 -2
- data/lib/reflex/key_event.rb +12 -12
- data/lib/reflex/model.rb +22 -22
- data/lib/reflex/model_owner.rb +7 -7
- data/lib/reflex/model_view.rb +1 -1
- data/lib/reflex/module.rb +5 -5
- data/lib/reflex/pointer.rb +107 -0
- data/lib/reflex/pointer_event.rb +16 -54
- data/lib/reflex/polygon_shape.rb +2 -2
- data/lib/reflex/reflex.rb +3 -3
- data/lib/reflex/scroll_event.rb +1 -1
- data/lib/reflex/selector.rb +4 -4
- data/lib/reflex/shape.rb +13 -13
- data/lib/reflex/style.rb +11 -11
- data/lib/reflex/style_length.rb +1 -1
- data/lib/reflex/text_view.rb +2 -2
- data/lib/reflex/timer.rb +2 -2
- data/lib/reflex/timer_event.rb +3 -2
- data/lib/reflex/update_event.rb +1 -1
- data/lib/reflex/view.rb +32 -32
- data/lib/reflex/wheel_event.rb +2 -10
- data/lib/reflex/window.rb +6 -6
- data/lib/reflex.rb +1 -0
- data/lib/reflexion.rb +17 -17
- data/reflex.gemspec +5 -5
- data/samples/reflexion/noise.rb +1 -1
- data/samples/tree.rb +1 -1
- data/src/event.cpp +792 -86
- data/src/event.h +47 -0
- data/src/image_view.cpp +2 -2
- data/src/ios/event.h +15 -3
- data/src/ios/event.mm +126 -11
- data/src/ios/view_controller.mm +50 -22
- data/src/ios/window.mm +1 -1
- data/src/osx/event.h +15 -4
- data/src/osx/event.mm +214 -24
- data/src/osx/native_window.mm +84 -17
- data/src/pointer.cpp +203 -0
- data/src/pointer.h +26 -0
- data/src/selector.cpp +1 -1
- data/src/shape.cpp +11 -13
- data/src/shape.h +1 -1
- data/src/view.cpp +205 -118
- data/src/view.h +5 -10
- data/src/window.cpp +334 -104
- data/src/window.h +22 -3
- data/src/world.cpp +6 -4
- data/test/helper.rb +3 -3
- data/test/test_application.rb +1 -1
- data/test/test_capture_event.rb +22 -6
- data/test/test_contact_event.rb +40 -0
- data/test/test_draw_event.rb +35 -0
- data/test/test_event.rb +33 -5
- data/test/test_focus_event.rb +34 -0
- data/test/test_frame_event.rb +38 -0
- data/test/test_has_frame.rb +11 -11
- data/test/test_key_event.rb +33 -0
- data/test/test_pointer.rb +149 -0
- data/test/test_pointer_event.rb +70 -104
- data/test/test_reflex.rb +1 -1
- data/test/test_scroll_event.rb +39 -0
- data/test/test_selector.rb +15 -8
- data/test/test_shape.rb +8 -8
- data/test/test_style.rb +13 -13
- data/test/test_style_length.rb +5 -5
- data/test/test_timer_event.rb +38 -0
- data/test/test_update_event.rb +29 -0
- data/test/test_view.rb +57 -30
- data/test/test_wheel_event.rb +40 -0
- data/test/test_window.rb +29 -27
- metadata +64 -35
data/lib/reflex/module.rb
CHANGED
@@ -8,23 +8,23 @@ module Reflex
|
|
8
8
|
|
9
9
|
module_function
|
10
10
|
|
11
|
-
def name
|
11
|
+
def name()
|
12
12
|
super.split('::')[-2]
|
13
13
|
end
|
14
14
|
|
15
|
-
def version
|
15
|
+
def version()
|
16
16
|
open(root_dir 'VERSION') {|f| f.readline.chomp}
|
17
17
|
end
|
18
18
|
|
19
|
-
def root_dir
|
19
|
+
def root_dir(path = '')
|
20
20
|
File.expand_path "../../#{path}", __dir__
|
21
21
|
end
|
22
22
|
|
23
|
-
def inc_dir
|
23
|
+
def inc_dir()
|
24
24
|
root_dir 'include'
|
25
25
|
end
|
26
26
|
|
27
|
-
def lib_dir
|
27
|
+
def lib_dir()
|
28
28
|
root_dir 'lib'
|
29
29
|
end
|
30
30
|
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'xot/bit_flag_accessor'
|
5
|
+
require 'xot/const_symbol_accessor'
|
6
|
+
require 'reflex/ext'
|
7
|
+
|
8
|
+
|
9
|
+
module Reflex
|
10
|
+
|
11
|
+
|
12
|
+
class Pointer
|
13
|
+
|
14
|
+
include Comparable
|
15
|
+
|
16
|
+
alias types get_type
|
17
|
+
alias action get_action
|
18
|
+
|
19
|
+
bit_flag_reader :types, **{
|
20
|
+
none: TYPE_NONE,
|
21
|
+
mouse: MOUSE,
|
22
|
+
mouse_left: MOUSE_LEFT,
|
23
|
+
mouse_right: MOUSE_RIGHT,
|
24
|
+
mouse_middle: MOUSE_MIDDLE,
|
25
|
+
touch: TOUCH,
|
26
|
+
pen: PEN
|
27
|
+
}
|
28
|
+
|
29
|
+
const_symbol_reader :action, **{
|
30
|
+
none: ACTION_NONE,
|
31
|
+
down: DOWN,
|
32
|
+
up: UP,
|
33
|
+
move: MOVE,
|
34
|
+
cancel: CANCEL,
|
35
|
+
stay: STAY
|
36
|
+
}
|
37
|
+
|
38
|
+
def mouse?()
|
39
|
+
(get_type & MOUSE) != 0
|
40
|
+
end
|
41
|
+
|
42
|
+
def mouse_left?()
|
43
|
+
(get_type & MOUSE_LEFT) != 0
|
44
|
+
end
|
45
|
+
|
46
|
+
def mouse_right?()
|
47
|
+
(get_type & MOUSE_RIGHT) != 0
|
48
|
+
end
|
49
|
+
|
50
|
+
def mouse_middle?()
|
51
|
+
(get_type & MOUSE_MIDDLE) != 0
|
52
|
+
end
|
53
|
+
|
54
|
+
alias left? mouse_left?
|
55
|
+
alias right? mouse_right?
|
56
|
+
alias middle? mouse_middle?
|
57
|
+
|
58
|
+
def touch?()
|
59
|
+
(get_type & TOUCH) != 0
|
60
|
+
end
|
61
|
+
|
62
|
+
def pen?()
|
63
|
+
(get_type & PEN) != 0
|
64
|
+
end
|
65
|
+
|
66
|
+
def down?()
|
67
|
+
get_action == DOWN
|
68
|
+
end
|
69
|
+
|
70
|
+
def up?()
|
71
|
+
get_action == UP
|
72
|
+
end
|
73
|
+
|
74
|
+
def move?()
|
75
|
+
get_action == MOVE
|
76
|
+
end
|
77
|
+
|
78
|
+
def cancel?()
|
79
|
+
get_action == CANCEL
|
80
|
+
end
|
81
|
+
|
82
|
+
def stay?()
|
83
|
+
get_action == STAY
|
84
|
+
end
|
85
|
+
|
86
|
+
alias pos position
|
87
|
+
|
88
|
+
def x()
|
89
|
+
position.x
|
90
|
+
end
|
91
|
+
|
92
|
+
def y()
|
93
|
+
position.y
|
94
|
+
end
|
95
|
+
|
96
|
+
def <=>(o)
|
97
|
+
inspect <=> o.inspect
|
98
|
+
end
|
99
|
+
|
100
|
+
def inspect()
|
101
|
+
"#<Reflex::Pointer id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} click:#{click_count} drag:#{drag?} time:#{time.round 2}>"
|
102
|
+
end
|
103
|
+
|
104
|
+
end# Pointer
|
105
|
+
|
106
|
+
|
107
|
+
end# Reflex
|
data/lib/reflex/pointer_event.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
require '
|
5
|
-
require 'xot/const_symbol_accessor'
|
4
|
+
require 'forwardable'
|
6
5
|
require 'reflex/ext'
|
7
6
|
|
8
7
|
|
@@ -11,65 +10,28 @@ module Reflex
|
|
11
10
|
|
12
11
|
class PointerEvent < Event
|
13
12
|
|
14
|
-
|
13
|
+
extend Forwardable
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
def_delegators :first,
|
16
|
+
:id,
|
17
|
+
:types, :mouse?, :touch?, :pen?,
|
18
|
+
:mouse_left?, :left?, :mouse_right?, :right?, :mouse_middle?, :middle?,
|
19
|
+
:action, :down?, :up?, :move?, :cancel?, :stay?,
|
20
|
+
:position, :pos, :x, :y, :modifiers, :click_count, :drag?,
|
21
|
+
:time, :prev
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
down: TYPE_DOWN,
|
22
|
-
up: TYPE_UP,
|
23
|
-
move: TYPE_MOVE
|
24
|
-
}
|
25
|
-
|
26
|
-
bit_flag_reader :pointer_type, {
|
27
|
-
none: POINTER_NONE,
|
28
|
-
mouse_left: POINTER_MOUSE_LEFT,
|
29
|
-
mouse_right: POINTER_MOUSE_RIGHT,
|
30
|
-
mouse_middle: POINTER_MOUSE_MIDDLE,
|
31
|
-
touch: POINTER_TOUCH,
|
32
|
-
pen: POINTER_PEN
|
33
|
-
}
|
34
|
-
|
35
|
-
def down? ()
|
36
|
-
get_type == TYPE_DOWN
|
37
|
-
end
|
38
|
-
|
39
|
-
def up? ()
|
40
|
-
get_type == TYPE_UP
|
41
|
-
end
|
42
|
-
|
43
|
-
def move? ()
|
44
|
-
get_type == TYPE_MOVE
|
45
|
-
end
|
46
|
-
|
47
|
-
def left? ()
|
48
|
-
(get_pointer_type & POINTER_MOUSE_LEFT) != 0
|
23
|
+
def pointers()
|
24
|
+
to_enum :each
|
49
25
|
end
|
50
26
|
|
51
|
-
def
|
52
|
-
(
|
27
|
+
def inspect()
|
28
|
+
"#<Reflex::PointerEvent id:#{id} #{type} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} click:#{click_count} drag:#{drag?} time:#{time.round 2}>"
|
53
29
|
end
|
54
30
|
|
55
|
-
|
56
|
-
(get_pointer_type & POINTER_MOUSE_MIDDLE) != 0
|
57
|
-
end
|
58
|
-
|
59
|
-
def touch? ()
|
60
|
-
(get_pointer_type & POINTER_TOUCH) != 0
|
61
|
-
end
|
62
|
-
|
63
|
-
def pen? ()
|
64
|
-
(get_pointer_type & POINTER_PEN) != 0
|
65
|
-
end
|
66
|
-
|
67
|
-
def positions ()
|
68
|
-
size.times.map {|i| position i}
|
69
|
-
end
|
31
|
+
private
|
70
32
|
|
71
|
-
def
|
72
|
-
|
33
|
+
def first()
|
34
|
+
self[0]
|
73
35
|
end
|
74
36
|
|
75
37
|
end# PointerEvent
|
data/lib/reflex/polygon_shape.rb
CHANGED
data/lib/reflex/reflex.rb
CHANGED
@@ -10,15 +10,15 @@ module Reflex
|
|
10
10
|
|
11
11
|
extend module ClassMethods
|
12
12
|
|
13
|
-
def start
|
13
|
+
def start(*args, &block)
|
14
14
|
Application.new(*args, &block).start
|
15
15
|
end
|
16
16
|
|
17
|
-
def quit
|
17
|
+
def quit()
|
18
18
|
Application.instance.quit
|
19
19
|
end
|
20
20
|
|
21
|
-
def window
|
21
|
+
def window(*args, &block)
|
22
22
|
Window.new(*args, &block).tap {|w| w.show}
|
23
23
|
end
|
24
24
|
|
data/lib/reflex/scroll_event.rb
CHANGED
data/lib/reflex/selector.rb
CHANGED
@@ -15,22 +15,22 @@ module Reflex
|
|
15
15
|
include Xot::Setter
|
16
16
|
include HasTags
|
17
17
|
|
18
|
-
def self.selector
|
18
|
+
def self.selector(*args)
|
19
19
|
arg0 = args.first
|
20
20
|
arg0.kind_of?(Selector) ? arg0 : self.new(*args)
|
21
21
|
end
|
22
22
|
|
23
|
-
def initialize
|
23
|
+
def initialize(options = nil, &block)
|
24
24
|
super()
|
25
25
|
set options if options
|
26
26
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
27
27
|
end
|
28
28
|
|
29
|
-
def to_s
|
29
|
+
def to_s()
|
30
30
|
"{name:#{name}, tags:[#{tags.to_a.join ', '}]}"
|
31
31
|
end
|
32
32
|
|
33
|
-
def inspect
|
33
|
+
def inspect()
|
34
34
|
"#<#{self.class} #{to_s}>"
|
35
35
|
end
|
36
36
|
|
data/lib/reflex/shape.rb
CHANGED
@@ -24,36 +24,36 @@ module Reflex
|
|
24
24
|
:density, :friction, :restitution, :sensor,
|
25
25
|
:category_bits, :collision_mask
|
26
26
|
|
27
|
-
def initialize
|
27
|
+
def initialize(options = nil, &block)
|
28
28
|
super()
|
29
29
|
set options if options
|
30
30
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
31
31
|
end
|
32
32
|
|
33
|
-
def on_contact
|
33
|
+
def on_contact(e)
|
34
34
|
end
|
35
35
|
|
36
|
-
def on_contact_begin
|
36
|
+
def on_contact_begin(e)
|
37
37
|
end
|
38
38
|
|
39
|
-
def on_contact_end
|
39
|
+
def on_contact_end(e)
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
-
def on_contact!
|
45
|
-
call_contact!
|
46
|
-
owner&.delay {on_contact
|
44
|
+
def on_contact!(*args)
|
45
|
+
call_contact!(*args)
|
46
|
+
owner&.delay {on_contact(*args)}# delay to avoid physics world lock
|
47
47
|
end
|
48
48
|
|
49
|
-
def on_contact_begin!
|
50
|
-
call_contact_begin!
|
51
|
-
owner&.delay {on_contact_begin
|
49
|
+
def on_contact_begin!(*args)
|
50
|
+
call_contact_begin!(*args)
|
51
|
+
owner&.delay {on_contact_begin(*args)}
|
52
52
|
end
|
53
53
|
|
54
|
-
def on_contact_end!
|
55
|
-
call_contact_end!
|
56
|
-
owner&.delay {on_contact_end
|
54
|
+
def on_contact_end!(*args)
|
55
|
+
call_contact_end!(*args)
|
56
|
+
owner&.delay {on_contact_end(*args)}
|
57
57
|
end
|
58
58
|
|
59
59
|
end# Shape
|
data/lib/reflex/style.rb
CHANGED
@@ -16,35 +16,35 @@ module Reflex
|
|
16
16
|
include Xot::Setter
|
17
17
|
include HasTags
|
18
18
|
|
19
|
-
def initialize
|
19
|
+
def initialize(options = nil, &block)
|
20
20
|
super()
|
21
21
|
set options if options
|
22
22
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
23
23
|
end
|
24
24
|
|
25
|
-
def flow=
|
26
|
-
set_flow
|
25
|
+
def flow=(*syms)
|
26
|
+
set_flow(*syms.flatten.map {|sym| sym2flow sym})
|
27
27
|
end
|
28
28
|
|
29
|
-
def flow
|
29
|
+
def flow()
|
30
30
|
get_flow.map {|n| flow2sym n}
|
31
31
|
end
|
32
32
|
|
33
|
-
def foreground=
|
33
|
+
def foreground=(fill, stroke = nil)
|
34
34
|
self.foreground_fill = fill
|
35
35
|
self.foreground_stroke = stroke
|
36
36
|
end
|
37
37
|
|
38
|
-
def foreground
|
38
|
+
def foreground()
|
39
39
|
return foreground_fill, foreground_stroke
|
40
40
|
end
|
41
41
|
|
42
|
-
def background=
|
42
|
+
def background=(fill, stroke = nil)
|
43
43
|
self.background_fill = fill
|
44
44
|
self.background_stroke = stroke
|
45
45
|
end
|
46
46
|
|
47
|
-
def background
|
47
|
+
def background()
|
48
48
|
return background_fill, background_stroke
|
49
49
|
end
|
50
50
|
|
@@ -95,7 +95,7 @@ module Reflex
|
|
95
95
|
alias stroke_width= foreground_stroke_width=
|
96
96
|
alias stroke_width foreground_stroke_width
|
97
97
|
|
98
|
-
def inspect
|
98
|
+
def inspect()
|
99
99
|
attrs = {
|
100
100
|
selector: selector,
|
101
101
|
flow: flow,
|
@@ -123,11 +123,11 @@ module Reflex
|
|
123
123
|
|
124
124
|
FLOW2SYM = SYM2FLOW.inject({}) {|h, (k, v)| h[v] = k; h}
|
125
125
|
|
126
|
-
def sym2flow
|
126
|
+
def sym2flow(sym)
|
127
127
|
SYM2FLOW[sym] || FLOW_NONE
|
128
128
|
end
|
129
129
|
|
130
|
-
def flow2sym
|
130
|
+
def flow2sym(flow)
|
131
131
|
FLOW2SYM[flow] || :none
|
132
132
|
end
|
133
133
|
|
data/lib/reflex/style_length.rb
CHANGED
data/lib/reflex/text_view.rb
CHANGED
@@ -18,14 +18,14 @@ module Reflex
|
|
18
18
|
alias text= data=
|
19
19
|
alias text data
|
20
20
|
|
21
|
-
def content_bounds
|
21
|
+
def content_bounds()
|
22
22
|
s = string
|
23
23
|
return 0, 0 unless s && window
|
24
24
|
font = @font || window.painter.font
|
25
25
|
[font.width(s), font.height].map &:ceil
|
26
26
|
end
|
27
27
|
|
28
|
-
def on_draw
|
28
|
+
def on_draw(e)
|
29
29
|
s = string
|
30
30
|
e.painter.push font: @font do
|
31
31
|
text s
|
data/lib/reflex/timer.rb
CHANGED
@@ -14,13 +14,13 @@ module Reflex
|
|
14
14
|
|
15
15
|
alias view owner
|
16
16
|
|
17
|
-
def inspect
|
17
|
+
def inspect()
|
18
18
|
"#<Reflex::Timer owner:#{owner} id:#{id} interval:#{interval} count:#{count}>"
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def call_timer_block
|
23
|
+
def call_timer_block()
|
24
24
|
@block.call self if @block
|
25
25
|
end
|
26
26
|
|
data/lib/reflex/timer_event.rb
CHANGED
@@ -15,11 +15,12 @@ module Reflex
|
|
15
15
|
def_delegators :timer,
|
16
16
|
:name=, :name,
|
17
17
|
:add_tag, :remove_tag, :each_tag,
|
18
|
-
:selector=, :selector
|
18
|
+
:selector=, :selector,
|
19
|
+
:count=
|
19
20
|
|
20
21
|
alias view owner
|
21
22
|
|
22
|
-
def inspect
|
23
|
+
def inspect()
|
23
24
|
"#<Reflex::TimerEvent owner:#{owner} id:#{id} interval:#{interval} count:#{count}>"
|
24
25
|
end
|
25
26
|
|
data/lib/reflex/update_event.rb
CHANGED
data/lib/reflex/view.rb
CHANGED
@@ -54,84 +54,84 @@ module Reflex
|
|
54
54
|
flag :all, CAPTURE_ALL
|
55
55
|
end
|
56
56
|
|
57
|
-
def initialize
|
57
|
+
def initialize(options = nil, &block)
|
58
58
|
super()
|
59
59
|
set options if options
|
60
60
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
61
61
|
end
|
62
62
|
|
63
|
-
def timeout
|
63
|
+
def timeout(seconds = 0, count: 1, &block)
|
64
64
|
timer = start_timer seconds, count
|
65
65
|
timer.block = block if block
|
66
66
|
timer
|
67
67
|
end
|
68
68
|
|
69
|
-
def interval
|
69
|
+
def interval(seconds = 0, &block)
|
70
70
|
timeout seconds, count: -1, &block
|
71
71
|
end
|
72
72
|
|
73
|
-
def delay
|
73
|
+
def delay(seconds = 0, &block)
|
74
74
|
timeout seconds, &block
|
75
75
|
end
|
76
76
|
|
77
|
-
def remove_self
|
77
|
+
def remove_self()
|
78
78
|
parent.remove self if parent
|
79
79
|
end
|
80
80
|
|
81
|
-
def find_child
|
81
|
+
def find_child(*args)
|
82
82
|
find_children(*args).first
|
83
83
|
end
|
84
84
|
|
85
|
-
def children
|
85
|
+
def children()
|
86
86
|
to_enum :each_child
|
87
87
|
end
|
88
88
|
|
89
|
-
def styles
|
89
|
+
def styles()
|
90
90
|
to_enum :each_style
|
91
91
|
end
|
92
92
|
|
93
|
-
def style
|
93
|
+
def style(*args, &block)
|
94
94
|
s = get_style args.empty? ? nil : Selector.selector(*args)
|
95
95
|
Xot::BlockUtil.instance_eval_or_block_call s, &block if block
|
96
96
|
s
|
97
97
|
end
|
98
98
|
|
99
|
-
def shapes
|
99
|
+
def shapes()
|
100
100
|
to_enum :each_shape
|
101
101
|
end
|
102
102
|
|
103
|
-
def categories
|
103
|
+
def categories()
|
104
104
|
@categories ||= Xot::BitFlag.new(auto: true, all: 1)
|
105
105
|
end
|
106
106
|
|
107
|
-
def category=
|
108
|
-
set_category_bits parent_categories.symbols2bits
|
107
|
+
def category=(*symbols)
|
108
|
+
set_category_bits parent_categories.symbols2bits(*symbols)
|
109
109
|
end
|
110
110
|
|
111
|
-
def category
|
111
|
+
def category()
|
112
112
|
parent_categories.bits2symbols get_category_bits
|
113
113
|
end
|
114
114
|
|
115
|
-
def collision=
|
116
|
-
set_collision_mask parent_categories.symbols2bits
|
115
|
+
def collision=(*categories)
|
116
|
+
set_collision_mask parent_categories.symbols2bits(*categories)
|
117
117
|
end
|
118
118
|
|
119
|
-
def collision
|
119
|
+
def collision()
|
120
120
|
parent_categories.bits2symbols get_collision_mask
|
121
121
|
end
|
122
122
|
|
123
|
-
def capturing?
|
123
|
+
def capturing?(*args)
|
124
124
|
cap = capture
|
125
125
|
args.all? {|type| cap.include? type}
|
126
126
|
end
|
127
127
|
|
128
|
-
def on_contact
|
128
|
+
def on_contact(e)
|
129
129
|
end
|
130
130
|
|
131
|
-
def on_contact_begin
|
131
|
+
def on_contact_begin(e)
|
132
132
|
end
|
133
133
|
|
134
|
-
def on_contact_end
|
134
|
+
def on_contact_end(e)
|
135
135
|
end
|
136
136
|
|
137
137
|
universal_accessor :shape, :name, :selector, :frame, :angle, :zoom, :capture,
|
@@ -157,32 +157,32 @@ module Reflex
|
|
157
157
|
|
158
158
|
alias meter meter2pixel
|
159
159
|
|
160
|
-
def self.has_model
|
160
|
+
def self.has_model()
|
161
161
|
include ModelView
|
162
162
|
end
|
163
163
|
|
164
164
|
protected
|
165
165
|
|
166
|
-
def parent_categories
|
166
|
+
def parent_categories()
|
167
167
|
raise InvalidStateError unless parent
|
168
168
|
parent.categories
|
169
169
|
end
|
170
170
|
|
171
171
|
private
|
172
172
|
|
173
|
-
def on_contact!
|
174
|
-
call_contact!
|
175
|
-
delay {on_contact
|
173
|
+
def on_contact!(*args)
|
174
|
+
call_contact!(*args)
|
175
|
+
delay {on_contact(*args)}# delay to avoid physics world lock
|
176
176
|
end
|
177
177
|
|
178
|
-
def on_contact_begin!
|
179
|
-
call_contact_begin!
|
180
|
-
delay {on_contact_begin
|
178
|
+
def on_contact_begin!(*args)
|
179
|
+
call_contact_begin!(*args)
|
180
|
+
delay {on_contact_begin(*args)}
|
181
181
|
end
|
182
182
|
|
183
|
-
def on_contact_end!
|
184
|
-
call_contact_end!
|
185
|
-
delay {on_contact_end
|
183
|
+
def on_contact_end!(*args)
|
184
|
+
call_contact_end!(*args)
|
185
|
+
delay {on_contact_end(*args)}
|
186
186
|
end
|
187
187
|
|
188
188
|
end# View
|
data/lib/reflex/wheel_event.rb
CHANGED
@@ -9,16 +9,8 @@ module Reflex
|
|
9
9
|
|
10
10
|
class WheelEvent < Event
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def delta ()
|
17
|
-
Point.new dx, dy, dz
|
18
|
-
end
|
19
|
-
|
20
|
-
def inspect ()
|
21
|
-
"#<Reflex::WheelEvent dx:#{dx} dy:#{dy} dz:#{dz} x:#{x} y:#{y} z:#{z} mod:#{modifiers}>"
|
12
|
+
def inspect()
|
13
|
+
"#<Reflex::WheelEvent x:#{x} y:#{y} z:#{z} dx:#{dx} dy:#{dy} dz:#{dz} mod:#{modifiers}>"
|
22
14
|
end
|
23
15
|
|
24
16
|
end# WheelEvent
|
data/lib/reflex/window.rb
CHANGED
@@ -24,7 +24,7 @@ module Reflex
|
|
24
24
|
:timeout, :delay, :interval,
|
25
25
|
:add_child, :add,
|
26
26
|
:remove_child, :remove,
|
27
|
-
:find_child,
|
27
|
+
:children, :find_child, :find, :find_children,
|
28
28
|
:style, :styles, :scroll_to, :scroll_by, :scroll,
|
29
29
|
:meter2pixel, :meter, :wall,
|
30
30
|
:zoom=, :zoom,
|
@@ -51,23 +51,23 @@ module Reflex
|
|
51
51
|
universal_accessor :title, :frame,
|
52
52
|
resizable: {reader: :resizable?}
|
53
53
|
|
54
|
-
def initialize
|
54
|
+
def initialize(options = nil, &block)
|
55
55
|
super()
|
56
56
|
set options if options
|
57
57
|
@show_block = block
|
58
58
|
end
|
59
59
|
|
60
|
-
def paint
|
61
|
-
painter.begin
|
60
|
+
def paint(&block)
|
61
|
+
painter.begin(&block)
|
62
62
|
end
|
63
63
|
|
64
|
-
def self.show
|
64
|
+
def self.show(*args, &block)
|
65
65
|
new(*args, &block).show
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
69
69
|
|
70
|
-
def call_show_block
|
70
|
+
def call_show_block()
|
71
71
|
return unless @show_block
|
72
72
|
Xot::BlockUtil.instance_eval_or_block_call self, &@show_block
|
73
73
|
@show_block = nil
|