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.
7 #ifndef CAFU_GUISYS_COMPONENT_TRANSFORM_HPP_INCLUDED
8 #define CAFU_GUISYS_COMPONENT_TRANSFORM_HPP_INCLUDED
10 #include "CompBase.hpp"
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.
20 class ComponentTransformT
: public ComponentBaseT
25 ComponentTransformT();
27 /// The copy constructor.
28 /// @param Comp The component to create a copy of.
29 ComponentTransformT(const ComponentTransformT
& Comp
);
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(); }
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
); }
39 // Base class overrides.
40 ComponentTransformT
* Clone() const;
41 const char* GetName() const { return "Transform"; }
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
;
52 // The Lua API methods of this class.
53 static int toString(lua_State
* LuaState
);
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
[];
63 enum SizeFlagsT
{ RATIO
, FIXED
};
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?
69 // SizeFlagsT HorzFlags[3];
70 // SizeFlagsT VertFlags[3];