reflexion 0.1.21 → 0.1.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/contact_event.cpp +6 -6
  3. data/.doc/ext/reflex/focus_event.cpp +6 -6
  4. data/.doc/ext/reflex/key_event.cpp +210 -12
  5. data/.doc/ext/reflex/pointer_event.cpp +21 -21
  6. data/VERSION +1 -1
  7. data/ext/reflex/contact_event.cpp +6 -6
  8. data/ext/reflex/focus_event.cpp +6 -6
  9. data/ext/reflex/key_event.cpp +211 -12
  10. data/ext/reflex/pointer_event.cpp +21 -21
  11. data/include/reflex/defs.h +143 -91
  12. data/lib/reflex/application.rb +3 -3
  13. data/lib/reflex/autoinit.rb +1 -1
  14. data/lib/reflex/button.rb +7 -7
  15. data/lib/reflex/capture_event.rb +7 -7
  16. data/lib/reflex/contact_event.rb +4 -4
  17. data/lib/reflex/draw_event.rb +2 -2
  18. data/lib/reflex/ellipse_shape.rb +2 -2
  19. data/lib/reflex/focus_event.rb +4 -4
  20. data/lib/reflex/frame_event.rb +5 -5
  21. data/lib/reflex/helper.rb +20 -20
  22. data/lib/reflex/image_view.rb +2 -2
  23. data/lib/reflex/key_event.rb +5 -5
  24. data/lib/reflex/model.rb +22 -22
  25. data/lib/reflex/model_owner.rb +7 -7
  26. data/lib/reflex/model_view.rb +1 -1
  27. data/lib/reflex/module.rb +5 -5
  28. data/lib/reflex/pointer_event.rb +12 -12
  29. data/lib/reflex/polygon_shape.rb +2 -2
  30. data/lib/reflex/reflex.rb +3 -3
  31. data/lib/reflex/scroll_event.rb +1 -1
  32. data/lib/reflex/selector.rb +4 -4
  33. data/lib/reflex/shape.rb +13 -13
  34. data/lib/reflex/style.rb +11 -11
  35. data/lib/reflex/style_length.rb +1 -1
  36. data/lib/reflex/text_view.rb +2 -2
  37. data/lib/reflex/timer.rb +2 -2
  38. data/lib/reflex/timer_event.rb +1 -1
  39. data/lib/reflex/update_event.rb +1 -1
  40. data/lib/reflex/view.rb +32 -32
  41. data/lib/reflex/wheel_event.rb +3 -3
  42. data/lib/reflex/window.rb +5 -5
  43. data/lib/reflexion.rb +17 -17
  44. data/reflex.gemspec +4 -4
  45. data/samples/reflexion/noise.rb +1 -1
  46. data/samples/tree.rb +1 -1
  47. data/src/ios/window.mm +1 -1
  48. data/src/osx/event.h +8 -0
  49. data/src/osx/event.mm +173 -1
  50. data/src/osx/native_window.mm +5 -1
  51. data/src/view.cpp +38 -10
  52. data/src/window.cpp +1 -1
  53. data/test/helper.rb +3 -3
  54. data/test/test_application.rb +1 -1
  55. data/test/test_capture_event.rb +6 -6
  56. data/test/test_event.rb +2 -2
  57. data/test/test_has_frame.rb +11 -11
  58. data/test/test_pointer_event.rb +13 -13
  59. data/test/test_reflex.rb +1 -1
  60. data/test/test_selector.rb +8 -8
  61. data/test/test_shape.rb +8 -8
  62. data/test/test_style.rb +13 -13
  63. data/test/test_style_length.rb +5 -5
  64. data/test/test_view.rb +30 -30
  65. data/test/test_window.rb +10 -10
  66. metadata +10 -10
@@ -12,8 +12,8 @@ module Reflex
12
12
 
13
13
  universal_accessor :polygon
14
14
 
15
- def initialize (polygon, *args, &block)
16
- super *args, &block
15
+ def initialize(polygon, *args, &block)
16
+ super(*args, &block)
17
17
  self.polygon = polygon
18
18
  end
19
19
 
data/lib/reflex/reflex.rb CHANGED
@@ -10,15 +10,15 @@ module Reflex
10
10
 
11
11
  extend module ClassMethods
12
12
 
13
- def start (*args, &block)
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 (*args, &block)
21
+ def window(*args, &block)
22
22
  Window.new(*args, &block).tap {|w| w.show}
23
23
  end
24
24
 
@@ -9,7 +9,7 @@ module Reflex
9
9
 
10
10
  class ScrollEvent < Event
11
11
 
12
- def inspect ()
12
+ def inspect()
13
13
  "#<Reflex::ScrollEvent x:#{x} y:#{y} z:#{z} dx:#{dx} dy:#{dy} dz:#{dz}>"
14
14
  end
15
15
 
@@ -15,22 +15,22 @@ module Reflex
15
15
  include Xot::Setter
16
16
  include HasTags
17
17
 
18
- def self.selector (*args)
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 (options = nil, &block)
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 (options = nil, &block)
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 (e)
33
+ def on_contact(e)
34
34
  end
35
35
 
36
- def on_contact_begin (e)
36
+ def on_contact_begin(e)
37
37
  end
38
38
 
39
- def on_contact_end (e)
39
+ def on_contact_end(e)
40
40
  end
41
41
 
42
42
  private
43
43
 
44
- def on_contact! (*args)
45
- call_contact! *args
46
- owner&.delay {on_contact *args}# delay to avoid physics world lock
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! (*args)
50
- call_contact_begin! *args
51
- owner&.delay {on_contact_begin *args}
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! (*args)
55
- call_contact_end! *args
56
- owner&.delay {on_contact_end *args}
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 (options = nil, &block)
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= (*syms)
26
- set_flow *syms.flatten.map {|sym| sym2flow sym}
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= (fill, stroke = nil)
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= (fill, stroke = nil)
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 (sym)
126
+ def sym2flow(sym)
127
127
  SYM2FLOW[sym] || FLOW_NONE
128
128
  end
129
129
 
130
- def flow2sym (flow)
130
+ def flow2sym(flow)
131
131
  FLOW2SYM[flow] || :none
132
132
  end
133
133
 
@@ -9,7 +9,7 @@ module Reflex
9
9
 
10
10
  class StyleLength
11
11
 
12
- def inspect ()
12
+ def inspect()
13
13
  "#<#{self.class.name} #{to_s}>"
14
14
  end
15
15
 
@@ -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 (e)
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
 
@@ -19,7 +19,7 @@ module Reflex
19
19
 
20
20
  alias view owner
21
21
 
22
- def inspect ()
22
+ def inspect()
23
23
  "#<Reflex::TimerEvent owner:#{owner} id:#{id} interval:#{interval} count:#{count}>"
24
24
  end
25
25
 
@@ -9,7 +9,7 @@ module Reflex
9
9
 
10
10
  class UpdateEvent < Event
11
11
 
12
- def inspect ()
12
+ def inspect()
13
13
  "#<Reflex::UpdateEvent dt:#{dt}>"
14
14
  end
15
15
 
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 (options = nil, &block)
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 (seconds = 0, count: 1, &block)
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 (seconds = 0, &block)
69
+ def interval(seconds = 0, &block)
70
70
  timeout seconds, count: -1, &block
71
71
  end
72
72
 
73
- def delay (seconds = 0, &block)
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 (*args)
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 (*args, &block)
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= (*symbols)
108
- set_category_bits parent_categories.symbols2bits *symbols
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= (*categories)
116
- set_collision_mask parent_categories.symbols2bits *categories
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? (*args)
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 (e)
128
+ def on_contact(e)
129
129
  end
130
130
 
131
- def on_contact_begin (e)
131
+ def on_contact_begin(e)
132
132
  end
133
133
 
134
- def on_contact_end (e)
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! (*args)
174
- call_contact! *args
175
- delay {on_contact *args}# delay to avoid physics world lock
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! (*args)
179
- call_contact_begin! *args
180
- delay {on_contact_begin *args}
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! (*args)
184
- call_contact_end! *args
185
- delay {on_contact_end *args}
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
@@ -9,15 +9,15 @@ module Reflex
9
9
 
10
10
  class WheelEvent < Event
11
11
 
12
- def position ()
12
+ def position()
13
13
  Point.new x, y, z
14
14
  end
15
15
 
16
- def delta ()
16
+ def delta()
17
17
  Point.new dx, dy, dz
18
18
  end
19
19
 
20
- def inspect ()
20
+ def inspect()
21
21
  "#<Reflex::WheelEvent dx:#{dx} dy:#{dy} dz:#{dz} x:#{x} y:#{y} z:#{z} mod:#{modifiers}>"
22
22
  end
23
23
 
data/lib/reflex/window.rb CHANGED
@@ -51,23 +51,23 @@ module Reflex
51
51
  universal_accessor :title, :frame,
52
52
  resizable: {reader: :resizable?}
53
53
 
54
- def initialize (options = nil, &block)
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 (&block)
61
- painter.begin &block
60
+ def paint(&block)
61
+ painter.begin(&block)
62
62
  end
63
63
 
64
- def self.show (*args, &block)
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