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