reflexion 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- 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/ext/reflex/style_length.cpp
CHANGED
data/ext/reflex/view.cpp
CHANGED
@@ -141,15 +141,17 @@ RUCY_DEF1(remove_style, style)
|
|
141
141
|
RUCY_END
|
142
142
|
|
143
143
|
static
|
144
|
-
|
144
|
+
RUCY_DEF1(get_style, selector)
|
145
145
|
{
|
146
146
|
CHECK;
|
147
|
-
check_arg_count(__FILE__, __LINE__, "View#get_style", argc, 0, 1);
|
148
147
|
|
149
|
-
|
150
|
-
|
148
|
+
Reflex::Style* s = NULL;
|
149
|
+
if (selector)
|
150
|
+
s = THIS->get_style(to<Reflex::Selector>(selector), true);
|
151
151
|
else
|
152
|
-
|
152
|
+
s = THIS->style(true);
|
153
|
+
|
154
|
+
return s ? value(*s) : nil();
|
153
155
|
}
|
154
156
|
RUCY_END
|
155
157
|
|
@@ -320,6 +322,22 @@ RUCY_DEF0(get_frame)
|
|
320
322
|
}
|
321
323
|
RUCY_END
|
322
324
|
|
325
|
+
static
|
326
|
+
RUCY_DEF1(set_zoom, zoom)
|
327
|
+
{
|
328
|
+
CHECK;
|
329
|
+
THIS->set_zoom(to<float>(zoom));
|
330
|
+
}
|
331
|
+
RUCY_END
|
332
|
+
|
333
|
+
static
|
334
|
+
RUCY_DEF0(get_zoom)
|
335
|
+
{
|
336
|
+
CHECK;
|
337
|
+
return value(THIS->zoom());
|
338
|
+
}
|
339
|
+
RUCY_END
|
340
|
+
|
323
341
|
static
|
324
342
|
RUCY_DEF0(get_angle)
|
325
343
|
{
|
@@ -709,6 +727,8 @@ Init_view ()
|
|
709
727
|
cView.define_method("selector", get_selector);
|
710
728
|
cView.define_private_method("set_frame", set_frame);
|
711
729
|
cView.define_private_method("get_frame", get_frame);
|
730
|
+
cView.define_method("zoom=", set_zoom);
|
731
|
+
cView.define_method("zoom", get_zoom);
|
712
732
|
cView.define_method("angle", get_angle);
|
713
733
|
cView.define_method("scroll_to", scroll_to);
|
714
734
|
cView.define_method("scroll_by", scroll_by);
|
data/include/reflex/body.h
CHANGED
@@ -67,6 +67,18 @@ namespace Reflex
|
|
67
67
|
|
68
68
|
float angular_velocity () const;
|
69
69
|
|
70
|
+
void apply_force (coord x, coord y);
|
71
|
+
|
72
|
+
void apply_force (const Point& force);
|
73
|
+
|
74
|
+
void apply_torque (float torque);
|
75
|
+
|
76
|
+
void apply_linear_impulse (coord x, coord y);
|
77
|
+
|
78
|
+
void apply_linear_impulse (const Point& impulse);
|
79
|
+
|
80
|
+
void apply_angular_impulse (float impulse);
|
81
|
+
|
70
82
|
void set_density (float density);
|
71
83
|
|
72
84
|
float density () const;
|
@@ -79,6 +91,10 @@ namespace Reflex
|
|
79
91
|
|
80
92
|
float restitution () const;
|
81
93
|
|
94
|
+
void set_gravity_scale (float scale);
|
95
|
+
|
96
|
+
float gravity_scale () const;
|
97
|
+
|
82
98
|
iterator begin ();
|
83
99
|
|
84
100
|
const_iterator begin () const;
|
data/include/reflex/ruby.h
CHANGED
@@ -5,14 +5,16 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
#include <reflex/ruby/reflex.h>
|
8
|
-
#include <reflex/ruby/application.h>
|
9
|
-
#include <reflex/ruby/window.h>
|
10
|
-
#include <reflex/ruby/view.h>
|
11
8
|
#include <reflex/ruby/selector.h>
|
12
9
|
#include <reflex/ruby/style.h>
|
13
10
|
#include <reflex/ruby/event.h>
|
14
11
|
#include <reflex/ruby/body.h>
|
15
12
|
#include <reflex/ruby/fixture.h>
|
13
|
+
#include <reflex/ruby/application.h>
|
14
|
+
#include <reflex/ruby/window.h>
|
15
|
+
#include <reflex/ruby/view.h>
|
16
|
+
#include <reflex/ruby/image_view.h>
|
17
|
+
#include <reflex/ruby/shape_view.h>
|
16
18
|
|
17
19
|
|
18
20
|
#endif//EOH
|
data/include/reflex/ruby/style.h
CHANGED
@@ -14,6 +14,9 @@ namespace Reflex
|
|
14
14
|
{
|
15
15
|
|
16
16
|
|
17
|
+
Rucy::Class style_length_class ();
|
18
|
+
// class Reflex::StyleLength
|
19
|
+
|
17
20
|
Rucy::Class style_class ();
|
18
21
|
// class Reflex::Style
|
19
22
|
|
@@ -21,6 +24,8 @@ namespace Reflex
|
|
21
24
|
}// Reflex
|
22
25
|
|
23
26
|
|
27
|
+
RUCY_DECLARE_VALUE_FROM_TO(Reflex::StyleLength)
|
28
|
+
|
24
29
|
RUCY_DECLARE_VALUE_FROM_TO(Reflex::Style)
|
25
30
|
|
26
31
|
|
@@ -28,6 +33,12 @@ namespace Rucy
|
|
28
33
|
{
|
29
34
|
|
30
35
|
|
36
|
+
template <> inline Class
|
37
|
+
get_ruby_class<Reflex::StyleLength> ()
|
38
|
+
{
|
39
|
+
return Reflex::style_length_class();
|
40
|
+
}
|
41
|
+
|
31
42
|
template <> inline Class
|
32
43
|
get_ruby_class<Reflex::Style> ()
|
33
44
|
{
|
data/include/reflex/selector.h
CHANGED
@@ -29,6 +29,10 @@ namespace Reflex
|
|
29
29
|
|
30
30
|
Selector (const char* name = NULL);
|
31
31
|
|
32
|
+
This copy () const;
|
33
|
+
|
34
|
+
bool contains (const This& selector) const;
|
35
|
+
|
32
36
|
void set_name (const char* name);
|
33
37
|
|
34
38
|
const char* name () const;
|
@@ -45,12 +49,14 @@ namespace Reflex
|
|
45
49
|
|
46
50
|
const_iterator end () const;
|
47
51
|
|
48
|
-
bool
|
52
|
+
bool is_empty () const;
|
49
53
|
|
50
54
|
friend bool operator == (const This& lhs, const This& rhs);
|
51
55
|
|
52
56
|
friend bool operator != (const This& lhs, const This& rhs);
|
53
57
|
|
58
|
+
friend bool operator < (const This& lhs, const This& rhs);
|
59
|
+
|
54
60
|
struct Data;
|
55
61
|
|
56
62
|
Xot::PImpl<Data, true> self;
|
data/include/reflex/style.h
CHANGED
@@ -4,17 +4,63 @@
|
|
4
4
|
#define __REFLEX_STYLE_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <xot/
|
7
|
+
#include <xot/pimpl.h>
|
8
8
|
#include <reflex/color.h>
|
9
9
|
#include <reflex/image.h>
|
10
10
|
#include <reflex/selector.h>
|
11
|
-
#include <reflex/style_length.h>
|
12
11
|
|
13
12
|
|
14
13
|
namespace Reflex
|
15
14
|
{
|
16
15
|
|
17
16
|
|
17
|
+
class View;
|
18
|
+
|
19
|
+
|
20
|
+
class StyleLength
|
21
|
+
{
|
22
|
+
|
23
|
+
typedef StyleLength This;
|
24
|
+
|
25
|
+
public:
|
26
|
+
|
27
|
+
typedef coord Value;
|
28
|
+
|
29
|
+
enum Unit {NONE = 0, PIXEL, PERCENT, UNIT_LAST};
|
30
|
+
|
31
|
+
StyleLength ();
|
32
|
+
|
33
|
+
StyleLength (Value value, Unit unit = PIXEL);
|
34
|
+
|
35
|
+
explicit StyleLength (const char* str);
|
36
|
+
|
37
|
+
This copy () const;
|
38
|
+
|
39
|
+
void reset (Value value = 0, Unit unit = NONE);
|
40
|
+
|
41
|
+
void reset (const char* str);
|
42
|
+
|
43
|
+
Value value () const;
|
44
|
+
|
45
|
+
Unit unit () const;
|
46
|
+
|
47
|
+
String to_s () const;
|
48
|
+
|
49
|
+
operator bool () const;
|
50
|
+
|
51
|
+
bool operator ! () const;
|
52
|
+
|
53
|
+
friend bool operator == (const This& lhs, const This& rhs);
|
54
|
+
|
55
|
+
friend bool operator != (const This& lhs, const This& rhs);
|
56
|
+
|
57
|
+
struct Data;
|
58
|
+
|
59
|
+
Xot::PImpl<Data, true> self;
|
60
|
+
|
61
|
+
};// StyleLength
|
62
|
+
|
63
|
+
|
18
64
|
class Style
|
19
65
|
{
|
20
66
|
|
@@ -22,7 +68,11 @@ namespace Reflex
|
|
22
68
|
|
23
69
|
public:
|
24
70
|
|
25
|
-
enum Flow
|
71
|
+
enum Flow
|
72
|
+
{
|
73
|
+
FLOW_NONE = 0, FLOW_RIGHT, FLOW_DOWN, FLOW_LEFT, FLOW_UP,
|
74
|
+
FLOW_LAST
|
75
|
+
};
|
26
76
|
|
27
77
|
typedef Selector:: iterator tag_iterator;
|
28
78
|
|
@@ -30,10 +80,6 @@ namespace Reflex
|
|
30
80
|
|
31
81
|
Style (const char* name = NULL);
|
32
82
|
|
33
|
-
Style (const This& obj);
|
34
|
-
|
35
|
-
Style& operator = (const This& obj);
|
36
|
-
|
37
83
|
~Style ();
|
38
84
|
|
39
85
|
void set_name (const char* name);
|
@@ -62,27 +108,29 @@ namespace Reflex
|
|
62
108
|
|
63
109
|
void get_flow (Flow* main, Flow* sub) const;
|
64
110
|
|
65
|
-
void set_size (const StyleLength2& size);
|
66
|
-
|
67
111
|
void set_width (const StyleLength& width);
|
68
112
|
|
69
113
|
void set_height (const StyleLength& height);
|
70
114
|
|
71
|
-
const
|
115
|
+
const StyleLength& width () const;
|
116
|
+
|
117
|
+
const StyleLength& height () const;
|
72
118
|
|
73
|
-
void
|
119
|
+
void set_left (const StyleLength& left);
|
74
120
|
|
75
|
-
void
|
121
|
+
void set_top (const StyleLength& top);
|
76
122
|
|
77
|
-
void
|
123
|
+
void set_right (const StyleLength& right);
|
78
124
|
|
79
|
-
void
|
125
|
+
void set_bottom (const StyleLength& bottom);
|
80
126
|
|
81
|
-
|
127
|
+
const StyleLength& left () const;
|
82
128
|
|
83
|
-
const
|
129
|
+
const StyleLength& top () const;
|
84
130
|
|
85
|
-
|
131
|
+
const StyleLength& right () const;
|
132
|
+
|
133
|
+
const StyleLength& bottom () const;
|
86
134
|
|
87
135
|
void set_offset_left (const StyleLength& left);
|
88
136
|
|
@@ -92,9 +140,13 @@ namespace Reflex
|
|
92
140
|
|
93
141
|
void set_offset_bottom (const StyleLength& bottom);
|
94
142
|
|
95
|
-
const
|
143
|
+
const StyleLength& offset_left () const;
|
144
|
+
|
145
|
+
const StyleLength& offset_top () const;
|
146
|
+
|
147
|
+
const StyleLength& offset_right () const;
|
96
148
|
|
97
|
-
|
149
|
+
const StyleLength& offset_bottom () const;
|
98
150
|
|
99
151
|
void set_margin_left (const StyleLength& left);
|
100
152
|
|
@@ -104,9 +156,13 @@ namespace Reflex
|
|
104
156
|
|
105
157
|
void set_margin_bottom (const StyleLength& bottom);
|
106
158
|
|
107
|
-
const
|
159
|
+
const StyleLength& margin_left () const;
|
160
|
+
|
161
|
+
const StyleLength& margin_top () const;
|
162
|
+
|
163
|
+
const StyleLength& margin_right () const;
|
108
164
|
|
109
|
-
|
165
|
+
const StyleLength& margin_bottom () const;
|
110
166
|
|
111
167
|
void set_padding_left (const StyleLength& left);
|
112
168
|
|
@@ -116,15 +172,25 @@ namespace Reflex
|
|
116
172
|
|
117
173
|
void set_padding_bottom (const StyleLength& bottom);
|
118
174
|
|
119
|
-
const
|
175
|
+
const StyleLength& padding_left () const;
|
176
|
+
|
177
|
+
const StyleLength& padding_top () const;
|
178
|
+
|
179
|
+
const StyleLength& padding_right () const;
|
180
|
+
|
181
|
+
const StyleLength& padding_bottom () const;
|
182
|
+
|
183
|
+
void set_fill (const Color& fill);
|
184
|
+
|
185
|
+
const Color& fill () const;
|
120
186
|
|
121
|
-
void
|
187
|
+
void set_stroke (const Color& stroke);
|
122
188
|
|
123
|
-
const Color&
|
189
|
+
const Color& stroke () const;
|
124
190
|
|
125
|
-
void
|
191
|
+
void set_image (const Image& image);
|
126
192
|
|
127
|
-
const Image&
|
193
|
+
const Image& image () const;
|
128
194
|
|
129
195
|
friend bool operator == (const This& lhs, const This& rhs);
|
130
196
|
|
@@ -132,7 +198,7 @@ namespace Reflex
|
|
132
198
|
|
133
199
|
struct Data;
|
134
200
|
|
135
|
-
Xot::
|
201
|
+
Xot::PImpl<Data, true> self;
|
136
202
|
|
137
203
|
};// Style
|
138
204
|
|
data/include/reflex/view.h
CHANGED
@@ -89,15 +89,15 @@ namespace Reflex
|
|
89
89
|
|
90
90
|
virtual const_child_iterator child_end () const;
|
91
91
|
|
92
|
-
virtual Style
|
92
|
+
virtual Style* style (bool create = false);
|
93
93
|
|
94
|
-
virtual const Style
|
94
|
+
virtual const Style* style () const;
|
95
95
|
|
96
96
|
virtual void add_style (const Style& style);
|
97
97
|
|
98
98
|
virtual void remove_style (const Style& style);
|
99
99
|
|
100
|
-
virtual Style* get_style (const Selector& selector);
|
100
|
+
virtual Style* get_style (const Selector& selector, bool create = false);
|
101
101
|
|
102
102
|
virtual const Style* get_style (const Selector& selector) const;
|
103
103
|
|
@@ -122,7 +122,7 @@ namespace Reflex
|
|
122
122
|
|
123
123
|
virtual Point content_size () const;
|
124
124
|
|
125
|
-
virtual void
|
125
|
+
virtual void make_body ();
|
126
126
|
|
127
127
|
virtual void clear_body ();
|
128
128
|
|
@@ -154,6 +154,10 @@ namespace Reflex
|
|
154
154
|
|
155
155
|
virtual const Bounds& frame () const;
|
156
156
|
|
157
|
+
virtual void set_zoom (float zoom);
|
158
|
+
|
159
|
+
virtual float zoom () const;
|
160
|
+
|
157
161
|
virtual float angle () const;
|
158
162
|
|
159
163
|
virtual void scroll_to (coord x, coord y, coord z = 0);
|
data/lib/reflex.rb
CHANGED
data/lib/reflex/body.rb
CHANGED
data/lib/reflex/button.rb
CHANGED
data/lib/reflex/selector.rb
CHANGED
@@ -15,14 +15,23 @@ module Reflex
|
|
15
15
|
include Xot::Setter
|
16
16
|
include HasTags
|
17
17
|
|
18
|
+
def self.selector (*args)
|
19
|
+
arg0 = args.first
|
20
|
+
arg0.kind_of?(Selector) ? arg0 : self.new(*args)
|
21
|
+
end
|
22
|
+
|
18
23
|
def initialize (opts = {}, &block)
|
19
24
|
super()
|
20
25
|
set opts
|
21
26
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
22
27
|
end
|
23
28
|
|
29
|
+
def to_s ()
|
30
|
+
"{name:#{name}, tags:[#{tags.to_a.join ', '}]}"
|
31
|
+
end
|
32
|
+
|
24
33
|
def inspect ()
|
25
|
-
"#<#{self.class}
|
34
|
+
"#<#{self.class} #{to_s}>"
|
26
35
|
end
|
27
36
|
|
28
37
|
end# Selector
|