Gorgon Game Engine
Layer.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "ConsumableEvent.h"
5 #include "Geometry/Point.h"
6 #include "Geometry/Bounds.h"
7 #include "Geometry/Transform3D.h"
8 #include "Input/Mouse.h"
9 
10 namespace Gorgon {
11  class Layer;
12 
15 
17  extern Geometry::Bounds Clip;
18 
20  extern Geometry::Point Offset;
21 
22  class MouseHandler {
23  public:
25  layers.Swap(other.layers);
26  }
27 
29  layers.Swap(other.layers);
30 
31  return *this;
32  }
33 
34  explicit MouseHandler(Layer *layer = nullptr) {
35  if(layer) layers.Add(layer);
36  }
37 
38  operator Layer *() const {
39  if(layers.GetSize())
40  return &layers[0];
41  else
42  return nullptr;
43  }
44 
45  operator bool() const {
46  return layers.GetCount() > 0;
47  }
48 
49  void Clear() {
50  layers.Clear();
51  }
52 
53  void Add(Layer *l) {
54  layers.Add(l);
55  }
56 
57  void Swap(MouseHandler &other) {
58  layers.Swap(other.layers);
59  }
60 
62  };
63 
65  inline void ResetTransform(const Geometry::Size &size) {
66  Transform={};
67  Transform.Translate({-1.0f, 1.0f, 0});
68  Transform.Scale(2.0f / size.Width, -2.0f / size.Height, 1.0f);
69  }
70 
79  class Layer {
80  public:
81 
85  bounds(bounds)
86  { }
87 
91 
93  Layer(const Geometry::Point &location) :
94  Layer({location, Geometry::Size::Max()})
95  { }
96 
98  Layer(const Layer&) = delete;
99 
101  Layer(Layer &&other) : Children(children) {
102  Swap(other);
103  }
104 
106  Layer &operator =(const Layer &)=delete;
107 
109  Layer &operator =(Layer &&other) {
110  if(parent)
111  parent->Remove(this);
112 
113  while(children.GetSize())
114  Remove(*children.First());
115 
116  Swap(other);
117 
118  return *this;
119  }
120 
122  virtual ~Layer();
123 
125  void Swap(Layer &other) {
126  using std::swap;
127 
128  if(this == &other) return;
129 
130  swap(bounds, other.bounds);
131  swap(isvisible, other.isvisible);
132  swap(children, other.children);
133 
134  for(auto &l : children)
135  l.parent = this;
136 
137  for(auto &l : other.children)
138  l.parent = &other;
139 
140  if(parent==other.parent) return;
141 
142  auto myparent = parent;
143  auto otherparent = other.parent;
144 
145  int myind = -1;
146  int otherind = -1;
147 
148  if(myparent) {
149  myind = myparent->Children.FindLocation(this);
150  }
151 
152  if(otherparent) {
153  otherind = otherparent->Children.FindLocation(other);
154  }
155 
156  if(myparent) {
157  myparent->Remove(this);
158  myparent->Insert(other, myind);
159  }
160 
161  if(otherparent) {
162  otherparent->Remove(other);
163  otherparent->Insert(this, otherind);
164  }
165  }
166 
170 
173  void Add(Layer &layer);
174 
177  void Add(Layer *layer) {
178  if(!layer) return;
179 
180  Add(*layer);
181  }
182 
184  void setname(std::string value) {
185 #ifndef NDEBUG
186  name = value;
187 #endif
188  }
189 
192  void Insert(Layer &layer, long under);
193 
196  void Insert(Layer *layer, long under) {
197  if(!layer) return;
198 
199  Insert(*layer, under);
200  }
201 
203  void Remove(Layer &layer) {
204  children.Remove(layer);
205 
206  removed(layer);
207  layer.located(nullptr);
208  layer.parent = nullptr;
209  }
210 
212  void Remove(Layer *layer) {
213  if(!layer) return;
214 
215  Remove(*layer);
216  }
217 
219  bool HasParent() const {
220  return parent!=nullptr;
221  }
222 
226  virtual Layer &GetParent() const {
227  if(!parent) throw std::runtime_error("No parent is set");
228 
229  return *parent;
230  }
231 
233  Layer &GetTopLevel() const {
234  if(!parent)
235  return const_cast<Layer &>(*this);
236 
237  return parent->GetTopLevel();
238  }
239 
241  virtual Geometry::Point TranslateToTopLevel(Geometry::Point location = {0, 0}) const {
242  const Layer *cur = this;
243  while(cur->HasParent()) {
244  location += cur->GetLocation();
245  cur = &cur->GetParent();
246  }
247 
248  return location;
249  }
250 
252  if(!parent) return *this;
253 
254  return parent->GetTopLevel();
255  }
257 
261 
264  return children.begin();
265  }
266 
269  return children.end();
270  }
271 
274  return children.First();
275  }
276 
279  return children.Last();
280  }
282 
283 
287 
290  void PlaceBefore(int before) {
291  if(parent) {
292  if(before==parent->children.GetCount()) before --;
293 
294  parent->children.MoveBefore(*this, before++);
295  }
296  }
297 
301  void PlaceToTop() {
302  if(parent)
303  parent->children.MoveBefore(*this, parent->children.GetCount());
304  }
305 
307  void PlaceToBottom() {
308  if(parent)
309  parent->children.MoveBefore(*this, 0);
310  }
311 
314  int GetOrder() const {
315  if(parent)
316  return parent->children.FindLocation(this);
317  else
318  return -1;
319  }
321 
325 
327  virtual void Move(const Geometry::Point &location) {
328  bounds.Move(location);
329  }
330 
332  virtual void Move(int x, int y) {
333  bounds.Move({x, y});
334  }
335 
337  virtual void Resize(const Geometry::Size &size) {
338  bounds.Resize(size);
339  }
340 
342  virtual void Resize(int width, int height) {
343  bounds.Resize({width, height});
344  }
345 
347  void SetWidth(int width) {
348  bounds.SetWidth(width);
349  }
350 
352  void SetHeight(int height) {
353  bounds.SetHeight(height);
354  }
355 
358  this->bounds=bounds;
359  }
360 
363  return bounds.GetSize();
364  }
365 
370  if(!parent)
371  return bounds.GetSize();
372 
373  auto ps = parent->GetCalculatedSize();
374  auto s = GetSize();
375  auto p = GetLocation();
376 
377 
378 
379  if(s.Width == 0) {
380  s.Width = ps.Width;
381  s.Width -= p.X;
382  }
383 
384  if(s.Height == 0) {
385  s.Height = ps.Height;
386  s.Height -= p.Y;
387  }
388 
389  return s;
390  }
391 
393  int GetWidth() const {
394  return bounds.Width();
395  }
396 
398  int GetHeight() const {
399  return bounds.Height();
400  }
401 
404  return bounds.TopLeft();
405  }
406 
408  int GetLeft() const {
409  return bounds.Left;
410  }
411 
413  int GetTop() const {
414  return bounds.Top;
415  }
416 
419  return bounds;
420  }
421 
424  if(!parent)
425  return bounds;
426 
427  auto p = GetLocation();
428  auto s = GetSize();
429 
430  auto pb = parent->GetEffectiveBounds();
431 
432  if(s == Geometry::Size(0, 0)) {
433  s = pb.GetSize();
434  s.Width -= p.X;
435  s.Height -= p.Y;
436  }
437  else {
438  auto w = pb.Width() - p.X;
439  auto h = pb.Height() - p.Y;
440 
441  if(s.Width > w)
442  s.Width = w;
443 
444  if(s.Height > h)
445  s.Height = h;
446  }
447 
448  return {p, s};
449  }
451 
453  virtual void Show() { isvisible=true; }
454 
456  virtual void Hide() { isvisible=false; }
457 
459  virtual bool IsVisible() const {
460  if(parent && !parent->isvisible) return false;
461 
462  return isvisible;
463  }
464 
468  virtual bool propagate_mouseevent(Input::Mouse::EventType evet, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers);
469 
471  virtual void Render();
472 
476 
479 
480  protected:
481 
484  virtual void added(Layer &layer) { }
485 
488  virtual void removed(Layer &layer) { }
489 
491  virtual void located(Layer *parent) { }
492 
494  void dotransformandclip(bool inverse = false);
495 
497  void reverttransformandclip();
498 
502 
504  Layer *parent = nullptr;
505 
508 
511  bool isvisible =true;
512 
513 #ifndef NDEBUG
514  std::string name;
516 #endif
517 
518  };
519 
520 }
Gorgon::Graphics::TextureTarget::DrawMode
DrawMode
Definition: TextureTargets.h:14
Gorgon::Layer::Resize
virtual void Resize(const Geometry::Size &size)
Resizes the layer to the given size.
Definition: Layer.h:337
Gorgon::Graphics::MaskedShader::SetDiffuse
MaskedShader & SetDiffuse(GL::Texture value)
Sets diffuse texture.
Definition: Shaders.h:103
Gorgon::Geometry::basic_Rectangle::TopLeft
basic_Point< T_ > TopLeft() const
Returns the top left coordinates of the rectangle.
Definition: Rectangle.h:198
Gorgon::Geometry::basic_Bounds
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
Gorgon::swap
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
Gorgon::Layer::Layer
Layer(const Geometry::Bounds &bounds)
Initializing constructor.
Definition: Layer.h:83
Gorgon::Input::Mouse::Rotate
@ Rotate
Definition: Mouse.h:27
Layer.h
Gorgon::Geometry::basic_Transform3D::Translate
void Translate(const basic_Point3D< T_ > &p)
Definition: Transform3D.h:69
Gorgon::Layer::~Layer
virtual ~Layer()
Destructor.
Definition: Layer.cpp:159
Gorgon::Input::Layer::out
std::function< void(Layer &)> out
Definition: Layer.h:1161
Gorgon::Graphics::MaskedAlphaShader::SetTextureCoords
MaskedAlphaShader & SetTextureCoords(const GL::QuadTextureCoords &value)
Sets texture coordinates.
Definition: Shaders.h:204
Gorgon::Layer::Remove
void Remove(Layer *layer)
Removes the given layer.
Definition: Layer.h:212
Gorgon::Graphics::Tiling::Horizontal
@ Horizontal
Gorgon::Geometry::basic_Bounds::Move
void Move(const basic_Point< T_ > &p)
Changes the position of the bounds.
Definition: Bounds.h:212
Gorgon::Layer::Layer
Layer(const Geometry::Point &location)
Constructor that places the layer to the given location.
Definition: Layer.h:93
Gorgon::GL::Clear
void Clear()
Clears the window pointed by the active context.
Definition: OpenGL.cpp:277
Gorgon::Graphics::TextureSource::IsPartial
bool IsPartial() const
Returns whether this texture uses only a part of the GL::Texture.
Definition: Graphics.h:495
Gorgon::Graphics::MaskedAlphaShader::SetAlpha
MaskedAlphaShader & SetAlpha(GL::Texture value)
Sets alpha texture.
Definition: Shaders.h:212
Gorgon::Input::Mouse::Scroll_Hor
@ Scroll_Hor
Definition: Mouse.h:25
Gorgon::Layer::Layer
Layer(const Layer &)=delete
Copy constructor is disabled.
Gorgon::Layer::Add
void Add(Layer &layer)
Adds the given layer as a child.
Definition: Layer.cpp:23
Gorgon::Layer::Layer
Layer(Layer &&other)
Move constructor.
Definition: Layer.h:101
Gorgon::Input::Mouse::HitCheck
@ HitCheck
Checks if the coordinate hits the layer, always called first.
Definition: Mouse.h:15
Gorgon::Layer::GetLocation
Geometry::Point GetLocation() const
Returns the current location of the layer.
Definition: Layer.h:403
Gorgon::Input::Mouse::Click
@ Click
Definition: Mouse.h:22
Collection.h
contains collection, a vector of references.
Gorgon::Layer::Children
const Containers::Collection< Layer > & Children
Sub-layers that this layer holds, all the sub-layers are considered to be above current layer.
Definition: Layer.h:475
Gorgon::Graphics::internal::ActivateQuadVertices
void ActivateQuadVertices()
Definition: Graphics.cpp:23
Bounds.h
contains the Bounds class
Point.h
contains point class.
Gorgon::Layer::dotransformandclip
void dotransformandclip(bool inverse=false)
Performs transformation and clipping. Use inverse for reverse mapping for mouse events.
Definition: Layer.cpp:115
Window.h
Gorgon::Geometry::basic_Size::Height
T_ Height
Height of this size object.
Definition: Size.h:261
Gorgon::Input::Layer::propagate_mouseevent
virtual bool propagate_mouseevent(Input::Mouse::EventType event, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers) override
Propagates a mouse event. Some events will be called directly.
Definition: Layer.cpp:18
Gorgon::Graphics::Layer::Render
virtual void Render() override
Render this layer to the GL. This function is used internally and not necessary to be called.
Definition: Layer.cpp:61
Gorgon::Layer::Add
void Add(Layer *layer)
Adds the given layer as a child.
Definition: Layer.h:177
Gorgon::Geometry::basic_Bounds::Width
T_ Width() const
Calculates and returns the width of the bounds.
Definition: Bounds.h:130
Gorgon::Graphics::MaskedFillShader::SetVertexCoords
MaskedFillShader & SetVertexCoords(const GL::QuadVertices &value)
Definition: Shaders.h:287
Gorgon::Layer::parent
Layer * parent
Parent layer, could be nullptr.
Definition: Layer.h:504
Gorgon::Input::Layer::zoom
std::function< bool(Layer &, Geometry::Point, float amount)> zoom
Definition: Layer.h:1164
Gorgon::Input::Layer::click
std::function< void(Layer &, Geometry::Point, Input::Mouse::Button)> click
Definition: Layer.h:1156
Gorgon::Clip
Geometry::Bounds Clip
Current clipping size, for mouse and clipping events.
Definition: Layer.cpp:20
Gorgon::MouseHandler::MouseHandler
MouseHandler(MouseHandler &&other)
Definition: Layer.h:24
Gorgon::Float
float Float
Represents floating point data type.
Definition: Types.h:16
Gorgon::Layer::end
Containers::Collection< Layer >::ConstIterator end() const
An iterator pointing to the end of the children.
Definition: Layer.h:268
Gorgon::Graphics::MaskedShader::SetTextureCoords
MaskedShader & SetTextureCoords(const GL::QuadTextureCoords &value)
Sets texture coordinates.
Definition: Shaders.h:95
Gorgon::Graphics::RGBAf
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
Gorgon::Input::Mouse::Move
@ Move
Definition: Mouse.h:17
Gorgon::Geometry::basic_Bounds::Height
T_ Height() const
Calculates and returns the height of the bounds.
Definition: Bounds.h:135
Gorgon::Geometry::basic_Rectangle::Width
T_ Width
Width of the rectangle.
Definition: Rectangle.h:360
Gorgon::Graphics::MaskedShader::SetMask
MaskedShader & SetMask(GL::Texture value)
Definition: Shaders.h:117
Gorgon::Layer::Last
Containers::Collection< Layer >::ConstIterator Last() const
An iterator pointing to the last item of the children.
Definition: Layer.h:278
Gorgon::Geometry::Size
basic_Size< int > Size
Definition: Size.h:385
Gorgon::MouseHandler::Swap
void Swap(MouseHandler &other)
Definition: Layer.h:57
Gorgon::ResetTransform
void ResetTransform(const Geometry::Size &size)
This should be called by the windows to reset transformation stack.
Definition: Layer.h:65
Gorgon::Layer::IsVisible
virtual bool IsVisible() const
Returns whether this layer is effectively visible.
Definition: Layer.h:459
Gorgon::Graphics::MaskedAlphaShader::Use
static MaskedAlphaShader & Use()
Definition: Shaders.h:189
Gorgon::Layer::GetCalculatedSize
Geometry::Size GetCalculatedSize() const
Returns the size of the layer.
Definition: Layer.h:369
Gorgon::Geometry::basic_Transform3D::Scale
void Scale(T_ x, T_ y, T_ z=1)
Definition: Transform3D.h:91
Gorgon::Geometry::basic_Transform3D
Definition: Transform3D.h:12
Gorgon::Layer::GetBounds
Geometry::Bounds GetBounds() const
Returns the boundaries of the layer.
Definition: Layer.h:418
Color.h
Gorgon::Geometry::basic_Bounds::Left
T_ Left
Left-most boundary.
Definition: Bounds.h:399
Gorgon::Layer::GetTop
int GetTop() const
Returns the current location of the layer.
Definition: Layer.h:413
Gorgon::Geometry::basic_Size::Max
static basic_Size Max()
Returns the maximum representable size.
Definition: Size.h:251
Gorgon::Layer::GetLeft
int GetLeft() const
Returns the current location of the layer.
Definition: Layer.h:408
Gorgon::Graphics::Tiling
Tiling
Details which directions a texture should tile.
Definition: Graphics.h:31
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Geometry::basic_Size
This class represents a 2D geometric size.
Definition: Size.h:23
Gorgon::GL::SetDefaultClear
void SetDefaultClear()
Sets default clear parameters as current.
Definition: OpenGL.cpp:268
Gorgon::Graphics::TextureTarget::UseMask
@ UseMask
Definition: TextureTargets.h:18
Gorgon::Layer::GetParent
virtual Layer & GetParent() const
Returns the parent of this layer.
Definition: Layer.h:226
Gorgon::Layer::reverttransformandclip
void reverttransformandclip()
Reverts previously done transformation.
Definition: Layer.cpp:149
Gorgon::Input::Mouse::Scroll_Vert
@ Scroll_Vert
Definition: Mouse.h:24
Gorgon::Layer::bounds
Geometry::Bounds bounds
Bounds of this layer.
Definition: Layer.h:507
Gorgon::Input::Layer::over
std::function< void(Layer &)> over
Definition: Layer.h:1160
Gorgon::Graphics::Layer::Draw
virtual void Draw(const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f))=0
Draws a simple texture to the screen.
Gorgon::Input::Keyboard::Keycodes::Up
constexpr Key Up
Definition: Keyboard.h:63
Gorgon::Graphics::TextureSource::GetCoordinates
virtual const Geometry::Pointf * GetCoordinates() const =0
Should return the coordinates of the texture to be used.
Gorgon::Graphics::TextureTarget::FrameBuffer
@ FrameBuffer
Definition: TextureTargets.h:16
Shaders.h
Gorgon::Layer::PlaceBefore
void PlaceBefore(int before)
Places this layer before the given index.
Definition: Layer.h:290
Gorgon::Layer::propagate_mouseevent
virtual bool propagate_mouseevent(Input::Mouse::EventType evet, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers)
Propagates a mouse event.
Definition: Layer.cpp:63
Gorgon::Input::Mouse::MovePressed
@ MovePressed
Move event while a button is pressed.
Definition: Mouse.h:18
Gorgon::Input::Mouse::Zoom
@ Zoom
Definition: Mouse.h:26
Gorgon::Layer::located
virtual void located(Layer *parent)
Will be called when this layer is added to another.
Definition: Layer.h:491
Gorgon::Layer::Move
virtual void Move(int x, int y)
Moves this layer to the given location.
Definition: Layer.h:332
Gorgon::MouseHandler::Clear
void Clear()
Definition: Layer.h:49
Gorgon::Graphics::MaskedFillShader::SetTint
MaskedFillShader & SetTint(const Graphics::RGBAf &value)
Definition: Shaders.h:294
Gorgon::Graphics::internal::DrawQuadVertices
void DrawQuadVertices()
Definition: Graphics.cpp:32
Gorgon::Containers::Collection
Collection is a container for reference typed objects.
Definition: Collection.h:21
Gorgon::Geometry::Point
basic_Point< int > Point
Definition: Point.h:598
Gorgon::MouseHandler::operator=
MouseHandler & operator=(MouseHandler &&other)
Definition: Layer.h:28
Gorgon::Transform
Geometry::Transform3D Transform
Current layer transformation, only for render and mouse.
Definition: Layer.cpp:18
Gorgon::Layer::GetWidth
int GetWidth() const
Returns the width of the layer.
Definition: Layer.h:393
Gorgon::Graphics::TextureTarget::Normal
@ Normal
Definition: TextureTargets.h:15
Gorgon::MouseHandler
Definition: Layer.h:22
Gorgon::Input::Mouse::Over
@ Over
Definition: Mouse.h:16
Gorgon::Input::Mouse::DownPressed
@ DownPressed
Down event while a button is already pressed.
Definition: Mouse.h:21
Gorgon::Layer::Render
virtual void Render()
Renders the current layer, default handling is to pass the request to the sub-layers....
Definition: Layer.cpp:51
Gorgon::Input::Layer::move
std::function< void(Layer &, Geometry::Point)> move
Definition: Layer.h:1159
Gorgon::Layer::Move
virtual void Move(const Geometry::Point &location)
Moves this layer to the given location.
Definition: Layer.h:327
Gorgon::Graphics::ShaderMode::ToMask
@ ToMask
Gorgon::Layer::SetBounds
void SetBounds(const Geometry::Bounds &bounds)
Sets the boundaries of this layer.
Definition: Layer.h:357
Gorgon::Layer::Insert
void Insert(Layer *layer, long under)
Inserts the given layer before the given index.
Definition: Layer.h:196
Gorgon::Geometry::basic_Rectangle::TopRight
basic_Point< T_ > TopRight() const
Returns the top right coordinates of the rectangle.
Definition: Rectangle.h:203
Gorgon::GL::Shader::Use
void Use()
Definition: Shader.cpp:87
Gorgon::Containers::Collection::ConstIterator
Const iterator allows iteration of const collections.
Definition: Collection.h:137
Gorgon::Geometry::Bounds
basic_Bounds< int > Bounds
Definition: Bounds.h:722
Gorgon::Input::Layer::mytransform
Geometry::Transform3D mytransform
Definition: Layer.h:1167
Gorgon::Graphics::Tiling::None
@ None
Gorgon::Input::Layer::down
std::function< void(Layer &, Geometry::Point, Input::Mouse::Button)> down
Definition: Layer.h:1157
Gorgon::GL::FrameBuffer
This is a frame buffer object that can be used for render to texture tasks.
Definition: FrameBuffer.h:13
Gorgon::Graphics::ColorMode::Alpha
@ Alpha
8bit alpha only color mode
Gorgon::Layer::Remove
void Remove(Layer &layer)
Removes the given layer.
Definition: Layer.h:203
Gorgon::Layer
This class is the base class for all layer types.
Definition: Layer.h:79
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Layer::GetEffectiveBounds
Geometry::Bounds GetEffectiveBounds() const
Returns the effective boundaries of the layer.
Definition: Layer.h:423
Gorgon::Input::Layer::vscroll
std::function< bool(Layer &, Geometry::Point, float amount)> vscroll
Definition: Layer.h:1162
Gorgon::Layer::GetOrder
int GetOrder() const
Gets the current order of the stack.
Definition: Layer.h:314
Gorgon::Layer::SetWidth
void SetWidth(int width)
Resizes the layer to the given size.
Definition: Layer.h:347
Gorgon::Graphics::MaskedAlphaShader::SetMask
MaskedAlphaShader & SetMask(GL::Texture value)
Definition: Shaders.h:228
Gorgon::Input::Mouse::EventType
EventType
The type of a mouse event.
Definition: Mouse.h:14
Gorgon::Graphics::ShaderMode::Normal
@ Normal
Gorgon::Window::Windows
static const Containers::Collection< Window > & Windows
List of currently created windows.
Definition: Window.h:401
Gorgon::Layer::First
Containers::Collection< Layer >::ConstIterator First() const
An iterator pointing to the start of the children.
Definition: Layer.h:273
Gorgon::Layer::added
virtual void added(Layer &layer)
Will be called when a layer is added.
Definition: Layer.h:484
Gorgon::Geometry::basic_Bounds::SetHeight
void SetHeight(const T_ &height)
Changes the height of the bounds, anchor is the topleft.
Definition: Bounds.h:207
Gorgon::Geometry::basic_Bounds::Right
T_ Right
Right-most boundary.
Definition: Bounds.h:405
Gorgon::Layer::PlaceToTop
void PlaceToTop()
Places this layer to the top of the layer stack its in.
Definition: Layer.h:301
Gorgon::UI::Graphics
@ Graphics
Definition: Template.h:164
Gorgon::Geometry::basic_Rectangle::Height
T_ Height
Height of the rectangle.
Definition: Rectangle.h:363
Gorgon::Graphics::TextureSource
This interface represents a GL texture source.
Definition: Graphics.h:480
Gorgon::Graphics::MaskedFillShader::Use
static MaskedFillShader & Use()
Definition: Shaders.h:280
glBlendFuncSeparate
PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate
Definition: OpenGL.cpp:69
Gorgon::Input::needsclip
bool needsclip(Input::Mouse::EventType event)
Definition: Layer.cpp:5
Gorgon::Input::Layer::hscroll
std::function< bool(Layer &, Geometry::Point, float amount)> hscroll
Definition: Layer.h:1163
Gorgon::Geometry::basic_Bounds::Bottom
T_ Bottom
Bottom-most boundary.
Definition: Bounds.h:408
Gorgon::Input::Layer::rotate
std::function< bool(Layer &, Geometry::Point, float amount)> rotate
Definition: Layer.h:1165
Gorgon::GL::SetDefaultBlending
void SetDefaultBlending()
Sets default blending parameters as current.
Definition: OpenGL.cpp:264
Gorgon::prev_Offset
std::vector< Geometry::Point > prev_Offset
Definition: Layer.cpp:16
Gorgon::Geometry::basic_Bounds::Resize
void Resize(const basic_Size< T_ > &size)
Definition: Bounds.h:145
Gorgon::Geometry::basic_Bounds::TopLeft
basic_Point< T_ > TopLeft() const
Returns top left corner.
Definition: Bounds.h:105
Gorgon::Geometry::basic_Rectangle::BottomLeft
basic_Point< T_ > BottomLeft() const
Returns the bottom left coordinates of the rectangle.
Definition: Rectangle.h:208
Gorgon::Layer::Hide
virtual void Hide()
Hides this layer.
Definition: Layer.h:456
Gorgon::Layer::Show
virtual void Show()
Displays this layer.
Definition: Layer.h:453
Transform3D.h
Gorgon::Geometry::basic_Size::Width
T_ Width
Width of this size object.
Definition: Size.h:258
Gorgon::Layer::setname
void setname(std::string value)
For debugging.
Definition: Layer.h:184
Gorgon::Geometry::basic_Rectangle::BottomRight
basic_Point< T_ > BottomRight() const
Returns the bottom right coordinates of the rectangle.
Definition: Rectangle.h:213
Gorgon::Geometry::basic_Bounds::GetSize
basic_Size< T_ > GetSize() const
Returns the size of the bounds object.
Definition: Bounds.h:141
Gorgon::Graphics::MaskedShader::SetTint
MaskedShader & SetTint(const Graphics::RGBAf &value)
Definition: Shaders.h:110
Gorgon::Layer::GetTopLevel
Layer & GetTopLevel() const
Returns the top level layer that contains this layer.
Definition: Layer.h:233
Gorgon::Input::Mouse::Button
Button
Lists the mouse button constants.
Definition: Mouse.h:31
Gorgon::Layer::Layer
Layer()
Constructor that sets the layer to cover entire parent, no matter how big it is.
Definition: Layer.h:90
Gorgon::Geometry::basic_Bounds::SetWidth
void SetWidth(const T_ &width)
Changes the width of the bounds, anchor is the topleft.
Definition: Bounds.h:202
Gorgon::Layer::Swap
void Swap(Layer &other)
Swaps two layers, mostly used for move semantics.
Definition: Layer.h:125
Gorgon::Graphics::MaskedShader::SetVertexCoords
MaskedShader & SetVertexCoords(const GL::QuadVertices &value)
Definition: Shaders.h:87
Gorgon::Layer::GetHeight
int GetHeight() const
Returns the height of the layer.
Definition: Layer.h:398
Gorgon::prev_Clip
std::vector< Geometry::Bounds > prev_Clip
Definition: Layer.cpp:15
Gorgon::Offset
Geometry::Point Offset
Current layer offset from the top left of the window.
Definition: Layer.cpp:21
Gorgon::MouseHandler::Add
void Add(Layer *l)
Definition: Layer.h:53
Gorgon::Layer::name
std::string name
For debugging.
Definition: Layer.h:515
Gorgon::Graphics::MaskedFillShader::SetMask
MaskedFillShader & SetMask(GL::Texture value)
Definition: Shaders.h:301
Gorgon::Layer::begin
Containers::Collection< Layer >::ConstIterator begin() const
An iterator pointing to the start of the children.
Definition: Layer.h:263
Gorgon::Layer::PlaceToBottom
void PlaceToBottom()
Places this layer to the bottom of the layer stack.
Definition: Layer.h:307
Gorgon::Geometry::basic_Rectangle
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Gorgon::Graphics::MaskedAlphaShader::SetVertexCoords
MaskedAlphaShader & SetVertexCoords(const GL::QuadVertices &value)
Definition: Shaders.h:196
Gorgon::Layer::children
Containers::Collection< Layer > children
Child layers that this layer holds, all child layers are considered to be above current layer.
Definition: Layer.h:501
Gorgon::Input::Layer::hitcheck
std::function< bool(Layer &, Geometry::Point)> hitcheck
Definition: Layer.h:1155
Gorgon::MouseHandler::layers
Containers::Collection< Layer > layers
Definition: Layer.h:61
Gorgon::Layer::HasParent
bool HasParent() const
Returns whether this layer has a parent.
Definition: Layer.h:219
Gorgon::Layer::SetHeight
void SetHeight(int height)
Resizes the layer to the given size.
Definition: Layer.h:352
Gorgon::Geometry::Transform3D
basic_Transform3D< Float > Transform3D
Definition: Transform3D.h:176
Gorgon::Input::Mouse::Out
@ Out
Definition: Mouse.h:19
Gorgon::Layer::operator=
Layer & operator=(const Layer &)=delete
Copy assignment is deleted.
Gorgon::Graphics::TextureSource::GetImageSize
virtual Geometry::Size GetImageSize() const =0
Should return the size of the image stored in texture. Not the whole texture size.
Gorgon::Layer::removed
virtual void removed(Layer &layer)
Will be called when a layer is removed.
Definition: Layer.h:488
Gorgon::Layer::TranslateToTopLevel
virtual Geometry::Point TranslateToTopLevel(Geometry::Point location={0, 0}) const
Translates the given location to the top level.
Definition: Layer.h:241
Gorgon::Layer::isvisible
bool isvisible
Whether this layer is visible, invisible layers will not be drawn or receive any events.
Definition: Layer.h:511
Gorgon::prev_Transform
std::vector< Geometry::Transform3D > prev_Transform
Definition: Layer.cpp:14
Gorgon::ScreenSize
Geometry::Size ScreenSize
Definition: Window.cpp:15
Gorgon::Input::Layer::up
std::function< void(Layer &, Geometry::Point, Input::Mouse::Button)> up
Definition: Layer.h:1158
Gorgon::Layer::Insert
void Insert(Layer &layer, long under)
Inserts the given layer before the given index.
Definition: Layer.cpp:34
Gorgon::Layer::EntireRegion
static const Geometry::Bounds EntireRegion
When used as layer bounds, represents the entire region its placed in.
Definition: Layer.h:478
Gorgon::LayerColor
Graphics::RGBAf LayerColor
Definition: Layer.cpp:172
Gorgon::Utils::NotImplemented
void NotImplemented(const std::string &what="This feature")
Definition: Assert.h:187
Gorgon::Graphics::MaskedShader::Use
static MaskedShader & Use()
Definition: Shaders.h:80
Mouse.h
Gorgon::Geometry::basic_Bounds::Top
T_ Top
Top-most boundary.
Definition: Bounds.h:402
Gorgon::Layer::GetSize
Geometry::Size GetSize() const
Returns the size of the layer.
Definition: Layer.h:362
Gorgon::Layer::GetTopLevel
Layer & GetTopLevel()
Definition: Layer.h:251
Gorgon::Graphics::TextureTarget::ToMask
@ ToMask
Definition: TextureTargets.h:17
Gorgon::Graphics::MaskedAlphaShader::SetTint
MaskedAlphaShader & SetTint(const Graphics::RGBAf &value)
Definition: Shaders.h:221
Gorgon::Input::Keyboard::Keycodes::Down
constexpr Key Down
Definition: Keyboard.h:65
Gorgon::MouseHandler::MouseHandler
MouseHandler(Layer *layer=nullptr)
Definition: Layer.h:34