Source/Gorgon/Layer.h

Tue, 06 Jul 2021 10:22:49 +0300

author
cemkalyoncu
date
Tue, 06 Jul 2021 10:22:49 +0300
branch
4.x-dev
changeset 1701
b168349a931d
parent 1508
58d190b948ea
permissions
-rw-r--r--

* Image/Bitmap rotate

764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
1 #pragma once
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
2
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
3 #include "Containers/Collection.h"
910
38c9cc8ac94f * Groundwork for mouse input event
cemkalyoncu
parents: 904
diff changeset
4 #include "ConsumableEvent.h"
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
5 #include "Geometry/Point.h"
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
6 #include "Geometry/Bounds.h"
910
38c9cc8ac94f * Groundwork for mouse input event
cemkalyoncu
parents: 904
diff changeset
7 #include "Geometry/Transform3D.h"
38c9cc8ac94f * Groundwork for mouse input event
cemkalyoncu
parents: 904
diff changeset
8 #include "Input/Mouse.h"
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
9
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
10 namespace Gorgon {
910
38c9cc8ac94f * Groundwork for mouse input event
cemkalyoncu
parents: 904
diff changeset
11 class Layer;
38c9cc8ac94f * Groundwork for mouse input event
cemkalyoncu
parents: 904
diff changeset
12
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
13 /// Current layer transformation, only for render and mouse
1292
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
14 extern Geometry::Transform3D Transform;
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
15
1155
ac738967f7f2 * Green shooter is finished
cemkalyoncu
parents: 1121
diff changeset
16 /// Current clipping size, for mouse and clipping events
975
35bbf7cc495f * Graphics clipping
cemkalyoncu
parents: 939
diff changeset
17 extern Geometry::Bounds Clip;
1292
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
18
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
19 /// Current layer offset from the top left of the window
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
20 extern Geometry::Point Offset;
914
0858abee0f02 * Better mouse handler registration (incomplete)
cemkalyoncu
parents: 910
diff changeset
21
916
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
22 class MouseHandler {
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
23 public:
1011
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
24 MouseHandler(MouseHandler &&other) {
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
25 layers.Swap(other.layers);
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
26 }
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
27
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
28 MouseHandler &operator =(MouseHandler &&other) {
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
29 layers.Swap(other.layers);
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
30
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
31 return *this;
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
32 }
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
33
1249
b9a720d08147 * Basic widget container design is finalized
cemkalyoncu
parents: 1155
diff changeset
34 explicit MouseHandler(Layer *layer = nullptr) {
916
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
35 if(layer) layers.Add(layer);
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
36 }
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
37
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
38 operator Layer *() const {
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
39 if(layers.GetSize())
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
40 return &layers[0];
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
41 else
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
42 return nullptr;
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
43 }
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
44
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
45 operator bool() const {
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
46 return layers.GetCount() > 0;
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
47 }
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
48
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
49 void Clear() {
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
50 layers.Clear();
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
51 }
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
52
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
53 void Add(Layer *l) {
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
54 layers.Add(l);
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
55 }
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
56
1011
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
57 void Swap(MouseHandler &other) {
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
58 layers.Swap(other.layers);
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
59 }
c77faf04113d * Reorganized generic test
cemkalyoncu
parents: 975
diff changeset
60
916
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
61 Containers::Collection<Layer> layers;
6c3f422da3ae * Mouse system is complete, requires through testing
cemkalyoncu
parents: 914
diff changeset
62 };
910
38c9cc8ac94f * Groundwork for mouse input event
cemkalyoncu
parents: 904
diff changeset
63
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
64 /// This should be called by the windows to reset transformation stack.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
65 inline void ResetTransform(const Geometry::Size &size) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
66 Transform={};
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
67 Transform.Translate({-1.0f, 1.0f, 0});
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
68 Transform.Scale(2.0f / size.Width, -2.0f / size.Height, 1.0f);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
69 }
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
70
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
71 /**
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
72 * This class is the base class for all layer types.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
73 * All common methods are implemented with a common way.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
74 * This class always implements basic processing functions.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
75 * Derived classes can override them. Unless overridden these
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
76 * basic functions only propagate the call. Copying a layer is
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
77 * dangerous and therefore disabled. @nosubgrouping
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
78 */
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
79 class Layer {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
80 public:
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
81
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
82 /// Initializing constructor
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
83 Layer(const Geometry::Bounds &bounds) :
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
84 Children(children),
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
85 bounds(bounds)
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
86 { }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
87
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
88 /// Constructor that sets the layer to cover entire parent, no matter how big it is. The
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
89 /// location of the layer is set to be the origin
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
90 Layer() : Layer(EntireRegion) { }
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
91
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
92 /// Constructor that places the layer to the given location
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
93 Layer(const Geometry::Point &location) :
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
94 Layer({location, Geometry::Size::Max()})
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
95 { }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
96
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
97 /// Copy constructor is disabled.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
98 Layer(const Layer&) = delete;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
99
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
100 /// Move constructor
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
101 Layer(Layer &&other) : Children(children) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
102 Swap(other);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
103 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
104
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
105 /// Copy assignment is deleted
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
106 Layer &operator =(const Layer &)=delete;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
107
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
108 /// Move assignment
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
109 Layer &operator =(Layer &&other);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
110
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
111 /// Destructor
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
112 virtual ~Layer();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
113
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
114 /// Swaps two layers, mostly used for move semantics
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
115 void Swap(Layer &other);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
116
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
117 /// @name Children related functions
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
118 /// @{
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
119 /// These functions deals with child layers.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
120
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
121 /// Adds the given layer as a child. Notice that the newly added
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
122 /// layer is drawn on top of others.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
123 virtual void Add(Layer &layer);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
124
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
125 /// Adds the given layer as a child. Notice that the newly added
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
126 /// layer is drawn on top of others.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
127 void Add(Layer *layer) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
128 if(!layer) return;
1353
3be35aeb382b #87: alt+tab on linux causing freeze
cemkalyoncu
parents: 1299
diff changeset
129
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
130 Add(*layer);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
131 }
1292
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
132
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
133 /// For debugging
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
134 void setname(std::string value) {
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
135 #ifndef NDEBUG
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
136 name = value;
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
137 #endif
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
138 }
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
139
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
140 /// Inserts the given layer before the given index. The newly inserted
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
141 /// layer will be drawn *under* the layer in the given index
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
142 virtual void Insert(Layer &layer, long under);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
143
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
144 /// Inserts the given layer before the given index. The newly inserted
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
145 /// layer will be drawn *under* the layer in the given index
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
146 void Insert(Layer *layer, long under) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
147 if(!layer) return;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
148
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
149 Insert(*layer, under);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
150 }
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
151
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
152 /// Removes the given layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
153 virtual void Remove(Layer &layer) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
154 children.Remove(layer);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
155
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
156 removed(layer);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
157 layer.located(nullptr);
1291
62a6b45a4668 * Panel mouse scroll (limits is still not working)
cemkalyoncu
parents: 1279
diff changeset
158 layer.parent = nullptr;
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
159 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
160
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
161 /// Removes the given layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
162 void Remove(Layer *layer) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
163 if(!layer) return;
1484
6a0de0bd14ad #134 Layer extender request
cemkalyoncu
parents: 1400
diff changeset
164
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
165 Remove(*layer);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
166 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
167
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
168 /// Returns whether this layer has a parent
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
169 virtual bool HasParent() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
170 return parent!=nullptr;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
171 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
172
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
173 /// Returns the parent of this layer. Throws if no parent is set. Use HasParent
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
174 /// to make sure this layer has a parent
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
175 /// @throw std::runtime_error if no parent is set
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
176 virtual Layer &GetParent() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
177 if(!parent) throw std::runtime_error("No parent is set");
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
178
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
179 return *parent;
1484
6a0de0bd14ad #134 Layer extender request
cemkalyoncu
parents: 1400
diff changeset
180 }
975
35bbf7cc495f * Graphics clipping
cemkalyoncu
parents: 939
diff changeset
181
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
182 /// Returns the top level layer that contains this layer.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
183 virtual Layer &GetTopLevel() {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
184 if(!parent)
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
185 return *this;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
186
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
187 return parent->GetTopLevel();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
188 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
189
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
190 /// Returns the top level layer that contains this layer.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
191 virtual Layer &GetTopLevel() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
192 if(!parent)
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
193 return const_cast<Layer &>(*this);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
194
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
195 return parent->GetTopLevel();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
196 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
197
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
198 /// Translates the given location to the top level
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
199 virtual Geometry::Point TranslateToTopLevel(Geometry::Point location = {0, 0}) const;
975
35bbf7cc495f * Graphics clipping
cemkalyoncu
parents: 939
diff changeset
200
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
201 /// @}
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
202
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
203 /// @name Iterator related functions
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
204 /// @{
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
205 /// These functions return an iterator that allows children to be iterated.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
206
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
207 /// An iterator pointing to the start of the children
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
208 Containers::Collection<Layer>::ConstIterator begin() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
209 return children.begin();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
210 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
211
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
212 /// An iterator pointing to the end of the children
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
213 Containers::Collection<Layer>::ConstIterator end() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
214 return children.end();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
215 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
216
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
217 /// An iterator pointing to the start of the children
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
218 Containers::Collection<Layer>::ConstIterator First() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
219 return children.First();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
220 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
221
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
222 /// An iterator pointing to the last item of the children
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
223 Containers::Collection<Layer>::ConstIterator Last() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
224 return children.Last();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
225 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
226 /// @}
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
227
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
228
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
229 /// @name Ordering functions
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
230 /// @{
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
231 /// This layer should be a in another layer for these methods to work.
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
232
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
233 /// Places this layer before the given index. This layer will be drawn
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
234 /// above the given index.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
235 void PlaceBefore(int before) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
236 if(parent) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
237 if(before==parent->children.GetCount()) before --;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
238
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
239 parent->children.MoveBefore(*this, before++);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
240 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
241 }
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
242
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
243 /// Places this layer to the top of the layer stack its in. This makes
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
244 /// sure that its not being covered by other layers apart from its own
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
245 /// children
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
246 void PlaceToTop() {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
247 if(parent)
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
248 parent->children.MoveBefore(*this, parent->children.GetCount());
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
249 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
250
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
251 /// Places this layer to the bottom of the layer stack.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
252 void PlaceToBottom() {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
253 if(parent)
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
254 parent->children.MoveBefore(*this, 0);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
255 }
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
256
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
257 /// Gets the current order of the stack. 0 means the layer is the bottommost
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
258 /// layer in the stack
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
259 int GetOrder() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
260 if(parent)
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
261 return parent->children.FindLocation(this);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
262 else
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
263 return -1;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
264 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
265 /// @}
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
266
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
267 /// @name Geometry related functions
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
268 /// @{
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
269 /// These functions modify or return the boundaries of this layer
1019
c72a1acd9bba * Drag and drop system is now working, dragsource still needs testing
cemkalyoncu
parents: 1011
diff changeset
270
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
271 /// Moves this layer to the given location
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
272 virtual void Move(const Geometry::Point &location) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
273 bounds.Move(location);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
274 }
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
275
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
276 /// Moves this layer to the given location
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
277 virtual void Move(int x, int y) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
278 bounds.Move({x, y});
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
279 }
1019
c72a1acd9bba * Drag and drop system is now working, dragsource still needs testing
cemkalyoncu
parents: 1011
diff changeset
280
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
281 /// Resizes the layer to the given size
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
282 virtual void Resize(const Geometry::Size &size) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
283 bounds.Resize(size);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
284 }
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
285
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
286 /// Resizes the layer to the given size
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
287 void Resize(int width, int height) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
288 Resize({width, height});
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
289 }
975
35bbf7cc495f * Graphics clipping
cemkalyoncu
parents: 939
diff changeset
290
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
291 /// Resizes the layer to the given size
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
292 void SetWidth(int width) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
293 bounds.SetWidth(width);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
294 }
1362
6ff4adabed06 #21: Layer related crash has been solved
cemkalyoncu
parents: 1354
diff changeset
295
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
296 /// Resizes the layer to the given size
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
297 void SetHeight(int height) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
298 bounds.SetHeight(height);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
299 }
1362
6ff4adabed06 #21: Layer related crash has been solved
cemkalyoncu
parents: 1354
diff changeset
300
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
301 /// Sets the boundaries of this layer.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
302 virtual void SetBounds(const Geometry::Bounds &bounds) {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
303 this->bounds=bounds;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
304 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
305
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
306 /// Returns the size of the layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
307 Geometry::Size GetSize() const {
1506
c24aade1ec31 * ComponentStack autosize support
cemkalyoncu
parents: 1484
diff changeset
308 return GetBounds().GetSize();
1299
ec4c9548925b * An input layer bug is solved
cemkalyoncu
parents: 1292
diff changeset
309 }
ec4c9548925b * An input layer bug is solved
cemkalyoncu
parents: 1292
diff changeset
310
ec4c9548925b * An input layer bug is solved
cemkalyoncu
parents: 1292
diff changeset
311 /// Returns the size of the layer. If any dimension size is
ec4c9548925b * An input layer bug is solved
cemkalyoncu
parents: 1292
diff changeset
312 /// 0, it means the layer will span its parent, this function
ec4c9548925b * An input layer bug is solved
cemkalyoncu
parents: 1292
diff changeset
313 /// will perform necessary calculation to get parent size.
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
314 Geometry::Size GetCalculatedSize() const;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
315
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
316 /// Returns the width of the layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
317 int GetWidth() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
318 return GetBounds().Width();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
319 }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
320
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
321 /// Returns the height of the layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
322 int GetHeight() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
323 return GetBounds().Height();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
324 }
1400
2312b91a08c0 * 4 additional mouse button mapping
cemkalyoncu
parents: 1362
diff changeset
325
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
326 /// Returns the current location of the layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
327 Geometry::Point GetLocation() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
328 return GetBounds().TopLeft();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
329 }
1400
2312b91a08c0 * 4 additional mouse button mapping
cemkalyoncu
parents: 1362
diff changeset
330
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
331 /// Returns the current location of the layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
332 int GetLeft() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
333 return GetBounds().Left;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
334 }
1400
2312b91a08c0 * 4 additional mouse button mapping
cemkalyoncu
parents: 1362
diff changeset
335
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
336 /// Returns the current location of the layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
337 int GetTop() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
338 return GetBounds().Top;
1299
ec4c9548925b * An input layer bug is solved
cemkalyoncu
parents: 1292
diff changeset
339 }
ec4c9548925b * An input layer bug is solved
cemkalyoncu
parents: 1292
diff changeset
340
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
341 /// Returns the boundaries of the layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
342 virtual Geometry::Bounds GetBounds() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
343 return bounds;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
344 }
1121
acf7f7054107 * Unit test for layer system, completion: 60%
cemkalyoncu
parents: 1026
diff changeset
345
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
346 /// Returns the effective boundaries of the layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
347 Geometry::Bounds GetEffectiveBounds() const;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
348 /// @}
939
06b07820b5d9 * Tiled rendering
cemkalyoncu
parents: 919
diff changeset
349
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
350 /// Displays this layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
351 virtual void Show() { isvisible=true; }
939
06b07820b5d9 * Tiled rendering
cemkalyoncu
parents: 919
diff changeset
352
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
353 /// Hides this layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
354 virtual void Hide() { isvisible=false; }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
355
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
356 /// Returns whether this layer is effectively visible
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
357 virtual bool IsVisible() const {
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
358 if(parent && !parent->isvisible) return false;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
359
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
360 return isvisible;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
361 }
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
362
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
363 /// Propagates a mouse event. Some events will be called directly. Do not use this function. Direct calls should never touch handlers.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
364 /// Input layers should cache perform transformations on direct calls. Direct calls should not be clipped. button is set only for
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
365 /// Click/Down/Up events, amount will be set for Scroll/Zoom events. Mouse event system is not thread safe.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
366 virtual bool propagate_mouseevent(Input::Mouse::EventType evet, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers);
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
367
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
368 /// Renders the current layer, default handling is to pass the request to the sub-layers. Rendering is not thread safe.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
369 virtual void Render();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
370
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
371 /// Sub-layers that this layer holds, all the sub-layers are
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
372 /// considered to be above current layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
373 const Containers::Collection<Layer> &Children;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
374
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
375 /// When used as layer bounds, represents the entire region its placed in.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
376 static const Geometry::Bounds EntireRegion;
914
0858abee0f02 * Better mouse handler registration (incomplete)
cemkalyoncu
parents: 910
diff changeset
377
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
378 protected:
910
38c9cc8ac94f * Groundwork for mouse input event
cemkalyoncu
parents: 904
diff changeset
379
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
380 /// Will be called when a layer is added. This function will even be called
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
381 /// when the given layer was already in the children.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
382 virtual void added(Layer &layer) { }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
383
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
384 /// Will be called when a layer is removed. This function will be called even
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
385 /// if the given layer is not a child of this layer.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
386 virtual void removed(Layer &layer) { }
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
387
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
388 /// Will be called when this layer is added to another.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
389 virtual void located(Layer *parent) { }
975
35bbf7cc495f * Graphics clipping
cemkalyoncu
parents: 939
diff changeset
390
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
391 /// Performs transformation and clipping. Use inverse for reverse mapping for mouse events
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
392 void dotransformandclip(bool inverse = false);
975
35bbf7cc495f * Graphics clipping
cemkalyoncu
parents: 939
diff changeset
393
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
394 /// Reverts previously done transformation
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
395 void reverttransformandclip();
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
396
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
397 /// Child layers that this layer holds, all child layers are
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
398 /// considered to be above current layer
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
399 Containers::Collection<Layer> children;
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
400
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
401 /// Parent layer, could be nullptr
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
402 Layer *parent = nullptr;
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
403
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
404 /// Bounds of this layer.
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
405 Geometry::Bounds bounds;
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
406
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
407 /// Whether this layer is visible, invisible layers will not
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
408 /// be drawn or receive any events
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
409 bool isvisible =true;
1292
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
410
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
411 #ifndef NDEBUG
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
412 /// For debugging
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
413 std::string name;
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
414 #endif
67cfdfebed59 * Another clipping bug is solved
cemkalyoncu
parents: 1291
diff changeset
415
1508
58d190b948ea #210 Gorgon::Window now contains multiple layers
cemkalyoncu
parents: 1506
diff changeset
416 };
764
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
417
7c71952bd75b Gorgon code base has been moved to Source/Gorgon
cengizkandemir
parents:
diff changeset
418 }

mercurial