reflexion 0.1.10 → 0.1.11

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/body.cpp +53 -0
  3. data/.doc/ext/reflex/native.cpp +0 -4
  4. data/.doc/ext/reflex/selector.cpp +3 -3
  5. data/.doc/ext/reflex/style.cpp +390 -30
  6. data/.doc/ext/reflex/style_length.cpp +1 -1
  7. data/.doc/ext/reflex/view.cpp +24 -6
  8. data/VERSION +1 -1
  9. data/ext/reflex/body.cpp +59 -0
  10. data/ext/reflex/native.cpp +0 -4
  11. data/ext/reflex/selector.cpp +3 -3
  12. data/ext/reflex/style.cpp +432 -32
  13. data/ext/reflex/style_length.cpp +1 -1
  14. data/ext/reflex/view.cpp +25 -5
  15. data/include/reflex/body.h +16 -0
  16. data/include/reflex/ruby.h +5 -3
  17. data/include/reflex/ruby/style.h +11 -0
  18. data/include/reflex/selector.h +7 -1
  19. data/include/reflex/style.h +93 -27
  20. data/include/reflex/view.h +8 -4
  21. data/lib/reflex.rb +0 -2
  22. data/lib/reflex/body.rb +1 -0
  23. data/lib/reflex/button.rb +1 -0
  24. data/lib/reflex/selector.rb +10 -1
  25. data/lib/reflex/style.rb +15 -0
  26. data/lib/reflex/style_length.rb +1 -1
  27. data/lib/reflex/view.rb +5 -2
  28. data/lib/reflex/window.rb +2 -2
  29. data/samples/reflexion/breakout.rb +4 -9
  30. data/src/body.cpp +61 -0
  31. data/src/ios/event.mm +1 -3
  32. data/src/ios/native_window.mm +3 -20
  33. data/src/ios/opengl_view.mm +1 -1
  34. data/src/ios/window.mm +7 -0
  35. data/src/selector.cpp +38 -16
  36. data/src/style.cpp +515 -161
  37. data/src/view.cpp +371 -242
  38. data/src/world.cpp +8 -0
  39. data/test/test_selector.rb +14 -12
  40. data/test/test_style.rb +11 -6
  41. data/test/test_style_length.rb +5 -6
  42. data/test/test_view.rb +8 -7
  43. metadata +2 -17
  44. data/.doc/ext/reflex/style_length2.cpp +0 -149
  45. data/.doc/ext/reflex/style_length4.cpp +0 -192
  46. data/ext/reflex/style_length2.cpp +0 -157
  47. data/ext/reflex/style_length4.cpp +0 -204
  48. data/include/reflex/ruby/style_length.h +0 -63
  49. data/include/reflex/style_length.h +0 -147
  50. data/lib/reflex/style_length2.rb +0 -34
  51. data/lib/reflex/style_length4.rb +0 -38
  52. data/src/style_length.cpp +0 -341
  53. data/test/test_style_length2.rb +0 -50
  54. data/test/test_style_length4.rb +0 -56
@@ -1,157 +0,0 @@
1
- #include "reflex/ruby/style_length.h"
2
-
3
-
4
- #include <rucy.h>
5
- #include "defs.h"
6
-
7
-
8
- using namespace Rucy;
9
-
10
-
11
- RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength2)
12
-
13
- #define THIS to<Reflex::StyleLength2*>(self)
14
-
15
- #define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength2, self)
16
-
17
-
18
- static
19
- RUCY_DEF_ALLOC(alloc, klass)
20
- {
21
- return new_type<Reflex::StyleLength2>(klass);
22
- }
23
- RUCY_END
24
-
25
- static
26
- RUCY_DEF1(initialize_copy, obj)
27
- {
28
- CHECK;
29
- *THIS = to<Reflex::StyleLength2&>(obj).copy();
30
- return self;
31
- }
32
- RUCY_END
33
-
34
- static
35
- RUCY_DEF1(set_width, width)
36
- {
37
- CHECK;
38
- THIS->set_width(to<Reflex::StyleLength>(width));
39
- }
40
- RUCY_END
41
-
42
- static
43
- RUCY_DEF0(get_width)
44
- {
45
- CHECK;
46
- return value(THIS->width());
47
- }
48
- RUCY_END
49
-
50
- static
51
- RUCY_DEF1(set_height, height)
52
- {
53
- CHECK;
54
- THIS->set_height(to<Reflex::StyleLength>(height));
55
- }
56
- RUCY_END
57
-
58
- static
59
- RUCY_DEF0(get_height)
60
- {
61
- CHECK;
62
- return value(THIS->height());
63
- }
64
- RUCY_END
65
-
66
- static
67
- RUCY_DEF2(set_at, index, length)
68
- {
69
- CHECK;
70
-
71
- int i = index.as_i(), size = (int) THIS->size();
72
- while (i < 0) i += size;
73
-
74
- if (i >= size)
75
- index_error(__FILE__, __LINE__);
76
-
77
- (*THIS)[i] = to<Reflex::StyleLength>(length);
78
- }
79
- RUCY_END
80
-
81
- static
82
- RUCY_DEF1(get_at, index)
83
- {
84
- CHECK;
85
-
86
- int i = index.as_i(), size = (int) THIS->size();
87
- while (i < 0) i += size;
88
-
89
- if (i >= size)
90
- index_error(__FILE__, __LINE__);
91
-
92
- return value((*THIS)[i]);
93
- }
94
- RUCY_END
95
-
96
-
97
- static Class cStyleLength2;
98
-
99
- void
100
- Init_style_length2 ()
101
- {
102
- Module mReflex = define_module("Reflex");
103
-
104
- cStyleLength2 = mReflex.define_class("StyleLength2");
105
- cStyleLength2.define_alloc_func(alloc);
106
- cStyleLength2.define_private_method("initialize_copy", initialize_copy);
107
- cStyleLength2.define_method("width=", set_width);
108
- cStyleLength2.define_method("width", get_width);
109
- cStyleLength2.define_method("height=", set_height);
110
- cStyleLength2.define_method("height", get_height);
111
- cStyleLength2.define_method("[]=", set_at);
112
- cStyleLength2.define_method("[]", get_at);
113
- }
114
-
115
-
116
- namespace Rucy
117
- {
118
-
119
-
120
- template <> Reflex::StyleLength2
121
- value_to<Reflex::StyleLength2> (Value value, bool convert)
122
- {
123
- if (convert && value.is_array())
124
- {
125
- Value* a = value.as_array();
126
- switch (value.size())
127
- {
128
- case 1: return Reflex::StyleLength2(
129
- to<Reflex::StyleLength>(a[0]));
130
-
131
- case 2: return Reflex::StyleLength2(
132
- to<Reflex::StyleLength>(a[0]),
133
- to<Reflex::StyleLength>(a[1]));
134
-
135
- default: argument_error(__FILE__, __LINE__);
136
- }
137
- }
138
-
139
- return value_to<Reflex::StyleLength2&>(value, convert);
140
- }
141
-
142
-
143
- }// Rucy
144
-
145
-
146
- namespace Reflex
147
- {
148
-
149
-
150
- Class
151
- style_length2_class ()
152
- {
153
- return cStyleLength2;
154
- }
155
-
156
-
157
- }// Reflex
@@ -1,204 +0,0 @@
1
- #include "reflex/ruby/style_length.h"
2
-
3
-
4
- #include <rucy.h>
5
- #include "defs.h"
6
-
7
-
8
- using namespace Rucy;
9
-
10
-
11
- RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength4)
12
-
13
- #define THIS to<Reflex::StyleLength4*>(self)
14
-
15
- #define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength4, self)
16
-
17
-
18
- static
19
- RUCY_DEF_ALLOC(alloc, klass)
20
- {
21
- return new_type<Reflex::StyleLength4>(klass);
22
- }
23
- RUCY_END
24
-
25
- static
26
- RUCY_DEF1(initialize_copy, obj)
27
- {
28
- CHECK;
29
- *THIS = to<Reflex::StyleLength4&>(obj).copy();
30
- return self;
31
- }
32
- RUCY_END
33
-
34
- static
35
- RUCY_DEF1(set_left, left)
36
- {
37
- CHECK;
38
- THIS->set_left(to<Reflex::StyleLength>(left));
39
- }
40
- RUCY_END
41
-
42
- static
43
- RUCY_DEF0(get_left)
44
- {
45
- CHECK;
46
- return value(THIS->left());
47
- }
48
- RUCY_END
49
-
50
- static
51
- RUCY_DEF1(set_top, top)
52
- {
53
- CHECK;
54
- THIS->set_top(to<Reflex::StyleLength>(top));
55
- }
56
- RUCY_END
57
-
58
- static
59
- RUCY_DEF0(get_top)
60
- {
61
- CHECK;
62
- return value(THIS->top());
63
- }
64
- RUCY_END
65
-
66
- static
67
- RUCY_DEF1(set_right, right)
68
- {
69
- CHECK;
70
- THIS->set_right(to<Reflex::StyleLength>(right));
71
- }
72
- RUCY_END
73
-
74
- static
75
- RUCY_DEF0(get_right)
76
- {
77
- CHECK;
78
- return value(THIS->right());
79
- }
80
- RUCY_END
81
-
82
- static
83
- RUCY_DEF1(set_bottom, bottom)
84
- {
85
- CHECK;
86
- THIS->set_bottom(to<Reflex::StyleLength>(bottom));
87
- }
88
- RUCY_END
89
-
90
- static
91
- RUCY_DEF0(get_bottom)
92
- {
93
- CHECK;
94
- return value(THIS->bottom());
95
- }
96
- RUCY_END
97
-
98
- static
99
- RUCY_DEF2(set_at, index, length)
100
- {
101
- CHECK;
102
-
103
- int i = index.as_i(), size = (int) THIS->size();
104
- while (i < 0) i += size;
105
-
106
- if (i >= size)
107
- index_error(__FILE__, __LINE__);
108
-
109
- (*THIS)[i] = to<Reflex::StyleLength>(length);
110
- }
111
- RUCY_END
112
-
113
- static
114
- RUCY_DEF1(get_at, index)
115
- {
116
- CHECK;
117
-
118
- int i = index.as_i(), size = (int) THIS->size();
119
- while (i < 0) i += size;
120
-
121
- if (i >= size)
122
- index_error(__FILE__, __LINE__);
123
-
124
- return value((*THIS)[i]);
125
- }
126
- RUCY_END
127
-
128
-
129
- static Class cStyleLength4;
130
-
131
- void
132
- Init_style_length4 ()
133
- {
134
- Module mReflex = define_module("Reflex");
135
-
136
- cStyleLength4 = mReflex.define_class("StyleLength4");
137
- cStyleLength4.define_alloc_func(alloc);
138
- cStyleLength4.define_private_method("initialize_copy", initialize_copy);
139
- cStyleLength4.define_method("left=", set_left);
140
- cStyleLength4.define_method("left", get_left);
141
- cStyleLength4.define_method("top=", set_top);
142
- cStyleLength4.define_method("top", get_top);
143
- cStyleLength4.define_method("right=", set_right);
144
- cStyleLength4.define_method("right", get_right);
145
- cStyleLength4.define_method("bottom=", set_bottom);
146
- cStyleLength4.define_method("bottom", get_bottom);
147
- cStyleLength4.define_method("[]=", set_at);
148
- cStyleLength4.define_method("[]", get_at);
149
- }
150
-
151
-
152
- namespace Rucy
153
- {
154
-
155
-
156
- template <> Reflex::StyleLength4
157
- value_to<Reflex::StyleLength4> (Value value, bool convert)
158
- {
159
- if (convert && value.is_array())
160
- {
161
- Value* a = value.as_array();
162
- switch (value.size())
163
- {
164
- case 1: return Reflex::StyleLength4(
165
- to<Reflex::StyleLength>(a[0]));
166
-
167
- case 2: return Reflex::StyleLength4(
168
- to<Reflex::StyleLength>(a[0]),
169
- to<Reflex::StyleLength>(a[1]));
170
-
171
- case 3: return Reflex::StyleLength4(
172
- to<Reflex::StyleLength>(a[0]),
173
- to<Reflex::StyleLength>(a[1]),
174
- to<Reflex::StyleLength>(a[2]));
175
-
176
- case 4: return Reflex::StyleLength4(
177
- to<Reflex::StyleLength>(a[0]),
178
- to<Reflex::StyleLength>(a[1]),
179
- to<Reflex::StyleLength>(a[2]),
180
- to<Reflex::StyleLength>(a[3]));
181
-
182
- default: argument_error(__FILE__, __LINE__);
183
- }
184
- }
185
-
186
- return value_to<Reflex::StyleLength4&>(value, convert);
187
- }
188
-
189
-
190
- }// Rucy
191
-
192
-
193
- namespace Reflex
194
- {
195
-
196
-
197
- Class
198
- style_length4_class ()
199
- {
200
- return cStyleLength4;
201
- }
202
-
203
-
204
- }// Reflex
@@ -1,63 +0,0 @@
1
- // -*- c++ -*-
2
- #pragma once
3
- #ifndef __REFLEX_RUBY_STYLE_LENGTH_H__
4
- #define __REFLEX_RUBY_STYLE_LENGTH_H__
5
-
6
-
7
- #include <rucy/rucy.h>
8
- #include <rucy/class.h>
9
- #include <rucy/extension.h>
10
- #include <reflex/style.h>
11
-
12
-
13
- namespace Reflex
14
- {
15
-
16
-
17
- Rucy::Class style_length_class ();
18
- // class Reflex::StyleLength
19
-
20
- Rucy::Class style_length2_class ();
21
- // class Reflex::StyleLength2
22
-
23
- Rucy::Class style_length4_class ();
24
- // class Reflex::StyleLength4
25
-
26
-
27
- }// Reflex
28
-
29
-
30
- RUCY_DECLARE_VALUE_FROM_TO(Reflex::StyleLength)
31
-
32
- RUCY_DECLARE_VALUE_FROM_TO(Reflex::StyleLength2)
33
-
34
- RUCY_DECLARE_VALUE_FROM_TO(Reflex::StyleLength4)
35
-
36
-
37
- namespace Rucy
38
- {
39
-
40
-
41
- template <> inline Class
42
- get_ruby_class<Reflex::StyleLength> ()
43
- {
44
- return Reflex::style_length_class();
45
- }
46
-
47
- template <> inline Class
48
- get_ruby_class<Reflex::StyleLength2> ()
49
- {
50
- return Reflex::style_length2_class();
51
- }
52
-
53
- template <> inline Class
54
- get_ruby_class<Reflex::StyleLength4> ()
55
- {
56
- return Reflex::style_length4_class();
57
- }
58
-
59
-
60
- }// Rucy
61
-
62
-
63
- #endif//EOH
@@ -1,147 +0,0 @@
1
- // -*- c++ -*-
2
- #pragma once
3
- #ifndef __REFLEX_STYLE_LENGTH_H__
4
- #define __REFLEX_STYLE_LENGTH_H__
5
-
6
-
7
- #include <xot/pimpl.h>
8
- #include <reflex/defs.h>
9
-
10
-
11
- namespace Reflex
12
- {
13
-
14
-
15
- class StyleLength
16
- {
17
-
18
- public:
19
-
20
- typedef coord Value;
21
-
22
- enum Unit {NONE = 0, PIXEL, PERCENT, UNIT_LAST};
23
-
24
- StyleLength ();
25
-
26
- StyleLength (Value value, Unit unit = PIXEL);
27
-
28
- explicit StyleLength (const char* str);
29
-
30
- StyleLength copy () const;
31
-
32
- void reset (Value value = 0, Unit unit = NONE);
33
-
34
- void reset (const char* str);
35
-
36
- Value value () const;
37
-
38
- Unit unit () const;
39
-
40
- bool get_pixel (coord* pixel, coord parent_size) const;
41
-
42
- String to_s () const;
43
-
44
- operator bool () const;
45
-
46
- bool operator ! () const;
47
-
48
- struct Data;
49
-
50
- Xot::PImpl<Data, true> self;
51
-
52
- };// StyleLength
53
-
54
-
55
- class StyleLength2
56
- {
57
-
58
- public:
59
-
60
- StyleLength2 ();
61
-
62
- StyleLength2 (const StyleLength& all);
63
-
64
- StyleLength2 (const StyleLength& width, const StyleLength& height);
65
-
66
- StyleLength2 copy () const;
67
-
68
- void set_width (const StyleLength& width);
69
-
70
- const StyleLength& width () const;
71
-
72
- void set_height (const StyleLength& height);
73
-
74
- const StyleLength& height () const;
75
-
76
- size_t size () const;
77
-
78
- StyleLength& operator [] (size_t i);
79
-
80
- const StyleLength& operator [] (size_t i) const;
81
-
82
- struct Data;
83
-
84
- Xot::PImpl<Data, true> self;
85
-
86
- };// StyleLength2
87
-
88
-
89
- class StyleLength4
90
- {
91
-
92
- public:
93
-
94
- StyleLength4 ();
95
-
96
- StyleLength4 (const StyleLength& all);
97
-
98
- StyleLength4 (
99
- const StyleLength& horizontal,
100
- const StyleLength& vertical);
101
-
102
- StyleLength4 (
103
- const StyleLength& left,
104
- const StyleLength& vertical,
105
- const StyleLength& right);
106
-
107
- StyleLength4 (
108
- const StyleLength& left,
109
- const StyleLength& top,
110
- const StyleLength& right,
111
- const StyleLength& bottom);
112
-
113
- StyleLength4 copy () const;
114
-
115
- void set_left (const StyleLength& left);
116
-
117
- const StyleLength& left () const;
118
-
119
- void set_top (const StyleLength& top);
120
-
121
- const StyleLength& top () const;
122
-
123
- void set_right (const StyleLength& right);
124
-
125
- const StyleLength& right () const;
126
-
127
- void set_bottom (const StyleLength& bottom);
128
-
129
- const StyleLength& bottom () const;
130
-
131
- size_t size () const;
132
-
133
- StyleLength& operator [] (size_t i);
134
-
135
- const StyleLength& operator [] (size_t i) const;
136
-
137
- struct Data;
138
-
139
- Xot::PImpl<Data, true> self;
140
-
141
- };// StyleLength4
142
-
143
-
144
- }// Reflex
145
-
146
-
147
- #endif//EOH