reflexion 0.1.20 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/capture_event.cpp +6 -5
  3. data/.doc/ext/reflex/contact_event.cpp +18 -16
  4. data/.doc/ext/reflex/draw_event.cpp +10 -8
  5. data/.doc/ext/reflex/event.cpp +10 -10
  6. data/.doc/ext/reflex/focus_event.cpp +18 -17
  7. data/.doc/ext/reflex/frame_event.cpp +17 -17
  8. data/.doc/ext/reflex/key_event.cpp +227 -28
  9. data/.doc/ext/reflex/native.cpp +2 -0
  10. data/.doc/ext/reflex/pointer.cpp +158 -0
  11. data/.doc/ext/reflex/pointer_event.cpp +32 -91
  12. data/.doc/ext/reflex/scroll_event.cpp +14 -17
  13. data/.doc/ext/reflex/selector.cpp +8 -0
  14. data/.doc/ext/reflex/timer.cpp +9 -1
  15. data/.doc/ext/reflex/timer_event.cpp +4 -13
  16. data/.doc/ext/reflex/update_event.cpp +6 -5
  17. data/.doc/ext/reflex/view.cpp +57 -0
  18. data/.doc/ext/reflex/wheel_event.cpp +39 -22
  19. data/.doc/ext/reflex/window.cpp +41 -0
  20. data/VERSION +1 -1
  21. data/ext/reflex/capture_event.cpp +6 -5
  22. data/ext/reflex/contact_event.cpp +18 -16
  23. data/ext/reflex/draw_event.cpp +9 -7
  24. data/ext/reflex/event.cpp +11 -11
  25. data/ext/reflex/focus_event.cpp +18 -17
  26. data/ext/reflex/frame_event.cpp +16 -16
  27. data/ext/reflex/key_event.cpp +228 -28
  28. data/ext/reflex/native.cpp +2 -0
  29. data/ext/reflex/pointer.cpp +170 -0
  30. data/ext/reflex/pointer_event.cpp +31 -96
  31. data/ext/reflex/scroll_event.cpp +15 -18
  32. data/ext/reflex/selector.cpp +9 -0
  33. data/ext/reflex/timer.cpp +15 -6
  34. data/ext/reflex/timer_event.cpp +9 -19
  35. data/ext/reflex/update_event.cpp +6 -5
  36. data/ext/reflex/view.cpp +67 -3
  37. data/ext/reflex/wheel_event.cpp +40 -21
  38. data/ext/reflex/window.cpp +49 -3
  39. data/include/reflex/defs.h +140 -106
  40. data/include/reflex/event.h +232 -124
  41. data/include/reflex/pointer.h +107 -0
  42. data/include/reflex/ruby/pointer.h +41 -0
  43. data/include/reflex/ruby/view.h +9 -0
  44. data/include/reflex/ruby/window.h +9 -0
  45. data/include/reflex/selector.h +1 -1
  46. data/include/reflex/shape.h +2 -2
  47. data/include/reflex/view.h +6 -4
  48. data/include/reflex/window.h +14 -8
  49. data/lib/reflex/application.rb +3 -3
  50. data/lib/reflex/autoinit.rb +1 -1
  51. data/lib/reflex/button.rb +7 -7
  52. data/lib/reflex/capture_event.rb +7 -7
  53. data/lib/reflex/contact_event.rb +10 -10
  54. data/lib/reflex/draw_event.rb +2 -2
  55. data/lib/reflex/ellipse_shape.rb +2 -2
  56. data/lib/reflex/focus_event.rb +11 -11
  57. data/lib/reflex/frame_event.rb +5 -5
  58. data/lib/reflex/helper.rb +20 -20
  59. data/lib/reflex/image_view.rb +2 -2
  60. data/lib/reflex/key_event.rb +12 -12
  61. data/lib/reflex/model.rb +22 -22
  62. data/lib/reflex/model_owner.rb +7 -7
  63. data/lib/reflex/model_view.rb +1 -1
  64. data/lib/reflex/module.rb +5 -5
  65. data/lib/reflex/pointer.rb +107 -0
  66. data/lib/reflex/pointer_event.rb +16 -54
  67. data/lib/reflex/polygon_shape.rb +2 -2
  68. data/lib/reflex/reflex.rb +3 -3
  69. data/lib/reflex/scroll_event.rb +1 -1
  70. data/lib/reflex/selector.rb +4 -4
  71. data/lib/reflex/shape.rb +13 -13
  72. data/lib/reflex/style.rb +11 -11
  73. data/lib/reflex/style_length.rb +1 -1
  74. data/lib/reflex/text_view.rb +2 -2
  75. data/lib/reflex/timer.rb +2 -2
  76. data/lib/reflex/timer_event.rb +3 -2
  77. data/lib/reflex/update_event.rb +1 -1
  78. data/lib/reflex/view.rb +32 -32
  79. data/lib/reflex/wheel_event.rb +2 -10
  80. data/lib/reflex/window.rb +8 -7
  81. data/lib/reflex.rb +1 -0
  82. data/lib/reflexion.rb +17 -17
  83. data/reflex.gemspec +5 -5
  84. data/samples/reflexion/noise.rb +1 -1
  85. data/samples/tree.rb +1 -1
  86. data/src/event.cpp +792 -86
  87. data/src/event.h +47 -0
  88. data/src/image_view.cpp +2 -2
  89. data/src/ios/event.h +15 -3
  90. data/src/ios/event.mm +126 -11
  91. data/src/ios/view_controller.mm +51 -23
  92. data/src/ios/window.mm +18 -0
  93. data/src/osx/event.h +15 -4
  94. data/src/osx/event.mm +214 -24
  95. data/src/osx/native_window.mm +85 -18
  96. data/src/osx/window.mm +22 -0
  97. data/src/pointer.cpp +203 -0
  98. data/src/pointer.h +26 -0
  99. data/src/selector.cpp +1 -1
  100. data/src/shape.cpp +11 -13
  101. data/src/shape.h +1 -1
  102. data/src/view.cpp +205 -118
  103. data/src/view.h +5 -10
  104. data/src/window.cpp +346 -104
  105. data/src/window.h +28 -3
  106. data/src/world.cpp +6 -4
  107. data/test/helper.rb +3 -3
  108. data/test/test_application.rb +1 -1
  109. data/test/test_capture_event.rb +22 -6
  110. data/test/test_contact_event.rb +40 -0
  111. data/test/test_draw_event.rb +35 -0
  112. data/test/test_event.rb +33 -5
  113. data/test/test_focus_event.rb +34 -0
  114. data/test/test_frame_event.rb +38 -0
  115. data/test/test_has_frame.rb +11 -11
  116. data/test/test_key_event.rb +33 -0
  117. data/test/test_pointer.rb +149 -0
  118. data/test/test_pointer_event.rb +70 -104
  119. data/test/test_reflex.rb +1 -1
  120. data/test/test_scroll_event.rb +39 -0
  121. data/test/test_selector.rb +15 -8
  122. data/test/test_shape.rb +8 -8
  123. data/test/test_style.rb +13 -13
  124. data/test/test_style_length.rb +5 -5
  125. data/test/test_timer_event.rb +38 -0
  126. data/test/test_update_event.rb +29 -0
  127. data/test/test_view.rb +57 -30
  128. data/test/test_wheel_event.rb +40 -0
  129. data/test/test_window.rb +45 -26
  130. metadata +64 -35
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, :find, :find_children,
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,
@@ -48,25 +48,26 @@ module Reflex
48
48
  :friction=, :friction,
49
49
  :restitution=, :restitution
50
50
 
51
- universal_accessor :title, :frame
51
+ universal_accessor :title, :frame,
52
+ resizable: {reader: :resizable?}
52
53
 
53
- def initialize (options = nil, &block)
54
+ def initialize(options = nil, &block)
54
55
  super()
55
56
  set options if options
56
57
  @show_block = block
57
58
  end
58
59
 
59
- def paint (&block)
60
- painter.begin &block
60
+ def paint(&block)
61
+ painter.begin(&block)
61
62
  end
62
63
 
63
- def self.show (*args, &block)
64
+ def self.show(*args, &block)
64
65
  new(*args, &block).show
65
66
  end
66
67
 
67
68
  private
68
69
 
69
- def call_show_block ()
70
+ def call_show_block()
70
71
  return unless @show_block
71
72
  Xot::BlockUtil.instance_eval_or_block_call self, &@show_block
72
73
  @show_block = nil
data/lib/reflex.rb CHANGED
@@ -33,6 +33,7 @@ require 'reflex/frame_event'
33
33
  require 'reflex/scroll_event'
34
34
  require 'reflex/focus_event'
35
35
  require 'reflex/key_event'
36
+ require 'reflex/pointer'
36
37
  require 'reflex/pointer_event'
37
38
  require 'reflex/wheel_event'
38
39
  require 'reflex/capture_event'
data/lib/reflexion.rb CHANGED
@@ -18,7 +18,7 @@ module Reflexion
18
18
  }
19
19
 
20
20
 
21
- def call_event (event, *args, &block)
21
+ def call_event(event, *args, &block)
22
22
  $event = event
23
23
  Xot::BlockUtil.instance_eval_or_block_call *args, &block if block
24
24
  $event = nil
@@ -27,7 +27,7 @@ module Reflexion
27
27
 
28
28
  class App < Application
29
29
 
30
- def on_motion (e)
30
+ def on_motion(e)
31
31
  super
32
32
  call_event e, e, &$motion
33
33
  end
@@ -39,29 +39,29 @@ module Reflexion
39
39
 
40
40
  attr_reader :event
41
41
 
42
- def initialize (*args, &block)
42
+ def initialize(*args, &block)
43
43
  super
44
44
  $window = self
45
45
  call_event nil, self, &$setup
46
46
  end
47
47
 
48
- def on_update (e)
48
+ def on_update(e)
49
49
  super
50
50
  redraw
51
51
  call_event e, e, &$update
52
52
  end
53
53
 
54
- def on_draw (e)
54
+ def on_draw(e)
55
55
  super
56
56
  call_event e, e.painter, &$draw
57
57
  end
58
58
 
59
- def on_key (e)
59
+ def on_key(e)
60
60
  super
61
61
  call_event e, e, &$key
62
62
  end
63
63
 
64
- def on_pointer (e)
64
+ def on_pointer(e)
65
65
  super
66
66
  call_event e, e, &$pointer
67
67
  end
@@ -71,43 +71,43 @@ module Reflexion
71
71
 
72
72
  module_function
73
73
 
74
- def window ()
74
+ def window()
75
75
  $window ||= MainWindow.new DEFAULTS
76
76
  end
77
77
 
78
- def event ()
78
+ def event()
79
79
  $event
80
80
  end
81
81
 
82
- def setup (&block)
82
+ def setup(&block)
83
83
  $setup = block
84
84
  end
85
85
 
86
- def update (&block)
86
+ def update(&block)
87
87
  $update = block
88
88
  end
89
89
 
90
- def draw (&block)
90
+ def draw(&block)
91
91
  $draw = block
92
92
  end
93
93
 
94
- def key (&block)
94
+ def key(&block)
95
95
  $key = block
96
96
  end
97
97
 
98
- def pointer (&block)
98
+ def pointer(&block)
99
99
  $pointer = block
100
100
  end
101
101
 
102
- def motion (&block)
102
+ def motion(&block)
103
103
  $motion = block
104
104
  end
105
105
 
106
- def start ()
106
+ def start()
107
107
  App.new {window.show}.start
108
108
  end
109
109
 
110
- def quit ()
110
+ def quit()
111
111
  window.close
112
112
  end
113
113
 
data/reflex.gemspec CHANGED
@@ -26,12 +26,12 @@ Gem::Specification.new do |s|
26
26
  s.homepage = "https://github.com/xord/reflex"
27
27
 
28
28
  s.platform = Gem::Platform::RUBY
29
- s.required_ruby_version = '~> 2'
29
+ s.required_ruby_version = '>= 2.6.0'
30
30
 
31
- s.add_runtime_dependency 'xot', '~> 0.1.20'
32
- s.add_runtime_dependency 'rucy', '~> 0.1.20'
33
- s.add_runtime_dependency 'beeps', '~> 0.1.20'
34
- s.add_runtime_dependency 'rays', '~> 0.1.20'
31
+ s.add_runtime_dependency 'xot', '~> 0.1.24'
32
+ s.add_runtime_dependency 'rucy', '~> 0.1.24'
33
+ s.add_runtime_dependency 'beeps', '~> 0.1.24'
34
+ s.add_runtime_dependency 'rays', '~> 0.1.24'
35
35
 
36
36
  s.files = `git ls-files`.split $/
37
37
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
@@ -12,7 +12,7 @@ y = 0
12
12
 
13
13
  draw do
14
14
  stroke :white
15
- lines *(0..200).map {|x|
15
+ line *(0..200).map {|x|
16
16
  xx = x * 5
17
17
  yy = 200 + Rays.perlin(x / 10.0, y / 100.0) * 100
18
18
  [xx, yy]
data/samples/tree.rb CHANGED
@@ -48,7 +48,7 @@ class W < Reflex::Window
48
48
  end
49
49
 
50
50
  def on_pointer_move (e)
51
- $scroll = [-e.x.floor, -e.y.floor]
51
+ $scroll = [e.x.floor, e.y.floor]
52
52
  end
53
53
 
54
54
  end# W