Remove Mapgen V7 floatlands in preparation for new implementation (#9238)
[oweals/minetest.git] / src / gui / guiButton.h
index b6b0c126c0bcbfbcef4eaa4091b04ad65589e112..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
@@ -76,19 +81,19 @@ public:
        virtual ~GUIButton();\r
 \r
        //! called if an event happened.\r
-       virtual bool OnEvent(const SEvent& event);\r
+       virtual bool OnEvent(const SEvent& event) override;\r
 \r
        //! draws the element and its children\r
-       virtual void draw();\r
+       virtual void draw() override;\r
 \r
        //! sets another skin independent font. if this is set to zero, the button uses the font of the skin.\r
-       virtual void setOverrideFont(gui::IGUIFont* font=0);\r
+       virtual void setOverrideFont(gui::IGUIFont* font=0) override;\r
 \r
        //! Gets the override font (if any)\r
-       virtual gui::IGUIFont* getOverrideFont() const;\r
+       virtual gui::IGUIFont* getOverrideFont() const override;\r
 \r
        //! Get the font which is used right now for drawing\r
-       virtual gui::IGUIFont* getActiveFont() const;\r
+       virtual gui::IGUIFont* getActiveFont() const override;\r
 \r
        //! Sets another color for the button text.\r
        virtual void setOverrideColor(video::SColor color);\r
@@ -102,35 +107,36 @@ 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, video::ITexture* image=0, const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0));\r
+       virtual void setImage(gui::EGUI_BUTTON_IMAGE_STATE state,\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)\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)\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)\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)\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);\r
+       virtual void setSpriteBank(gui::IGUISpriteBank* bank=0) override;\r
 \r
        //! Sets the animated sprite for a specific button state\r
        /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite\r
@@ -163,34 +169,39 @@ public:
        //! Sets if the button should behave like a push button. Which means it\r
        //! can be in two states: Normal or Pressed. With a click on the button,\r
        //! the user can change the state of the button.\r
-       virtual void setIsPushButton(bool isPushButton=true);\r
+       virtual void setIsPushButton(bool isPushButton=true) override;\r
 \r
        //! Checks whether the button is a push button\r
-       virtual bool isPushButton() const;\r
+       virtual bool isPushButton() const override;\r
 \r
        //! Sets the pressed state of the button if this is a pushbutton\r
-       virtual void setPressed(bool pressed=true);\r
+       virtual void setPressed(bool pressed=true) override;\r
 \r
        //! Returns if the button is currently pressed\r
-       virtual bool isPressed() const;\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);\r
+       virtual void setDrawBorder(bool border=true) override;\r
 \r
        //! Checks if the button face and border are being drawn\r
-       virtual bool isDrawingBorder() const;\r
+       virtual bool isDrawingBorder() const override;\r
 \r
        //! Sets if the alpha channel should be used for drawing images on the button (default is false)\r
-       virtual void setUseAlphaChannel(bool useAlphaChannel=true);\r
+       virtual void setUseAlphaChannel(bool useAlphaChannel=true) override;\r
 \r
        //! Checks if the alpha channel should be used for drawing images on the button\r
-       virtual bool isAlphaChannelUsed() const;\r
+       virtual bool isAlphaChannelUsed() const override;\r
 \r
        //! Sets if the button should scale the button images to fit\r
-       virtual void setScaleImage(bool scaleImage=true);\r
+       virtual void setScaleImage(bool scaleImage=true) override;\r
 \r
        //! Checks whether the button scales the used images\r
-       virtual bool isScalingImage() const;\r
+       virtual bool isScalingImage() const override;\r
 \r
        //! Get if the shift key was pressed in last EGET_BUTTON_CLICKED event\r
        virtual bool getClickShiftState() const\r
@@ -205,14 +216,21 @@ public:
        }\r
 \r
        //! Writes attributes of the element.\r
-       virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;\r
+       virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const override;\r
 \r
        //! Reads attributes of the element\r
-       virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);\r
+       virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) override;\r
 \r
 \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
@@ -223,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
@@ -286,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
@@ -305,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