Cafu Engine
CompImage.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_IMAGE_HPP_INCLUDED
8 #define CAFU_GUISYS_COMPONENT_IMAGE_HPP_INCLUDED
9 
10 #include "CompBase.hpp"
11 
12 
13 namespace MatSys { class RenderMaterialT; }
14 
15 
16 namespace cf
17 {
18  namespace GuiSys
19  {
20  /// This component adds an image to its window.
22  {
23  public:
24 
25  /// The constructor.
27 
28  /// The copy constructor.
29  /// @param Comp The component to create a copy of.
30  ComponentImageT(const ComponentImageT& Comp);
31 
32  /// The destructor.
34 
35  /// Returns the name of the MatSys material that is used for the image.
36  const std::string& GetMatName() const { return m_MatName.Get(); }
37 
38  // Base class overrides.
39  ComponentImageT* Clone() const;
40  const char* GetName() const { return "Image"; }
41  void UpdateDependencies(WindowT* Window);
42  void Render() const;
43 
44 
45  // The TypeSys related declarations for this class.
46  const cf::TypeSys::TypeInfoT* GetType() const { return &TypeInfo; }
47  static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params);
48  static const cf::TypeSys::TypeInfoT TypeInfo;
49 
50 
51  protected:
52 
53  // The Lua API methods of this class.
54  static int toString(lua_State* LuaState);
55 
56  static const luaL_Reg MethodsList[]; ///< The list of Lua methods for this class.
57  static const char* DocClass;
58  static const cf::TypeSys::MethsDocT DocMethods[];
59  static const cf::TypeSys::VarsDocT DocVars[];
60 
61 
62  private:
63 
64  /// A variable of type std::string, specifically for material names. It updates the related
65  /// render material instance in the parent ComponentImageT whenever a new material name is set.
66  class VarMatNameT : public TypeSys::VarT<std::string>
67  {
68  public:
69 
70  VarMatNameT(const char* Name, const std::string& Value, const char* Flags[], ComponentImageT& CompImg);
71  VarMatNameT(const VarMatNameT& Var, ComponentImageT& CompImg);
72 
73  // Base class overrides.
74  void Set(const std::string& v);
75 
76 
77  private:
78 
79  ComponentImageT& m_CompImg; ///< The parent ComponentImageT that contains this variable.
80  };
81 
82 
83  void FillMemberVars(); ///< A helper method for the constructors.
84 
85  VarMatNameT m_MatName; ///< The name of the image material.
86  MatSys::RenderMaterialT* m_MatInst; ///< The render instance of the material.
87  TypeSys::VarT<Vector3fT> m_Color; ///< The color with which the image is tinted.
88  TypeSys::VarT<float> m_Alpha; ///< The alpha component of the color.
89  };
90  }
91 }
92 
93 #endif
ComponentImageT()
The constructor.
Definition: CompImage.cpp:93
ComponentImageT * Clone() const
The virtual copy constructor.
Definition: CompImage.cpp:138
This class represents a surface render material.
Definition: RenderMaterial.hpp:25
const std::string & GetMatName() const
Returns the name of the MatSys material that is used for the image.
Definition: CompImage.hpp:36
This is a "wrapper" around a normal C++ variable.
Definition: SetCompVar.hpp:15
~ComponentImageT()
The destructor.
Definition: CompImage.cpp:126
This is the base class for the components that a window is composed/aggregated of.
Definition: CompBase.hpp:51
void UpdateDependencies(WindowT *Window)
This method is called whenever something "external" to this component has changed: ...
Definition: CompImage.cpp:144
static const luaL_Reg MethodsList[]
The list of Lua methods for this class.
Definition: CompImage.hpp:56
This component adds an image to its window.
Definition: CompImage.hpp:21
This class represents a window of the GuiSys.
Definition: Window.hpp:54
const char * GetName() const
Returns the name of this component.
Definition: CompImage.hpp:40
void Render() const
This method implements the graphical output of this component.
Definition: CompImage.cpp:180
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
Definition: TypeSys.hpp:68