reflexion 0.1.12 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.doc/ext/reflex/application.cpp +9 -5
- data/.doc/ext/reflex/capture_event.cpp +4 -9
- data/.doc/ext/reflex/contact_event.cpp +17 -13
- data/.doc/ext/reflex/draw_event.cpp +3 -8
- data/.doc/ext/reflex/ellipse_shape.cpp +51 -24
- data/.doc/ext/reflex/event.cpp +0 -4
- data/.doc/ext/reflex/filter.cpp +81 -0
- data/.doc/ext/reflex/focus_event.cpp +9 -13
- data/.doc/ext/reflex/frame_event.cpp +47 -14
- data/.doc/ext/reflex/image_view.cpp +1 -10
- data/.doc/ext/reflex/key_event.cpp +9 -14
- data/.doc/ext/reflex/line_shape.cpp +99 -0
- data/.doc/ext/reflex/motion_event.cpp +73 -0
- data/.doc/ext/reflex/native.cpp +18 -18
- data/.doc/ext/reflex/pointer_event.cpp +27 -25
- data/.doc/ext/reflex/polygon_shape.cpp +65 -0
- data/.doc/ext/reflex/rect_shape.cpp +102 -23
- data/.doc/ext/reflex/reflex.cpp +24 -3
- data/.doc/ext/reflex/scroll_event.cpp +8 -15
- data/.doc/ext/reflex/selector.cpp +43 -15
- data/.doc/ext/reflex/shape.cpp +211 -0
- data/.doc/ext/reflex/style.cpp +359 -185
- data/.doc/ext/reflex/style_length.cpp +163 -35
- data/.doc/ext/reflex/timer.cpp +101 -0
- data/.doc/ext/reflex/timer_event.cpp +123 -0
- data/.doc/ext/reflex/update_event.cpp +12 -8
- data/.doc/ext/reflex/view.cpp +548 -144
- data/.doc/ext/reflex/wheel_event.cpp +5 -28
- data/.doc/ext/reflex/window.cpp +7 -15
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/Rakefile +14 -12
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +10 -5
- data/ext/reflex/capture_event.cpp +4 -9
- data/ext/reflex/contact_event.cpp +18 -13
- data/ext/reflex/defs.h +5 -2
- data/ext/reflex/draw_event.cpp +3 -8
- data/ext/reflex/ellipse_shape.cpp +56 -25
- data/ext/reflex/event.cpp +0 -4
- data/ext/reflex/extconf.rb +1 -2
- data/ext/reflex/filter.cpp +86 -0
- data/ext/reflex/focus_event.cpp +11 -15
- data/ext/reflex/frame_event.cpp +52 -14
- data/ext/reflex/image_view.cpp +1 -10
- data/ext/reflex/key_event.cpp +9 -14
- data/ext/reflex/line_shape.cpp +104 -0
- data/ext/reflex/motion_event.cpp +77 -0
- data/ext/reflex/native.cpp +18 -18
- data/ext/reflex/pointer_event.cpp +27 -25
- data/ext/reflex/polygon_shape.cpp +68 -0
- data/ext/reflex/rect_shape.cpp +113 -24
- data/ext/reflex/reflex.cpp +24 -3
- data/ext/reflex/scroll_event.cpp +8 -15
- data/ext/reflex/selector.cpp +46 -16
- data/ext/reflex/selector.h +130 -0
- data/ext/reflex/shape.cpp +231 -0
- data/ext/reflex/style.cpp +363 -192
- data/ext/reflex/style_length.cpp +164 -37
- data/ext/reflex/timer.cpp +108 -0
- data/ext/reflex/timer_event.cpp +133 -0
- data/ext/reflex/update_event.cpp +13 -8
- data/ext/reflex/view.cpp +594 -150
- data/ext/reflex/wheel_event.cpp +5 -30
- data/ext/reflex/window.cpp +7 -15
- data/include/reflex.h +5 -4
- data/include/reflex/application.h +2 -0
- data/include/reflex/debug.h +22 -0
- data/include/reflex/defs.h +45 -2
- data/include/reflex/event.h +55 -11
- data/include/reflex/exception.h +17 -2
- data/include/reflex/filter.h +56 -0
- data/include/reflex/image_view.h +1 -1
- data/include/reflex/ruby.h +6 -4
- data/include/reflex/ruby/application.h +17 -9
- data/include/reflex/ruby/event.h +22 -0
- data/include/reflex/ruby/filter.h +69 -0
- data/include/reflex/ruby/reflex.h +1 -0
- data/include/reflex/ruby/selector.h +1 -1
- data/include/reflex/ruby/shape.h +140 -0
- data/include/reflex/ruby/style.h +1 -1
- data/include/reflex/ruby/timer.h +69 -0
- data/include/reflex/ruby/view.h +43 -76
- data/include/reflex/ruby/window.h +17 -32
- data/include/reflex/selector.h +54 -2
- data/include/reflex/shape.h +211 -0
- data/include/reflex/style.h +136 -76
- data/include/reflex/timer.h +73 -0
- data/include/reflex/view.h +181 -59
- data/include/reflex/window.h +4 -3
- data/lib/reflex.rb +13 -6
- data/lib/reflex/application.rb +6 -3
- data/lib/reflex/button.rb +2 -2
- data/lib/reflex/{texture.rb → camera.rb} +2 -2
- data/lib/reflex/capture_event.rb +7 -6
- data/lib/reflex/contact_event.rb +10 -12
- data/lib/reflex/draw_event.rb +6 -1
- data/lib/reflex/ellipse_shape.rb +27 -0
- data/lib/reflex/filter.rb +18 -0
- data/lib/reflex/fixture.rb +4 -0
- data/lib/reflex/focus_event.rb +10 -12
- data/lib/reflex/frame_event.rb +1 -1
- data/lib/reflex/helper.rb +17 -29
- data/lib/reflex/key_event.rb +13 -11
- data/lib/reflex/line_shape.rb +18 -0
- data/lib/reflex/matrix.rb +13 -0
- data/lib/reflex/module.rb +4 -19
- data/lib/reflex/pointer_event.rb +28 -35
- data/lib/reflex/polygon.rb +14 -0
- data/lib/reflex/polygon_shape.rb +23 -0
- data/lib/reflex/polyline.rb +13 -0
- data/lib/reflex/rect_shape.rb +20 -0
- data/lib/reflex/reflex.rb +1 -3
- data/lib/reflex/scroll_event.rb +1 -1
- data/lib/reflex/selector.rb +2 -2
- data/lib/reflex/shape.rb +62 -0
- data/lib/reflex/style.rb +78 -11
- data/lib/reflex/style_length.rb +0 -11
- data/lib/reflex/text_view.rb +7 -24
- data/lib/reflex/timer.rb +30 -0
- data/lib/reflex/timer_event.rb +29 -0
- data/lib/reflex/update_event.rb +1 -1
- data/lib/reflex/view.rb +127 -32
- data/lib/reflex/wheel_event.rb +9 -1
- data/lib/reflex/window.rb +29 -9
- data/lib/reflexion.rb +23 -7
- data/reflex.gemspec +8 -10
- data/samples/bats.rb +4 -4
- data/samples/camera.rb +45 -0
- data/samples/fans.rb +1 -1
- data/samples/fps.rb +5 -3
- data/samples/hello.rb +4 -6
- data/samples/image.rb +5 -4
- data/samples/ios/hello/hello.xcodeproj/project.pbxproj +0 -2
- data/samples/layout.rb +16 -7
- data/samples/model.rb +10 -7
- data/samples/physics.rb +22 -20
- data/samples/reflexion/breakout.rb +4 -5
- data/samples/reflexion/hello.rb +2 -2
- data/samples/reflexion/jump_action.rb +191 -0
- data/samples/reflexion/noise.rb +23 -0
- data/samples/reflexion/paint.rb +7 -6
- data/samples/reflexion/physics.rb +15 -8
- data/samples/reflexion/pulse.rb +24 -10
- data/samples/shader.rb +8 -6
- data/samples/shapes.rb +79 -14
- data/samples/tree.rb +9 -10
- data/samples/views.rb +3 -3
- data/samples/visuals.rb +2 -5
- data/src/body.cpp +146 -345
- data/src/body.h +91 -0
- data/src/event.cpp +65 -15
- data/src/exception.cpp +13 -3
- data/src/filter.cpp +76 -0
- data/src/fixture.cpp +164 -39
- data/src/fixture.h +85 -0
- data/src/image_view.cpp +4 -4
- data/src/ios/app_delegate.h +5 -10
- data/src/ios/app_delegate.mm +79 -41
- data/src/ios/application.h +32 -0
- data/src/ios/application.mm +35 -25
- data/src/ios/event.mm +8 -4
- data/src/ios/reflex.mm +0 -7
- data/src/ios/view_controller.h +37 -0
- data/src/ios/view_controller.mm +424 -0
- data/src/ios/window.h +40 -0
- data/src/ios/window.mm +59 -250
- data/src/osx/app_delegate.h +5 -10
- data/src/osx/app_delegate.mm +52 -55
- data/src/osx/application.h +32 -0
- data/src/osx/application.mm +44 -39
- data/src/osx/native_window.h +0 -15
- data/src/osx/native_window.mm +127 -127
- data/src/osx/opengl_view.h +0 -2
- data/src/osx/opengl_view.mm +12 -3
- data/src/osx/reflex.mm +0 -9
- data/src/osx/window.h +42 -0
- data/src/osx/window.mm +45 -252
- data/src/selector.cpp +232 -7
- data/src/selector.h +52 -0
- data/src/shape.cpp +1191 -0
- data/src/shape.h +61 -0
- data/src/style.cpp +573 -376
- data/src/style.h +39 -0
- data/src/timer.cpp +288 -0
- data/src/timer.h +55 -0
- data/src/view.cpp +1624 -984
- data/src/view.h +56 -0
- data/src/win32/window.cpp +3 -4
- data/src/window.cpp +302 -20
- data/src/window.h +94 -0
- data/src/world.cpp +112 -111
- data/src/world.h +34 -53
- data/task/box2d.rake +31 -10
- data/test/test_capture_event.rb +8 -6
- data/test/test_pointer_event.rb +130 -0
- data/test/test_selector.rb +1 -1
- data/test/test_shape.rb +71 -0
- data/test/test_style.rb +77 -11
- data/test/test_style_length.rb +42 -13
- data/test/test_view.rb +138 -14
- metadata +115 -213
- data/.doc/ext/reflex/arc_shape.cpp +0 -89
- data/.doc/ext/reflex/body.cpp +0 -299
- data/.doc/ext/reflex/fixture.cpp +0 -101
- data/.doc/ext/reflex/shape_view.cpp +0 -153
- data/ext/reflex/arc_shape.cpp +0 -94
- data/ext/reflex/body.cpp +0 -328
- data/ext/reflex/fixture.cpp +0 -108
- data/ext/reflex/shape_view.cpp +0 -161
- data/include/reflex/bitmap.h +0 -20
- data/include/reflex/body.h +0 -128
- data/include/reflex/bounds.h +0 -20
- data/include/reflex/color.h +0 -20
- data/include/reflex/color_space.h +0 -20
- data/include/reflex/fixture.h +0 -117
- data/include/reflex/font.h +0 -20
- data/include/reflex/image.h +0 -20
- data/include/reflex/matrix.h +0 -20
- data/include/reflex/painter.h +0 -20
- data/include/reflex/point.h +0 -24
- data/include/reflex/ruby/body.h +0 -41
- data/include/reflex/ruby/fixture.h +0 -41
- data/include/reflex/ruby/shape_view.h +0 -96
- data/include/reflex/shader.h +0 -20
- data/include/reflex/shape_view.h +0 -146
- data/include/reflex/texture.h +0 -20
- data/lib/reflex/body.rb +0 -22
- data/lib/reflex/flags.rb +0 -18
- data/lib/reflex/shape_view.rb +0 -25
- data/src/ios/application_data.h +0 -45
- data/src/ios/native_window.h +0 -39
- data/src/ios/native_window.mm +0 -224
- data/src/ios/opengl_view.h +0 -13
- data/src/ios/opengl_view.mm +0 -139
- data/src/ios/window_data.h +0 -75
- data/src/osx/application_data.h +0 -45
- data/src/osx/window_data.h +0 -75
- data/src/physics/Box2D/Box2D.h +0 -68
- data/src/physics/Box2D/Collision/Shapes/b2ChainShape.cpp +0 -193
- data/src/physics/Box2D/Collision/Shapes/b2ChainShape.h +0 -105
- data/src/physics/Box2D/Collision/Shapes/b2CircleShape.cpp +0 -99
- data/src/physics/Box2D/Collision/Shapes/b2CircleShape.h +0 -91
- data/src/physics/Box2D/Collision/Shapes/b2EdgeShape.cpp +0 -138
- data/src/physics/Box2D/Collision/Shapes/b2EdgeShape.h +0 -74
- data/src/physics/Box2D/Collision/Shapes/b2PolygonShape.cpp +0 -467
- data/src/physics/Box2D/Collision/Shapes/b2PolygonShape.h +0 -101
- data/src/physics/Box2D/Collision/Shapes/b2Shape.h +0 -101
- data/src/physics/Box2D/Collision/b2BroadPhase.cpp +0 -119
- data/src/physics/Box2D/Collision/b2BroadPhase.h +0 -257
- data/src/physics/Box2D/Collision/b2CollideCircle.cpp +0 -154
- data/src/physics/Box2D/Collision/b2CollideEdge.cpp +0 -698
- data/src/physics/Box2D/Collision/b2CollidePolygon.cpp +0 -239
- data/src/physics/Box2D/Collision/b2Collision.cpp +0 -252
- data/src/physics/Box2D/Collision/b2Collision.h +0 -277
- data/src/physics/Box2D/Collision/b2Distance.cpp +0 -603
- data/src/physics/Box2D/Collision/b2Distance.h +0 -141
- data/src/physics/Box2D/Collision/b2DynamicTree.cpp +0 -778
- data/src/physics/Box2D/Collision/b2DynamicTree.h +0 -289
- data/src/physics/Box2D/Collision/b2TimeOfImpact.cpp +0 -486
- data/src/physics/Box2D/Collision/b2TimeOfImpact.h +0 -58
- data/src/physics/Box2D/Common/b2BlockAllocator.cpp +0 -215
- data/src/physics/Box2D/Common/b2BlockAllocator.h +0 -62
- data/src/physics/Box2D/Common/b2Draw.cpp +0 -44
- data/src/physics/Box2D/Common/b2Draw.h +0 -86
- data/src/physics/Box2D/Common/b2GrowableStack.h +0 -85
- data/src/physics/Box2D/Common/b2Math.cpp +0 -94
- data/src/physics/Box2D/Common/b2Math.h +0 -720
- data/src/physics/Box2D/Common/b2Settings.cpp +0 -44
- data/src/physics/Box2D/Common/b2Settings.h +0 -151
- data/src/physics/Box2D/Common/b2StackAllocator.cpp +0 -83
- data/src/physics/Box2D/Common/b2StackAllocator.h +0 -60
- data/src/physics/Box2D/Common/b2Timer.cpp +0 -101
- data/src/physics/Box2D/Common/b2Timer.h +0 -50
- data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp +0 -53
- data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h +0 -39
- data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp +0 -53
- data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h +0 -39
- data/src/physics/Box2D/Dynamics/Contacts/b2CircleContact.cpp +0 -52
- data/src/physics/Box2D/Dynamics/Contacts/b2CircleContact.h +0 -39
- data/src/physics/Box2D/Dynamics/Contacts/b2Contact.cpp +0 -247
- data/src/physics/Box2D/Dynamics/Contacts/b2Contact.h +0 -349
- data/src/physics/Box2D/Dynamics/Contacts/b2ContactSolver.cpp +0 -838
- data/src/physics/Box2D/Dynamics/Contacts/b2ContactSolver.h +0 -95
- data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp +0 -49
- data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h +0 -39
- data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp +0 -49
- data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h +0 -39
- data/src/physics/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp +0 -49
- data/src/physics/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h +0 -38
- data/src/physics/Box2D/Dynamics/Contacts/b2PolygonContact.cpp +0 -52
- data/src/physics/Box2D/Dynamics/Contacts/b2PolygonContact.h +0 -39
- data/src/physics/Box2D/Dynamics/Joints/b2DistanceJoint.cpp +0 -260
- data/src/physics/Box2D/Dynamics/Joints/b2DistanceJoint.h +0 -169
- data/src/physics/Box2D/Dynamics/Joints/b2FrictionJoint.cpp +0 -251
- data/src/physics/Box2D/Dynamics/Joints/b2FrictionJoint.h +0 -119
- data/src/physics/Box2D/Dynamics/Joints/b2GearJoint.cpp +0 -419
- data/src/physics/Box2D/Dynamics/Joints/b2GearJoint.h +0 -125
- data/src/physics/Box2D/Dynamics/Joints/b2Joint.cpp +0 -211
- data/src/physics/Box2D/Dynamics/Joints/b2Joint.h +0 -226
- data/src/physics/Box2D/Dynamics/Joints/b2MotorJoint.cpp +0 -304
- data/src/physics/Box2D/Dynamics/Joints/b2MotorJoint.h +0 -133
- data/src/physics/Box2D/Dynamics/Joints/b2MouseJoint.cpp +0 -222
- data/src/physics/Box2D/Dynamics/Joints/b2MouseJoint.h +0 -129
- data/src/physics/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp +0 -629
- data/src/physics/Box2D/Dynamics/Joints/b2PrismaticJoint.h +0 -196
- data/src/physics/Box2D/Dynamics/Joints/b2PulleyJoint.cpp +0 -348
- data/src/physics/Box2D/Dynamics/Joints/b2PulleyJoint.h +0 -152
- data/src/physics/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp +0 -502
- data/src/physics/Box2D/Dynamics/Joints/b2RevoluteJoint.h +0 -204
- data/src/physics/Box2D/Dynamics/Joints/b2RopeJoint.cpp +0 -241
- data/src/physics/Box2D/Dynamics/Joints/b2RopeJoint.h +0 -114
- data/src/physics/Box2D/Dynamics/Joints/b2WeldJoint.cpp +0 -344
- data/src/physics/Box2D/Dynamics/Joints/b2WeldJoint.h +0 -126
- data/src/physics/Box2D/Dynamics/Joints/b2WheelJoint.cpp +0 -419
- data/src/physics/Box2D/Dynamics/Joints/b2WheelJoint.h +0 -210
- data/src/physics/Box2D/Dynamics/b2Body.cpp +0 -549
- data/src/physics/Box2D/Dynamics/b2Body.h +0 -860
- data/src/physics/Box2D/Dynamics/b2ContactManager.cpp +0 -296
- data/src/physics/Box2D/Dynamics/b2ContactManager.h +0 -52
- data/src/physics/Box2D/Dynamics/b2Fixture.cpp +0 -303
- data/src/physics/Box2D/Dynamics/b2Fixture.h +0 -345
- data/src/physics/Box2D/Dynamics/b2Island.cpp +0 -539
- data/src/physics/Box2D/Dynamics/b2Island.h +0 -93
- data/src/physics/Box2D/Dynamics/b2TimeStep.h +0 -70
- data/src/physics/Box2D/Dynamics/b2World.cpp +0 -1339
- data/src/physics/Box2D/Dynamics/b2World.h +0 -354
- data/src/physics/Box2D/Dynamics/b2WorldCallbacks.cpp +0 -36
- data/src/physics/Box2D/Dynamics/b2WorldCallbacks.h +0 -155
- data/src/physics/Box2D/Rope/b2Rope.cpp +0 -259
- data/src/physics/Box2D/Rope/b2Rope.h +0 -115
- data/src/shape_view.cpp +0 -306
data/src/shape.h
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __REFLEX_SRC_SHAPE_H__
|
4
|
+
#define __REFLEX_SRC_SHAPE_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <xot/util.h>
|
8
|
+
#include <reflex/shape.h>
|
9
|
+
|
10
|
+
|
11
|
+
class b2Shape;
|
12
|
+
|
13
|
+
|
14
|
+
namespace Reflex
|
15
|
+
{
|
16
|
+
|
17
|
+
|
18
|
+
class WallShape : public Shape
|
19
|
+
{
|
20
|
+
|
21
|
+
typedef Shape Super;
|
22
|
+
|
23
|
+
public:
|
24
|
+
|
25
|
+
enum Position
|
26
|
+
{
|
27
|
+
|
28
|
+
LEFT = Xot::bit(0),
|
29
|
+
|
30
|
+
TOP = Xot::bit(1),
|
31
|
+
|
32
|
+
RIGHT = Xot::bit(2),
|
33
|
+
|
34
|
+
BOTTOM = Xot::bit(3),
|
35
|
+
|
36
|
+
ALL = LEFT | TOP | RIGHT | BOTTOM
|
37
|
+
|
38
|
+
};// Position
|
39
|
+
|
40
|
+
enum {DEFAULT_THICKNESS = 100};
|
41
|
+
|
42
|
+
WallShape (uint positions, coord thickness = DEFAULT_THICKNESS);
|
43
|
+
|
44
|
+
virtual void on_draw (DrawEvent* e);
|
45
|
+
|
46
|
+
};// WallShape
|
47
|
+
|
48
|
+
|
49
|
+
bool Shape_set_owner (Shape* shape, View* owner);
|
50
|
+
|
51
|
+
bool Shape_has_frame (const Shape& shape);
|
52
|
+
|
53
|
+
void Shape_update (Shape* shape, bool force = false);
|
54
|
+
|
55
|
+
void Shape_call_contact_event (Shape* shape, const ContactEvent& event);
|
56
|
+
|
57
|
+
|
58
|
+
}// Reflex
|
59
|
+
|
60
|
+
|
61
|
+
#endif//EOH
|
data/src/style.cpp
CHANGED
@@ -1,44 +1,24 @@
|
|
1
|
-
#include "
|
1
|
+
#include "style.h"
|
2
2
|
|
3
3
|
|
4
|
-
#include <boost/noncopyable.hpp>
|
5
|
-
#include "reflex/view.h"
|
6
4
|
#include "reflex/exception.h"
|
5
|
+
#include "reflex/debug.h"
|
6
|
+
#include "view.h"
|
7
|
+
#include "selector.h"
|
7
8
|
|
8
9
|
|
9
10
|
namespace Reflex
|
10
11
|
{
|
11
12
|
|
12
13
|
|
13
|
-
template <typename T>
|
14
|
+
template <typename T, typename DefaultValue = T>
|
14
15
|
class StyleValue
|
15
16
|
{
|
16
17
|
|
17
|
-
typedef StyleValue<T> This;
|
18
|
+
typedef StyleValue<T, DefaultValue> This;
|
18
19
|
|
19
20
|
typedef T Value;
|
20
21
|
|
21
|
-
class Wrapper : public boost::noncopyable, public Xot::RefCountable<>
|
22
|
-
{
|
23
|
-
|
24
|
-
public:
|
25
|
-
|
26
|
-
Wrapper () {}
|
27
|
-
|
28
|
-
Wrapper (const Value& value) : value(value) {}
|
29
|
-
|
30
|
-
void reset (const Value& value_) {value = value_;}
|
31
|
-
|
32
|
-
Value& get () {return value;}
|
33
|
-
|
34
|
-
const Value& get () const {return value;}
|
35
|
-
|
36
|
-
private:
|
37
|
-
|
38
|
-
Value value;
|
39
|
-
|
40
|
-
};// Wrapper
|
41
|
-
|
42
22
|
public:
|
43
23
|
|
44
24
|
StyleValue ()
|
@@ -60,13 +40,15 @@ namespace Reflex
|
|
60
40
|
|
61
41
|
This& operator = (const Value& value)
|
62
42
|
{
|
63
|
-
|
43
|
+
set_wrapper(new ValueWrapper(value));
|
64
44
|
return *this;
|
65
45
|
}
|
66
46
|
|
67
47
|
This& operator = (const This& obj)
|
68
48
|
{
|
69
|
-
if (&obj
|
49
|
+
if (&obj == this) return *this;
|
50
|
+
const ValueWrapper* p = obj.wrapper();
|
51
|
+
set_wrapper(p ? new ValueWrapper(*p) : NULL);
|
70
52
|
return *this;
|
71
53
|
}
|
72
54
|
|
@@ -75,46 +57,44 @@ namespace Reflex
|
|
75
57
|
clear();
|
76
58
|
}
|
77
59
|
|
78
|
-
|
60
|
+
bool clear ()
|
79
61
|
{
|
80
|
-
|
62
|
+
return set_wrapper(NULL);
|
81
63
|
}
|
82
64
|
|
83
|
-
|
65
|
+
bool set (const Value& value)
|
84
66
|
{
|
85
|
-
|
86
|
-
if (
|
87
|
-
|
88
|
-
if (!create)
|
89
|
-
invalid_state_error(__FILE__, __LINE__);
|
67
|
+
const ValueWrapper* p = wrapper();
|
68
|
+
if (p && p->value() == value)
|
69
|
+
return false;
|
90
70
|
|
91
|
-
|
92
|
-
|
93
|
-
return p->get();
|
71
|
+
set_wrapper(new ValueWrapper(value));
|
72
|
+
return true;
|
94
73
|
}
|
95
74
|
|
96
|
-
const Value& get (
|
75
|
+
const Value& get () const
|
97
76
|
{
|
98
|
-
|
99
|
-
|
77
|
+
static const Value DEFVAL = DefaultValue();
|
78
|
+
|
79
|
+
const ValueWrapper* p = wrapper();
|
80
|
+
return p ? p->value() : DEFVAL;
|
100
81
|
}
|
101
82
|
|
102
|
-
|
83
|
+
const Value& get (const Value& defval) const
|
103
84
|
{
|
104
|
-
|
105
|
-
|
106
|
-
return false;
|
107
|
-
|
108
|
-
current = val;
|
109
|
-
return true;
|
85
|
+
const ValueWrapper* p = wrapper();
|
86
|
+
return p ? p->value() : defval;
|
110
87
|
}
|
111
88
|
|
112
|
-
void override (const This&
|
89
|
+
void override (const This& obj)
|
113
90
|
{
|
114
|
-
if (!
|
91
|
+
if (!obj)
|
92
|
+
return;
|
93
|
+
|
94
|
+
if (*this && !is_inherited())
|
115
95
|
return;
|
116
96
|
|
117
|
-
|
97
|
+
set_wrapper(obj.wrapper());
|
118
98
|
set_inherited();
|
119
99
|
}
|
120
100
|
|
@@ -123,17 +103,42 @@ namespace Reflex
|
|
123
103
|
return get_pointer_flag(pwrapper);
|
124
104
|
}
|
125
105
|
|
126
|
-
operator bool () const
|
106
|
+
operator bool () const
|
107
|
+
{
|
108
|
+
return wrapper() != NULL;
|
109
|
+
}
|
127
110
|
|
128
|
-
bool operator ! () const
|
111
|
+
bool operator ! () const
|
112
|
+
{
|
113
|
+
return !operator bool();
|
114
|
+
}
|
129
115
|
|
130
116
|
private:
|
131
117
|
|
132
|
-
|
118
|
+
class ValueWrapper : public Xot::RefCountable<>
|
119
|
+
{
|
120
|
+
|
121
|
+
public:
|
122
|
+
|
123
|
+
ValueWrapper () : value_(DefaultValue()) {}
|
124
|
+
|
125
|
+
ValueWrapper (const Value& value) : value_(value) {}
|
126
|
+
|
127
|
+
ValueWrapper (const ValueWrapper& obj) : value_(obj.value_) {}
|
133
128
|
|
134
|
-
|
129
|
+
const Value& value () const {return value_;}
|
130
|
+
|
131
|
+
private:
|
132
|
+
|
133
|
+
Value value_;
|
134
|
+
|
135
|
+
};// ValueWrapper
|
136
|
+
|
137
|
+
const ValueWrapper* pwrapper;
|
138
|
+
|
139
|
+
const ValueWrapper* set_wrapper (const ValueWrapper* ptr)
|
135
140
|
{
|
136
|
-
|
141
|
+
const ValueWrapper* p = wrapper();
|
137
142
|
if (ptr != p)
|
138
143
|
{
|
139
144
|
if (p) p->release();
|
@@ -149,7 +154,10 @@ namespace Reflex
|
|
149
154
|
pwrapper = Xot::set_pointer_flag(pwrapper, state);
|
150
155
|
}
|
151
156
|
|
152
|
-
|
157
|
+
const ValueWrapper* wrapper () const
|
158
|
+
{
|
159
|
+
return Xot::set_pointer_flag(pwrapper, false);
|
160
|
+
}
|
153
161
|
|
154
162
|
};// StyleValue
|
155
163
|
|
@@ -157,79 +165,56 @@ namespace Reflex
|
|
157
165
|
struct StyleLength::Data
|
158
166
|
{
|
159
167
|
|
168
|
+
Type type;
|
169
|
+
|
160
170
|
Value value;
|
161
171
|
|
162
|
-
|
172
|
+
Data ()
|
173
|
+
: type(NONE), value(0)
|
174
|
+
{
|
175
|
+
}
|
163
176
|
|
164
|
-
|
177
|
+
bool is_variable () const
|
178
|
+
{
|
179
|
+
return type == PERCENT || type == FILL || type == FIT;
|
180
|
+
}
|
165
181
|
|
166
182
|
friend bool operator == (const Data& lhs, const Data& rhs)
|
167
183
|
{
|
168
|
-
return lhs.
|
184
|
+
return lhs.type == rhs.type && lhs.value == rhs.value;
|
169
185
|
}
|
170
186
|
|
171
187
|
};// StyleLength::Data
|
172
188
|
|
173
189
|
|
174
|
-
StyleLength::StyleLength ()
|
175
|
-
{
|
176
|
-
}
|
177
|
-
|
178
|
-
StyleLength::StyleLength (Value value, Unit unit)
|
179
|
-
{
|
180
|
-
reset(value, unit);
|
181
|
-
}
|
182
|
-
|
183
|
-
StyleLength::StyleLength (const char* str)
|
190
|
+
StyleLength::StyleLength (Type type, Value value)
|
184
191
|
{
|
185
|
-
reset(
|
192
|
+
reset(type, value);
|
186
193
|
}
|
187
194
|
|
188
195
|
StyleLength
|
189
196
|
StyleLength::copy () const
|
190
197
|
{
|
191
|
-
return StyleLength(
|
198
|
+
return StyleLength(type(), value());
|
192
199
|
}
|
193
200
|
|
194
201
|
void
|
195
|
-
StyleLength::reset (
|
202
|
+
StyleLength::reset (Type type, Value value)
|
196
203
|
{
|
197
|
-
if (
|
204
|
+
if (type < NONE || TYPE_MAX <= type)
|
198
205
|
argument_error(__FILE__, __LINE__);
|
199
206
|
|
200
|
-
|
201
|
-
|
202
|
-
}
|
203
|
-
|
204
|
-
static StyleLength::Unit
|
205
|
-
str2unit (const char* s)
|
206
|
-
{
|
207
|
-
if (strcasecmp(s, "px") == 0) return StyleLength::PIXEL;
|
208
|
-
else if (strcasecmp(s, "%") == 0) return StyleLength::PERCENT;
|
209
|
-
else return StyleLength::NONE;
|
210
|
-
}
|
207
|
+
if (type == FIT && value != 1)
|
208
|
+
argument_error(__FILE__, __LINE__);
|
211
209
|
|
212
|
-
|
213
|
-
|
214
|
-
{
|
215
|
-
switch (unit)
|
216
|
-
{
|
217
|
-
case StyleLength::PIXEL: return "px";
|
218
|
-
case StyleLength::PERCENT: return "%";
|
219
|
-
default: return NULL;
|
220
|
-
}
|
210
|
+
self->type = type;
|
211
|
+
self->value = value;
|
221
212
|
}
|
222
213
|
|
223
|
-
|
224
|
-
StyleLength::
|
214
|
+
StyleLength::Type
|
215
|
+
StyleLength::type () const
|
225
216
|
{
|
226
|
-
|
227
|
-
char suffix[256];
|
228
|
-
int count = sscanf(str, "%f%s", &num, suffix);
|
229
|
-
if (count != 2)
|
230
|
-
argument_error(__FILE__, __LINE__);
|
231
|
-
|
232
|
-
reset(num, str2unit(suffix));
|
217
|
+
return self->type;
|
233
218
|
}
|
234
219
|
|
235
220
|
StyleLength::Value
|
@@ -238,34 +223,9 @@ namespace Reflex
|
|
238
223
|
return self->value;
|
239
224
|
}
|
240
225
|
|
241
|
-
StyleLength::Unit
|
242
|
-
StyleLength::unit () const
|
243
|
-
{
|
244
|
-
return self->unit;
|
245
|
-
}
|
246
|
-
|
247
|
-
String
|
248
|
-
StyleLength::to_s () const
|
249
|
-
{
|
250
|
-
if (!*this)
|
251
|
-
return "";
|
252
|
-
|
253
|
-
String num;
|
254
|
-
if (fmod(self->value, 1) == 0)
|
255
|
-
num = Xot::stringf("%d", (long) self->value);
|
256
|
-
else
|
257
|
-
num = Xot::stringf("%g", self->value);
|
258
|
-
|
259
|
-
const char* suffix = unit2str(self->unit);;
|
260
|
-
if (!suffix)
|
261
|
-
invalid_state_error(__FILE__, __LINE__);
|
262
|
-
|
263
|
-
return num + suffix;
|
264
|
-
}
|
265
|
-
|
266
226
|
StyleLength::operator bool () const
|
267
227
|
{
|
268
|
-
return NONE < self->
|
228
|
+
return NONE < self->type && self->type < TYPE_MAX;
|
269
229
|
}
|
270
230
|
|
271
231
|
bool
|
@@ -287,56 +247,73 @@ namespace Reflex
|
|
287
247
|
}
|
288
248
|
|
289
249
|
|
290
|
-
|
291
|
-
get_default_flow (Style::Flow* main, Style::Flow* sub)
|
250
|
+
struct Style::Data
|
292
251
|
{
|
293
|
-
assert(main || sub);
|
294
252
|
|
295
|
-
|
296
|
-
|
297
|
-
|
253
|
+
struct WhiteColor : public Color
|
254
|
+
{
|
255
|
+
WhiteColor () : Color(1, 1) {}
|
256
|
+
};
|
298
257
|
|
258
|
+
struct TransparentColor : public Color
|
259
|
+
{
|
260
|
+
TransparentColor () : Color(0, 0) {}
|
261
|
+
};
|
299
262
|
|
300
|
-
|
301
|
-
|
263
|
+
struct MaxLength : public StyleLength
|
264
|
+
{
|
265
|
+
MaxLength () : StyleLength(PERCENT, 100) {}
|
266
|
+
};
|
302
267
|
|
303
|
-
typedef StyleValue<bool>
|
268
|
+
typedef StyleValue<bool> BoolValue;
|
304
269
|
|
305
|
-
typedef StyleValue<int>
|
270
|
+
typedef StyleValue<int> IntValue;
|
306
271
|
|
307
|
-
typedef StyleValue<double>
|
272
|
+
typedef StyleValue<double> FloatValue;
|
308
273
|
|
309
|
-
typedef StyleValue<
|
274
|
+
typedef StyleValue<coord> CoordValue;
|
310
275
|
|
311
|
-
typedef StyleValue<
|
276
|
+
typedef StyleValue<Color> ColorValue;
|
312
277
|
|
313
|
-
typedef StyleValue<
|
278
|
+
typedef StyleValue<Image> ImageValue;
|
279
|
+
|
280
|
+
typedef StyleValue<StyleLength> LengthValue;
|
314
281
|
|
315
282
|
View* owner;
|
316
283
|
|
317
|
-
|
284
|
+
SelectorPtr pselector;
|
285
|
+
|
286
|
+
IntValue flow;
|
287
|
+
|
288
|
+
StyleValue<StyleLength, MaxLength> width, height;
|
318
289
|
|
319
|
-
|
290
|
+
LengthValue left, top, right, bottom;
|
320
291
|
|
321
|
-
|
292
|
+
LengthValue margin_left, margin_top, margin_right, margin_bottom;
|
322
293
|
|
323
|
-
|
294
|
+
LengthValue padding_left, padding_top, padding_right, padding_bottom;
|
324
295
|
|
325
|
-
|
296
|
+
LengthValue center_x, center_y;
|
326
297
|
|
327
|
-
|
298
|
+
StyleValue<Color, WhiteColor> fore_fill;
|
328
299
|
|
329
|
-
|
300
|
+
StyleValue<Color, TransparentColor> fore_stroke, back_fill, back_stroke;
|
330
301
|
|
331
|
-
|
302
|
+
CoordValue fore_stroke_width, back_stroke_width;
|
332
303
|
|
333
|
-
|
304
|
+
ImageValue image;
|
334
305
|
|
335
306
|
Data ()
|
336
307
|
: owner(NULL)
|
337
308
|
{
|
338
309
|
}
|
339
310
|
|
311
|
+
Selector& selector ()
|
312
|
+
{
|
313
|
+
if (!pselector) pselector.reset(new Selector);
|
314
|
+
return *pselector;
|
315
|
+
}
|
316
|
+
|
340
317
|
enum FlowOffset {FLOW_MASK = 0xffff, FLOW_SHIFT = 16};
|
341
318
|
|
342
319
|
bool set_flow (Flow main, Flow sub)
|
@@ -346,57 +323,110 @@ namespace Reflex
|
|
346
323
|
|
347
324
|
Flow flow_main () const
|
348
325
|
{
|
349
|
-
Flow
|
350
|
-
get_default_flow(&defval, NULL);
|
351
|
-
return (Flow) (flow.get(defval) & FLOW_MASK);
|
326
|
+
return (Flow) (flow.get(FLOW_NONE) & FLOW_MASK);
|
352
327
|
}
|
353
328
|
|
354
329
|
Flow flow_sub () const
|
355
330
|
{
|
356
|
-
Flow
|
357
|
-
get_default_flow(NULL, &defval);
|
358
|
-
return (Flow) ((flow.get(defval << FLOW_SHIFT) >> FLOW_SHIFT) & FLOW_MASK);
|
331
|
+
return (Flow) ((flow.get(FLOW_NONE << FLOW_SHIFT) >> FLOW_SHIFT) & FLOW_MASK);
|
359
332
|
}
|
360
333
|
|
361
334
|
};// Data
|
362
335
|
|
363
336
|
|
364
|
-
|
337
|
+
bool
|
338
|
+
Style_set_owner (Style* style, View* owner)
|
365
339
|
{
|
340
|
+
assert(style);
|
366
341
|
|
367
|
-
|
368
|
-
|
369
|
-
static const Image image;
|
370
|
-
|
371
|
-
static const StyleLength length;
|
342
|
+
if (!!style->self->owner == !!owner)
|
343
|
+
return false;
|
372
344
|
|
373
|
-
|
345
|
+
style->self->owner = owner;
|
346
|
+
return true;
|
347
|
+
}
|
374
348
|
|
349
|
+
template <typename T>
|
350
|
+
static bool
|
351
|
+
is_variable (const T& length)
|
352
|
+
{
|
353
|
+
return length.get().self->is_variable();
|
354
|
+
}
|
375
355
|
|
376
356
|
bool
|
377
|
-
|
357
|
+
Style_has_variable_lengths (const Style& style)
|
378
358
|
{
|
379
|
-
|
359
|
+
Style::Data* s = style.self.get();
|
360
|
+
if (!s) return false;
|
380
361
|
|
381
|
-
|
382
|
-
|
362
|
+
return
|
363
|
+
is_variable(s->width) ||
|
364
|
+
is_variable(s->height) ||
|
383
365
|
|
384
|
-
|
385
|
-
|
366
|
+
is_variable(s->left) ||
|
367
|
+
is_variable(s->top) ||
|
368
|
+
is_variable(s->right) ||
|
369
|
+
is_variable(s->bottom) ||
|
370
|
+
|
371
|
+
is_variable(s->margin_left) ||
|
372
|
+
is_variable(s->margin_top) ||
|
373
|
+
is_variable(s->margin_right) ||
|
374
|
+
is_variable(s->margin_bottom) ||
|
375
|
+
|
376
|
+
is_variable(s->padding_left) ||
|
377
|
+
is_variable(s->padding_top) ||
|
378
|
+
is_variable(s->padding_right) ||
|
379
|
+
is_variable(s->padding_bottom) ||
|
380
|
+
|
381
|
+
is_variable(s->center_x) ||
|
382
|
+
is_variable(s->center_y);
|
386
383
|
}
|
387
384
|
|
385
|
+
template <typename T>
|
388
386
|
static void
|
389
|
-
|
387
|
+
clear_inherited_value (T* value)
|
390
388
|
{
|
391
|
-
|
392
|
-
|
389
|
+
assert(value);
|
390
|
+
|
391
|
+
if (value->is_inherited())
|
392
|
+
value->clear();
|
393
|
+
}
|
394
|
+
|
395
|
+
void
|
396
|
+
Style_clear_inherited_values (Style* style)
|
397
|
+
{
|
398
|
+
assert(style);
|
393
399
|
|
394
|
-
|
395
|
-
|
400
|
+
Style::Data* self = style->self.get();
|
401
|
+
|
402
|
+
clear_inherited_value(&self->flow);
|
403
|
+
clear_inherited_value(&self->width);
|
404
|
+
clear_inherited_value(&self->height);
|
405
|
+
clear_inherited_value(&self->left);
|
406
|
+
clear_inherited_value(&self->top);
|
407
|
+
clear_inherited_value(&self->right);
|
408
|
+
clear_inherited_value(&self->bottom);
|
409
|
+
clear_inherited_value(&self->margin_left);
|
410
|
+
clear_inherited_value(&self->margin_top);
|
411
|
+
clear_inherited_value(&self->margin_right);
|
412
|
+
clear_inherited_value(&self->margin_bottom);
|
413
|
+
clear_inherited_value(&self->padding_left);
|
414
|
+
clear_inherited_value(&self->padding_top);
|
415
|
+
clear_inherited_value(&self->padding_right);
|
416
|
+
clear_inherited_value(&self->padding_bottom);
|
417
|
+
clear_inherited_value(&self->center_x);
|
418
|
+
clear_inherited_value(&self->center_y);
|
419
|
+
clear_inherited_value(&self->fore_fill);
|
420
|
+
clear_inherited_value(&self->fore_stroke);
|
421
|
+
clear_inherited_value(&self->fore_stroke_width);
|
422
|
+
clear_inherited_value(&self->back_fill);
|
423
|
+
clear_inherited_value(&self->back_stroke);
|
424
|
+
clear_inherited_value(&self->back_stroke_width);
|
425
|
+
clear_inherited_value(&self->image);
|
396
426
|
}
|
397
427
|
|
398
428
|
void
|
399
|
-
|
429
|
+
Style_override (Style* overridden, const Style& overrides)
|
400
430
|
{
|
401
431
|
assert(overridden);
|
402
432
|
|
@@ -404,120 +434,166 @@ namespace Reflex
|
|
404
434
|
Style::Data* to = overridden->self.get();
|
405
435
|
if (!from || !to) return;
|
406
436
|
|
407
|
-
to->flow
|
408
|
-
to->width
|
409
|
-
to->height
|
410
|
-
to->left
|
411
|
-
to->top
|
412
|
-
to->right
|
413
|
-
to->bottom
|
414
|
-
to->
|
415
|
-
to->
|
416
|
-
to->
|
417
|
-
to->
|
418
|
-
to->
|
419
|
-
to->
|
420
|
-
to->
|
421
|
-
to->
|
422
|
-
to->
|
423
|
-
to->
|
424
|
-
to->
|
425
|
-
to->
|
426
|
-
to->
|
427
|
-
to->
|
428
|
-
to->
|
437
|
+
to->flow .override(from->flow);
|
438
|
+
to->width .override(from->width);
|
439
|
+
to->height .override(from->height);
|
440
|
+
to->left .override(from->left);
|
441
|
+
to->top .override(from->top);
|
442
|
+
to->right .override(from->right);
|
443
|
+
to->bottom .override(from->bottom);
|
444
|
+
to->margin_left .override(from->margin_left);
|
445
|
+
to->margin_top .override(from->margin_top);
|
446
|
+
to->margin_right .override(from->margin_right);
|
447
|
+
to->margin_bottom .override(from->margin_bottom);
|
448
|
+
to->padding_left .override(from->padding_left);
|
449
|
+
to->padding_top .override(from->padding_top);
|
450
|
+
to->padding_right .override(from->padding_right);
|
451
|
+
to->padding_bottom .override(from->padding_bottom);
|
452
|
+
to->center_x .override(from->center_x);
|
453
|
+
to->center_y .override(from->center_y);
|
454
|
+
to->fore_fill .override(from->fore_fill);
|
455
|
+
to->fore_stroke .override(from->fore_stroke);
|
456
|
+
to->fore_stroke_width.override(from->fore_stroke_width);
|
457
|
+
to->back_fill .override(from->back_fill);
|
458
|
+
to->back_stroke .override(from->back_stroke);
|
459
|
+
to->back_stroke_width.override(from->back_stroke_width);
|
460
|
+
to->image .override(from->image);
|
429
461
|
}
|
430
462
|
|
431
|
-
|
432
|
-
|
463
|
+
bool
|
464
|
+
StyleLength_get_pixel_length (
|
465
|
+
coord* pixel_length, const StyleLength& style_length, coord parent_size)
|
433
466
|
{
|
434
|
-
|
435
|
-
}
|
467
|
+
assert(pixel_length);
|
436
468
|
|
437
|
-
|
438
|
-
|
439
|
-
}
|
469
|
+
if (!style_length)
|
470
|
+
return false;
|
440
471
|
|
441
|
-
|
442
|
-
Style::set_name (const char* name)
|
443
|
-
{
|
444
|
-
update_owner(*this);
|
472
|
+
coord old_length = *pixel_length;
|
445
473
|
|
446
|
-
|
474
|
+
StyleLength::Value value = style_length.value();
|
475
|
+
switch (style_length.type())
|
476
|
+
{
|
477
|
+
case StyleLength::PIXEL:
|
478
|
+
*pixel_length = value;
|
479
|
+
break;
|
447
480
|
|
448
|
-
|
449
|
-
|
481
|
+
case StyleLength::PERCENT:
|
482
|
+
*pixel_length =
|
483
|
+
(value == 100) ? parent_size : floor(parent_size * value / 100);
|
484
|
+
break;
|
450
485
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
486
|
+
case StyleLength::FILL:
|
487
|
+
break;
|
488
|
+
|
489
|
+
default:
|
490
|
+
invalid_state_error(__FILE__, __LINE__);
|
491
|
+
}
|
492
|
+
|
493
|
+
return *pixel_length != old_length;
|
455
494
|
}
|
456
495
|
|
457
|
-
void
|
458
|
-
|
496
|
+
static void
|
497
|
+
update_frame (View* view, const Style& style)
|
459
498
|
{
|
460
|
-
|
499
|
+
assert(view);
|
461
500
|
|
462
|
-
|
501
|
+
View* parent = view->parent();
|
502
|
+
if (!parent) return;
|
463
503
|
|
464
|
-
|
504
|
+
Bounds frame = view->frame();
|
505
|
+
const Bounds& parent_frame = parent->frame();
|
506
|
+
|
507
|
+
bool update = false;
|
508
|
+
update |=
|
509
|
+
StyleLength_get_pixel_length(&frame.w, style.width(), parent_frame.w);
|
510
|
+
update |=
|
511
|
+
StyleLength_get_pixel_length(&frame.h, style.height(), parent_frame.h);
|
512
|
+
|
513
|
+
if (update)
|
514
|
+
View_set_frame(view, frame);
|
465
515
|
}
|
466
516
|
|
467
517
|
void
|
468
|
-
|
518
|
+
Style_apply_to (const Style& style, View* view)
|
469
519
|
{
|
470
|
-
|
520
|
+
assert(view);
|
471
521
|
|
472
|
-
|
522
|
+
//update_margin(view, values);
|
523
|
+
//update_padding(view, values);
|
524
|
+
update_frame(view, style);
|
525
|
+
//update_background(view, values);
|
526
|
+
}
|
473
527
|
|
474
|
-
|
528
|
+
bool
|
529
|
+
Style_has_width (const Style& style)
|
530
|
+
{
|
531
|
+
return style.self->width;
|
475
532
|
}
|
476
533
|
|
477
|
-
|
478
|
-
Style
|
534
|
+
bool
|
535
|
+
Style_has_height (const Style& style)
|
479
536
|
{
|
480
|
-
return self->
|
537
|
+
return style.self->height;
|
481
538
|
}
|
482
539
|
|
483
|
-
|
484
|
-
Style
|
540
|
+
static void
|
541
|
+
update_owner (const Style& style)
|
485
542
|
{
|
486
|
-
|
543
|
+
View* owner = style.self->owner;
|
544
|
+
if (!owner) return;
|
545
|
+
|
546
|
+
View_update_styles(owner, style.selector());
|
487
547
|
}
|
488
548
|
|
489
|
-
|
490
|
-
Style::
|
549
|
+
|
550
|
+
Style::Style (const char* name)
|
491
551
|
{
|
492
|
-
|
552
|
+
if (name) set_name(name);
|
493
553
|
}
|
494
554
|
|
495
|
-
|
496
|
-
Style::tag_end () const
|
555
|
+
Style::~Style ()
|
497
556
|
{
|
498
|
-
return self->selector.end();
|
499
557
|
}
|
500
558
|
|
501
559
|
void
|
502
|
-
Style::
|
560
|
+
Style::set_name (const char* name)
|
503
561
|
{
|
504
562
|
update_owner(*this);
|
563
|
+
HasSelector::set_name(name);
|
564
|
+
update_owner(*this);
|
565
|
+
}
|
505
566
|
|
506
|
-
|
567
|
+
void
|
568
|
+
Style::add_tag (const char* tag)
|
569
|
+
{
|
570
|
+
update_owner(*this);
|
571
|
+
HasSelector::add_tag(tag);
|
572
|
+
update_owner(*this);
|
573
|
+
}
|
507
574
|
|
575
|
+
void
|
576
|
+
Style::remove_tag (const char* tag)
|
577
|
+
{
|
578
|
+
update_owner(*this);
|
579
|
+
HasSelector::remove_tag(tag);
|
508
580
|
update_owner(*this);
|
509
581
|
}
|
510
582
|
|
511
|
-
|
512
|
-
Style::
|
583
|
+
void
|
584
|
+
Style::clear_tags ()
|
513
585
|
{
|
514
|
-
|
586
|
+
update_owner(*this);
|
587
|
+
HasSelector::clear_tags();
|
588
|
+
update_owner(*this);
|
515
589
|
}
|
516
590
|
|
517
|
-
|
518
|
-
Style::
|
591
|
+
void
|
592
|
+
Style::set_selector (const Selector& selector)
|
519
593
|
{
|
520
|
-
|
594
|
+
update_owner(*this);
|
595
|
+
HasSelector::set_selector(selector);
|
596
|
+
update_owner(*this);
|
521
597
|
}
|
522
598
|
|
523
599
|
enum FlowDir {FLOW_INVALID = 0, FLOW_H, FLOW_V};
|
@@ -539,8 +615,8 @@ namespace Reflex
|
|
539
615
|
Style::set_flow (Flow main, Flow sub)
|
540
616
|
{
|
541
617
|
if (
|
542
|
-
main < FLOW_NONE ||
|
543
|
-
sub < FLOW_NONE ||
|
618
|
+
main < FLOW_NONE || FLOW_MAX <= main ||
|
619
|
+
sub < FLOW_NONE || FLOW_MAX <= sub ||
|
544
620
|
(main != FLOW_NONE && (get_flow_dir(main) == get_flow_dir(sub))) ||
|
545
621
|
(main == FLOW_NONE && sub != FLOW_NONE))
|
546
622
|
{
|
@@ -552,6 +628,13 @@ namespace Reflex
|
|
552
628
|
update_owner(*this);
|
553
629
|
}
|
554
630
|
|
631
|
+
void
|
632
|
+
Style::clear_flow ()
|
633
|
+
{
|
634
|
+
if (self->flow.clear())
|
635
|
+
update_owner(*this);
|
636
|
+
}
|
637
|
+
|
555
638
|
void
|
556
639
|
Style::get_flow (Flow* main, Flow* sub) const
|
557
640
|
{
|
@@ -576,16 +659,30 @@ namespace Reflex
|
|
576
659
|
update_owner(*this);
|
577
660
|
}
|
578
661
|
|
662
|
+
void
|
663
|
+
Style::clear_width ()
|
664
|
+
{
|
665
|
+
if (self->width.clear())
|
666
|
+
update_owner(*this);
|
667
|
+
}
|
668
|
+
|
669
|
+
void
|
670
|
+
Style::clear_height ()
|
671
|
+
{
|
672
|
+
if (self->height.clear())
|
673
|
+
update_owner(*this);
|
674
|
+
}
|
675
|
+
|
579
676
|
const StyleLength&
|
580
677
|
Style::width () const
|
581
678
|
{
|
582
|
-
return self->width.get(
|
679
|
+
return self->width.get();
|
583
680
|
}
|
584
681
|
|
585
682
|
const StyleLength&
|
586
683
|
Style::height () const
|
587
684
|
{
|
588
|
-
return self->height.get(
|
685
|
+
return self->height.get();
|
589
686
|
}
|
590
687
|
|
591
688
|
void
|
@@ -616,80 +713,56 @@ namespace Reflex
|
|
616
713
|
update_owner(*this);
|
617
714
|
}
|
618
715
|
|
619
|
-
const StyleLength&
|
620
|
-
Style::left () const
|
621
|
-
{
|
622
|
-
return self->left.get(Zero::length);
|
623
|
-
}
|
624
|
-
|
625
|
-
const StyleLength&
|
626
|
-
Style::top () const
|
627
|
-
{
|
628
|
-
return self->top.get(Zero::length);
|
629
|
-
}
|
630
|
-
|
631
|
-
const StyleLength&
|
632
|
-
Style::right () const
|
633
|
-
{
|
634
|
-
return self->right.get(Zero::length);
|
635
|
-
}
|
636
|
-
|
637
|
-
const StyleLength&
|
638
|
-
Style::bottom () const
|
639
|
-
{
|
640
|
-
return self->bottom.get(Zero::length);
|
641
|
-
}
|
642
|
-
|
643
716
|
void
|
644
|
-
Style::
|
717
|
+
Style::clear_left ()
|
645
718
|
{
|
646
|
-
if (self->
|
719
|
+
if (self->left.clear())
|
647
720
|
update_owner(*this);
|
648
721
|
}
|
649
722
|
|
650
723
|
void
|
651
|
-
Style::
|
724
|
+
Style::clear_top ()
|
652
725
|
{
|
653
|
-
if (self->
|
726
|
+
if (self->top.clear())
|
654
727
|
update_owner(*this);
|
655
728
|
}
|
656
729
|
|
657
730
|
void
|
658
|
-
Style::
|
731
|
+
Style::clear_right ()
|
659
732
|
{
|
660
|
-
if (self->
|
733
|
+
if (self->right.clear())
|
661
734
|
update_owner(*this);
|
662
735
|
}
|
663
736
|
|
664
737
|
void
|
665
|
-
Style::
|
738
|
+
Style::clear_bottom ()
|
666
739
|
{
|
667
|
-
if (self->
|
740
|
+
if (self->bottom.clear())
|
668
741
|
update_owner(*this);
|
669
742
|
}
|
670
743
|
|
671
744
|
const StyleLength&
|
672
|
-
Style::
|
745
|
+
Style::left () const
|
673
746
|
{
|
674
|
-
return self->
|
747
|
+
return self->left.get();
|
675
748
|
}
|
676
749
|
|
677
750
|
const StyleLength&
|
678
|
-
Style::
|
751
|
+
Style::top () const
|
679
752
|
{
|
680
|
-
return self->
|
753
|
+
return self->top.get();
|
681
754
|
}
|
682
755
|
|
683
756
|
const StyleLength&
|
684
|
-
Style::
|
757
|
+
Style::right () const
|
685
758
|
{
|
686
|
-
return self->
|
759
|
+
return self->right.get();
|
687
760
|
}
|
688
761
|
|
689
762
|
const StyleLength&
|
690
|
-
Style::
|
763
|
+
Style::bottom () const
|
691
764
|
{
|
692
|
-
return self->
|
765
|
+
return self->bottom.get();
|
693
766
|
}
|
694
767
|
|
695
768
|
void
|
@@ -720,28 +793,56 @@ namespace Reflex
|
|
720
793
|
update_owner(*this);
|
721
794
|
}
|
722
795
|
|
796
|
+
void
|
797
|
+
Style::clear_margin_left ()
|
798
|
+
{
|
799
|
+
if (self->margin_left.clear())
|
800
|
+
update_owner(*this);
|
801
|
+
}
|
802
|
+
|
803
|
+
void
|
804
|
+
Style::clear_margin_top ()
|
805
|
+
{
|
806
|
+
if (self->margin_top.clear())
|
807
|
+
update_owner(*this);
|
808
|
+
}
|
809
|
+
|
810
|
+
void
|
811
|
+
Style::clear_margin_right ()
|
812
|
+
{
|
813
|
+
if (self->margin_right.clear())
|
814
|
+
update_owner(*this);
|
815
|
+
}
|
816
|
+
|
817
|
+
void
|
818
|
+
Style::clear_margin_bottom ()
|
819
|
+
{
|
820
|
+
if (self->margin_bottom.clear())
|
821
|
+
update_owner(*this);
|
822
|
+
}
|
823
|
+
|
723
824
|
const StyleLength&
|
724
825
|
Style::margin_left () const
|
725
826
|
{
|
726
|
-
return self->margin_left.get(
|
827
|
+
return self->margin_left.get();
|
727
828
|
}
|
728
829
|
|
729
830
|
const StyleLength&
|
730
831
|
Style::margin_top () const
|
731
832
|
{
|
732
|
-
return self->margin_top.get(
|
833
|
+
return self->margin_top.get();
|
733
834
|
}
|
734
835
|
|
735
836
|
const StyleLength&
|
736
837
|
Style::margin_right () const
|
737
838
|
{
|
738
|
-
return self->margin_right.get(
|
839
|
+
return self->margin_right.get();
|
739
840
|
}
|
740
841
|
|
741
842
|
const StyleLength&
|
742
843
|
Style::margin_bottom () const
|
743
844
|
{
|
744
|
-
return self->margin_bottom.get(
|
845
|
+
return self->margin_bottom.get();
|
745
846
|
}
|
746
847
|
|
747
848
|
void
|
@@ -772,158 +873,254 @@ namespace Reflex
|
|
772
873
|
update_owner(*this);
|
773
874
|
}
|
774
875
|
|
876
|
+
void
|
877
|
+
Style::clear_padding_left ()
|
878
|
+
{
|
879
|
+
if (self->padding_left.clear())
|
880
|
+
update_owner(*this);
|
881
|
+
}
|
882
|
+
|
883
|
+
void
|
884
|
+
Style::clear_padding_top ()
|
885
|
+
{
|
886
|
+
if (self->padding_top.clear())
|
887
|
+
update_owner(*this);
|
888
|
+
}
|
889
|
+
|
890
|
+
void
|
891
|
+
Style::clear_padding_right ()
|
892
|
+
{
|
893
|
+
if (self->padding_right.clear())
|
894
|
+
update_owner(*this);
|
895
|
+
}
|
896
|
+
|
897
|
+
void
|
898
|
+
Style::clear_padding_bottom ()
|
899
|
+
{
|
900
|
+
if (self->padding_bottom.clear())
|
901
|
+
update_owner(*this);
|
902
|
+
}
|
903
|
+
|
775
904
|
const StyleLength&
|
776
905
|
Style::padding_left () const
|
777
906
|
{
|
778
|
-
return self->padding_left.get(
|
907
|
+
return self->padding_left.get();
|
779
908
|
}
|
780
909
|
|
781
910
|
const StyleLength&
|
782
911
|
Style::padding_top () const
|
783
912
|
{
|
784
|
-
return self->padding_top.get(
|
913
|
+
return self->padding_top.get();
|
785
914
|
}
|
786
915
|
|
787
916
|
const StyleLength&
|
788
917
|
Style::padding_right () const
|
789
918
|
{
|
790
|
-
return self->padding_right.get(
|
919
|
+
return self->padding_right.get();
|
791
920
|
}
|
792
921
|
|
793
922
|
const StyleLength&
|
794
923
|
Style::padding_bottom () const
|
795
924
|
{
|
796
|
-
return self->padding_bottom.get(
|
925
|
+
return self->padding_bottom.get();
|
797
926
|
}
|
798
927
|
|
799
928
|
void
|
800
|
-
Style::
|
929
|
+
Style::set_center_x (const StyleLength& x)
|
801
930
|
{
|
802
|
-
if (self->
|
931
|
+
if (self->center_x.set(x))
|
803
932
|
update_owner(*this);
|
804
933
|
}
|
805
934
|
|
806
|
-
|
807
|
-
Style::
|
935
|
+
void
|
936
|
+
Style::set_center_y (const StyleLength& y)
|
808
937
|
{
|
809
|
-
|
938
|
+
if (self->center_y.set(y))
|
939
|
+
update_owner(*this);
|
810
940
|
}
|
811
941
|
|
812
942
|
void
|
813
|
-
Style::
|
943
|
+
Style::clear_center_x ()
|
814
944
|
{
|
815
|
-
if (self->
|
945
|
+
if (self->center_x.clear())
|
816
946
|
update_owner(*this);
|
817
947
|
}
|
818
948
|
|
819
|
-
|
820
|
-
Style::
|
949
|
+
void
|
950
|
+
Style::clear_center_y ()
|
821
951
|
{
|
822
|
-
|
952
|
+
if (self->center_y.clear())
|
953
|
+
update_owner(*this);
|
954
|
+
}
|
955
|
+
|
956
|
+
const StyleLength&
|
957
|
+
Style::center_x () const
|
958
|
+
{
|
959
|
+
return self->center_x.get();
|
960
|
+
}
|
961
|
+
|
962
|
+
const StyleLength&
|
963
|
+
Style::center_y () const
|
964
|
+
{
|
965
|
+
return self->center_y.get();
|
823
966
|
}
|
824
967
|
|
825
968
|
void
|
826
|
-
Style::
|
969
|
+
Style::set_foreground_fill (const Color& fill)
|
827
970
|
{
|
828
|
-
if (self->
|
971
|
+
if (self->fore_fill.set(fill))
|
829
972
|
update_owner(*this);
|
830
973
|
}
|
831
974
|
|
832
|
-
|
833
|
-
Style::
|
975
|
+
void
|
976
|
+
Style::set_foreground_stroke (const Color& stroke)
|
834
977
|
{
|
835
|
-
|
978
|
+
if (self->fore_stroke.set(stroke))
|
979
|
+
update_owner(*this);
|
836
980
|
}
|
837
981
|
|
838
|
-
|
839
|
-
|
982
|
+
void
|
983
|
+
Style::set_foreground_stroke_width (coord width)
|
840
984
|
{
|
841
|
-
|
985
|
+
if (self->fore_stroke_width.set(width))
|
986
|
+
update_owner(*this);
|
842
987
|
}
|
843
988
|
|
844
|
-
|
845
|
-
|
989
|
+
void
|
990
|
+
Style::set_background_fill (const Color& fill)
|
846
991
|
{
|
847
|
-
|
992
|
+
if (self->back_fill.set(fill))
|
993
|
+
update_owner(*this);
|
848
994
|
}
|
849
995
|
|
996
|
+
void
|
997
|
+
Style::set_background_stroke (const Color& stroke)
|
998
|
+
{
|
999
|
+
if (self->back_stroke.set(stroke))
|
1000
|
+
update_owner(*this);
|
1001
|
+
}
|
850
1002
|
|
851
|
-
|
852
|
-
|
853
|
-
coord* pixel_length,
|
854
|
-
const StyleLength& style_length, const coord* parent_size)
|
1003
|
+
void
|
1004
|
+
Style::set_background_stroke_width (coord width)
|
855
1005
|
{
|
856
|
-
if (
|
857
|
-
|
1006
|
+
if (self->back_stroke_width.set(width))
|
1007
|
+
update_owner(*this);
|
1008
|
+
}
|
858
1009
|
|
859
|
-
|
860
|
-
|
1010
|
+
void
|
1011
|
+
Style::clear_foreground_fill ()
|
1012
|
+
{
|
1013
|
+
if (self->fore_fill.clear())
|
1014
|
+
update_owner(*this);
|
1015
|
+
}
|
861
1016
|
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
break;
|
1017
|
+
void
|
1018
|
+
Style::clear_foreground_stroke ()
|
1019
|
+
{
|
1020
|
+
if (self->fore_stroke.clear())
|
1021
|
+
update_owner(*this);
|
1022
|
+
}
|
869
1023
|
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
1024
|
+
void
|
1025
|
+
Style::clear_foreground_stroke_width ()
|
1026
|
+
{
|
1027
|
+
if (self->fore_stroke_width.clear())
|
1028
|
+
update_owner(*this);
|
1029
|
+
}
|
874
1030
|
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
1031
|
+
void
|
1032
|
+
Style::clear_background_fill ()
|
1033
|
+
{
|
1034
|
+
if (self->back_fill.clear())
|
1035
|
+
update_owner(*this);
|
1036
|
+
}
|
879
1037
|
|
880
|
-
|
881
|
-
|
882
|
-
|
1038
|
+
void
|
1039
|
+
Style::clear_background_stroke ()
|
1040
|
+
{
|
1041
|
+
if (self->back_stroke.clear())
|
1042
|
+
update_owner(*this);
|
1043
|
+
}
|
883
1044
|
|
884
|
-
|
885
|
-
|
1045
|
+
void
|
1046
|
+
Style::clear_background_stroke_width ()
|
1047
|
+
{
|
1048
|
+
if (self->back_stroke_width.clear())
|
1049
|
+
update_owner(*this);
|
1050
|
+
}
|
886
1051
|
|
887
|
-
|
888
|
-
|
1052
|
+
const Color&
|
1053
|
+
Style::foreground_fill () const
|
1054
|
+
{
|
1055
|
+
return self->fore_fill.get();
|
889
1056
|
}
|
890
1057
|
|
891
|
-
|
892
|
-
|
1058
|
+
const Color&
|
1059
|
+
Style::foreground_stroke () const
|
893
1060
|
{
|
894
|
-
|
895
|
-
|
1061
|
+
return self->fore_stroke.get();
|
1062
|
+
}
|
896
1063
|
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
1064
|
+
coord
|
1065
|
+
Style::foreground_stroke_width () const
|
1066
|
+
{
|
1067
|
+
return self->fore_stroke_width.get();
|
1068
|
+
}
|
901
1069
|
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
1070
|
+
const Color&
|
1071
|
+
Style::background_fill () const
|
1072
|
+
{
|
1073
|
+
return self->back_fill.get();
|
1074
|
+
}
|
907
1075
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
1076
|
+
const Color&
|
1077
|
+
Style::background_stroke () const
|
1078
|
+
{
|
1079
|
+
return self->back_stroke.get();
|
1080
|
+
}
|
912
1081
|
|
913
|
-
|
914
|
-
|
1082
|
+
coord
|
1083
|
+
Style::background_stroke_width () const
|
1084
|
+
{
|
1085
|
+
return self->back_stroke_width.get();
|
915
1086
|
}
|
916
1087
|
|
917
1088
|
void
|
918
|
-
|
1089
|
+
Style::set_image (const Image& image)
|
919
1090
|
{
|
920
|
-
if (
|
921
|
-
|
1091
|
+
if (self->image.set(image))
|
1092
|
+
update_owner(*this);
|
1093
|
+
}
|
922
1094
|
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
1095
|
+
void
|
1096
|
+
Style::clear_image ()
|
1097
|
+
{
|
1098
|
+
if (self->image.clear())
|
1099
|
+
update_owner(*this);
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
const Image&
|
1103
|
+
Style::image () const
|
1104
|
+
{
|
1105
|
+
return self->image.get();
|
1106
|
+
}
|
1107
|
+
|
1108
|
+
bool
|
1109
|
+
operator == (const Style& lhs, const Style& rhs)
|
1110
|
+
{
|
1111
|
+
return lhs.self.get() == rhs.self.get();
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
bool
|
1115
|
+
operator != (const Style& lhs, const Style& rhs)
|
1116
|
+
{
|
1117
|
+
return !operator==(lhs, rhs);
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
SelectorPtr*
|
1121
|
+
Style::get_selector_ptr ()
|
1122
|
+
{
|
1123
|
+
return &self->pselector;
|
927
1124
|
}
|
928
1125
|
|
929
1126
|
|