Gorgon Game Engine
Component.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Template.h"
4 #include "../Graphics/Layer.h"
5 #include "../Animation/ControlledTimer.h"
6 
7 namespace Gorgon { namespace UI {
8 
15  class Component {
16  public:
17  Component(const ComponentTemplate &temp) : temp(&temp) { }
18 
20  const ComponentTemplate &GetTemplate() const {
21  return *temp;
22  }
23 
25 
26  Geometry::Size size = {-1, -1};
27 
28  //for containers
30 
31  //used to convert point to value
32  Geometry::Rectangle range = {0, 0, 0, 0};
33 
34  //for horizontal this means right, for vertical this means bottom.
35  bool anchorotherside = false;
36 
37  bool anchtoparent = false;
38 
39  bool reversed = false;
40 
41  int parent = -1;
42 
43  private:
44  const ComponentTemplate *temp;
45  };
46 
51  public:
53  if(dynamic_cast<const Animation::Base*>(primary))
54  dynamic_cast<const Animation::Base*>(primary)->DeleteAnimation();
55 
56  if(dynamic_cast<const Animation::Base*>(secondary))
57  dynamic_cast<const Animation::Base*>(secondary)->DeleteAnimation();
58 
59  delete layer;
60  delete timer;
61  }
62 
65  const Graphics::Drawable *primary = nullptr;
66 
68  const Graphics::Drawable *secondary = nullptr;
69 
71  Graphics::Layer *layer = nullptr;
72 
75  };
76 
77 }}
Gorgon::UI::Component
This class is an instance of a component.
Definition: Component.h:15
Gorgon::UI::ComponentStorage::secondary
const Graphics::Drawable * secondary
Secondary is for container overlay.
Definition: Component.h:68
Gorgon::Graphics::Layer
This layer allows drawing texture images on.
Definition: Layer.h:169
Gorgon::UI::ComponentTemplate
Defines an object according to the Box Model.
Definition: Template.h:600
Gorgon::Animation::ControlledTimer
This class is a timer that has its progression strictly controlled.
Definition: ControlledTimer.h:19
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::UI::ComponentStorage::layer
Graphics::Layer * layer
If necessary a layer will be assigned to this component.
Definition: Component.h:71
Gorgon::UI::ComponentStorage::~ComponentStorage
~ComponentStorage()
Definition: Component.h:52
Gorgon::Animation::Base
This is the base class for all animations.
Definition: Animation.h:306
Gorgon::UI::ComponentStorage
This class stores component related data.
Definition: Component.h:50
Gorgon::UI::Component::reversed
bool reversed
Definition: Component.h:39
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Animation::Base::DeleteAnimation
virtual void DeleteAnimation() const
Deletes this animation.
Definition: Animation.h:379
Gorgon::UI::Component::location
Geometry::Point location
Definition: Component.h:24
Gorgon::UI::ComponentStorage::timer
Animation::ControlledTimer * timer
This is a controlled timer that will be used for ModifyAnimation value modification.
Definition: Component.h:74
Gorgon::UI::Component::GetTemplate
const ComponentTemplate & GetTemplate() const
Returns the template, component should have a template at all times.
Definition: Component.h:20
Gorgon::UI::Component::innersize
Geometry::Size innersize
Definition: Component.h:29
Gorgon::UI::ComponentStorage::primary
const Graphics::Drawable * primary
Primary drawable is either background for container or the graphics for the graphic template.
Definition: Component.h:65
Gorgon::Graphics::Drawable
Represents a drawable object, that can be drawn to the given point.
Definition: Drawables.h:17
Gorgon::UI::Component::anchorotherside
bool anchorotherside
Definition: Component.h:35
Gorgon::UI::Component::parent
int parent
Definition: Component.h:41
Template.h
This file contains UI component template system.
Gorgon::UI::Component::Component
Component(const ComponentTemplate &temp)
Definition: Component.h:17
Gorgon::Geometry::basic_Rectangle
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Gorgon::UI::Component::size
Geometry::Size size
Definition: Component.h:26
Gorgon::UI::Component::anchtoparent
bool anchtoparent
Definition: Component.h:37
Gorgon::UI::Component::range
Geometry::Rectangle range
Definition: Component.h:32