[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 | |
---|
[8555] | 9 | #include "base_object.h" |
---|
| 10 | |
---|
[8448] | 11 | #include "glgui_defs.h" |
---|
[3543] | 12 | |
---|
[8141] | 13 | #include "font.h" |
---|
| 14 | #include "texture.h" |
---|
| 15 | #include "color.h" |
---|
[3543] | 16 | |
---|
[8141] | 17 | namespace OrxGui |
---|
| 18 | { |
---|
| 19 | //! A class for Defining Styles to the opengl-gui. |
---|
[8555] | 20 | class GLGuiStyle : public BaseObject |
---|
[8141] | 21 | { |
---|
[8143] | 22 | public: |
---|
[8448] | 23 | GLGuiStyle(const TiXmlElement* root = NULL); |
---|
| 24 | virtual ~GLGuiStyle(); |
---|
[1853] | 25 | |
---|
[8143] | 26 | |
---|
[8448] | 27 | /// Retrieve |
---|
[8559] | 28 | /** @returns left borderWidth @param state the State to retrieve from */ |
---|
[8448] | 29 | inline float borderLeft(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderLeft; } |
---|
[8559] | 30 | /** @returns right borderWidth @param state the State to retrieve from */ |
---|
[8448] | 31 | inline float borderRight(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderRight; } |
---|
[8559] | 32 | /** @returns top borderWidth @param state the State to retrieve from */ |
---|
[8448] | 33 | inline float borderTop(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderTop; } |
---|
[8559] | 34 | /** @returns bottom borderWidth @param state the State to retrieve from */ |
---|
[8448] | 35 | inline float borderBottom(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._borderBottom; } |
---|
[8559] | 36 | /** @returns textSize @param state the State to retrieve from */ |
---|
[8448] | 37 | inline float textSize(OrxGui::State state = GLGUI_DEFAULT_STYLE) const { return _style[state]._textSize; } |
---|
[8559] | 38 | /** @returns the Background Color @param state the State to retrieve from */ |
---|
[8448] | 39 | inline const Color& backgroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._backgroundColor; } |
---|
[8559] | 40 | /** @returns background Texture. @param state the State to retrieve from */ |
---|
[8448] | 41 | inline const Texture& backgrorundTexture(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._backgroundTexture; } |
---|
[8559] | 42 | /** @returns the foreground Color @param state the State to retrieve from */ |
---|
[8448] | 43 | inline const Color& foregroundColor(OrxGui::State state= GLGUI_DEFAULT_STYLE) const { return _style[state]._foregroundColor; } |
---|
[8144] | 44 | |
---|
[8559] | 45 | /** @returns FeaturePosition */ |
---|
[8448] | 46 | inline FeaturePosition featurePosition() const { return _featurePosition; } |
---|
[8559] | 47 | /** @returns the font */ |
---|
[8448] | 48 | inline const Font* const font() const { return _font; } |
---|
[8559] | 49 | /** @returns true if the Element is Animated */ |
---|
[8448] | 50 | inline bool animated() const { return _animated; } |
---|
[8559] | 51 | /** @returns true if State-Changes are animated */ |
---|
[8448] | 52 | inline bool animatedStateChanges() const { return _animatedStateChanges; } |
---|
[8144] | 53 | |
---|
[1853] | 54 | |
---|
[8448] | 55 | |
---|
| 56 | /// SETUP |
---|
[8518] | 57 | void reset(); |
---|
[8448] | 58 | void loadParams(const TiXmlElement* root); |
---|
| 59 | |
---|
| 60 | void setBorderLeft(float value); |
---|
| 61 | void setBorderLeft(float value, OrxGui::State state); |
---|
[8554] | 62 | void setBorderLeftS(float value, const std::string& stateName); |
---|
[8448] | 63 | |
---|
| 64 | void setBorderRight(float value); |
---|
| 65 | void setBorderRight(float value, OrxGui::State state); |
---|
[8554] | 66 | void setBorderRightS(float value, const std::string& stateName); |
---|
[8448] | 67 | |
---|
| 68 | void setBorderTop(float value); |
---|
| 69 | void setBorderTop(float value, OrxGui::State state); |
---|
[8554] | 70 | void setBorderTopS(float value, const std::string& stateName); |
---|
[8448] | 71 | |
---|
| 72 | void setBorderBottom(float value); |
---|
| 73 | void setBorderBottom(float value, OrxGui::State state); |
---|
[8554] | 74 | void setBorderBottomS(float value, const std::string& stateName); |
---|
[8448] | 75 | |
---|
| 76 | void setTextSize(float value); |
---|
| 77 | void setTextSize(float value, OrxGui::State state); |
---|
[8554] | 78 | void setTextSizeS(float value, const std::string& stateName); |
---|
[8448] | 79 | |
---|
| 80 | void setBackgroundColor(const Color& color); |
---|
| 81 | void setBackgroundColor(const Color& color, OrxGui::State state); |
---|
[8554] | 82 | void setBackgroundColorS(float r, float g, float b, float a, const std::string& stateName); |
---|
[8448] | 83 | |
---|
| 84 | void setBackgroundTexture(const Texture& texture); |
---|
| 85 | void setBackgroundTexture(const Texture& texture, OrxGui::State state); |
---|
[8554] | 86 | void setBackgroundTexture(const std::string& textureName, const std::string& stateName); |
---|
[8448] | 87 | |
---|
| 88 | void setForegroundColor(const Color& color); |
---|
| 89 | void setForegroundColor(const Color& color, OrxGui::State state); |
---|
[8554] | 90 | void setForegroundColorS(float r, float g, float b, float a, const std::string& stateName); |
---|
[8448] | 91 | |
---|
| 92 | |
---|
| 93 | void setFeaturePosition(FeaturePosition featurePosition); |
---|
[8559] | 94 | void setFeaturePositionS(const std::string& featurePosition); |
---|
[8448] | 95 | |
---|
| 96 | void setFont(Font* font); |
---|
| 97 | void setFont(const std::string& fontName); |
---|
| 98 | |
---|
| 99 | void setAnimated(bool animated); |
---|
[8518] | 100 | void setAnimatedStateChanges(bool animated); |
---|
[8448] | 101 | |
---|
[8554] | 102 | private: |
---|
| 103 | bool getState(const std::string& stateName, OrxGui::State* state); |
---|
| 104 | |
---|
[8141] | 105 | private: |
---|
[8448] | 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 |
---|
[1853] | 112 | |
---|
[8448] | 113 | float _textSize; //!< The TextSize of the Widget. |
---|
[8141] | 114 | |
---|
[8448] | 115 | Color _backgroundColor; //!< The BackgroundColor of the Widget. |
---|
| 116 | Texture _backgroundTexture; //!< The BackgroundTexture of the Widget. |
---|
[8141] | 117 | |
---|
[8448] | 118 | Color _foregroundColor; //!< The foregroundColor of the Widget. |
---|
| 119 | } |
---|
| 120 | StatedStyle; |
---|
[8141] | 121 | |
---|
[8143] | 122 | |
---|
[8559] | 123 | StatedStyle _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States |
---|
[8448] | 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. |
---|
[8141] | 131 | }; |
---|
| 132 | } |
---|
| 133 | #endif /* _GLGUI_STYLE_H */ |
---|