]> git.lizzy.rs Git - minetest.git/blobdiff - src/gui/guiButton.h
Translated using Weblate (Malay)
[minetest.git] / src / gui / guiButton.h
index 37b278d25aca18830264a91e701819dacdd7cefd..ee9bb6f2196412fcef5a09f51bee845d3488f2ec 100644 (file)
@@ -13,6 +13,7 @@
 #include "ITexture.h"\r
 #include "SColor.h"\r
 #include "guiSkin.h"\r
+#include "StyleSpec.h"\r
 \r
 using namespace irr;\r
 \r
@@ -67,7 +68,12 @@ using namespace irr;
 #endif\r
 \r
 class ISimpleTextureSource;\r
-class StyleSpec;\r
+\r
+#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8)\r
+#define OVERRIDE_19\r
+#else\r
+#define OVERRIDE_19 override\r
+#endif\r
 \r
 class GUIButton : public gui::IGUIButton\r
 {\r
@@ -75,7 +81,8 @@ class GUIButton : public gui::IGUIButton
 \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
@@ -96,22 +103,27 @@ class GUIButton : public gui::IGUIButton
        virtual gui::IGUIFont* getActiveFont() const override;\r
 \r
        //! Sets another color for the button text.\r
-       virtual void setOverrideColor(video::SColor color);\r
+       virtual void setOverrideColor(video::SColor color) OVERRIDE_19;\r
 \r
        //! Gets the override color\r
-       virtual video::SColor getOverrideColor(void) const;\r
+       virtual video::SColor getOverrideColor(void) const OVERRIDE_19;\r
+\r
+       #if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR > 8\r
+       //! Gets the currently used text color\r
+       virtual video::SColor getActiveColor() const override;\r
+       #endif\r
 \r
        //! Sets if the button text should use the override color or the color in the gui skin.\r
-       virtual void enableOverrideColor(bool enable);\r
+       virtual void enableOverrideColor(bool enable) OVERRIDE_19;\r
 \r
        //! Checks if an override color is enabled\r
-       virtual bool isOverrideColorEnabled(void) const;\r
+       virtual bool isOverrideColorEnabled(void) const OVERRIDE_19;\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=nullptr,\r
-                       const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0));\r
+                       const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0)) OVERRIDE_19;\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=nullptr) override;\r
@@ -125,16 +137,10 @@ class GUIButton : public gui::IGUIButton
        //! 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
-\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
@@ -146,7 +152,7 @@ class GUIButton : public gui::IGUIButton
        */\r
        virtual void setSprite(gui::EGUI_BUTTON_STATE state, s32 index,\r
                                                   video::SColor color=video::SColor(255,255,255,255),\r
-                                                  bool loop=false, bool scale=false);\r
+                                                  bool loop=false, bool scale=false) OVERRIDE_19;\r
 \r
 #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8)\r
        void setSprite(gui::EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop) override {\r
@@ -155,16 +161,16 @@ class GUIButton : public gui::IGUIButton
 #endif\r
 \r
        //! Get the sprite-index for the given state or -1 when no sprite is set\r
-       virtual s32 getSpriteIndex(gui::EGUI_BUTTON_STATE state) const;\r
+       virtual s32 getSpriteIndex(gui::EGUI_BUTTON_STATE state) const OVERRIDE_19;\r
 \r
        //! Get the sprite color for the given state. Color is only used when a sprite is set.\r
-       virtual video::SColor getSpriteColor(gui::EGUI_BUTTON_STATE state) const;\r
+       virtual video::SColor getSpriteColor(gui::EGUI_BUTTON_STATE state) const OVERRIDE_19;\r
 \r
        //! Returns if the sprite in the given state does loop\r
-       virtual bool getSpriteLoop(gui::EGUI_BUTTON_STATE state) const;\r
+       virtual bool getSpriteLoop(gui::EGUI_BUTTON_STATE state) const OVERRIDE_19;\r
 \r
        //! Returns if the sprite in the given state is scaled\r
-       virtual bool getSpriteScale(gui::EGUI_BUTTON_STATE state) const;\r
+       virtual bool getSpriteScale(gui::EGUI_BUTTON_STATE state) const OVERRIDE_19;\r
 \r
        //! 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
@@ -204,43 +210,42 @@ class GUIButton : public gui::IGUIButton
        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
+       virtual bool getClickShiftState() const OVERRIDE_19\r
        {\r
                return ClickShiftState;\r
        }\r
 \r
        //! Get if the control key was pressed in last EGET_BUTTON_CLICKED event\r
-       virtual bool getClickControlState() const\r
+       virtual bool getClickControlState() const OVERRIDE_19\r
        {\r
                return ClickControlState;\r
        }\r
 \r
-       //! Writes attributes of the element.\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) 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
+       //! 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, ISimpleTextureSource *tsrc);\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
+       ISimpleTextureSource *getTextureSource() { return TSrc; }\r
+\r
        struct ButtonImage\r
        {\r
                ButtonImage() : Texture(0), SourceRect(core::rect<s32>(0,0,0,0))\r
@@ -308,6 +313,8 @@ class GUIButton : public gui::IGUIButton
 \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
@@ -326,9 +333,14 @@ class GUIButton : public gui::IGUIButton
 \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