Remove Mapgen V7 floatlands in preparation for new implementation (#9238)
[oweals/minetest.git] / src / gui / guiButton.h
index 63e29ccfcf7b72c6a61b73fea2a0d1b32e4041ee..37b278d25aca18830264a91e701819dacdd7cefd 100644 (file)
@@ -6,6 +6,8 @@
 \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
@@ -64,6 +66,9 @@ using namespace irr;
 \r
 #endif\r
 \r
+class ISimpleTextureSource;\r
+class StyleSpec;\r
+\r
 class GUIButton : public gui::IGUIButton\r
 {\r
 public:\r
@@ -102,34 +107,33 @@ public:
        //! Checks if an override color is enabled\r
        virtual bool isOverrideColorEnabled(void) const;\r
 \r
+       // PATCH\r
        //! Sets an image which should be displayed on the button when it is in the given state.\r
        virtual void setImage(gui::EGUI_BUTTON_IMAGE_STATE state,\r
-                       video::ITexture* image=0,\r
+                       video::ITexture* image=nullptr,\r
                        const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0));\r
 \r
        //! Sets an image which should be displayed on the button when it is in normal state.\r
-       virtual void setImage(video::ITexture* image=0) override\r
-       {\r
-               setImage(gui::EGBIS_IMAGE_UP, image);\r
-       }\r
+       virtual void setImage(video::ITexture* image=nullptr) override;\r
 \r
        //! Sets an image which should be displayed on the button when it is in normal state.\r
-       virtual void setImage(video::ITexture* image, const core::rect<s32>& pos) override\r
-       {\r
-               setImage(gui::EGBIS_IMAGE_UP, image, pos);\r
-       }\r
+       virtual void setImage(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 pressed state.\r
-       virtual void setPressedImage(video::ITexture* image=0) override\r
-       {\r
-               setImage(gui::EGBIS_IMAGE_DOWN, image);\r
-       }\r
+       virtual void setPressedImage(video::ITexture* image=nullptr) override;\r
 \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
-               setImage(gui::EGBIS_IMAGE_DOWN, image, pos);\r
-       }\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
+\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
@@ -176,6 +180,11 @@ public:
        //! 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
@@ -215,6 +224,13 @@ public:
 \r
 \r
        void setColor(video::SColor color);\r
+       // PATCH\r
+       void setHoveredColor(video::SColor color);\r
+       void setPressedColor(video::SColor color);\r
+\r
+       //! Set element properties from a StyleSpec\r
+       virtual void setFromStyle(const StyleSpec& style, ISimpleTextureSource *tsrc);\r
+       // END PATCH\r
 \r
 \r
        //! Do not drop returned handle\r
@@ -225,28 +241,6 @@ protected:
        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
-\r
        struct ButtonImage\r
        {\r
                ButtonImage() : Texture(0), SourceRect(core::rect<s32>(0,0,0,0))\r
@@ -288,6 +282,30 @@ private:
                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
        gui::IGUIFont* OverrideFont;\r
@@ -307,4 +325,10 @@ private:
        bool ScaleImage;\r
 \r
        video::SColor Colors[4];\r
+       // PATCH\r
+       video::SColor HoveredColors[4];\r
+       video::SColor PressedColors[4];\r
+\r
+       gui::IGUIStaticText *StaticText;\r
+       // END PATCH\r
 };\r