\r
#include "IrrCompileConfig.h"\r
\r
+#include <IGUIStaticText.h>\r
+#include "irrlicht_changes/static_text.h"\r
#include "IGUIButton.h"\r
#include "IGUISpriteBank.h"\r
#include "ITexture.h"\r
#include "SColor.h"\r
#include "guiSkin.h"\r
+#include "StyleSpec.h"\r
\r
using namespace irr;\r
\r
\r
#endif\r
\r
+class ISimpleTextureSource;\r
+\r
class GUIButton : public gui::IGUIButton\r
{\r
public:\r
\r
//! constructor\r
GUIButton(gui::IGUIEnvironment* environment, gui::IGUIElement* parent,\r
- s32 id, core::rect<s32> rectangle, bool noclip=false);\r
+ s32 id, core::rect<s32> rectangle, ISimpleTextureSource *tsrc,\r
+ bool noclip=false);\r
\r
//! destructor\r
virtual ~GUIButton();\r
//! Sets an image which should be displayed on the button when it is in pressed state.\r
virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos) override;\r
\r
- //! Sets an image which should be displayed on the button when it is in hovered state.\r
- virtual void setHoveredImage(video::ITexture* image=nullptr);\r
+ //! Sets the text displayed by the button\r
+ virtual void setText(const wchar_t* text) override;\r
// END PATCH\r
\r
- //! Sets an image which should be displayed on the button when it is in hovered state.\r
- virtual void setHoveredImage(video::ITexture* image, const core::rect<s32>& pos);\r
-\r
//! Sets the sprite bank used by the button\r
virtual void setSpriteBank(gui::IGUISpriteBank* bank=0) override;\r
\r
//! Returns if the button is currently pressed\r
virtual bool isPressed() const override;\r
\r
+ // PATCH\r
+ //! Returns if this element (or one of its direct children) is hovered\r
+ bool isHovered() const;\r
+ // END PATCH\r
+\r
//! Sets if the button should use the skin to draw its border\r
virtual void setDrawBorder(bool border=true) override;\r
\r
\r
void setColor(video::SColor color);\r
// PATCH\r
- void setHoveredColor(video::SColor color);\r
- void setPressedColor(video::SColor color);\r
+ //! Set element properties from a StyleSpec corresponding to the button state\r
+ void setFromState();\r
+\r
+ //! Set element properties from a StyleSpec\r
+ virtual void setFromStyle(const StyleSpec& style);\r
+\r
+ //! Set the styles used for each state\r
+ void setStyles(const std::array<StyleSpec, StyleSpec::NUM_STATES>& styles);\r
// END PATCH\r
\r
\r
//! Do not drop returned handle\r
- static GUIButton* addButton(gui::IGUIEnvironment *environment, const core::rect<s32>& rectangle,\r
- IGUIElement* parent, s32 id, const wchar_t* text, const wchar_t *tooltiptext=L"");\r
+ static GUIButton* addButton(gui::IGUIEnvironment *environment,\r
+ const core::rect<s32>& rectangle, ISimpleTextureSource *tsrc,\r
+ IGUIElement* parent, s32 id, const wchar_t* text,\r
+ const wchar_t *tooltiptext=L"");\r
\r
protected:\r
void drawSprite(gui::EGUI_BUTTON_STATE state, u32 startTime, const core::position2di& center);\r
gui::EGUI_BUTTON_IMAGE_STATE getImageState(bool pressed) const;\r
\r
-private:\r
-\r
- struct ButtonSprite\r
- {\r
- ButtonSprite() : Index(-1), Loop(false), Scale(false)\r
- {\r
- }\r
-\r
- bool operator==(const ButtonSprite& other) const\r
- {\r
- return Index == other.Index && Color == other.Color && Loop == other.Loop && Scale == other.Scale;\r
- }\r
-\r
- s32 Index;\r
- video::SColor Color;\r
- bool Loop;\r
- bool Scale;\r
- };\r
-\r
- ButtonSprite ButtonSprites[gui::EGBS_COUNT];\r
- gui::IGUISpriteBank* SpriteBank;\r
+ ISimpleTextureSource *getTextureSource() { return TSrc; }\r
\r
struct ButtonImage\r
{\r
core::rect<s32> SourceRect;\r
};\r
\r
+ gui::EGUI_BUTTON_IMAGE_STATE getImageState(bool pressed, const ButtonImage* images) const;\r
+\r
+private:\r
+\r
+ struct ButtonSprite\r
+ {\r
+ ButtonSprite() : Index(-1), Loop(false), Scale(false)\r
+ {\r
+ }\r
+\r
+ bool operator==(const ButtonSprite& other) const\r
+ {\r
+ return Index == other.Index && Color == other.Color && Loop == other.Loop && Scale == other.Scale;\r
+ }\r
+\r
+ s32 Index;\r
+ video::SColor Color;\r
+ bool Loop;\r
+ bool Scale;\r
+ };\r
+\r
+ ButtonSprite ButtonSprites[gui::EGBS_COUNT];\r
+ gui::IGUISpriteBank* SpriteBank;\r
+\r
ButtonImage ButtonImages[gui::EGBIS_COUNT];\r
\r
+ std::array<StyleSpec, StyleSpec::NUM_STATES> Styles;\r
+\r
gui::IGUIFont* OverrideFont;\r
\r
bool OverrideColorEnabled;\r
\r
video::SColor Colors[4];\r
// PATCH\r
- video::SColor HoveredColors[4];\r
- video::SColor PressedColors[4];\r
+ bool WasHovered = false;\r
+ ISimpleTextureSource *TSrc;\r
+\r
+ gui::IGUIStaticText *StaticText;\r
+\r
+ core::rect<s32> BgMiddle;\r
+ core::rect<s32> Padding;\r
+ core::vector2d<s32> ContentOffset;\r
+ video::SColor BgColor;\r
// END PATCH\r
};\r