aboutsummaryrefslogtreecommitdiff
path: root/src/gui/guiButton.h
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:19:54 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:19:54 +0100
commitad148587dcf5244c2d2011dba339786c765c54c4 (patch)
treebdd914121cd326da2ed26679838878e3edffc841 /src/gui/guiButton.h
parent1145b05ea0bda87dc0827821385810eced08f774 (diff)
downloaddragonfireclient-ad148587dcf5244c2d2011dba339786c765c54c4.tar.xz
Make Lint Happy
Diffstat (limited to 'src/gui/guiButton.h')
-rw-r--r--src/gui/guiButton.h251
1 files changed, 128 insertions, 123 deletions
diff --git a/src/gui/guiButton.h b/src/gui/guiButton.h
index 95fa1a2a1..cd0b4ec5f 100644
--- a/src/gui/guiButton.h
+++ b/src/gui/guiButton.h
@@ -18,52 +18,55 @@
using namespace irr;
#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8)
- namespace irr { namespace gui {
-
- //! State of buttons used for drawing texture images.
- //! Note that only a single state is active at a time
- //! Also when no image is defined for a state it will use images from another state
- //! and if that state is not set from the replacement for that,etc.
- //! So in many cases setting EGBIS_IMAGE_UP and EGBIS_IMAGE_DOWN is sufficient.
- enum EGUI_BUTTON_IMAGE_STATE {
- //! When no other states have images they will all use this one.
- EGBIS_IMAGE_UP,
- //! When not set EGBIS_IMAGE_UP is used.
- EGBIS_IMAGE_UP_MOUSEOVER,
- //! When not set EGBIS_IMAGE_UP_MOUSEOVER is used.
- EGBIS_IMAGE_UP_FOCUSED,
- //! When not set EGBIS_IMAGE_UP_FOCUSED is used.
- EGBIS_IMAGE_UP_FOCUSED_MOUSEOVER,
- //! When not set EGBIS_IMAGE_UP is used.
- EGBIS_IMAGE_DOWN,
- //! When not set EGBIS_IMAGE_DOWN is used.
- EGBIS_IMAGE_DOWN_MOUSEOVER,
- //! When not set EGBIS_IMAGE_DOWN_MOUSEOVER is used.
- EGBIS_IMAGE_DOWN_FOCUSED,
- //! When not set EGBIS_IMAGE_DOWN_FOCUSED is used.
- EGBIS_IMAGE_DOWN_FOCUSED_MOUSEOVER,
- //! When not set EGBIS_IMAGE_UP or EGBIS_IMAGE_DOWN are used (depending on button state).
- EGBIS_IMAGE_DISABLED,
- //! not used, counts the number of enumerated items
- EGBIS_COUNT
- };
-
- //! Names for gui button image states
- const c8 *const GUIButtonImageStateNames[EGBIS_COUNT + 1] =
- {
- "Image", // not "ImageUp" as it otherwise breaks serialization of old files
- "ImageUpOver",
- "ImageUpFocused",
- "ImageUpFocusedOver",
- "PressedImage", // not "ImageDown" as it otherwise breaks serialization of old files
- "ImageDownOver",
- "ImageDownFocused",
- "ImageDownFocusedOver",
- "ImageDisabled",
- 0 // count
- };
-
- }}
+namespace irr
+{
+namespace gui
+{
+
+//! State of buttons used for drawing texture images.
+//! Note that only a single state is active at a time
+//! Also when no image is defined for a state it will use images from another state
+//! and if that state is not set from the replacement for that,etc.
+//! So in many cases setting EGBIS_IMAGE_UP and EGBIS_IMAGE_DOWN is sufficient.
+enum EGUI_BUTTON_IMAGE_STATE
+{
+ //! When no other states have images they will all use this one.
+ EGBIS_IMAGE_UP,
+ //! When not set EGBIS_IMAGE_UP is used.
+ EGBIS_IMAGE_UP_MOUSEOVER,
+ //! When not set EGBIS_IMAGE_UP_MOUSEOVER is used.
+ EGBIS_IMAGE_UP_FOCUSED,
+ //! When not set EGBIS_IMAGE_UP_FOCUSED is used.
+ EGBIS_IMAGE_UP_FOCUSED_MOUSEOVER,
+ //! When not set EGBIS_IMAGE_UP is used.
+ EGBIS_IMAGE_DOWN,
+ //! When not set EGBIS_IMAGE_DOWN is used.
+ EGBIS_IMAGE_DOWN_MOUSEOVER,
+ //! When not set EGBIS_IMAGE_DOWN_MOUSEOVER is used.
+ EGBIS_IMAGE_DOWN_FOCUSED,
+ //! When not set EGBIS_IMAGE_DOWN_FOCUSED is used.
+ EGBIS_IMAGE_DOWN_FOCUSED_MOUSEOVER,
+ //! When not set EGBIS_IMAGE_UP or EGBIS_IMAGE_DOWN are used (depending on button
+ //! state).
+ EGBIS_IMAGE_DISABLED,
+ //! not used, counts the number of enumerated items
+ EGBIS_COUNT
+};
+
+//! Names for gui button image states
+const c8 *const GUIButtonImageStateNames[EGBIS_COUNT + 1] = {
+ "Image", // not "ImageUp" as it otherwise breaks serialization of old
+ // files
+ "ImageUpOver", "ImageUpFocused", "ImageUpFocusedOver",
+ "PressedImage", // not "ImageDown" as it otherwise breaks serialization of
+ // old files
+ "ImageDownOver", "ImageDownFocused", "ImageDownFocusedOver",
+ "ImageDisabled",
+ 0 // count
+};
+
+}
+}
#endif
@@ -72,29 +75,29 @@ class ISimpleTextureSource;
class GUIButton : public gui::IGUIButton
{
public:
-
//! constructor
- GUIButton(gui::IGUIEnvironment* environment, gui::IGUIElement* parent,
- s32 id, core::rect<s32> rectangle, ISimpleTextureSource *tsrc,
- bool noclip=false);
+ GUIButton(gui::IGUIEnvironment *environment, gui::IGUIElement *parent, s32 id,
+ core::rect<s32> rectangle, ISimpleTextureSource *tsrc,
+ bool noclip = false);
//! destructor
virtual ~GUIButton();
//! called if an event happened.
- virtual bool OnEvent(const SEvent& event) override;
+ virtual bool OnEvent(const SEvent &event) override;
//! draws the element and its children
virtual void draw() override;
- //! sets another skin independent font. if this is set to zero, the button uses the font of the skin.
- virtual void setOverrideFont(gui::IGUIFont* font=0) override;
+ //! sets another skin independent font. if this is set to zero, the button uses
+ //! the font of the skin.
+ virtual void setOverrideFont(gui::IGUIFont *font = 0) override;
//! Gets the override font (if any)
- virtual gui::IGUIFont* getOverrideFont() const override;
+ virtual gui::IGUIFont *getOverrideFont() const override;
//! Get the font which is used right now for drawing
- virtual gui::IGUIFont* getActiveFont() const override;
+ virtual gui::IGUIFont *getActiveFont() const override;
//! Sets another color for the button text.
virtual void setOverrideColor(video::SColor color);
@@ -102,49 +105,58 @@ public:
//! Gets the override color
virtual video::SColor getOverrideColor(void) const;
- //! Sets if the button text should use the override color or the color in the gui skin.
+ //! Sets if the button text should use the override color or the color in the gui
+ //! skin.
virtual void enableOverrideColor(bool enable);
//! Checks if an override color is enabled
virtual bool isOverrideColorEnabled(void) const;
// PATCH
- //! Sets an image which should be displayed on the button when it is in the given state.
+ //! Sets an image which should be displayed on the button when it is in the given
+ //! state.
virtual void setImage(gui::EGUI_BUTTON_IMAGE_STATE state,
- video::ITexture* image=nullptr,
- const core::rect<s32>& sourceRect=core::rect<s32>(0,0,0,0));
+ video::ITexture *image = nullptr,
+ const core::rect<s32> &sourceRect = core::rect<s32>(0, 0, 0, 0));
- //! Sets an image which should be displayed on the button when it is in normal state.
- virtual void setImage(video::ITexture* image=nullptr) override;
+ //! Sets an image which should be displayed on the button when it is in normal
+ //! state.
+ virtual void setImage(video::ITexture *image = nullptr) override;
- //! Sets an image which should be displayed on the button when it is in normal state.
- virtual void setImage(video::ITexture* image, const core::rect<s32>& pos) override;
+ //! Sets an image which should be displayed on the button when it is in normal
+ //! state.
+ virtual void setImage(
+ video::ITexture *image, const core::rect<s32> &pos) override;
- //! Sets an image which should be displayed on the button when it is in pressed state.
- virtual void setPressedImage(video::ITexture* image=nullptr) override;
+ //! Sets an image which should be displayed on the button when it is in pressed
+ //! state.
+ virtual void setPressedImage(video::ITexture *image = nullptr) override;
- //! Sets an image which should be displayed on the button when it is in pressed state.
- virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos) override;
+ //! Sets an image which should be displayed on the button when it is in pressed
+ //! state.
+ virtual void setPressedImage(
+ video::ITexture *image, const core::rect<s32> &pos) override;
//! Sets the text displayed by the button
- virtual void setText(const wchar_t* text) override;
+ virtual void setText(const wchar_t *text) override;
// END PATCH
//! Sets the sprite bank used by the button
- virtual void setSpriteBank(gui::IGUISpriteBank* bank=0) override;
+ virtual void setSpriteBank(gui::IGUISpriteBank *bank = 0) override;
//! Sets the animated sprite for a specific button state
- /** \param index: Number of the sprite within the sprite bank, use -1 for no sprite
- \param state: State of the button to set the sprite for
- \param index: The sprite number from the current sprite bank
- \param color: The color of the sprite
+ /** \param index: Number of the sprite within the sprite bank, use -1 for no
+ sprite \param state: State of the button to set the sprite for \param index: The
+ sprite number from the current sprite bank \param color: The color of the sprite
*/
virtual void setSprite(gui::EGUI_BUTTON_STATE state, s32 index,
- video::SColor color=video::SColor(255,255,255,255),
- bool loop=false, bool scale=false);
+ video::SColor color = video::SColor(255, 255, 255, 255),
+ bool loop = false, bool scale = false);
#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8)
- void setSprite(gui::EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop) override {
+ void setSprite(gui::EGUI_BUTTON_STATE state, s32 index, video::SColor color,
+ bool loop) override
+ {
setSprite(state, index, color, loop, false);
}
#endif
@@ -152,7 +164,8 @@ public:
//! Get the sprite-index for the given state or -1 when no sprite is set
virtual s32 getSpriteIndex(gui::EGUI_BUTTON_STATE state) const;
- //! Get the sprite color for the given state. Color is only used when a sprite is set.
+ //! Get the sprite color for the given state. Color is only used when a sprite is
+ //! set.
virtual video::SColor getSpriteColor(gui::EGUI_BUTTON_STATE state) const;
//! Returns if the sprite in the given state does loop
@@ -164,13 +177,13 @@ public:
//! Sets if the button should behave like a push button. Which means it
//! can be in two states: Normal or Pressed. With a click on the button,
//! the user can change the state of the button.
- virtual void setIsPushButton(bool isPushButton=true) override;
+ virtual void setIsPushButton(bool isPushButton = true) override;
//! Checks whether the button is a push button
virtual bool isPushButton() const override;
//! Sets the pressed state of the button if this is a pushbutton
- virtual void setPressed(bool pressed=true) override;
+ virtual void setPressed(bool pressed = true) override;
//! Returns if the button is currently pressed
virtual bool isPressed() const override;
@@ -181,42 +194,37 @@ public:
// END PATCH
//! Sets if the button should use the skin to draw its border
- virtual void setDrawBorder(bool border=true) override;
+ virtual void setDrawBorder(bool border = true) override;
//! Checks if the button face and border are being drawn
virtual bool isDrawingBorder() const override;
- //! Sets if the alpha channel should be used for drawing images on the button (default is false)
- virtual void setUseAlphaChannel(bool useAlphaChannel=true) override;
+ //! Sets if the alpha channel should be used for drawing images on the button
+ //! (default is false)
+ virtual void setUseAlphaChannel(bool useAlphaChannel = true) override;
//! Checks if the alpha channel should be used for drawing images on the button
virtual bool isAlphaChannelUsed() const override;
//! Sets if the button should scale the button images to fit
- virtual void setScaleImage(bool scaleImage=true) override;
+ virtual void setScaleImage(bool scaleImage = true) override;
//! Checks whether the button scales the used images
virtual bool isScalingImage() const override;
//! Get if the shift key was pressed in last EGET_BUTTON_CLICKED event
- virtual bool getClickShiftState() const
- {
- return ClickShiftState;
- }
+ virtual bool getClickShiftState() const { return ClickShiftState; }
//! Get if the control key was pressed in last EGET_BUTTON_CLICKED event
- virtual bool getClickControlState() const
- {
- return ClickControlState;
- }
+ virtual bool getClickControlState() const { return ClickControlState; }
//! Writes attributes of the element.
- virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const override;
+ virtual void serializeAttributes(io::IAttributes *out,
+ io::SAttributeReadWriteOptions *options) const override;
//! Reads attributes of the element
- virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) override;
-
-
+ virtual void deserializeAttributes(io::IAttributes *in,
+ io::SAttributeReadWriteOptions *options) override;
void setColor(video::SColor color);
// PATCH
@@ -224,79 +232,76 @@ public:
void setFromState();
//! Set element properties from a StyleSpec
- virtual void setFromStyle(const StyleSpec& style);
+ virtual void setFromStyle(const StyleSpec &style);
//! Set the styles used for each state
- void setStyles(const std::array<StyleSpec, StyleSpec::NUM_STATES>& styles);
+ void setStyles(const std::array<StyleSpec, StyleSpec::NUM_STATES> &styles);
// END PATCH
-
//! Do not drop returned handle
- static GUIButton* addButton(gui::IGUIEnvironment *environment,
- const core::rect<s32>& rectangle, ISimpleTextureSource *tsrc,
- IGUIElement* parent, s32 id, const wchar_t* text,
- const wchar_t *tooltiptext=L"");
+ static GUIButton *addButton(gui::IGUIEnvironment *environment,
+ const core::rect<s32> &rectangle, ISimpleTextureSource *tsrc,
+ IGUIElement *parent, s32 id, const wchar_t *text,
+ const wchar_t *tooltiptext = L"");
protected:
- void drawSprite(gui::EGUI_BUTTON_STATE state, u32 startTime, const core::position2di& center);
+ void drawSprite(gui::EGUI_BUTTON_STATE state, u32 startTime,
+ const core::position2di &center);
gui::EGUI_BUTTON_IMAGE_STATE getImageState(bool pressed) const;
ISimpleTextureSource *getTextureSource() { return TSrc; }
struct ButtonImage
{
- ButtonImage() : Texture(0), SourceRect(core::rect<s32>(0,0,0,0))
- {
- }
+ ButtonImage() : Texture(0), SourceRect(core::rect<s32>(0, 0, 0, 0)) {}
- ButtonImage(const ButtonImage& other) : Texture(0), SourceRect(core::rect<s32>(0,0,0,0))
+ ButtonImage(const ButtonImage &other) :
+ Texture(0), SourceRect(core::rect<s32>(0, 0, 0, 0))
{
*this = other;
}
~ButtonImage()
{
- if ( Texture )
+ if (Texture)
Texture->drop();
}
- ButtonImage& operator=(const ButtonImage& other)
+ ButtonImage &operator=(const ButtonImage &other)
{
- if ( this == &other )
+ if (this == &other)
return *this;
if (other.Texture)
other.Texture->grab();
- if ( Texture )
+ if (Texture)
Texture->drop();
Texture = other.Texture;
SourceRect = other.SourceRect;
return *this;
}
- bool operator==(const ButtonImage& other) const
+ bool operator==(const ButtonImage &other) const
{
return Texture == other.Texture && SourceRect == other.SourceRect;
}
-
- video::ITexture* Texture;
+ video::ITexture *Texture;
core::rect<s32> SourceRect;
};
- gui::EGUI_BUTTON_IMAGE_STATE getImageState(bool pressed, const ButtonImage* images) const;
+ gui::EGUI_BUTTON_IMAGE_STATE getImageState(
+ bool pressed, const ButtonImage *images) const;
private:
-
struct ButtonSprite
{
- ButtonSprite() : Index(-1), Loop(false), Scale(false)
- {
- }
+ ButtonSprite() : Index(-1), Loop(false), Scale(false) {}
- bool operator==(const ButtonSprite& other) const
+ bool operator==(const ButtonSprite &other) const
{
- return Index == other.Index && Color == other.Color && Loop == other.Loop && Scale == other.Scale;
+ return Index == other.Index && Color == other.Color &&
+ Loop == other.Loop && Scale == other.Scale;
}
s32 Index;
@@ -306,13 +311,13 @@ private:
};
ButtonSprite ButtonSprites[gui::EGBS_COUNT];
- gui::IGUISpriteBank* SpriteBank;
+ gui::IGUISpriteBank *SpriteBank;
ButtonImage ButtonImages[gui::EGBIS_COUNT];
std::array<StyleSpec, StyleSpec::NUM_STATES> Styles;
- gui::IGUIFont* OverrideFont;
+ gui::IGUIFont *OverrideFont;
bool OverrideColorEnabled;
video::SColor OverrideColor;