Cafu Engine
CompTransform.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_GUISYS_COMPONENT_TRANSFORM_HPP_INCLUDED
8 #define CAFU_GUISYS_COMPONENT_TRANSFORM_HPP_INCLUDED
9 
10 #include "CompBase.hpp"
11 
12 
13 namespace cf
14 {
15  namespace GuiSys
16  {
17  /// This component adds information about the position and size of the window.
18  /// It is one of the components that is "fundamental" to a window (cf::GuiSys::IsFundamental() returns `true`).
19  /// Every window must have exactly one.
21  {
22  public:
23 
24  /// The constructor.
26 
27  /// The copy constructor.
28  /// @param Comp The component to create a copy of.
30 
31  const Vector2fT& GetPos() const { return m_Pos.Get(); }
32  const Vector2fT& GetSize() const { return m_Size.Get(); }
33  float GetRotAngle() const { return m_RotAngle.Get(); }
34 
35  void SetPos(const Vector2fT& Pos) { m_Pos.Set(Pos); }
36  void SetSize(const Vector2fT& Size) { m_Size.Set(Size); }
37  void SetRotAngle(float RotAngle) { m_RotAngle.Set(RotAngle); }
38 
39  // Base class overrides.
40  ComponentTransformT* Clone() const;
41  const char* GetName() const { return "Transform"; }
42 
43 
44  // The TypeSys related declarations for this class.
45  const cf::TypeSys::TypeInfoT* GetType() const { return &TypeInfo; }
46  static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params);
47  static const cf::TypeSys::TypeInfoT TypeInfo;
48 
49 
50  protected:
51 
52  // The Lua API methods of this class.
53  static int toString(lua_State* LuaState);
54 
55  static const luaL_Reg MethodsList[]; ///< The list of Lua methods for this class.
56  static const char* DocClass;
57  static const cf::TypeSys::MethsDocT DocMethods[];
58  static const cf::TypeSys::VarsDocT DocVars[];
59 
60 
61  private:
62 
63  enum SizeFlagsT { RATIO, FIXED };
64 
65  TypeSys::VarT<Vector2fT> m_Pos; ///< The position of the top-left corner of the window, relative to its parent.
66  TypeSys::VarT<Vector2fT> m_Size; ///< The size of the window.
67  TypeSys::VarT<float> m_RotAngle; ///< The angle in degrees by how much this entire window is rotated. Obsolete if we have 3D transforms?
68 
69  // SizeFlagsT HorzFlags[3];
70  // SizeFlagsT VertFlags[3];
71  };
72  }
73 }
74 
75 #endif
static const luaL_Reg MethodsList[]
The list of Lua methods for this class.
Definition: CompTransform.hpp:55
ComponentTransformT * Clone() const
The virtual copy constructor.
Definition: CompTransform.cpp:57
This component adds information about the position and size of the window.
Definition: CompTransform.hpp:20
This is a "wrapper" around a normal C++ variable.
Definition: SetCompVar.hpp:15
This is the base class for the components that a window is composed/aggregated of.
Definition: CompBase.hpp:51
ComponentTransformT()
The constructor.
Definition: CompTransform.cpp:33
virtual void Set(const T &v)
Sets the value of this variable to the given value v.
Definition: Variables.hpp:189
const char * GetName() const
Returns the name of this component.
Definition: CompTransform.hpp:41
Definition: TypeSys.hpp:52
Definition: TypeSys.hpp:57
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79
const T & Get() const
Returns the value of this variable.
Definition: Variables.hpp:182
Definition: TypeSys.hpp:68