reflexion 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 720f804cad8f1348d221caee8b90c063419da65d955885a69301eeb01874bebe
4
- data.tar.gz: e37f6f9b3741722a328a6e63f637045ad79a7cb1bcf9c60ad75f17d29df7db70
3
+ metadata.gz: 5161374ea08be1889e5cc2efe3e1428e8d9d620f8bac6073e5b010bd10bedebe
4
+ data.tar.gz: 2ba43dca1df02955b05cf58f6a9046f21941a605f8c9d8c1bdc744fb8d808ab2
5
5
  SHA512:
6
- metadata.gz: af1ba3a6bdb955c33942ec891aa23243bfb9231fb31e45f6fe71f60ab86700e1eeba7f64328a5687277d6ba06e57eea725adc235e21c7b1fc7c9d1d6fb409549
7
- data.tar.gz: d159177ac4e9835d6b7443d957250f6c67c696d589608cb4047fa7fadac9a72ec5d87a65c80b806653f7ba2795f16f0c69413a73e1a33f85ed2ab8496d6bbce8
6
+ metadata.gz: 4e237f277deb2ca92edee8663023891f3bba4cc8d2ac8e54ed7317f1dee8907c159afb3e20a7b6c5d798e0d0979b8bec709cf19a18decba5578d782e36c1e8d8
7
+ data.tar.gz: 61430437a4717c0547f3fb8432e0faa0532391e1bee56fa46083986e4f1c68d7aa194d261264144c1f7416f4c1926e6f7ca4e32a0ca371835337e9a57b5abb65
@@ -26,8 +26,8 @@ VALUE initialize(VALUE self)
26
26
  check_arg_count(__FILE__, __LINE__, "ContactEvent#initialize", argc, 0, 2);
27
27
 
28
28
  THIS->type = (argc >= 1)
29
- ? (Reflex::ContactEvent::Type) to<int>(argv[0])
30
- : Reflex::ContactEvent::NONE;
29
+ ? (Reflex::ContactEvent::Type) to<int>(argv[0])
30
+ : Reflex::ContactEvent::NONE;
31
31
  THIS->shape = (argc >= 2) ? to<Reflex::Shape*>(argv[1]) : NULL;
32
32
 
33
33
  return rb_call_super(0, NULL);
@@ -157,7 +157,6 @@ Init_pointer_event ()
157
157
  cPointerEvent.define_const("POINTER_MOUSE_MIDDLE", Reflex::POINTER_MOUSE_MIDDLE);
158
158
  cPointerEvent.define_const("POINTER_TOUCH", Reflex::POINTER_TOUCH);
159
159
  cPointerEvent.define_const("POINTER_PEN", Reflex::POINTER_PEN);
160
- cPointerEvent.define_const("POINTER_TYPE_LAST", Reflex::POINTER_TYPE_LAST);
161
160
  }
162
161
 
163
162
 
@@ -1,4 +1,6 @@
1
- #include "reflex/reflex.h"
1
+ #include "reflex/ruby/reflex.h"
2
+
3
+
2
4
  #include "reflex/ruby/view.h"
3
5
  #include "reflex/ruby/timer.h"
4
6
  #include "../../src/window.h"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.14
1
+ 0.1.15
@@ -27,8 +27,8 @@ RUCY_DEFN(initialize)
27
27
  check_arg_count(__FILE__, __LINE__, "ContactEvent#initialize", argc, 0, 2);
28
28
 
29
29
  THIS->type = (argc >= 1)
30
- ? (Reflex::ContactEvent::Type) to<int>(argv[0])
31
- : Reflex::ContactEvent::NONE;
30
+ ? (Reflex::ContactEvent::Type) to<int>(argv[0])
31
+ : Reflex::ContactEvent::NONE;
32
32
  THIS->shape = (argc >= 2) ? to<Reflex::Shape*>(argv[1]) : NULL;
33
33
 
34
34
  return rb_call_super(0, NULL);
@@ -171,7 +171,6 @@ Init_pointer_event ()
171
171
  cPointerEvent.define_const("POINTER_MOUSE_MIDDLE", Reflex::POINTER_MOUSE_MIDDLE);
172
172
  cPointerEvent.define_const("POINTER_TOUCH", Reflex::POINTER_TOUCH);
173
173
  cPointerEvent.define_const("POINTER_PEN", Reflex::POINTER_PEN);
174
- cPointerEvent.define_const("POINTER_TYPE_LAST", Reflex::POINTER_TYPE_LAST);
175
174
  }
176
175
 
177
176
 
@@ -1,4 +1,6 @@
1
- #include "reflex/reflex.h"
1
+ #include "reflex/ruby/reflex.h"
2
+
3
+
2
4
  #include "reflex/ruby/view.h"
3
5
  #include "reflex/ruby/timer.h"
4
6
  #include "../../src/window.h"
@@ -215,8 +215,6 @@ namespace Reflex
215
215
 
216
216
  POINTER_PEN = 0x1 << 4,
217
217
 
218
- POINTER_TYPE_LAST = POINTER_PEN,
219
-
220
218
  };// PointType
221
219
 
222
220
 
@@ -5,6 +5,7 @@
5
5
 
6
6
 
7
7
  #include <rucy/module.h>
8
+ #include <reflex/reflex.h>
8
9
 
9
10
 
10
11
  namespace Reflex
@@ -24,7 +24,22 @@ namespace Reflex
24
24
 
25
25
  typedef coord Value;
26
26
 
27
- enum Type {NONE = 0, PIXEL, PERCENT, FILL, FIT, TYPE_LAST};
27
+ enum Type
28
+ {
29
+
30
+ NONE = 0,
31
+
32
+ PIXEL,
33
+
34
+ PERCENT,
35
+
36
+ FILL,
37
+
38
+ FIT,
39
+
40
+ TYPE_MAX
41
+
42
+ };// Type
28
43
 
29
44
  StyleLength (Type type = NONE, Value value = 0);
30
45
 
@@ -60,9 +75,20 @@ namespace Reflex
60
75
 
61
76
  enum Flow
62
77
  {
63
- FLOW_NONE = 0, FLOW_RIGHT, FLOW_DOWN, FLOW_LEFT, FLOW_UP,
64
- FLOW_LAST
65
- };
78
+
79
+ FLOW_NONE = 0,
80
+
81
+ FLOW_RIGHT,
82
+
83
+ FLOW_DOWN,
84
+
85
+ FLOW_LEFT,
86
+
87
+ FLOW_UP,
88
+
89
+ FLOW_MAX
90
+
91
+ };// Flow
66
92
 
67
93
  Style (const char* name = NULL);
68
94
 
@@ -47,6 +47,22 @@ Reflex::Window.new do
47
47
  translate 100, 0
48
48
  ellipse x, y, w, h, hole: 10, from: 200, to: 300
49
49
  polygon Rays::Polygon.ellipse x, y2, w, h, hole: 10, from: 200, to: 300
50
+
51
+ translate 100, 0
52
+ curve x, y, x + w, y, x + w, y + h, x, y + h
53
+ polygon Rays::Polygon.curve x, y2, x + w, y2, x + w, y2 + h, x, y2 + h
54
+
55
+ translate 100, 0
56
+ curve x, y, x + w, y, x + w, y + h, x, y + h, loop: true
57
+ polygon Rays::Polygon.curve x, y2, x + w, y2, x + w, y2 + h, x, y2 + h, loop: true
58
+
59
+ translate 100, 0
60
+ bezier x, y, x + w, y, x + w, y + h, x, y + h
61
+ polygon Rays::Polygon.bezier x, y2, x + w, y2, x + w, y2 + h, x, y2 + h
62
+
63
+ translate 100, 0
64
+ bezier x, y, x + w, y, x + w, y + h, x, y + h, loop: true
65
+ polygon Rays::Polygon.bezier x, y2, x + w, y2, x + w, y2 + h, x, y2 + h, loop: true
50
66
  end
51
67
 
52
68
  translate 0, 200
@@ -13,6 +13,10 @@
13
13
 
14
14
  - (ReflexView*) createReflexView;
15
15
 
16
+ - (void) startTimer;
17
+
18
+ - (void) stopTimer;
19
+
16
20
  - (void) viewDidResize;
17
21
 
18
22
  @end// ReflexViewController
@@ -144,11 +144,15 @@ ReflexViewController_get_show_fun ()
144
144
  }
145
145
 
146
146
  - (void) dealloc
147
+ {
148
+ [self cleanup];
149
+ [super dealloc];
150
+ }
151
+
152
+ - (void) cleanup
147
153
  {
148
154
  [self cleanupReflexView];
149
155
  [self unbind];
150
-
151
- [super dealloc];
152
156
  }
153
157
 
154
158
  - (void) bind: (Reflex::Window*) window
@@ -160,7 +164,8 @@ ReflexViewController_get_show_fun ()
160
164
  if (data.view_controller)
161
165
  Reflex::invalid_state_error(__FILE__, __LINE__);
162
166
 
163
- data.view_controller = [self retain];
167
+ // ruby value references view controller weakly.
168
+ data.view_controller = self;
164
169
 
165
170
  // Reflex::Window is not constructed completely,
166
171
  // so can not call ClassWrapper::retain().
@@ -180,8 +185,6 @@ ReflexViewController_get_show_fun ()
180
185
  ptr_for_rebind->Xot::template RefCountable<>::release();
181
186
  ptr_for_rebind = NULL;
182
187
  }
183
-
184
- assert(pwindow && !ptr_for_rebind);
185
188
  }
186
189
 
187
190
  - (void) unbind
@@ -189,12 +192,7 @@ ReflexViewController_get_show_fun ()
189
192
  [self rebind];
190
193
  if (!pwindow) return;
191
194
 
192
- Reflex::WindowData& data = Window_get_data(pwindow);
193
- if (data.view_controller)
194
- {
195
- [data.view_controller release];
196
- data.view_controller = nil;
197
- }
195
+ Window_get_data(pwindow).view_controller = nil;
198
196
 
199
197
  pwindow->release();
200
198
  pwindow = NULL;
@@ -211,7 +209,7 @@ ReflexViewController_get_show_fun ()
211
209
  [super didReceiveMemoryWarning];
212
210
 
213
211
  if ([self isViewLoaded] && !self.view.window)
214
- [self cleanupReflexView];
212
+ [self cleanup];
215
213
  }
216
214
 
217
215
  - (void) viewDidLoad
@@ -262,7 +260,7 @@ ReflexViewController_get_show_fun ()
262
260
 
263
261
  EAGLContext* context = view.context;
264
262
  if (context && context == [EAGLContext currentContext])
265
- [EAGLContext setCurrentContext: nil];
263
+ [EAGLContext setCurrentContext: (EAGLContext*) Rays::get_offscreen_context()];
266
264
 
267
265
  [view removeFromSuperview];
268
266
 
@@ -272,7 +270,7 @@ ReflexViewController_get_show_fun ()
272
270
  - (void) viewDidAppear: (BOOL) animated
273
271
  {
274
272
  [super viewDidAppear: animated];
275
- [self startTimer: 60];
273
+ [self startTimer];
276
274
  }
277
275
 
278
276
  - (void) viewDidDisappear: (BOOL) animated
@@ -281,6 +279,11 @@ ReflexViewController_get_show_fun ()
281
279
  [super viewDidDisappear: animated];
282
280
  }
283
281
 
282
+ - (void) startTimer
283
+ {
284
+ [self startTimer: 60];
285
+ }
286
+
284
287
  - (void) startTimer: (int) fps
285
288
  {
286
289
  [self stopTimer];
@@ -344,22 +347,7 @@ ReflexViewController_get_show_fun ()
344
347
  win->self->prev_fps = fps;
345
348
 
346
349
  Reflex::DrawEvent e(dt, fps);
347
-
348
- e.painter = win->painter();
349
- if (!e.painter)
350
- Xot::invalid_state_error(__FILE__, __LINE__);
351
-
352
- Rays::Bounds frame = win->frame();
353
- e.bounds.reset(0, 0, frame.width, frame.height);
354
-
355
- e.painter->begin();
356
- e.painter->clear();
357
-
358
- win->on_draw(&e);
359
- if (!e.is_blocked())
360
- Reflex::View_draw_tree(win->root(), e, 0, frame.move_to(0));
361
-
362
- e.painter->end();
350
+ Window_call_draw_event(win, &e);
363
351
  }
364
352
 
365
353
  - (void) viewDidResize
@@ -399,7 +387,7 @@ ReflexViewController_get_show_fun ()
399
387
  if (!win) return;
400
388
 
401
389
  Reflex::NativePointerEvent e(
402
- touches, event, self.view, Reflex::PointerEvent::DOWN);
390
+ touches, event, self.reflexView, Reflex::PointerEvent::DOWN);
403
391
  win->on_pointer(&e);
404
392
  }
405
393
 
@@ -409,7 +397,7 @@ ReflexViewController_get_show_fun ()
409
397
  if (!win) return;
410
398
 
411
399
  Reflex::NativePointerEvent e(
412
- touches, event, self.view, Reflex::PointerEvent::UP);
400
+ touches, event, self.reflexView, Reflex::PointerEvent::UP);
413
401
  win->on_pointer(&e);
414
402
  }
415
403
 
@@ -419,7 +407,7 @@ ReflexViewController_get_show_fun ()
419
407
  if (!win) return;
420
408
 
421
409
  Reflex::NativePointerEvent e(
422
- touches, event, self.view, Reflex::PointerEvent::UP);
410
+ touches, event, self.reflexView, Reflex::PointerEvent::UP);
423
411
  win->on_pointer(&e);
424
412
  }
425
413
 
@@ -429,7 +417,7 @@ ReflexViewController_get_show_fun ()
429
417
  if (!win) return;
430
418
 
431
419
  Reflex::NativePointerEvent e(
432
- touches, event, self.view, Reflex::PointerEvent::MOVE);
420
+ touches, event, self.reflexView, Reflex::PointerEvent::MOVE);
433
421
  win->on_pointer(&e);
434
422
  }
435
423
 
@@ -43,7 +43,7 @@ static const NSUInteger WINDOW_STYLE_MASK =
43
43
 
44
44
  [self setDelegate: self];
45
45
  [self setupContentView];
46
- [self startTimer: 60];
46
+ [self startTimer];
47
47
 
48
48
  return self;
49
49
  }
@@ -66,7 +66,8 @@ static const NSUInteger WINDOW_STYLE_MASK =
66
66
  if (data.native)
67
67
  Reflex::invalid_state_error(__FILE__, __LINE__);
68
68
 
69
- data.native = [self retain];
69
+ // ruby value references native window weakly.
70
+ data.native = self;
70
71
 
71
72
  // Reflex::Window is not constructed completely,
72
73
  // so can not call ClassWrapper::retain().
@@ -86,8 +87,6 @@ static const NSUInteger WINDOW_STYLE_MASK =
86
87
  ptr_for_rebind->Xot::template RefCountable<>::release();
87
88
  ptr_for_rebind = NULL;
88
89
  }
89
-
90
- assert(pwindow && !ptr_for_rebind);
91
90
  }
92
91
 
93
92
  - (void) unbind
@@ -95,12 +94,7 @@ static const NSUInteger WINDOW_STYLE_MASK =
95
94
  [self rebind];
96
95
  if (!pwindow) return;
97
96
 
98
- Reflex::WindowData& data = Window_get_data(pwindow);
99
- if (data.native)
100
- {
101
- [data.native release];
102
- data.native = nil;
103
- }
97
+ Window_get_data(pwindow).native = nil;
104
98
 
105
99
  pwindow->release();
106
100
  pwindow = NULL;
@@ -120,6 +114,11 @@ static const NSUInteger WINDOW_STYLE_MASK =
120
114
  [self setContentView: view];
121
115
  }
122
116
 
117
+ - (void) startTimer
118
+ {
119
+ [self startTimer: 60];
120
+ }
121
+
123
122
  - (void) startTimer: (int) fps
124
123
  {
125
124
  [self stopTimer];
@@ -183,22 +182,7 @@ static const NSUInteger WINDOW_STYLE_MASK =
183
182
  win->self->prev_fps = fps;
184
183
 
185
184
  Reflex::DrawEvent e(dt, fps);
186
-
187
- e.painter = win->painter();
188
- if (!e.painter)
189
- Xot::invalid_state_error(__FILE__, __LINE__);
190
-
191
- Rays::Bounds frame = win->frame();
192
- e.bounds.reset(0, 0, frame.width, frame.height);
193
-
194
- e.painter->begin();
195
- e.painter->clear();
196
-
197
- win->on_draw(&e);
198
- if (!e.is_blocked())
199
- Reflex::View_draw_tree(win->root(), e, 0, frame.move_to(0));
200
-
201
- e.painter->end();
185
+ Window_call_draw_event(win, &e);
202
186
  }
203
187
 
204
188
  - (BOOL) windowShouldClose: (id) sender
@@ -52,8 +52,8 @@ namespace Reflex
52
52
  if (!style) return NULL;
53
53
 
54
54
  return is_default_shape(shape)
55
- ? &style->background_fill()
56
- : &style->foreground_fill();
55
+ ? &style->background_fill()
56
+ : &style->foreground_fill();
57
57
  }
58
58
 
59
59
  static coord
@@ -65,8 +65,8 @@ namespace Reflex
65
65
  if (!style) return 0;
66
66
 
67
67
  return is_default_shape(shape)
68
- ? style->background_stroke_width()
69
- : style->foreground_stroke_width();
68
+ ? style->background_stroke_width()
69
+ : style->foreground_stroke_width();
70
70
  }
71
71
 
72
72
  static bool
@@ -201,7 +201,7 @@ namespace Reflex
201
201
  void
202
202
  StyleLength::reset (Type type, Value value)
203
203
  {
204
- if (type < NONE || TYPE_LAST <= type)
204
+ if (type < NONE || TYPE_MAX <= type)
205
205
  argument_error(__FILE__, __LINE__);
206
206
 
207
207
  if (type == FIT && value != 1)
@@ -225,7 +225,7 @@ namespace Reflex
225
225
 
226
226
  StyleLength::operator bool () const
227
227
  {
228
- return NONE < self->type && self->type < TYPE_LAST;
228
+ return NONE < self->type && self->type < TYPE_MAX;
229
229
  }
230
230
 
231
231
  bool
@@ -615,8 +615,8 @@ namespace Reflex
615
615
  Style::set_flow (Flow main, Flow sub)
616
616
  {
617
617
  if (
618
- main < FLOW_NONE || FLOW_LAST <= main ||
619
- sub < FLOW_NONE || FLOW_LAST <= sub ||
618
+ main < FLOW_NONE || FLOW_MAX <= main ||
619
+ sub < FLOW_NONE || FLOW_MAX <= sub ||
620
620
  (main != FLOW_NONE && (get_flow_dir(main) == get_flow_dir(sub))) ||
621
621
  (main == FLOW_NONE && sub != FLOW_NONE))
622
622
  {
@@ -189,8 +189,8 @@ namespace Reflex
189
189
  {
190
190
  World* world = parent_world();
191
191
  Body* b = world
192
- ? new Body(world, frame.position(), angle)
193
- : Body_create_temporary();
192
+ ? new Body(world, frame.position(), angle)
193
+ : Body_create_temporary();
194
194
  assert(b);
195
195
 
196
196
  pbody.reset(b);
@@ -36,6 +36,33 @@ namespace Reflex
36
36
  }
37
37
  }
38
38
 
39
+ void
40
+ Window_call_draw_event (Window* window, DrawEvent* event)
41
+ {
42
+ if (!window || !event)
43
+ argument_error(__FILE__, __LINE__);
44
+
45
+ Painter* painter = window->painter();
46
+ if (!painter)
47
+ Xot::invalid_state_error(__FILE__, __LINE__);
48
+
49
+ Rays::Bounds frame = window->frame();
50
+
51
+ event->painter = painter;
52
+ event->bounds.reset(0, 0, frame.width, frame.height);
53
+
54
+ painter->begin();
55
+ painter->push_state();
56
+ painter->clear();
57
+
58
+ window->on_draw(event);
59
+ if (!event->is_blocked())
60
+ Reflex::View_draw_tree(window->root(), *event, 0, frame.move_to(0));
61
+
62
+ painter->pop_state();
63
+ painter->end();
64
+ }
65
+
39
66
  namespace global
40
67
  {
41
68
 
@@ -80,6 +80,8 @@ namespace Reflex
80
80
 
81
81
  void Window_set_focus (Window* window, View* view);
82
82
 
83
+ void Window_call_draw_event (Window* window, DrawEvent* event);
84
+
83
85
 
84
86
  typedef View* (*Window_CreateRootViewFun) ();
85
87
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reflexion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-23 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot