1 | /*! |
---|
2 | * @file glgui_style.h |
---|
3 | * @brief Definition of the OpenGL-GUI Style of a Class. |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _GLGUI_STYLE_H |
---|
7 | #define _GLGUI_STYLE_H |
---|
8 | |
---|
9 | #include "base_object.h" |
---|
10 | |
---|
11 | #include "glgui_defs.h" |
---|
12 | |
---|
13 | #include "font.h" |
---|
14 | #include "texture.h" |
---|
15 | #include "color.h" |
---|
16 | |
---|
17 | namespace OrxGui |
---|
18 | { |
---|
19 | //! A class for Defining Styles to the opengl-gui. |
---|
20 | class GLGuiStyle : public BaseObject |
---|
21 | { |
---|
22 | public: |
---|
23 | GLGuiStyle(const TiXmlElement* root = NULL); |
---|
24 | virtual ~GLGuiStyle(); |
---|
25 | |
---|
26 | |
---|
27 | /// Retrieve |
---|
28 | /** @returns left borderWidth @param state the State to retrieve from */ |
---|
29 | inline float borderLeft(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderLeft; } |
---|
30 | /** @returns right borderWidth @param state the State to retrieve from */ |
---|
31 | inline float borderRight(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderRight; } |
---|
32 | /** @returns top borderWidth @param state the State to retrieve from */ |
---|
33 | inline float borderTop(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderTop; } |
---|
34 | /** @returns bottom borderWidth @param state the State to retrieve from */ |
---|
35 | inline float borderBottom(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderBottom; } |
---|
36 | /** @returns textSize @param state the State to retrieve from */ |
---|
37 | inline float textSize(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._textSize; } |
---|
38 | /** @returns the Background Color @param state the State to retrieve from */ |
---|
39 | inline const Color& backgroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._backgroundColor; } |
---|
40 | /** @returns background Texture. @param state the State to retrieve from */ |
---|
41 | inline const Texture& backgrorundTexture(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._backgroundTexture; } |
---|
42 | /** @returns the foreground Color @param state the State to retrieve from */ |
---|
43 | inline const Color& foregroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._foregroundColor; } |
---|
44 | |
---|
45 | /** @returns FeaturePosition */ |
---|
46 | inline FeaturePosition featurePosition() const { return _featurePosition; } |
---|
47 | /** @returns the font */ |
---|
48 | inline const Font* const font() const { return _font; } |
---|
49 | /** @returns true if the Element is Animated */ |
---|
50 | inline bool animated() const { return _animated; } |
---|
51 | /** @returns true if State-Changes are animated */ |
---|
52 | inline bool animatedStateChanges() const { return _animatedStateChanges; } |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | /// SETUP |
---|
57 | void reset(); |
---|
58 | void loadParams(const TiXmlElement* root); |
---|
59 | |
---|
60 | void setBorderLeft(float value); |
---|
61 | void setBorderLeft(float value, OrxGui::State state); |
---|
62 | void setBorderLeftS(float value, const std::string& stateName); |
---|
63 | |
---|
64 | void setBorderRight(float value); |
---|
65 | void setBorderRight(float value, OrxGui::State state); |
---|
66 | void setBorderRightS(float value, const std::string& stateName); |
---|
67 | |
---|
68 | void setBorderTop(float value); |
---|
69 | void setBorderTop(float value, OrxGui::State state); |
---|
70 | void setBorderTopS(float value, const std::string& stateName); |
---|
71 | |
---|
72 | void setBorderBottom(float value); |
---|
73 | void setBorderBottom(float value, OrxGui::State state); |
---|
74 | void setBorderBottomS(float value, const std::string& stateName); |
---|
75 | |
---|
76 | void setTextSize(float value); |
---|
77 | void setTextSize(float value, OrxGui::State state); |
---|
78 | void setTextSizeS(float value, const std::string& stateName); |
---|
79 | |
---|
80 | void setBackgroundColor(const Color& color); |
---|
81 | void setBackgroundColor(const Color& color, OrxGui::State state); |
---|
82 | void setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName); |
---|
83 | |
---|
84 | void setBackgroundTexture(const Texture& texture); |
---|
85 | void setBackgroundTexture(const Texture& texture, OrxGui::State state); |
---|
86 | void setBackgroundTexture(const std::string& textureName, const std::string& stateName); |
---|
87 | |
---|
88 | void setForegroundColor(const Color& color); |
---|
89 | void setForegroundColor(const Color& color, OrxGui::State state); |
---|
90 | void setForegroundColorS(float r, float g, float b, float a, const std::string& stateName); |
---|
91 | |
---|
92 | |
---|
93 | void setFeaturePosition(FeaturePosition featurePosition); |
---|
94 | void setFeaturePositionS(const std::string& featurePosition); |
---|
95 | |
---|
96 | void setFont(Font* font); |
---|
97 | void setFont(const std::string& fontName); |
---|
98 | |
---|
99 | void setAnimated(bool animated); |
---|
100 | void setAnimatedStateChanges(bool animated); |
---|
101 | |
---|
102 | private: |
---|
103 | bool getState(const std::string& stateName, OrxGui::State* state); |
---|
104 | |
---|
105 | private: |
---|
106 | typedef struct |
---|
107 | { |
---|
108 | float _borderLeft; //!< The Distance to the left Border of the widget, before any internal Element starts. |
---|
109 | float _borderRight; //!< The Distance to the right Border of the widget, before any internal Element starts. |
---|
110 | float _borderTop; //!< The Distance to the top Border of the widget, before any internal Element starts |
---|
111 | float _borderBottom; //!< The Distance to the bottom Border of the widget, before any internal Element starts |
---|
112 | |
---|
113 | float _textSize; //!< The TextSize of the Widget. |
---|
114 | |
---|
115 | Color _backgroundColor; //!< The BackgroundColor of the Widget. |
---|
116 | Texture _backgroundTexture; //!< The BackgroundTexture of the Widget. |
---|
117 | |
---|
118 | Color _foregroundColor; //!< The foregroundColor of the Widget. |
---|
119 | } |
---|
120 | StatedStyle; |
---|
121 | |
---|
122 | |
---|
123 | StatedStyle _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States |
---|
124 | |
---|
125 | FeaturePosition _featurePosition; //!< The Position a Feature will be layed at (checkbox(box), slider(text),...) |
---|
126 | Font* _font; //!< The Font used in the current Widget. |
---|
127 | |
---|
128 | |
---|
129 | bool _animated; //!< If the Widget is animated (Texture might be an AnimatedTexture.) |
---|
130 | bool _animatedStateChanges; //!< If the Transitions between States are Animated automatically. |
---|
131 | }; |
---|
132 | } |
---|
133 | #endif /* _GLGUI_STYLE_H */ |
---|