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.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/body.cpp +53 -0
- data/.doc/ext/reflex/native.cpp +0 -4
- data/.doc/ext/reflex/selector.cpp +3 -3
- data/.doc/ext/reflex/style.cpp +390 -30
- data/.doc/ext/reflex/style_length.cpp +1 -1
- data/.doc/ext/reflex/view.cpp +24 -6
- data/VERSION +1 -1
- data/ext/reflex/body.cpp +59 -0
- data/ext/reflex/native.cpp +0 -4
- data/ext/reflex/selector.cpp +3 -3
- data/ext/reflex/style.cpp +432 -32
- data/ext/reflex/style_length.cpp +1 -1
- data/ext/reflex/view.cpp +25 -5
- data/include/reflex/body.h +16 -0
- data/include/reflex/ruby.h +5 -3
- data/include/reflex/ruby/style.h +11 -0
- data/include/reflex/selector.h +7 -1
- data/include/reflex/style.h +93 -27
- data/include/reflex/view.h +8 -4
- data/lib/reflex.rb +0 -2
- data/lib/reflex/body.rb +1 -0
- data/lib/reflex/button.rb +1 -0
- data/lib/reflex/selector.rb +10 -1
- data/lib/reflex/style.rb +15 -0
- data/lib/reflex/style_length.rb +1 -1
- data/lib/reflex/view.rb +5 -2
- data/lib/reflex/window.rb +2 -2
- data/samples/reflexion/breakout.rb +4 -9
- data/src/body.cpp +61 -0
- data/src/ios/event.mm +1 -3
- data/src/ios/native_window.mm +3 -20
- data/src/ios/opengl_view.mm +1 -1
- data/src/ios/window.mm +7 -0
- data/src/selector.cpp +38 -16
- data/src/style.cpp +515 -161
- data/src/view.cpp +371 -242
- data/src/world.cpp +8 -0
- data/test/test_selector.rb +14 -12
- data/test/test_style.rb +11 -6
- data/test/test_style_length.rb +5 -6
- data/test/test_view.rb +8 -7
- metadata +2 -17
- data/.doc/ext/reflex/style_length2.cpp +0 -149
- data/.doc/ext/reflex/style_length4.cpp +0 -192
- data/ext/reflex/style_length2.cpp +0 -157
- data/ext/reflex/style_length4.cpp +0 -204
- data/include/reflex/ruby/style_length.h +0 -63
- data/include/reflex/style_length.h +0 -147
- data/lib/reflex/style_length2.rb +0 -34
- data/lib/reflex/style_length4.rb +0 -38
- data/src/style_length.cpp +0 -341
- data/test/test_style_length2.rb +0 -50
- data/test/test_style_length4.rb +0 -56
data/lib/reflex/style_length2.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'xot/setter'
|
5
|
-
require 'xot/block_util'
|
6
|
-
require 'reflex/ext'
|
7
|
-
|
8
|
-
|
9
|
-
module Reflex
|
10
|
-
|
11
|
-
|
12
|
-
class StyleLength2
|
13
|
-
|
14
|
-
include Xot::Setter
|
15
|
-
|
16
|
-
alias w= width=
|
17
|
-
alias w width
|
18
|
-
alias h= height=
|
19
|
-
alias h height
|
20
|
-
|
21
|
-
def initialize (opts = {}, &block)
|
22
|
-
super()
|
23
|
-
set opts
|
24
|
-
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_a ()
|
28
|
-
[width, height]
|
29
|
-
end
|
30
|
-
|
31
|
-
end# StyleLength2
|
32
|
-
|
33
|
-
|
34
|
-
end# Reflex
|
data/lib/reflex/style_length4.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require 'xot/setter'
|
5
|
-
require 'xot/block_util'
|
6
|
-
require 'reflex/ext'
|
7
|
-
|
8
|
-
|
9
|
-
module Reflex
|
10
|
-
|
11
|
-
|
12
|
-
class StyleLength4
|
13
|
-
|
14
|
-
include Xot::Setter
|
15
|
-
|
16
|
-
alias l= left=
|
17
|
-
alias l left
|
18
|
-
alias t= top=
|
19
|
-
alias t top
|
20
|
-
alias r= right=
|
21
|
-
alias r right
|
22
|
-
alias b= bottom=
|
23
|
-
alias b bottom
|
24
|
-
|
25
|
-
def initialize (opts = {}, &block)
|
26
|
-
super()
|
27
|
-
set opts
|
28
|
-
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
29
|
-
end
|
30
|
-
|
31
|
-
def to_a ()
|
32
|
-
[left, top, right, bottom]
|
33
|
-
end
|
34
|
-
|
35
|
-
end# StyleLength4
|
36
|
-
|
37
|
-
|
38
|
-
end# Reflex
|
data/src/style_length.cpp
DELETED
@@ -1,341 +0,0 @@
|
|
1
|
-
#include "reflex/style_length.h"
|
2
|
-
|
3
|
-
|
4
|
-
#include <math.h>
|
5
|
-
#include <boost/array.hpp>
|
6
|
-
#include "reflex/exception.h"
|
7
|
-
|
8
|
-
|
9
|
-
namespace Reflex
|
10
|
-
{
|
11
|
-
|
12
|
-
|
13
|
-
struct StyleLength::Data
|
14
|
-
{
|
15
|
-
|
16
|
-
Value value;
|
17
|
-
|
18
|
-
Unit unit;
|
19
|
-
|
20
|
-
Data () : value(0), unit(NONE) {}
|
21
|
-
|
22
|
-
};// StyleLength::Data
|
23
|
-
|
24
|
-
|
25
|
-
StyleLength::StyleLength ()
|
26
|
-
{
|
27
|
-
}
|
28
|
-
|
29
|
-
StyleLength::StyleLength (Value value, Unit unit)
|
30
|
-
{
|
31
|
-
reset(value, unit);
|
32
|
-
}
|
33
|
-
|
34
|
-
StyleLength::StyleLength (const char* str)
|
35
|
-
{
|
36
|
-
reset(str);
|
37
|
-
}
|
38
|
-
|
39
|
-
StyleLength
|
40
|
-
StyleLength::copy () const
|
41
|
-
{
|
42
|
-
return StyleLength(value(), unit());
|
43
|
-
}
|
44
|
-
|
45
|
-
void
|
46
|
-
StyleLength::reset (Value value, Unit unit)
|
47
|
-
{
|
48
|
-
if (unit != PIXEL) //unit < NONE || UNIT_LAST <= unit)
|
49
|
-
argument_error(__FILE__, __LINE__);
|
50
|
-
|
51
|
-
self->value = value;
|
52
|
-
self->unit = unit;
|
53
|
-
}
|
54
|
-
|
55
|
-
static StyleLength::Unit
|
56
|
-
str2unit (const char* s)
|
57
|
-
{
|
58
|
-
if (strcasecmp(s, "px") == 0) return StyleLength::PIXEL;
|
59
|
-
else if (strcasecmp(s, "%") == 0) return StyleLength::PERCENT;
|
60
|
-
else return StyleLength::NONE;
|
61
|
-
}
|
62
|
-
|
63
|
-
static const char*
|
64
|
-
unit2str (StyleLength::Unit unit)
|
65
|
-
{
|
66
|
-
switch (unit)
|
67
|
-
{
|
68
|
-
case StyleLength::PIXEL: return "px";
|
69
|
-
case StyleLength::PERCENT: return "%";
|
70
|
-
default: return NULL;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
void
|
75
|
-
StyleLength::reset (const char* str)
|
76
|
-
{
|
77
|
-
Value num;
|
78
|
-
char suffix[256];
|
79
|
-
int count = sscanf(str, "%f%s", &num, suffix);
|
80
|
-
if (count != 2)
|
81
|
-
argument_error(__FILE__, __LINE__);
|
82
|
-
|
83
|
-
reset(num, str2unit(suffix));
|
84
|
-
}
|
85
|
-
|
86
|
-
StyleLength::Value
|
87
|
-
StyleLength::value () const
|
88
|
-
{
|
89
|
-
return self->value;
|
90
|
-
}
|
91
|
-
|
92
|
-
StyleLength::Unit
|
93
|
-
StyleLength::unit () const
|
94
|
-
{
|
95
|
-
return self->unit;
|
96
|
-
}
|
97
|
-
|
98
|
-
bool
|
99
|
-
StyleLength::get_pixel (coord* pixel, coord parent_size) const
|
100
|
-
{
|
101
|
-
if (!pixel)
|
102
|
-
argument_error(__FILE__, __LINE__);
|
103
|
-
|
104
|
-
switch (self->unit)
|
105
|
-
{
|
106
|
-
case PIXEL: *pixel = self->value; break;
|
107
|
-
case PERCENT: *pixel = parent_size * self->value; break;
|
108
|
-
default: return false;
|
109
|
-
}
|
110
|
-
|
111
|
-
return true;
|
112
|
-
}
|
113
|
-
|
114
|
-
String
|
115
|
-
StyleLength::to_s () const
|
116
|
-
{
|
117
|
-
if (!*this)
|
118
|
-
invalid_state_error(__FILE__, __LINE__);
|
119
|
-
|
120
|
-
String num;
|
121
|
-
if (fmod(self->value, 1) == 0)
|
122
|
-
num = Xot::stringf("%d", (long) self->value);
|
123
|
-
else
|
124
|
-
num = Xot::stringf("%g", self->value);
|
125
|
-
|
126
|
-
const char* suffix = unit2str(self->unit);;
|
127
|
-
if (!suffix)
|
128
|
-
invalid_state_error(__FILE__, __LINE__);
|
129
|
-
|
130
|
-
return num + suffix;
|
131
|
-
}
|
132
|
-
|
133
|
-
StyleLength::operator bool () const
|
134
|
-
{
|
135
|
-
return NONE < self->unit && self->unit < UNIT_LAST;
|
136
|
-
}
|
137
|
-
|
138
|
-
bool
|
139
|
-
StyleLength::operator ! () const
|
140
|
-
{
|
141
|
-
return !operator bool();
|
142
|
-
}
|
143
|
-
|
144
|
-
|
145
|
-
struct StyleLength2::Data
|
146
|
-
{
|
147
|
-
|
148
|
-
boost::array<StyleLength, 2> array;
|
149
|
-
|
150
|
-
};// StyleLength2::Data
|
151
|
-
|
152
|
-
|
153
|
-
StyleLength2::StyleLength2 ()
|
154
|
-
{
|
155
|
-
}
|
156
|
-
|
157
|
-
StyleLength2::StyleLength2 (const StyleLength& all)
|
158
|
-
{
|
159
|
-
StyleLength2& a = *this;
|
160
|
-
a[0] = a[1] = all;
|
161
|
-
}
|
162
|
-
|
163
|
-
StyleLength2::StyleLength2 (const StyleLength& width, const StyleLength& height)
|
164
|
-
{
|
165
|
-
StyleLength2& a = *this;
|
166
|
-
a[0] = width;
|
167
|
-
a[1] = height;
|
168
|
-
}
|
169
|
-
|
170
|
-
StyleLength2
|
171
|
-
StyleLength2::copy () const
|
172
|
-
{
|
173
|
-
return StyleLength2(width().copy(), height().copy());
|
174
|
-
}
|
175
|
-
|
176
|
-
void
|
177
|
-
StyleLength2::set_width (const StyleLength& width)
|
178
|
-
{
|
179
|
-
(*this)[0] = width;
|
180
|
-
}
|
181
|
-
|
182
|
-
const StyleLength&
|
183
|
-
StyleLength2::width () const
|
184
|
-
{
|
185
|
-
return (*this)[0];
|
186
|
-
}
|
187
|
-
|
188
|
-
void
|
189
|
-
StyleLength2::set_height (const StyleLength& height)
|
190
|
-
{
|
191
|
-
(*this)[1] = height;
|
192
|
-
}
|
193
|
-
|
194
|
-
const StyleLength&
|
195
|
-
StyleLength2::height () const
|
196
|
-
{
|
197
|
-
return (*this)[1];
|
198
|
-
}
|
199
|
-
|
200
|
-
size_t
|
201
|
-
StyleLength2::size () const
|
202
|
-
{
|
203
|
-
return self->array.size();
|
204
|
-
}
|
205
|
-
|
206
|
-
StyleLength&
|
207
|
-
StyleLength2::operator [] (size_t i)
|
208
|
-
{
|
209
|
-
return self->array[i];
|
210
|
-
}
|
211
|
-
|
212
|
-
const StyleLength&
|
213
|
-
StyleLength2::operator [] (size_t i) const
|
214
|
-
{
|
215
|
-
return const_cast<StyleLength2*>(this)->operator[](i);
|
216
|
-
}
|
217
|
-
|
218
|
-
|
219
|
-
struct StyleLength4::Data
|
220
|
-
{
|
221
|
-
|
222
|
-
boost::array<StyleLength, 4> array;
|
223
|
-
|
224
|
-
};// StyleLength4::Data
|
225
|
-
|
226
|
-
|
227
|
-
StyleLength4::StyleLength4 ()
|
228
|
-
{
|
229
|
-
}
|
230
|
-
|
231
|
-
StyleLength4::StyleLength4 (const StyleLength& all)
|
232
|
-
{
|
233
|
-
StyleLength4& a = *this;
|
234
|
-
a[0] = a[1] = a[2] = a[3] = all;
|
235
|
-
}
|
236
|
-
|
237
|
-
StyleLength4::StyleLength4 (const StyleLength& horizontal, const StyleLength& vertical)
|
238
|
-
{
|
239
|
-
StyleLength4& a = *this;
|
240
|
-
a[0] = a[2] = horizontal;
|
241
|
-
a[1] = a[3] = vertical;
|
242
|
-
}
|
243
|
-
|
244
|
-
StyleLength4::StyleLength4 (
|
245
|
-
const StyleLength& left,
|
246
|
-
const StyleLength& vertical,
|
247
|
-
const StyleLength& right)
|
248
|
-
{
|
249
|
-
StyleLength4& a = *this;
|
250
|
-
a[0] = left;
|
251
|
-
a[2] = right;
|
252
|
-
a[1] = a[3] = vertical;
|
253
|
-
}
|
254
|
-
|
255
|
-
StyleLength4::StyleLength4 (
|
256
|
-
const StyleLength& left,
|
257
|
-
const StyleLength& top,
|
258
|
-
const StyleLength& right,
|
259
|
-
const StyleLength& bottom)
|
260
|
-
{
|
261
|
-
StyleLength4& a = *this;
|
262
|
-
a[0] = left;
|
263
|
-
a[1] = top;
|
264
|
-
a[2] = right;
|
265
|
-
a[3] = bottom;
|
266
|
-
}
|
267
|
-
|
268
|
-
StyleLength4
|
269
|
-
StyleLength4::copy () const
|
270
|
-
{
|
271
|
-
return StyleLength4(left().copy(), top().copy(), right().copy(), bottom().copy());
|
272
|
-
}
|
273
|
-
|
274
|
-
void
|
275
|
-
StyleLength4::set_left (const StyleLength& left)
|
276
|
-
{
|
277
|
-
(*this)[0] = left;
|
278
|
-
}
|
279
|
-
|
280
|
-
const StyleLength&
|
281
|
-
StyleLength4::left () const
|
282
|
-
{
|
283
|
-
return (*this)[0];
|
284
|
-
}
|
285
|
-
|
286
|
-
void
|
287
|
-
StyleLength4::set_top (const StyleLength& top)
|
288
|
-
{
|
289
|
-
(*this)[1] = top;
|
290
|
-
}
|
291
|
-
|
292
|
-
const StyleLength&
|
293
|
-
StyleLength4::top () const
|
294
|
-
{
|
295
|
-
return (*this)[1];
|
296
|
-
}
|
297
|
-
|
298
|
-
void
|
299
|
-
StyleLength4::set_right (const StyleLength& right)
|
300
|
-
{
|
301
|
-
(*this)[2] = right;
|
302
|
-
}
|
303
|
-
|
304
|
-
const StyleLength&
|
305
|
-
StyleLength4::right () const
|
306
|
-
{
|
307
|
-
return (*this)[2];
|
308
|
-
}
|
309
|
-
|
310
|
-
void
|
311
|
-
StyleLength4::set_bottom (const StyleLength& bottom)
|
312
|
-
{
|
313
|
-
(*this)[3] = bottom;
|
314
|
-
}
|
315
|
-
|
316
|
-
const StyleLength&
|
317
|
-
StyleLength4::bottom () const
|
318
|
-
{
|
319
|
-
return (*this)[3];
|
320
|
-
}
|
321
|
-
|
322
|
-
size_t
|
323
|
-
StyleLength4::size () const
|
324
|
-
{
|
325
|
-
return self->array.size();
|
326
|
-
}
|
327
|
-
|
328
|
-
StyleLength&
|
329
|
-
StyleLength4::operator [] (size_t i)
|
330
|
-
{
|
331
|
-
return self->array[i];
|
332
|
-
}
|
333
|
-
|
334
|
-
const StyleLength&
|
335
|
-
StyleLength4::operator [] (size_t i) const
|
336
|
-
{
|
337
|
-
return const_cast<StyleLength4*>(this)->operator[](i);
|
338
|
-
}
|
339
|
-
|
340
|
-
|
341
|
-
}// Reflex
|
data/test/test_style_length2.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
|
4
|
-
require_relative 'helper'
|
5
|
-
|
6
|
-
|
7
|
-
class TestStyleLength2 < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def len2 (w = 0, h = 0, &block)
|
10
|
-
Reflex::StyleLength2.new width: w, height: h, &block
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_initialize ()
|
14
|
-
assert_equal 0, len2(*%w[]) .width.value
|
15
|
-
assert_equal 1, len2(*%w[1px]) .width.value
|
16
|
-
assert_equal 2, len2(*%w[1px 2px]).height.value
|
17
|
-
assert_equal :px, len2(*%w[1px]).width.unit
|
18
|
-
#assert_equal :%, len2(*%w[1%]).width.unit
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_wh ()
|
22
|
-
assert_equal '1px', len2(1) .width.to_s
|
23
|
-
assert_equal '2px', len2(1, 2).height.to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_to_a ()
|
27
|
-
assert_equal [0, 0], len2.to_a.map(&:value)
|
28
|
-
assert_equal [:px] * 2, len2.to_a.map(&:unit)
|
29
|
-
assert_equal [1, 2], len2(1, 2).to_a.map(&:value)
|
30
|
-
assert_equal [:px] * 2, len2(1, 2).to_a.map(&:unit)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_get_set_at ()
|
34
|
-
l = len2 1, 2
|
35
|
-
|
36
|
-
assert_equal 1, l[0].value
|
37
|
-
assert_equal 2, l[1].value
|
38
|
-
|
39
|
-
l[0] = '10px'
|
40
|
-
assert_equal 10, l[0].value
|
41
|
-
l[1] = '40px'
|
42
|
-
assert_equal 40, l[1].value
|
43
|
-
l[-1] = '30px'
|
44
|
-
assert_equal 30, l[ 1].value
|
45
|
-
assert_equal 30, l[-1].value
|
46
|
-
|
47
|
-
assert_raises(IndexError) {l[2] = '50px'}
|
48
|
-
end
|
49
|
-
|
50
|
-
end# TestStyleLength2
|