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
@@ -13,26 +13,26 @@ module Reflex
13
13
  alias dh dheight
14
14
  alias dpos dposition
15
15
 
16
- def x ()
16
+ def x()
17
17
  frame.x
18
18
  end
19
19
 
20
- def y ()
20
+ def y()
21
21
  frame.y
22
22
  end
23
23
 
24
- def width ()
24
+ def width()
25
25
  frame.width
26
26
  end
27
27
 
28
- def height ()
28
+ def height()
29
29
  frame.height
30
30
  end
31
31
 
32
32
  alias w width
33
33
  alias h height
34
34
 
35
- def inspect ()
35
+ def inspect()
36
36
  "#<Reflex::FrameEvent x:#{x} y:#{y} w:#{w} h:#{h} dx:#{dx} dy:#{dy} dw:#{dw} dh:#{dh}>"
37
37
  end
38
38
 
data/lib/reflex/helper.rb CHANGED
@@ -14,7 +14,7 @@ module Reflex
14
14
 
15
15
  include Xot::Hookable
16
16
 
17
- def hook (name, &block)
17
+ def hook(name, &block)
18
18
  super "on_#{name}".intern, &block
19
19
  end
20
20
 
@@ -23,28 +23,28 @@ module Reflex
23
23
 
24
24
  module HasFrame
25
25
 
26
- def move_to (*args)
27
- self.frame = frame.move_to *args
26
+ def move_to(*args)
27
+ self.frame = frame.move_to(*args)
28
28
  self
29
29
  end
30
30
 
31
- def move_by (*args)
32
- self.frame = frame.move_by *args
31
+ def move_by(*args)
32
+ self.frame = frame.move_by(*args)
33
33
  self
34
34
  end
35
35
 
36
- def resize_to (*args)
37
- self.frame = frame.resize_to *args
36
+ def resize_to(*args)
37
+ self.frame = frame.resize_to(*args)
38
38
  self
39
39
  end
40
40
 
41
- def resize_by (*args)
42
- self.frame = frame.resize_by *args
41
+ def resize_by(*args)
42
+ self.frame = frame.resize_by(*args)
43
43
  self
44
44
  end
45
45
 
46
- def inset_by (*args)
47
- self.frame = frame.inset_by *args
46
+ def inset_by(*args)
47
+ self.frame = frame.inset_by(*args)
48
48
  self
49
49
  end
50
50
 
@@ -56,10 +56,10 @@ module Reflex
56
56
  position pos size center
57
57
  ].each do |name|
58
58
  class_eval <<-END
59
- def #{name} ()
59
+ def #{name}()
60
60
  frame.#{name}
61
61
  end
62
- def #{name}= (*args)
62
+ def #{name}=(*args)
63
63
  self.frame = frame.tap {|b| b.send :#{name}=, *args}
64
64
  #{name}
65
65
  end
@@ -73,27 +73,27 @@ module Reflex
73
73
 
74
74
  module HasTags
75
75
 
76
- def tag= (*tags)
76
+ def tag=(*tags)
77
77
  clear_tags
78
- tag *tags.flatten
78
+ tag(*tags.flatten)
79
79
  end
80
80
 
81
81
  alias tags= tag=
82
82
 
83
- def tag (*tags)
83
+ def tag(*tags)
84
84
  tags.each {|tag| add_tag tag}
85
85
  end
86
86
 
87
- def untag (*tags)
87
+ def untag(*tags)
88
88
  tags.each {|tag| remove_tag tag}
89
89
  end
90
90
 
91
- def tags ()
91
+ def tags()
92
92
  to_enum :each_tag
93
93
  end
94
94
 
95
- def clear_tags ()
96
- untag *tags.to_a
95
+ def clear_tags()
96
+ untag(*tags.to_a)
97
97
  end
98
98
 
99
99
  end# HasTags
@@ -11,11 +11,11 @@ module Reflex
11
11
 
12
12
  has_model
13
13
 
14
- def image= (image)
14
+ def image=(image)
15
15
  self.data = image
16
16
  end
17
17
 
18
- def on_data_update (e)
18
+ def on_data_update(e)
19
19
  set_image self.data
20
20
  end
21
21
 
@@ -12,25 +12,25 @@ module Reflex
12
12
 
13
13
  alias get_type type
14
14
 
15
- const_symbol_reader :type, {
15
+ const_symbol_reader :type, **{
16
16
  none: TYPE_NONE,
17
17
  down: TYPE_DOWN,
18
18
  up: TYPE_UP
19
19
  }
20
20
 
21
- def down? ()
21
+ def down?()
22
22
  get_type == TYPE_DOWN
23
23
  end
24
24
 
25
- def up? ()
25
+ def up?()
26
26
  get_type == TYPE_UP
27
27
  end
28
28
 
29
- def repeat? ()
29
+ def repeat?()
30
30
  repeat >= 1
31
31
  end
32
32
 
33
- def inspect ()
33
+ def inspect()
34
34
  "#<Reflex::KeyEvent type:#{type} chars:'#{chars}' code:#{code} mod:#{modifiers} repeat:#{repeat} capture?:#{capture?}>"
35
35
  end
36
36
 
data/lib/reflex/model.rb CHANGED
@@ -18,12 +18,12 @@ module Reflex
18
18
 
19
19
  attr_reader :data
20
20
 
21
- def initialize (data = nil, &block)
21
+ def initialize(data = nil, &block)
22
22
  self.data = data if data
23
23
  Xot::BlockUtil.instance_eval_or_block_call self, &block if block
24
24
  end
25
25
 
26
- def data= (data)
26
+ def data=(data)
27
27
  skip, data = apply_filters(data).tap do |filtered|
28
28
  skip = filtered.nil? && !data.nil?
29
29
  break skip, filtered
@@ -35,79 +35,79 @@ module Reflex
35
35
  @data
36
36
  end
37
37
 
38
- def add_handler (handler)
38
+ def add_handler(handler)
39
39
  super
40
40
  invoke :attach, {}, only: handler
41
41
  end
42
42
 
43
- def remove_handler (handler)
43
+ def remove_handler(handler)
44
44
  invoke :detach, {}, only: handler
45
45
  super
46
46
  end
47
47
 
48
- def invoke (name, attributes = {}, options = {})
48
+ def invoke(name, attributes = {}, options = {})
49
49
  attributes[:data] ||= @data
50
50
  super "on_data_#{name}".intern, attributes, options
51
51
  end
52
52
 
53
- def add_filter (&block)
53
+ def add_filter(&block)
54
54
  (@filters ||= []).push block
55
55
  end
56
56
 
57
- def remove_filter (&block)
57
+ def remove_filter(&block)
58
58
  @filters.delete block if @filters
59
59
  end
60
60
 
61
61
  alias filter add_filter
62
62
 
63
- def validate (&block)
63
+ def validate(&block)
64
64
  filter {|data| block.call(data) ? data : nil}
65
65
  end
66
66
 
67
- def min= (min)
67
+ def min=(min)
68
68
  filter {|data| data < min ? min : data}
69
69
  end
70
70
 
71
- def max= (max)
71
+ def max=(max)
72
72
  filter {|data| data > max ? max : data}
73
73
  end
74
74
 
75
- def minmax= (range)
75
+ def minmax=(range)
76
76
  min, max = range.min, range.max
77
77
  filter {|data| data < min ? min : data > max ? max : data}
78
78
  end
79
79
 
80
- def int (defvar = nil)
80
+ def int(defvar = nil)
81
81
  call_symbols INT_SYMS
82
82
  end
83
83
 
84
- def float (defvar = nil)
84
+ def float(defvar = nil)
85
85
  call_symbols FLOAT_SYMS
86
86
  end
87
87
 
88
- def string (defvar = nil)
88
+ def string(defvar = nil)
89
89
  call_symbols STRING_SYMS
90
90
  end
91
91
 
92
- def [] (*args)
92
+ def [](*args)
93
93
  call_symbols ARRAY_GET_SYMS, *args
94
94
  end
95
95
 
96
- def []= (*args)
96
+ def []=(*args)
97
97
  ret = call_symbols ARRAY_SET_SYMS, *args
98
98
  invoke :update
99
99
  ret
100
100
  end
101
101
 
102
- def size ()
102
+ def size()
103
103
  call_symbols(ARRAY_SIZE_SYMS) || 0
104
104
  end
105
105
 
106
- def each (&block)
107
- data.each &block if block && data.respond_to?(:each)
106
+ def each(&block)
107
+ data.each(&block) if block && data.respond_to?(:each)
108
108
  end
109
109
 
110
- def inspect ()
110
+ def inspect()
111
111
  "#<Model data:#{@data.inspect}>"
112
112
  end
113
113
 
@@ -125,7 +125,7 @@ module Reflex
125
125
 
126
126
  ARRAY_SIZE_SYMS = [:size, :length]
127
127
 
128
- def apply_filters (data)
128
+ def apply_filters(data)
129
129
  return data unless @filters
130
130
  @filters.each do |filter|
131
131
  break if data.nil?
@@ -134,7 +134,7 @@ module Reflex
134
134
  data
135
135
  end
136
136
 
137
- def call_symbols (symbols, *args)
137
+ def call_symbols(symbols, *args)
138
138
  if dat = data
139
139
  symbols.each do |symbol|
140
140
  return dat.send symbol, *args if dat.respond_to? symbol
@@ -11,7 +11,7 @@ module Reflex
11
11
 
12
12
  attr_reader :model
13
13
 
14
- def model= (model)
14
+ def model=(model)
15
15
  return if model == @model
16
16
  @model.remove_handler self if @model
17
17
  @model = model
@@ -19,7 +19,7 @@ module Reflex
19
19
  model
20
20
  end
21
21
 
22
- def data= (data)
22
+ def data=(data)
23
23
  unless data.nil?
24
24
  self.model = Model.new unless @model
25
25
  @model.data = data
@@ -29,19 +29,19 @@ module Reflex
29
29
  data
30
30
  end
31
31
 
32
- def data ()
32
+ def data()
33
33
  @model ? @model.data : nil
34
34
  end
35
35
 
36
- def invoke (*args)
37
- @model.invoke *args if @model
36
+ def invoke(*args)
37
+ @model.invoke(*args) if @model
38
38
  end
39
39
 
40
- def on_data_attach (e)
40
+ def on_data_attach(e)
41
41
  invoke :update, {}, only: self
42
42
  end
43
43
 
44
- def on_data_detach (e)
44
+ def on_data_detach(e)
45
45
  invoke :update, {}, only: self
46
46
  end
47
47
 
@@ -11,7 +11,7 @@ module Reflex
11
11
 
12
12
  include ModelOwner
13
13
 
14
- def on_data_update (e)
14
+ def on_data_update(e)
15
15
  resize_to_fit
16
16
  redraw
17
17
  end
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 (path = '')
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
 
@@ -16,14 +16,14 @@ module Reflex
16
16
  alias get_type type
17
17
  alias get_pointer_type pointer_type
18
18
 
19
- const_symbol_reader :type, {
19
+ const_symbol_reader :type, **{
20
20
  none: TYPE_NONE,
21
21
  down: TYPE_DOWN,
22
22
  up: TYPE_UP,
23
23
  move: TYPE_MOVE
24
24
  }
25
25
 
26
- bit_flag_reader :pointer_type, {
26
+ bit_flag_reader :pointer_type, **{
27
27
  none: POINTER_NONE,
28
28
  mouse_left: POINTER_MOUSE_LEFT,
29
29
  mouse_right: POINTER_MOUSE_RIGHT,
@@ -32,43 +32,43 @@ module Reflex
32
32
  pen: POINTER_PEN
33
33
  }
34
34
 
35
- def down? ()
35
+ def down?()
36
36
  get_type == TYPE_DOWN
37
37
  end
38
38
 
39
- def up? ()
39
+ def up?()
40
40
  get_type == TYPE_UP
41
41
  end
42
42
 
43
- def move? ()
43
+ def move?()
44
44
  get_type == TYPE_MOVE
45
45
  end
46
46
 
47
- def left? ()
47
+ def left?()
48
48
  (get_pointer_type & POINTER_MOUSE_LEFT) != 0
49
49
  end
50
50
 
51
- def right? ()
51
+ def right?()
52
52
  (get_pointer_type & POINTER_MOUSE_RIGHT) != 0
53
53
  end
54
54
 
55
- def middle? ()
55
+ def middle?()
56
56
  (get_pointer_type & POINTER_MOUSE_MIDDLE) != 0
57
57
  end
58
58
 
59
- def touch? ()
59
+ def touch?()
60
60
  (get_pointer_type & POINTER_TOUCH) != 0
61
61
  end
62
62
 
63
- def pen? ()
63
+ def pen?()
64
64
  (get_pointer_type & POINTER_PEN) != 0
65
65
  end
66
66
 
67
- def positions ()
67
+ def positions()
68
68
  size.times.map {|i| position i}
69
69
  end
70
70
 
71
- def inspect ()
71
+ def inspect()
72
72
  "#<Reflex::PointerEvent type:#{type}/#{pointer_type} x:#{x} y:#{y} size:#{size} mod:#{modifiers} count:#{count} drag:#{drag?}>"
73
73
  end
74
74