reflexion 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.doc/ext/reflex/application.cpp +54 -39
- data/.doc/ext/reflex/capture_event.cpp +87 -0
- data/.doc/ext/reflex/draw_event.cpp +103 -0
- data/.doc/ext/reflex/event.cpp +73 -0
- data/.doc/ext/reflex/focus_event.cpp +98 -0
- data/.doc/ext/reflex/frame_event.cpp +133 -0
- data/.doc/ext/reflex/image_view.cpp +74 -0
- data/.doc/ext/reflex/key_event.cpp +124 -0
- data/.doc/ext/reflex/native.cpp +45 -6
- data/.doc/ext/reflex/pointer_event.cpp +181 -0
- data/.doc/ext/reflex/reflex.cpp +17 -41
- data/.doc/ext/reflex/scroll_event.cpp +141 -0
- data/.doc/ext/reflex/selector.cpp +135 -0
- data/.doc/ext/reflex/style.cpp +253 -0
- data/.doc/ext/reflex/style_length.cpp +133 -0
- data/.doc/ext/reflex/style_length2.cpp +149 -0
- data/.doc/ext/reflex/style_length4.cpp +192 -0
- data/.doc/ext/reflex/update_event.cpp +77 -0
- data/.doc/ext/reflex/view.cpp +408 -88
- data/.doc/ext/reflex/wheel_event.cpp +146 -0
- data/.doc/ext/reflex/window.cpp +95 -92
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +67 -49
- data/ext/reflex/capture_event.cpp +92 -0
- data/ext/reflex/draw_event.cpp +110 -0
- data/ext/reflex/event.cpp +77 -0
- data/ext/reflex/extconf.rb +18 -68
- data/ext/reflex/focus_event.cpp +104 -0
- data/ext/reflex/frame_event.cpp +143 -0
- data/ext/reflex/image_view.cpp +77 -0
- data/ext/reflex/key_event.cpp +133 -0
- data/ext/reflex/native.cpp +45 -6
- data/ext/reflex/pointer_event.cpp +195 -0
- data/ext/reflex/reflex.cpp +21 -47
- data/ext/reflex/scroll_event.cpp +152 -0
- data/ext/reflex/selector.cpp +144 -0
- data/ext/reflex/style.cpp +277 -0
- data/ext/reflex/style_length.cpp +140 -0
- data/ext/reflex/style_length2.cpp +157 -0
- data/ext/reflex/style_length4.cpp +204 -0
- data/ext/reflex/update_event.cpp +81 -0
- data/ext/reflex/view.cpp +469 -114
- data/ext/reflex/wheel_event.cpp +158 -0
- data/ext/reflex/window.cpp +130 -123
- data/include/reflex/application.h +12 -7
- data/include/reflex/defs.h +13 -89
- data/include/reflex/event.h +260 -0
- data/include/reflex/exception.h +17 -11
- data/include/reflex/image_view.h +45 -0
- data/include/reflex/reflex.h +2 -6
- data/include/reflex/ruby/application.h +40 -13
- data/include/reflex/ruby/event.h +72 -0
- data/include/reflex/ruby/image_view.h +25 -0
- data/include/reflex/ruby/selector.h +27 -0
- data/include/reflex/ruby/style.h +27 -0
- data/include/reflex/ruby/style_length.h +37 -0
- data/include/reflex/ruby/view.h +193 -38
- data/include/reflex/ruby/window.h +123 -39
- data/include/reflex/ruby.h +3 -2
- data/include/reflex/selector.h +64 -0
- data/include/reflex/style.h +144 -0
- data/include/reflex/style_length.h +147 -0
- data/include/reflex/view.h +182 -19
- data/include/reflex/window.h +35 -19
- data/include/reflex.h +7 -0
- data/lib/reflex/application.rb +14 -5
- data/lib/reflex/arc_shape.rb +20 -0
- data/lib/reflex/button.rb +75 -0
- data/lib/reflex/capture_event.rb +37 -0
- data/lib/reflex/color.rb +13 -0
- data/lib/reflex/color_space.rb +13 -0
- data/lib/reflex/draw_event.rb +19 -0
- data/lib/reflex/ellipse_shape.rb +20 -0
- data/lib/reflex/ext.rb +1 -1
- data/lib/reflex/flags.rb +18 -0
- data/lib/reflex/focus_event.rb +38 -0
- data/lib/reflex/font.rb +13 -0
- data/lib/reflex/frame_event.rb +42 -0
- data/lib/reflex/helper.rb +87 -30
- data/lib/reflex/image_view.rb +25 -0
- data/lib/reflex/key_event.rb +38 -0
- data/lib/reflex/line_shape.rb +20 -0
- data/lib/reflex/list_view.rb +15 -0
- data/lib/reflex/model.rb +149 -0
- data/lib/reflex/model_owner.rb +57 -0
- data/lib/reflex/model_view.rb +22 -0
- data/lib/reflex/module.rb +11 -7
- data/lib/reflex/pointer_event.rb +85 -0
- data/lib/reflex/rect_shape.rb +20 -0
- data/lib/reflex/reflex.rb +13 -2
- data/lib/reflex/scroll_event.rb +19 -0
- data/lib/reflex/selector.rb +31 -0
- data/lib/reflex/shader.rb +13 -0
- data/lib/reflex/shape.rb +34 -0
- data/lib/reflex/style.rb +55 -0
- data/lib/reflex/style_length.rb +30 -0
- data/lib/reflex/style_length2.rb +34 -0
- data/lib/reflex/style_length4.rb +38 -0
- data/lib/reflex/text_view.rb +55 -0
- data/lib/reflex/update_event.rb +19 -0
- data/lib/reflex/view.rb +38 -4
- data/lib/reflex/wheel_event.rb +19 -0
- data/lib/reflex/window.rb +7 -5
- data/lib/reflex.rb +38 -1
- data/lib/reflexion/include.rb +5 -0
- data/lib/reflexion.rb +100 -0
- data/reflex.gemspec +3 -4
- data/samples/app.rb +13 -0
- data/samples/bats.rb +91 -0
- data/samples/checker.rb +36 -0
- data/{examples/ruby/shapes.rb → samples/fans.rb} +12 -16
- data/samples/fps.rb +46 -0
- data/samples/grid.rb +60 -0
- data/{examples/ruby → samples}/hello.rb +14 -16
- data/samples/image.rb +44 -0
- data/samples/ios/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- data/samples/ios/hello/hello/Images.xcassets/LaunchImage.launchimage/Contents.json +51 -0
- data/samples/ios/hello/hello/en.lproj/InfoPlist.strings +2 -0
- data/samples/ios/hello/hello/hello-Info.plist +47 -0
- data/samples/ios/hello/hello/hello-Prefix.pch +10 -0
- data/samples/ios/hello/hello/main.cpp +79 -0
- data/samples/ios/hello/hello.xcodeproj/project.pbxproj +725 -0
- data/{examples/ruby → samples}/key.rb +11 -14
- data/samples/layout.rb +89 -0
- data/samples/model.rb +86 -0
- data/samples/osx/hello/hello/Images.xcassets/AppIcon.appiconset/Contents.json +58 -0
- data/samples/osx/hello/hello/en.lproj/Credits.rtf +29 -0
- data/samples/osx/hello/hello/en.lproj/InfoPlist.strings +2 -0
- data/samples/osx/hello/hello/hello-Info.plist +32 -0
- data/samples/osx/hello/hello/hello-Prefix.pch +3 -0
- data/samples/osx/hello/hello/main.cpp +79 -0
- data/samples/osx/hello/hello.xcodeproj/project.pbxproj +725 -0
- data/samples/reflexion/hello.rb +24 -0
- data/samples/reflexion/paint.rb +40 -0
- data/samples/reflexion/pulse.rb +34 -0
- data/samples/repl.rb +69 -0
- data/samples/shader.rb +41 -0
- data/samples/shapes.rb +30 -0
- data/{examples/ruby → samples}/text.rb +7 -8
- data/samples/tree.rb +71 -0
- data/samples/views.rb +41 -0
- data/samples/visuals.rb +22 -0
- data/src/event.cpp +225 -0
- data/src/exception.cpp +24 -15
- data/src/image_view.cpp +70 -0
- data/src/ios/app_delegate.h +17 -0
- data/src/ios/app_delegate.mm +120 -0
- data/src/ios/application.mm +116 -0
- data/src/{cocoa/applicationdata.h → ios/application_data.h} +6 -6
- data/src/ios/event.h +26 -0
- data/src/ios/event.mm +31 -0
- data/src/ios/native_window.h +37 -0
- data/src/ios/native_window.mm +220 -0
- data/src/ios/opengl_view.h +13 -0
- data/src/ios/opengl_view.mm +131 -0
- data/src/{cocoa → ios}/reflex.mm +8 -12
- data/src/ios/window.mm +303 -0
- data/src/ios/window_data.h +75 -0
- data/src/osx/app_delegate.h +17 -0
- data/src/{cocoa/cocoaapplication.mm → osx/app_delegate.mm} +90 -48
- data/src/osx/application.mm +132 -0
- data/src/osx/application_data.h +45 -0
- data/src/osx/event.h +42 -0
- data/src/osx/event.mm +112 -0
- data/src/osx/native_window.h +26 -0
- data/src/osx/native_window.mm +322 -0
- data/src/{cocoa/openglview.h → osx/opengl_view.h} +0 -4
- data/src/{cocoa/openglview.mm → osx/opengl_view.mm} +66 -23
- data/src/osx/reflex.mm +50 -0
- data/src/osx/window.mm +308 -0
- data/src/osx/window_data.h +75 -0
- data/src/selector.cpp +121 -0
- data/src/style.cpp +576 -0
- data/src/style_length.cpp +341 -0
- data/src/view.cpp +1228 -129
- data/src/win32/application.cpp +1 -1
- data/src/window.cpp +54 -26
- data/test/helper.rb +8 -4
- data/test/test_capture_event.rb +41 -0
- data/test/test_event.rb +20 -0
- data/test/test_has_frame.rb +45 -0
- data/test/test_model.rb +9 -0
- data/test/test_model_owner.rb +9 -0
- data/test/test_selector.rb +75 -0
- data/test/test_style.rb +70 -0
- data/test/test_style_length.rb +38 -0
- data/test/test_style_length2.rb +50 -0
- data/test/test_style_length4.rb +56 -0
- data/test/test_view.rb +97 -23
- data/test/test_window.rb +54 -46
- metadata +205 -84
- data/.doc/ext/reflex/defs.cpp +0 -8
- data/.doc/ext/reflex/key.cpp +0 -122
- data/.doc/ext/reflex/points.cpp +0 -151
- data/.gitignore +0 -14
- data/ChangeLog +0 -8
- data/examples/hello/.gitignore +0 -2
- data/examples/hello/Rakefile +0 -41
- data/examples/hello/main.cpp +0 -18
- data/examples/ruby/app.rb +0 -13
- data/examples/ruby/checker.rb +0 -41
- data/examples/ruby/fps.rb +0 -49
- data/examples/ruby/grid.rb +0 -65
- data/examples/ruby/views.rb +0 -88
- data/examples/ruby/visuals.rb +0 -27
- data/ext/reflex/defs.cpp +0 -8
- data/ext/reflex/key.cpp +0 -129
- data/ext/reflex/points.cpp +0 -161
- data/include/reflex/ruby/key.h +0 -39
- data/include/reflex/ruby/points.h +0 -39
- data/lib/reflex/visuals/string.rb +0 -53
- data/src/cocoa/application.mm +0 -101
- data/src/cocoa/cocoaapplication.h +0 -21
- data/src/cocoa/cocoawindow.h +0 -46
- data/src/cocoa/cocoawindow.mm +0 -230
- data/src/cocoa/defs.h +0 -34
- data/src/cocoa/defs.mm +0 -87
- data/src/cocoa/window.mm +0 -148
- data/src/cocoa/windowdata.h +0 -56
- data/src/defs.cpp +0 -47
- data/src/helper.h +0 -12
- data/src/reflex.cpp +0 -43
- /data/{README → README.md} +0 -0
@@ -0,0 +1,341 @@
|
|
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
|