reflexion 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +1 -1
  3. data/.doc/ext/reflex/capture_event.cpp +1 -1
  4. data/.doc/ext/reflex/contact_event.cpp +1 -1
  5. data/.doc/ext/reflex/draw_event.cpp +1 -1
  6. data/.doc/ext/reflex/ellipse_shape.cpp +1 -1
  7. data/.doc/ext/reflex/event.cpp +1 -1
  8. data/.doc/ext/reflex/filter.cpp +1 -1
  9. data/.doc/ext/reflex/focus_event.cpp +1 -1
  10. data/.doc/ext/reflex/frame_event.cpp +1 -1
  11. data/.doc/ext/reflex/image_view.cpp +1 -1
  12. data/.doc/ext/reflex/key_event.cpp +74 -69
  13. data/.doc/ext/reflex/line_shape.cpp +1 -1
  14. data/.doc/ext/reflex/motion_event.cpp +1 -1
  15. data/.doc/ext/reflex/pointer.cpp +7 -16
  16. data/.doc/ext/reflex/pointer_event.cpp +1 -1
  17. data/.doc/ext/reflex/polygon_shape.cpp +1 -1
  18. data/.doc/ext/reflex/rect_shape.cpp +1 -1
  19. data/.doc/ext/reflex/reflex.cpp +58 -50
  20. data/.doc/ext/reflex/screen.cpp +1 -1
  21. data/.doc/ext/reflex/scroll_event.cpp +1 -1
  22. data/.doc/ext/reflex/selector.cpp +2 -2
  23. data/.doc/ext/reflex/shape.cpp +1 -1
  24. data/.doc/ext/reflex/style.cpp +1 -1
  25. data/.doc/ext/reflex/style_length.cpp +5 -3
  26. data/.doc/ext/reflex/timer.cpp +1 -1
  27. data/.doc/ext/reflex/timer_event.cpp +1 -1
  28. data/.doc/ext/reflex/update_event.cpp +1 -1
  29. data/.doc/ext/reflex/view.cpp +17 -9
  30. data/.doc/ext/reflex/wheel_event.cpp +1 -1
  31. data/.doc/ext/reflex/window.cpp +1 -1
  32. data/.github/workflows/release-gem.yml +1 -1
  33. data/.github/workflows/test.yml +3 -0
  34. data/ChangeLog.md +17 -0
  35. data/Gemfile.lock +1 -1
  36. data/LICENSE +1 -1
  37. data/Rakefile +1 -2
  38. data/VERSION +1 -1
  39. data/ext/reflex/application.cpp +1 -1
  40. data/ext/reflex/capture_event.cpp +1 -1
  41. data/ext/reflex/contact_event.cpp +1 -1
  42. data/ext/reflex/defs.h +2 -0
  43. data/ext/reflex/draw_event.cpp +1 -1
  44. data/ext/reflex/ellipse_shape.cpp +1 -1
  45. data/ext/reflex/event.cpp +1 -1
  46. data/ext/reflex/extconf.rb +4 -4
  47. data/ext/reflex/filter.cpp +1 -1
  48. data/ext/reflex/focus_event.cpp +1 -1
  49. data/ext/reflex/frame_event.cpp +1 -1
  50. data/ext/reflex/image_view.cpp +1 -1
  51. data/ext/reflex/key_event.cpp +74 -69
  52. data/ext/reflex/line_shape.cpp +1 -1
  53. data/ext/reflex/motion_event.cpp +1 -1
  54. data/ext/reflex/pointer.cpp +7 -17
  55. data/ext/reflex/pointer_event.cpp +1 -1
  56. data/ext/reflex/polygon_shape.cpp +1 -1
  57. data/ext/reflex/rect_shape.cpp +1 -1
  58. data/ext/reflex/reflex.cpp +58 -50
  59. data/ext/reflex/screen.cpp +1 -1
  60. data/ext/reflex/scroll_event.cpp +1 -1
  61. data/ext/reflex/selector.cpp +2 -2
  62. data/ext/reflex/shape.cpp +1 -1
  63. data/ext/reflex/style.cpp +1 -1
  64. data/ext/reflex/style_length.cpp +5 -3
  65. data/ext/reflex/timer.cpp +1 -1
  66. data/ext/reflex/timer_event.cpp +1 -1
  67. data/ext/reflex/update_event.cpp +1 -1
  68. data/ext/reflex/view.cpp +18 -9
  69. data/ext/reflex/wheel_event.cpp +1 -1
  70. data/ext/reflex/window.cpp +1 -1
  71. data/include/reflex/defs.h +204 -187
  72. data/include/reflex/pointer.h +3 -5
  73. data/include/reflex/reflex.h +1 -0
  74. data/include/reflex/ruby/application.h +2 -2
  75. data/include/reflex/ruby/event.h +26 -26
  76. data/include/reflex/ruby/exception.h +3 -3
  77. data/include/reflex/ruby/filter.h +2 -2
  78. data/include/reflex/ruby/image_view.h +2 -2
  79. data/include/reflex/ruby/pointer.h +2 -2
  80. data/include/reflex/ruby/reflex.h +1 -1
  81. data/include/reflex/ruby/screen.h +2 -2
  82. data/include/reflex/ruby/selector.h +2 -2
  83. data/include/reflex/ruby/shape.h +10 -10
  84. data/include/reflex/ruby/style.h +4 -4
  85. data/include/reflex/ruby/timer.h +3 -3
  86. data/include/reflex/ruby/view.h +2 -2
  87. data/include/reflex/ruby/window.h +2 -2
  88. data/include/reflex/view.h +3 -1
  89. data/lib/reflex/extension.rb +4 -0
  90. data/lib/reflex/pointer.rb +1 -1
  91. data/lib/reflex/pointer_event.rb +2 -2
  92. data/reflex.gemspec +4 -4
  93. data/src/body.cpp +12 -6
  94. data/src/event.cpp +17 -31
  95. data/src/event.h +3 -3
  96. data/src/filter.cpp +3 -1
  97. data/src/ios/event.mm +20 -27
  98. data/src/osx/application.mm +6 -5
  99. data/src/osx/event.mm +1 -2
  100. data/src/pointer.cpp +12 -32
  101. data/src/pointer.h +0 -2
  102. data/src/selector.cpp +3 -1
  103. data/src/shape.cpp +5 -3
  104. data/src/style.cpp +14 -8
  105. data/src/view.cpp +47 -24
  106. data/src/win32/application.cpp +48 -35
  107. data/src/win32/device.cpp +18 -0
  108. data/src/win32/event.cpp +219 -0
  109. data/src/win32/event.h +50 -0
  110. data/src/win32/opengl.cpp +54 -27
  111. data/src/win32/opengl.h +15 -13
  112. data/src/win32/reflex.cpp +10 -16
  113. data/src/win32/screen.cpp +61 -0
  114. data/src/win32/screen.h +21 -0
  115. data/src/win32/window.cpp +445 -240
  116. data/src/window.cpp +28 -30
  117. data/src/window.h +3 -12
  118. data/test/test_pointer.rb +8 -10
  119. data/test/test_pointer_event.rb +8 -9
  120. data/test/test_window.rb +24 -21
  121. metadata +15 -12
  122. data/src/win32/defs.cpp +0 -303
  123. data/src/win32/defs.h +0 -34
@@ -9,14 +9,14 @@
9
9
  #include <reflex/selector.h>
10
10
 
11
11
 
12
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Reflex::Selector)
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(REFLEX_EXPORT, Reflex::Selector)
13
13
 
14
14
 
15
15
  namespace Reflex
16
16
  {
17
17
 
18
18
 
19
- Rucy::Class selector_class ();
19
+ REFLEX_EXPORT Rucy::Class selector_class ();
20
20
  // class Reflex::Selector
21
21
 
22
22
 
@@ -10,34 +10,34 @@
10
10
  #include <reflex/ruby/event.h>
11
11
 
12
12
 
13
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::Shape)
13
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Shape)
14
14
 
15
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::PolygonShape)
15
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::PolygonShape)
16
16
 
17
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::LineShape)
17
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::LineShape)
18
18
 
19
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::RectShape)
19
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::RectShape)
20
20
 
21
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::EllipseShape)
21
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::EllipseShape)
22
22
 
23
23
 
24
24
  namespace Reflex
25
25
  {
26
26
 
27
27
 
28
- Rucy::Class shape_class ();
28
+ REFLEX_EXPORT Rucy::Class shape_class ();
29
29
  // class Reflex::Shape
30
30
 
31
- Rucy::Class polygon_shape_class ();
31
+ REFLEX_EXPORT Rucy::Class polygon_shape_class ();
32
32
  // class Reflex::PolygonShape
33
33
 
34
- Rucy::Class line_shape_class ();
34
+ REFLEX_EXPORT Rucy::Class line_shape_class ();
35
35
  // class Reflex::LineShape
36
36
 
37
- Rucy::Class rect_shape_class ();
37
+ REFLEX_EXPORT Rucy::Class rect_shape_class ();
38
38
  // class Reflex::RectShape
39
39
 
40
- Rucy::Class ellipse_shape_class ();
40
+ REFLEX_EXPORT Rucy::Class ellipse_shape_class ();
41
41
  // class Reflex::EllipseShape
42
42
 
43
43
 
@@ -9,19 +9,19 @@
9
9
  #include <reflex/style.h>
10
10
 
11
11
 
12
- RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Reflex::StyleLength)
12
+ RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(REFLEX_EXPORT, Reflex::StyleLength)
13
13
 
14
- RUCY_DECLARE_VALUE_FROM_TO(Reflex::Style)
14
+ RUCY_DECLARE_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Style)
15
15
 
16
16
 
17
17
  namespace Reflex
18
18
  {
19
19
 
20
20
 
21
- Rucy::Class style_length_class ();
21
+ REFLEX_EXPORT Rucy::Class style_length_class ();
22
22
  // class Reflex::StyleLength
23
23
 
24
- Rucy::Class style_class ();
24
+ REFLEX_EXPORT Rucy::Class style_class ();
25
25
  // class Reflex::Style
26
26
 
27
27
 
@@ -9,14 +9,14 @@
9
9
  #include <reflex/timer.h>
10
10
 
11
11
 
12
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::Timer)
12
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Timer)
13
13
 
14
14
 
15
15
  namespace Reflex
16
16
  {
17
17
 
18
18
 
19
- Rucy::Class timer_class ();
19
+ REFLEX_EXPORT Rucy::Class timer_class ();
20
20
  // class Reflex::Timer
21
21
 
22
22
 
@@ -30,7 +30,7 @@ namespace Reflex
30
30
 
31
31
  virtual void fire ()
32
32
  {
33
- if (this->value.is_kind_of(timer_class()))
33
+ if (this->value.is_a(timer_class()))
34
34
  {
35
35
  RUCY_SYM(call_timer_block);
36
36
  this->value.call(call_timer_block);
@@ -10,14 +10,14 @@
10
10
  #include <reflex/ruby/event.h>
11
11
 
12
12
 
13
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::View)
13
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::View)
14
14
 
15
15
 
16
16
  namespace Reflex
17
17
  {
18
18
 
19
19
 
20
- Rucy::Class view_class ();
20
+ REFLEX_EXPORT Rucy::Class view_class ();
21
21
  // class Reflex::View
22
22
 
23
23
 
@@ -10,14 +10,14 @@
10
10
  #include <reflex/ruby/event.h>
11
11
 
12
12
 
13
- RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(Reflex::Window)
13
+ RUCY_DECLARE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::Window)
14
14
 
15
15
 
16
16
  namespace Reflex
17
17
  {
18
18
 
19
19
 
20
- Rucy::Class window_class ();
20
+ REFLEX_EXPORT Rucy::Class window_class ();
21
21
  // class Reflex::Window
22
22
 
23
23
 
@@ -309,7 +309,9 @@ namespace Reflex
309
309
  //
310
310
  // for physics child world
311
311
  //
312
- virtual void update_physics (float duration = 0);
312
+ virtual void create_world (float pixels_per_meter);
313
+
314
+ virtual void update_world (float duration = 0);
313
315
 
314
316
  virtual float meter2pixel (float meter = 1, bool create_world = true);
315
317
 
@@ -25,6 +25,10 @@ module Reflex
25
25
  root_dir 'lib'
26
26
  end
27
27
 
28
+ def ext_dir()
29
+ root_dir 'ext'
30
+ end
31
+
28
32
  end# Extension
29
33
 
30
34
 
@@ -95,7 +95,7 @@ module Reflex
95
95
  end
96
96
 
97
97
  def inspect()
98
- "#<Reflex::Pointer id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} drag:#{drag?} click:#{click_count} view:#{view_index} time:#{time.round 2}>"
98
+ "#<Reflex::Pointer id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} click:#{click_count} drag:#{drag?} time:#{time.round 2}>"
99
99
  end
100
100
 
101
101
  end# Pointer
@@ -16,7 +16,7 @@ module Reflex
16
16
  :types, :mouse?, :touch?, :pen?,
17
17
  :mouse_left?, :left?, :mouse_right?, :right?, :mouse_middle?, :middle?,
18
18
  :action, :down?, :up?, :move?, :cancel?, :stay?,
19
- :position, :pos, :x, :y, :modifiers, :drag?, :click_count, :view_index,
19
+ :position, :pos, :x, :y, :modifiers, :click_count, :drag?,
20
20
  :time, :prev, :down
21
21
 
22
22
  def pointers()
@@ -24,7 +24,7 @@ module Reflex
24
24
  end
25
25
 
26
26
  def inspect()
27
- "#<Reflex::PointerEvent id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} drag:#{drag?} click:#{click_count} view:#{view_index} time:#{time.round 2}>"
27
+ "#<Reflex::PointerEvent id:#{id} #{types} #{action} (#{x.round 2}, #{y.round 2}) mod:#{modifiers} click:#{click_count} drag:#{drag?} time:#{time.round 2}>"
28
28
  end
29
29
 
30
30
  end# PointerEvent
data/reflex.gemspec CHANGED
@@ -25,10 +25,10 @@ Gem::Specification.new do |s|
25
25
  s.platform = Gem::Platform::RUBY
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
- s.add_runtime_dependency 'xot', '~> 0.2.1'
29
- s.add_runtime_dependency 'rucy', '~> 0.2.1'
30
- s.add_runtime_dependency 'beeps', '~> 0.2.1'
31
- s.add_runtime_dependency 'rays', '~> 0.2.1'
28
+ s.add_runtime_dependency 'xot', '~> 0.3.1'
29
+ s.add_runtime_dependency 'rucy', '~> 0.3.1'
30
+ s.add_runtime_dependency 'beeps', '~> 0.3.1'
31
+ s.add_runtime_dependency 'rays', '~> 0.3.1'
32
32
 
33
33
  s.files = `git ls-files`.split $/
34
34
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
data/src/body.cpp CHANGED
@@ -284,24 +284,30 @@ namespace Reflex
284
284
  void
285
285
  Body_copy_attributes (Body* to, const Body& from)
286
286
  {
287
- if (!to)
288
- return;
289
-
290
- if (to->self->ppm != from.self->ppm)
291
- physics_error(__FILE__, __LINE__);
287
+ if (!to) return;
292
288
 
293
289
  b2Body* b2to = Body_get_b2ptr(to);
294
290
  const b2Body* b2from = Body_get_b2ptr(&from);
295
291
  assert(b2to && b2from);
296
292
 
297
293
  b2to->SetType( b2from->GetType());
298
- b2to->SetTransform( b2from->GetPosition(), b2from->GetAngle());
299
294
  b2to->SetLinearVelocity( b2from->GetLinearVelocity());
300
295
  b2to->SetAngularVelocity(b2from->GetAngularVelocity());
301
296
  b2to->SetLinearDamping( b2from->GetLinearDamping());
302
297
  b2to->SetAngularDamping( b2from->GetAngularDamping());
303
298
  b2to->SetGravityScale( b2from->GetGravityScale());
304
299
  b2to->SetBullet( b2from->IsBullet());
300
+
301
+ float ppm_to = to->self->ppm;
302
+ float ppm_from = from.self->ppm;
303
+ if (ppm_to == ppm_from)
304
+ b2to->SetTransform(b2from->GetPosition(), b2from->GetAngle());
305
+ else
306
+ {
307
+ auto pos = b2from->GetPosition();
308
+ pos *= ppm_from / ppm_to;
309
+ b2to->SetTransform(pos, b2from->GetAngle());
310
+ }
305
311
  }
306
312
 
307
313
  Body*
data/src/event.cpp CHANGED
@@ -1,6 +1,7 @@
1
1
  #include "event.h"
2
2
 
3
3
 
4
+ #include <algorithm>
4
5
  #include "reflex/timer.h"
5
6
  #include "reflex/shape.h"
6
7
  #include "reflex/exception.h"
@@ -506,11 +507,14 @@ namespace Reflex
506
507
 
507
508
 
508
509
  void
509
- KeyEvent_set_captured (KeyEvent* pthis, bool captured)
510
+ KeyEvent_set_chars (KeyEvent* pthis, const char* chars)
510
511
  {
511
- if (!pthis)
512
- argument_error(__FILE__, __LINE__);
512
+ pthis->self->chars = chars ? chars : "";
513
+ }
513
514
 
515
+ void
516
+ KeyEvent_set_captured (KeyEvent* pthis, bool captured)
517
+ {
514
518
  pthis->self->captured = captured;
515
519
  }
516
520
 
@@ -588,28 +592,16 @@ namespace Reflex
588
592
  {
589
593
  }
590
594
 
591
- void increment_view_indices ()
592
- {
593
- for (auto& pointer : pointers)
594
- Pointer_set_view_index(&pointer, pointer.view_index() + 1);
595
-
596
- if (parent) parent->increment_view_indices();
597
- }
598
-
599
595
  };// PointerEvent::Data
600
596
 
601
597
 
602
598
  void
603
- PointerEvent_add_pointer (
604
- PointerEvent* pthis, const Pointer& pointer,
605
- std::function<void(Pointer*)> fun)
599
+ PointerEvent_add_pointer (PointerEvent* pthis, const Pointer& pointer)
606
600
  {
607
601
  if (!pthis)
608
602
  argument_error(__FILE__, __LINE__);
609
603
 
610
604
  pthis->self->pointers.emplace_back(pointer);
611
-
612
- if (fun) fun(&pthis->self->pointers.back());
613
605
  }
614
606
 
615
607
  void
@@ -655,15 +647,6 @@ namespace Reflex
655
647
  fun(pointer);
656
648
  }
657
649
 
658
- void
659
- PointerEvent_increment_view_indices (PointerEvent* pthis)
660
- {
661
- if (!pthis)
662
- argument_error(__FILE__, __LINE__);
663
-
664
- pthis->self->increment_view_indices();
665
- }
666
-
667
650
  void
668
651
  PointerEvent_set_captured (PointerEvent* pthis, bool captured)
669
652
  {
@@ -676,23 +659,24 @@ namespace Reflex
676
659
  void
677
660
  PointerEvent_update_for_child_view (PointerEvent* pthis, const View* child)
678
661
  {
679
- if (!pthis || !child)
662
+ if (!pthis)
663
+ argument_error(__FILE__, __LINE__);
664
+ if (!child)
680
665
  argument_error(__FILE__, __LINE__);
681
666
 
682
667
  const Bounds& frame = child->frame();
683
- Bounds bounds = frame.dup().move_to(0, 0);
684
668
 
685
669
  std::vector<Pointer> pointers;
686
670
  for (const auto& pointer : pthis->self->pointers)
687
671
  {
672
+ if (!frame.is_include(pointer.position()))
673
+ continue;
674
+
688
675
  pointers.emplace_back(pointer);
689
676
  Pointer_update_positions(&pointers.back(), [&](Point* pos)
690
677
  {
691
678
  *pos = child->from_parent(*pos);
692
679
  });
693
-
694
- if (!bounds.is_include(pointers.back().position()))
695
- pointers.pop_back();
696
680
  }
697
681
  pthis->self->pointers = pointers;
698
682
  }
@@ -700,7 +684,9 @@ namespace Reflex
700
684
  void
701
685
  PointerEvent_update_for_capturing_view (PointerEvent* pthis, const View* view)
702
686
  {
703
- if (!pthis || !view)
687
+ if (!pthis)
688
+ argument_error(__FILE__, __LINE__);
689
+ if (!view)
704
690
  argument_error(__FILE__, __LINE__);
705
691
 
706
692
  for (auto& pointer : pthis->self->pointers)
data/src/event.h CHANGED
@@ -19,12 +19,12 @@ namespace Reflex
19
19
  void DrawEvent_set_bounds (DrawEvent* pthis, const Bounds& bounds);
20
20
 
21
21
 
22
+ void KeyEvent_set_chars (KeyEvent* pthis, const char* chars);
23
+
22
24
  void KeyEvent_set_captured (KeyEvent* pthis, bool captured);
23
25
 
24
26
 
25
- void PointerEvent_add_pointer (
26
- PointerEvent* pthis, const Pointer& pointer,
27
- std::function<void(Pointer*)> fun = NULL);
27
+ void PointerEvent_add_pointer (PointerEvent* pthis, const Pointer& pointer);
28
28
 
29
29
  void PointerEvent_erase_pointer (PointerEvent* pthis, Pointer::ID id);
30
30
 
data/src/filter.cpp CHANGED
@@ -36,7 +36,9 @@ namespace Reflex
36
36
  if (!self->shader)
37
37
  return;
38
38
 
39
- if (!painter || !image)
39
+ if (!painter)
40
+ argument_error(__FILE__, __LINE__);
41
+ if (!image)
40
42
  argument_error(__FILE__, __LINE__);
41
43
 
42
44
  painter->set_shader(self->shader);
data/src/ios/event.mm CHANGED
@@ -69,38 +69,31 @@ namespace Reflex
69
69
  (flags & UIKeyModifierNumericPad) ? MOD_NUMPAD : 0;
70
70
  }
71
71
 
72
- static Pointer
73
- create_pointer (UITouch* touch, UIEvent* event, UIView* view)
74
- {
75
- Pointer::Action action = get_action(touch);
76
-
77
- Pointer pointer(
78
- 0,
79
- get_type(touch),
80
- action,
81
- to_point([touch locationInView: view]),
82
- get_modifiers(event),
83
- action == Pointer::MOVE,
84
- (uint) touch.tapCount,
85
- 0,
86
- touch.timestamp);
87
-
88
- if (touch.phase != UITouchPhaseBegan)
89
- {
90
- Pointer_set_prev_position(
91
- &pointer, to_point([touch previousLocationInView: view]));
92
- }
93
-
94
- return pointer;
95
- }
96
-
97
72
  NativePointerEvent::NativePointerEvent (
98
73
  NSSet* touches, UIEvent* event, UIView* view)
99
74
  {
100
75
  for (UITouch* touch in touches)
101
76
  {
102
- Pointer pointer = create_pointer(touch, event, view);
103
- if (pointer) PointerEvent_add_pointer(this, pointer);
77
+ Pointer::Action action = get_action(touch);
78
+
79
+ Pointer pointer(
80
+ 0,
81
+ get_type(touch),
82
+ action,
83
+ to_point([touch locationInView: view]),
84
+ get_modifiers(event),
85
+ (uint) touch.tapCount,
86
+ action == Pointer::MOVE,
87
+ touch.timestamp);
88
+
89
+ if (pointer.action() != Pointer::DOWN)
90
+ {
91
+ Pointer_set_prev_position(
92
+ &pointer, to_point([touch previousLocationInView: view]));
93
+ }
94
+
95
+ if (pointer)
96
+ PointerEvent_add_pointer(this, pointer);
104
97
  }
105
98
  }
106
99
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  #import <AppKit/NSApplication.h>
6
6
  #include "reflex/exception.h"
7
+ #include "reflex/debug.h"
7
8
  #import "app_delegate.h"
8
9
 
9
10
 
@@ -42,11 +43,11 @@ namespace Reflex
42
43
  static ReflexAppDelegate*
43
44
  setup_app_delegate (NSApplication* app)
44
45
  {
45
- id<NSApplicationDelegate> delegate = [app delegate];
46
+ id<NSApplicationDelegate> delegate = app.delegate;
46
47
  if (!delegate)
47
48
  {
48
- delegate = [[[ReflexAppDelegate alloc] init] autorelease];
49
- [app setDelegate: delegate];
49
+ delegate = [[[ReflexAppDelegate alloc] init] autorelease];
50
+ app.delegate = delegate;
50
51
  }
51
52
 
52
53
  if (![delegate isKindOfClass: ReflexAppDelegate.class])
@@ -58,11 +59,11 @@ namespace Reflex
58
59
  void
59
60
  Application::start ()
60
61
  {
61
- NSApplication* app = [NSApplication sharedApplication];
62
+ NSApplication* app = NSApplication.sharedApplication;
62
63
  ReflexAppDelegate* delegate = setup_app_delegate(app);
63
64
  [delegate bind: this];
64
65
 
65
- if (![app isRunning])
66
+ if (!app.isRunning)
66
67
  [app run];
67
68
  else
68
69
  [delegate callOnStart];
data/src/osx/event.mm CHANGED
@@ -148,9 +148,8 @@ namespace Reflex
148
148
  action,
149
149
  get_pointer_position(event, view),
150
150
  get_modifiers(event),
151
- dragging,
152
151
  action == Pointer::MOVE && !dragging ? 0 : (uint) event.clickCount,
153
- 0,
152
+ dragging,
154
153
  time()));
155
154
  }
156
155
 
data/src/pointer.cpp CHANGED
@@ -1,7 +1,6 @@
1
1
  #include "pointer.h"
2
2
 
3
3
 
4
- #include <limits.h>
5
4
  #include <xot/time.h>
6
5
  #include "reflex/exception.h"
7
6
 
@@ -48,9 +47,7 @@ namespace Reflex
48
47
 
49
48
  Point position, prev_position;
50
49
 
51
- uint modifiers, flags;
52
-
53
- ushort click_count, view_index;
50
+ uint modifiers, click_count, flags;
54
51
 
55
52
  double time;
56
53
 
@@ -58,16 +55,14 @@ namespace Reflex
58
55
 
59
56
  Data (
60
57
  ID id = -1, uint types = TYPE_NONE, Action action = ACTION_NONE,
61
- const Point& position = 0, uint modifiers = 0,
58
+ const Point& position = 0, uint modifiers = 0, uint click_count = 0,
62
59
  bool drag = false, bool enter = false, bool exit = false,
63
- uint click_count = 0, uint view_index = 0, double time = 0)
60
+ double time = 0)
64
61
  : id(id), types(types), action(action),
65
- position(position), modifiers(modifiers),
62
+ position(position), modifiers(modifiers), click_count(click_count),
66
63
  flags(make_flags(drag, enter, exit)),
67
- click_count(click_count), view_index(view_index), time(time)
64
+ time(time)
68
65
  {
69
- if (view_index >= USHRT_MAX)
70
- argument_error(__FILE__, __LINE__);
71
66
  }
72
67
 
73
68
  uint make_flags (bool drag, bool enter, bool exit)
@@ -101,15 +96,6 @@ namespace Reflex
101
96
  it->self->id = id;
102
97
  }
103
98
 
104
- void
105
- Pointer_set_view_index (Pointer* it, uint view_index)
106
- {
107
- if (view_index >= USHRT_MAX)
108
- argument_error(__FILE__, __LINE__);
109
-
110
- it->self->view_index = view_index;
111
- }
112
-
113
99
  void
114
100
  Pointer_add_flag (Pointer* it, uint flag)
115
101
  {
@@ -177,12 +163,12 @@ namespace Reflex
177
163
 
178
164
  Pointer::Pointer (
179
165
  ID id, uint types, Action action,
180
- const Point& position, uint modifiers, bool drag,
181
- uint click_count, uint view_index, double time)
166
+ const Point& position, uint modifiers, uint click_count, bool drag,
167
+ double time)
182
168
  : self(new Data(
183
169
  id, types, action,
184
- position, modifiers, drag, false, false,
185
- click_count, view_index, time))
170
+ position, modifiers, click_count, drag, false, false,
171
+ time))
186
172
  {
187
173
  }
188
174
 
@@ -232,22 +218,16 @@ namespace Reflex
232
218
  return self->modifiers;
233
219
  }
234
220
 
235
- bool
236
- Pointer::is_drag () const
237
- {
238
- return Xot::has_flag(self->flags, Data::DRAG);
239
- }
240
-
241
221
  uint
242
222
  Pointer::click_count () const
243
223
  {
244
224
  return self->click_count;
245
225
  }
246
226
 
247
- uint
248
- Pointer::view_index () const
227
+ bool
228
+ Pointer::is_drag () const
249
229
  {
250
- return self->view_index;
230
+ return Xot::has_flag(self->flags, Data::DRAG);
251
231
  }
252
232
 
253
233
  double
data/src/pointer.h CHANGED
@@ -16,8 +16,6 @@ namespace Reflex
16
16
 
17
17
  void Pointer_set_id (Pointer* it, Pointer::ID id);
18
18
 
19
- void Pointer_set_view_index (Pointer* it, uint view_index);
20
-
21
19
  void Pointer_add_flag (Pointer* it, uint flag);
22
20
 
23
21
  void Pointer_remove_flag (Pointer* it, uint flag);
data/src/selector.cpp CHANGED
@@ -76,7 +76,9 @@ namespace Reflex
76
76
  void
77
77
  Selector::add_tag (const char* tag)
78
78
  {
79
- if (!tag || *tag == '\0')
79
+ if (!tag)
80
+ argument_error(__FILE__, __LINE__);
81
+ if (*tag == '\0')
80
82
  argument_error(__FILE__, __LINE__);
81
83
 
82
84
  iterator it = self->tags.find(tag);
data/src/shape.cpp CHANGED
@@ -444,7 +444,9 @@ namespace Reflex
444
444
  void
445
445
  Shape_call_contact_event (Shape* shape, ContactEvent* event)
446
446
  {
447
- if (!shape || !event)
447
+ if (!shape)
448
+ argument_error(__FILE__, __LINE__);
449
+ if (!event)
448
450
  argument_error(__FILE__, __LINE__);
449
451
 
450
452
  shape->on_contact(event);
@@ -1024,8 +1026,8 @@ namespace Reflex
1024
1026
  bool has_angle () const
1025
1027
  {
1026
1028
  return
1027
- angle_from != DEFAULT_ANGLE_FROM ||
1028
- angle_to != DEFAULT_ANGLE_TO;
1029
+ angle_from != (float) DEFAULT_ANGLE_FROM ||
1030
+ angle_to != (float) DEFAULT_ANGLE_TO;
1029
1031
  }
1030
1032
 
1031
1033
  Fixture* create_fixtures (Shape* shape) override
data/src/style.cpp CHANGED
@@ -202,7 +202,9 @@ namespace Reflex
202
202
  void
203
203
  StyleLength::reset (Type type, Value value)
204
204
  {
205
- if (type < NONE || TYPE_MAX <= type)
205
+ if (type < NONE)
206
+ argument_error(__FILE__, __LINE__);
207
+ if (type >= TYPE_MAX)
206
208
  argument_error(__FILE__, __LINE__);
207
209
 
208
210
  if (type == FIT && value != 1)
@@ -615,14 +617,18 @@ namespace Reflex
615
617
  void
616
618
  Style::set_flow (Flow main, Flow sub)
617
619
  {
618
- if (
619
- main < FLOW_NONE || FLOW_MAX <= main ||
620
- sub < FLOW_NONE || FLOW_MAX <= sub ||
621
- (main != FLOW_NONE && (get_flow_dir(main) == get_flow_dir(sub))) ||
622
- (main == FLOW_NONE && sub != FLOW_NONE))
623
- {
620
+ if (main < FLOW_NONE)
621
+ argument_error(__FILE__, __LINE__);
622
+ if (main >= FLOW_MAX)
623
+ argument_error(__FILE__, __LINE__);
624
+ if (sub < FLOW_NONE)
625
+ argument_error(__FILE__, __LINE__);
626
+ if (sub >= FLOW_MAX)
627
+ argument_error(__FILE__, __LINE__);
628
+ if (main != FLOW_NONE && (get_flow_dir(main) == get_flow_dir(sub)))
629
+ argument_error(__FILE__, __LINE__);
630
+ if (main == FLOW_NONE && sub != FLOW_NONE)
624
631
  argument_error(__FILE__, __LINE__);
625
- }
626
632
 
627
633
  self->set_flow(main, sub);
628
634