reflexion 0.1.35 → 0.1.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/view.cpp +17 -0
  3. data/ChangeLog.md +10 -0
  4. data/Rakefile +1 -1
  5. data/VERSION +1 -1
  6. data/ext/reflex/extconf.rb +0 -3
  7. data/ext/reflex/view.cpp +19 -0
  8. data/include/reflex/event.h +1 -1
  9. data/include/reflex/view.h +6 -0
  10. data/lib/reflex/application.rb +2 -3
  11. data/lib/reflex/autoinit.rb +0 -3
  12. data/lib/reflex/bitmap.rb +0 -3
  13. data/lib/reflex/bounds.rb +0 -3
  14. data/lib/reflex/button.rb +0 -3
  15. data/lib/reflex/camera.rb +0 -3
  16. data/lib/reflex/capture_event.rb +0 -3
  17. data/lib/reflex/color.rb +0 -3
  18. data/lib/reflex/color_space.rb +0 -3
  19. data/lib/reflex/contact_event.rb +0 -3
  20. data/lib/reflex/draw_event.rb +0 -3
  21. data/lib/reflex/ellipse_shape.rb +0 -3
  22. data/lib/reflex/ext.rb +0 -3
  23. data/lib/reflex/extension.rb +0 -3
  24. data/lib/reflex/filter.rb +0 -3
  25. data/lib/reflex/fixture.rb +0 -3
  26. data/lib/reflex/focus_event.rb +0 -3
  27. data/lib/reflex/font.rb +0 -3
  28. data/lib/reflex/frame_event.rb +0 -3
  29. data/lib/reflex/helper.rb +0 -3
  30. data/lib/reflex/image.rb +0 -3
  31. data/lib/reflex/image_view.rb +0 -3
  32. data/lib/reflex/key_event.rb +0 -3
  33. data/lib/reflex/line_shape.rb +0 -3
  34. data/lib/reflex/list_view.rb +0 -3
  35. data/lib/reflex/matrix.rb +0 -3
  36. data/lib/reflex/model.rb +0 -3
  37. data/lib/reflex/model_owner.rb +0 -3
  38. data/lib/reflex/model_view.rb +0 -3
  39. data/lib/reflex/painter.rb +0 -3
  40. data/lib/reflex/point.rb +0 -3
  41. data/lib/reflex/pointer.rb +0 -3
  42. data/lib/reflex/pointer_event.rb +0 -3
  43. data/lib/reflex/polygon.rb +0 -3
  44. data/lib/reflex/polygon_shape.rb +0 -3
  45. data/lib/reflex/polyline.rb +0 -3
  46. data/lib/reflex/rect_shape.rb +0 -3
  47. data/lib/reflex/reflex.rb +0 -3
  48. data/lib/reflex/scroll_event.rb +0 -3
  49. data/lib/reflex/selector.rb +0 -3
  50. data/lib/reflex/shader.rb +0 -3
  51. data/lib/reflex/shape.rb +0 -3
  52. data/lib/reflex/style.rb +0 -3
  53. data/lib/reflex/style_length.rb +0 -3
  54. data/lib/reflex/text_view.rb +0 -3
  55. data/lib/reflex/timer.rb +0 -3
  56. data/lib/reflex/timer_event.rb +0 -3
  57. data/lib/reflex/update_event.rb +0 -3
  58. data/lib/reflex/view.rb +10 -4
  59. data/lib/reflex/wheel_event.rb +0 -3
  60. data/lib/reflex/window.rb +2 -3
  61. data/lib/reflex.rb +0 -3
  62. data/lib/reflexion/include.rb +0 -3
  63. data/lib/reflexion.rb +0 -3
  64. data/reflex.gemspec +5 -5
  65. data/samples/app.rb +0 -3
  66. data/samples/bats.rb +0 -3
  67. data/samples/camera.rb +0 -3
  68. data/samples/checker.rb +0 -3
  69. data/samples/fans.rb +0 -3
  70. data/samples/fps.rb +0 -3
  71. data/samples/grid.rb +0 -3
  72. data/samples/hello.rb +0 -3
  73. data/samples/image.rb +0 -3
  74. data/samples/key.rb +0 -3
  75. data/samples/layout.rb +0 -3
  76. data/samples/model.rb +0 -3
  77. data/samples/physics.rb +0 -3
  78. data/samples/reflexion/breakout.rb +0 -3
  79. data/samples/reflexion/hello.rb +0 -3
  80. data/samples/reflexion/jump_action.rb +0 -3
  81. data/samples/reflexion/noise.rb +0 -3
  82. data/samples/reflexion/paint.rb +0 -3
  83. data/samples/reflexion/physics.rb +0 -3
  84. data/samples/reflexion/pulse.rb +0 -3
  85. data/samples/repl.rb +0 -3
  86. data/samples/shader.rb +0 -3
  87. data/samples/shapes.rb +0 -3
  88. data/samples/text.rb +0 -3
  89. data/samples/tree.rb +0 -3
  90. data/samples/views.rb +0 -3
  91. data/samples/visuals.rb +0 -3
  92. data/src/body.cpp +14 -0
  93. data/src/body.h +4 -0
  94. data/src/event.cpp +27 -28
  95. data/src/view.cpp +89 -14
  96. data/src/window.cpp +4 -2
  97. data/test/helper.rb +0 -3
  98. data/test/test_application.rb +4 -3
  99. data/test/test_capture_event.rb +0 -3
  100. data/test/test_contact_event.rb +0 -3
  101. data/test/test_draw_event.rb +0 -3
  102. data/test/test_event.rb +1 -4
  103. data/test/test_focus_event.rb +0 -3
  104. data/test/test_frame_event.rb +0 -3
  105. data/test/test_has_frame.rb +0 -3
  106. data/test/test_key_event.rb +0 -3
  107. data/test/test_model.rb +0 -3
  108. data/test/test_model_owner.rb +0 -3
  109. data/test/test_pointer.rb +0 -3
  110. data/test/test_pointer_event.rb +0 -3
  111. data/test/test_reflex_init.rb +0 -3
  112. data/test/test_scroll_event.rb +0 -3
  113. data/test/test_selector.rb +0 -3
  114. data/test/test_shape.rb +0 -3
  115. data/test/test_style.rb +0 -3
  116. data/test/test_style_length.rb +0 -3
  117. data/test/test_timer_event.rb +0 -3
  118. data/test/test_update_event.rb +0 -3
  119. data/test/test_view.rb +37 -3
  120. data/test/test_wheel_event.rb +0 -3
  121. data/test/test_window.rb +4 -3
  122. metadata +10 -10
data/samples/camera.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/checker.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/fans.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/fps.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/grid.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/hello.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/image.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/key.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/layout.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/model.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/physics.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot beeps rays reflex]
5
2
  .map {|s| File.expand_path "../../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot beeps rays reflex]
5
2
  .map {|s| File.expand_path "../../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot beeps rays reflex]
5
2
  .map {|s| File.expand_path "../../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot beeps rays reflex]
5
2
  .map {|s| File.expand_path "../../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot beeps rays reflex]
5
2
  .map {|s| File.expand_path "../../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot beeps rays reflex]
5
2
  .map {|s| File.expand_path "../../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot beeps rays reflex]
5
2
  .map {|s| File.expand_path "../../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/repl.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/shader.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/shapes.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/text.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/tree.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/views.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/samples/visuals.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[xot rays reflex]
5
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
data/src/body.cpp CHANGED
@@ -126,6 +126,14 @@ namespace Reflex
126
126
  self->b2body->ApplyAngularImpulse(impulse, true);
127
127
  }
128
128
 
129
+ void
130
+ Body::awake ()
131
+ {
132
+ validate(this);
133
+
134
+ self->b2body->SetAwake(true);
135
+ }
136
+
129
137
  float
130
138
  Body::meter2pixel (float meter) const
131
139
  {
@@ -141,6 +149,12 @@ namespace Reflex
141
149
  to_b2vec2(x, y, self->ppm), Xot::deg2rad(degree));
142
150
  }
143
151
 
152
+ void
153
+ Body::set_transform (const Point& position, float degree)
154
+ {
155
+ set_transform(position.x, position.y, degree);
156
+ }
157
+
144
158
  Point
145
159
  Body::position () const
146
160
  {
data/src/body.h CHANGED
@@ -41,10 +41,14 @@ namespace Reflex
41
41
 
42
42
  void apply_angular_impulse (float impulse);
43
43
 
44
+ void awake ();
45
+
44
46
  float meter2pixel (float meter = 1) const;
45
47
 
46
48
  void set_transform (coord x, coord y, float degree);
47
49
 
50
+ void set_transform (const Point& position, float degree);
51
+
48
52
  Point position () const;
49
53
 
50
54
  float angle () const;
data/src/event.cpp CHANGED
@@ -26,10 +26,10 @@ namespace Reflex
26
26
  {
27
27
  }
28
28
 
29
- void block ()
29
+ void block (bool parent)
30
30
  {
31
31
  blocked = true;
32
- if (parent) parent->block();
32
+ if (parent && this->parent) this->parent->block(true);
33
33
  }
34
34
 
35
35
  };// Event::Data
@@ -50,9 +50,9 @@ namespace Reflex
50
50
  }
51
51
 
52
52
  void
53
- Event::block ()
53
+ Event::block (bool parent)
54
54
  {
55
- self->block();
55
+ self->block(parent);
56
56
  }
57
57
 
58
58
  bool
@@ -634,29 +634,6 @@ namespace Reflex
634
634
  pthis->self->captured = captured;
635
635
  }
636
636
 
637
- static void
638
- filter_and_offset_pointer_positions (PointerEvent* event, const Bounds& frame)
639
- {
640
- assert(event);
641
-
642
- const Point& offset = frame.position();
643
-
644
- std::vector<Pointer> pointers;
645
- for (const auto& pointer : event->self->pointers)
646
- {
647
- if (!frame.is_include(pointer.position()))
648
- continue;
649
-
650
- pointers.emplace_back(pointer);
651
- Pointer_update_positions(&pointers.back(), [&](Point* pos)
652
- {
653
- *pos -= offset;
654
- });
655
- }
656
-
657
- event->self->pointers = pointers;
658
- }
659
-
660
637
  static void
661
638
  scroll_and_zoom_pointer_positions (
662
639
  PointerEvent* event, const Point& scroll, float zoom)
@@ -685,7 +662,26 @@ namespace Reflex
685
662
  if (!pthis || !view)
686
663
  argument_error(__FILE__, __LINE__);
687
664
 
688
- filter_and_offset_pointer_positions(pthis, view->frame());
665
+ const Bounds& frame = view->frame();
666
+ const Point& offset = frame.position();
667
+ Bounds bounds = frame.dup().move_to(0, 0);
668
+ float angle = view->angle();
669
+
670
+ std::vector<Pointer> pointers;
671
+ for (const auto& pointer : pthis->self->pointers)
672
+ {
673
+ pointers.emplace_back(pointer);
674
+ Pointer_update_positions(&pointers.back(), [&](Point* pos)
675
+ {
676
+ *pos -= offset;
677
+ pos->rotate(-angle);
678
+ });
679
+
680
+ if (!bounds.is_include(pointers.back().position()))
681
+ pointers.pop_back();
682
+ }
683
+ pthis->self->pointers = pointers;
684
+
689
685
  scroll_and_zoom_pointer_positions(pthis, view->scroll(), view->zoom());
690
686
  }
691
687
 
@@ -695,11 +691,14 @@ namespace Reflex
695
691
  if (!pthis || !view)
696
692
  argument_error(__FILE__, __LINE__);
697
693
 
694
+ float angle = view->angle();
695
+
698
696
  for (auto& pointer : pthis->self->pointers)
699
697
  {
700
698
  Pointer_update_positions(&pointer, [=](Point* pos)
701
699
  {
702
700
  *pos = view->from_window(*pos);
701
+ pos->rotate(-angle);
703
702
  });
704
703
  }
705
704
 
data/src/view.cpp CHANGED
@@ -4,6 +4,7 @@
4
4
  #include <assert.h>
5
5
  #include <memory>
6
6
  #include <algorithm>
7
+ #include <rays/matrix.h>
7
8
  #include "reflex/timer.h"
8
9
  #include "reflex/filter.h"
9
10
  #include "reflex/exception.h"
@@ -25,6 +26,8 @@ namespace Reflex
25
26
 
26
27
  static const char* WALL_NAME = "__WALL__";
27
28
 
29
+ static const Point ZERO = 0;
30
+
28
31
 
29
32
  struct View::Data
30
33
  {
@@ -68,6 +71,8 @@ namespace Reflex
68
71
 
69
72
  uint flags = FLAG_CLIP | FLAG_RESIZE_TO_FIT | REDRAW | UPDATE_LAYOUT | UPDATE_STYLE;
70
73
 
74
+ std::unique_ptr<Point> ppivot;
75
+
71
76
  std::unique_ptr<Point> pscroll;
72
77
 
73
78
  SelectorPtr pselector;
@@ -94,6 +99,12 @@ namespace Reflex
94
99
 
95
100
  std::unique_ptr<ChildList> pchildren;
96
101
 
102
+ Point& pivot ()
103
+ {
104
+ if (!ppivot) ppivot.reset(new Point);
105
+ return *ppivot;
106
+ }
107
+
97
108
  Point& scroll ()
98
109
  {
99
110
  if (!pscroll) pscroll.reset(new Point);
@@ -195,7 +206,40 @@ namespace Reflex
195
206
  {
196
207
  if (!pbody) return;
197
208
 
198
- pbody->set_transform(frame.x, frame.y, angle);
209
+ auto* pivot = ppivot.get();
210
+ if (pivot && (pivot->x != 0 || pivot->y != 0) && angle != 0)
211
+ {
212
+ Matrix m;
213
+ get_view2body_matrix(&m);
214
+ pbody->set_transform(m * Point(0), angle);
215
+ }
216
+ else
217
+ pbody->set_transform(frame.x, frame.y, angle);
218
+ }
219
+
220
+ void
221
+ get_view2body_matrix (Matrix* m)
222
+ {
223
+ assert(m && *m == 1 && ppivot && *ppivot != 0);
224
+
225
+ Point pivot = *ppivot * frame.size();
226
+ m->translate(frame.position() + pivot)
227
+ .rotate(angle)
228
+ .translate(-pivot);
229
+ }
230
+
231
+ void
232
+ get_body2view_matrix (Matrix* m)
233
+ {
234
+ assert(m && *m == 1 && ppivot && *ppivot != 0 && pbody);
235
+
236
+ Point pivot = *ppivot * frame.size();
237
+ float angle = pbody->angle();
238
+ m->translate(pbody->position())
239
+ .rotate(angle)
240
+ .translate( pivot)
241
+ .rotate(-angle)
242
+ .translate(-pivot);
199
243
  }
200
244
 
201
245
  void update_body_and_shapes ()
@@ -797,12 +841,23 @@ namespace Reflex
797
841
  update_view_body (View* view)
798
842
  {
799
843
  assert(view);
844
+ View::Data* self = view->self.get();
800
845
 
801
- Body* body = view->self->pbody.get();
846
+ Body* body = self->pbody.get();
802
847
  if (!body) return;
803
848
 
804
849
  Bounds frame = view->frame();
805
- frame.move_to(body->position());
850
+
851
+ auto* pivot = self->ppivot.get();
852
+ if (pivot && (pivot->x != 0 || pivot->y != 0) && self->angle != 0)
853
+ {
854
+ Matrix m;
855
+ self->get_body2view_matrix(&m);
856
+ frame.set_position(m * Point(0));
857
+ }
858
+ else
859
+ frame.set_position(body->position());
860
+
806
861
  update_view_frame(view, frame, view->zoom(), body->angle(), false);
807
862
  }
808
863
 
@@ -1083,7 +1138,7 @@ namespace Reflex
1083
1138
 
1084
1139
  if (event->is_blocked()) return;
1085
1140
 
1086
- View::ChildList* pchildren = view->self->pchildren.get();
1141
+ View::ChildList* pchildren = self->pchildren.get();
1087
1142
  if (pchildren)
1088
1143
  {
1089
1144
  for (auto& pchild : *pchildren)
@@ -1093,7 +1148,7 @@ namespace Reflex
1093
1148
  }
1094
1149
  }
1095
1150
 
1096
- World* child_world = view->self->pchild_world.get();
1151
+ World* child_world = self->pchild_world.get();
1097
1152
  if (child_world)
1098
1153
  {
1099
1154
  p->push_state();
@@ -1177,7 +1232,7 @@ namespace Reflex
1177
1232
  Point pos = bounds.position();
1178
1233
  Bounds clip2 = bounds.dup().move_by(offset) & clip;
1179
1234
 
1180
- bounds.move_to(0, 0, bounds.z);
1235
+ bounds.set_position(0, 0, bounds.z);
1181
1236
  if (self->pscroll)
1182
1237
  {
1183
1238
  bounds.move_by(-*self->pscroll);
@@ -1188,9 +1243,13 @@ namespace Reflex
1188
1243
  p->push_matrix();
1189
1244
  p->translate(pos);
1190
1245
 
1191
- float angle = self->angle;
1192
- if (angle != 0)
1193
- p->rotate(angle);
1246
+ if (self->angle != 0)
1247
+ {
1248
+ const Point* pivot = self->ppivot.get();
1249
+ if (pivot) p->translate( pivot->x * bounds.width, pivot->y * bounds.height);
1250
+ p->rotate(self->angle);
1251
+ if (pivot) p->translate(-pivot->x * bounds.width, -pivot->y * bounds.height);
1252
+ }
1194
1253
 
1195
1254
  float zoom = self->zoom;
1196
1255
  if (zoom != 1 && zoom > 0)
@@ -1285,6 +1344,9 @@ namespace Reflex
1285
1344
  {
1286
1345
  assert(view && event);
1287
1346
 
1347
+ if (view->self->pbody)
1348
+ view->self->pbody->awake();
1349
+
1288
1350
  view->on_pointer(event);
1289
1351
 
1290
1352
  switch ((*event)[0].action())
@@ -2070,7 +2132,23 @@ namespace Reflex
2070
2132
  return self->angle;
2071
2133
  }
2072
2134
 
2073
- static const Point ZERO_SCROLL;
2135
+ void
2136
+ View::set_pivot (float x, float y, float z)
2137
+ {
2138
+ self->pivot().reset(x, y, z);
2139
+ }
2140
+
2141
+ void
2142
+ View::set_pivot (const Point& pivot)
2143
+ {
2144
+ set_pivot(pivot.x, pivot.y, pivot.z);
2145
+ }
2146
+
2147
+ const Point&
2148
+ View::pivot () const
2149
+ {
2150
+ return self->ppivot ? self->pivot() : ZERO;
2151
+ }
2074
2152
 
2075
2153
  void
2076
2154
  View::scroll_to (coord x, coord y, coord z)
@@ -2110,10 +2188,7 @@ namespace Reflex
2110
2188
  const Point&
2111
2189
  View::scroll () const
2112
2190
  {
2113
- if (self->pscroll)
2114
- return self->scroll();
2115
- else
2116
- return ZERO_SCROLL;
2191
+ return self->pscroll ? self->scroll() : ZERO;
2117
2192
  }
2118
2193
 
2119
2194
  void
data/src/window.cpp CHANGED
@@ -176,7 +176,7 @@ namespace Reflex
176
176
 
177
177
  for (auto& [view, targets] : window->self->captures)
178
178
  {
179
- if (!is_capturing(view.get(), targets, View::CAPTURE_KEY))
179
+ if (!view->window() || !is_capturing(view.get(), targets, View::CAPTURE_KEY))
180
180
  continue;
181
181
 
182
182
  KeyEvent e = event->dup();
@@ -256,7 +256,7 @@ namespace Reflex
256
256
 
257
257
  for (auto& [view, targets] : window->self->captures)
258
258
  {
259
- if (targets.empty()) continue;
259
+ if (!view->window() || targets.empty()) continue;
260
260
 
261
261
  PointerEvent event;
262
262
  PointerEvent_set_captured(&event, true);
@@ -300,6 +300,8 @@ namespace Reflex
300
300
 
301
301
  for (auto& view : views_capturing_all)
302
302
  {
303
+ if (!view->window()) continue;
304
+
303
305
  PointerEvent e = event.dup();
304
306
  PointerEvent_update_for_capturing_view(&e, view);
305
307
  View_call_pointer_event(const_cast<View*>(view.get()), &e);
data/test/helper.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  %w[../xot ../rucy ../rays .]
5
2
  .map {|s| File.expand_path "../#{s}/lib", __dir__}
6
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
@@ -14,4 +11,8 @@ class TestApplication < Test::Unit::TestCase
14
11
  assert_equal 'AppName', @@app.name
15
12
  end
16
13
 
14
+ def test_inspect()
15
+ assert_match %r|#<Reflex::Application:0x\w{16}>|, @@app.inspect
16
+ end
17
+
17
18
  end# TestApplication
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
data/test/test_event.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
@@ -27,7 +24,7 @@ class TestEvent < Test::Unit::TestCase
27
24
  assert_true e.blocked?
28
25
  end
29
26
 
30
- def test_block_propagation()
27
+ def _test_block_propagation()
31
28
  e1 = event
32
29
  e2 = e1.dup
33
30
  e3 = e2.dup
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
data/test/test_model.rb CHANGED
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3
 
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
-
4
1
  require_relative 'helper'
5
2
 
6
3