#include <guiButton.h>
Classes | |
struct | ButtonImage |
struct | ButtonSprite |
Public Member Functions | |
GUIButton (gui::IGUIEnvironment *environment, gui::IGUIElement *parent, s32 id, core::rect< s32 > rectangle, ISimpleTextureSource *tsrc, bool noclip=false) | |
constructor More... | |
virtual | ~GUIButton () |
destructor More... | |
virtual bool | OnEvent (const SEvent &event) override |
called if an event happened. More... | |
virtual void | draw () override |
draws the element and its children More... | |
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. More... | |
virtual gui::IGUIFont * | getOverrideFont () const override |
Gets the override font (if any) More... | |
virtual gui::IGUIFont * | getActiveFont () const override |
Get the font which is used right now for drawing. More... | |
virtual void | setOverrideColor (video::SColor color) |
Sets another color for the button text. More... | |
virtual video::SColor | getOverrideColor (void) const |
Gets the override color. More... | |
virtual void | enableOverrideColor (bool enable) |
Sets if the button text should use the override color or the color in the gui skin. More... | |
virtual bool | isOverrideColorEnabled (void) const |
Checks if an override color is enabled. More... | |
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)) |
Sets an image which should be displayed on the button when it is in the given state. More... | |
virtual void | setImage (video::ITexture *image=nullptr) override |
Sets an image which should be displayed on the button when it is in normal state. More... | |
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. More... | |
virtual void | setPressedImage (video::ITexture *image=nullptr) override |
Sets an image which should be displayed on the button when it is in pressed state. More... | |
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. More... | |
virtual void | setText (const wchar_t *text) override |
Sets the text displayed by the button. More... | |
virtual void | setSpriteBank (gui::IGUISpriteBank *bank=0) override |
Sets the sprite bank used by the button. More... | |
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) |
Sets the animated sprite for a specific button state. More... | |
virtual s32 | getSpriteIndex (gui::EGUI_BUTTON_STATE state) const |
Get the sprite-index for the given state or -1 when no sprite is set. More... | |
virtual video::SColor | getSpriteColor (gui::EGUI_BUTTON_STATE state) const |
Get the sprite color for the given state. Color is only used when a sprite is set. More... | |
virtual bool | getSpriteLoop (gui::EGUI_BUTTON_STATE state) const |
Returns if the sprite in the given state does loop. More... | |
virtual bool | getSpriteScale (gui::EGUI_BUTTON_STATE state) const |
Returns if the sprite in the given state is scaled. More... | |
virtual void | setIsPushButton (bool isPushButton=true) override |
Sets if the button should behave like a push button. More... | |
virtual bool | isPushButton () const override |
Checks whether the button is a push button. More... | |
virtual void | setPressed (bool pressed=true) override |
Sets the pressed state of the button if this is a pushbutton. More... | |
virtual bool | isPressed () const override |
Returns if the button is currently pressed. More... | |
bool | isHovered () const |
Returns if this element (or one of its direct children) is hovered. More... | |
virtual void | setDrawBorder (bool border=true) override |
Sets if the button should use the skin to draw its border. More... | |
virtual bool | isDrawingBorder () const override |
Checks if the button face and border are being drawn. More... | |
virtual void | setUseAlphaChannel (bool useAlphaChannel=true) override |
Sets if the alpha channel should be used for drawing images on the button (default is false) More... | |
virtual bool | isAlphaChannelUsed () const override |
Checks if the alpha channel should be used for drawing images on the button. More... | |
virtual void | setScaleImage (bool scaleImage=true) override |
Sets if the button should scale the button images to fit. More... | |
virtual bool | isScalingImage () const override |
Checks whether the button scales the used images. More... | |
virtual bool | getClickShiftState () const |
Get if the shift key was pressed in last EGET_BUTTON_CLICKED event. More... | |
virtual bool | getClickControlState () const |
Get if the control key was pressed in last EGET_BUTTON_CLICKED event. More... | |
virtual void | serializeAttributes (io::IAttributes *out, io::SAttributeReadWriteOptions *options) const override |
Writes attributes of the element. More... | |
virtual void | deserializeAttributes (io::IAttributes *in, io::SAttributeReadWriteOptions *options) override |
Reads attributes of the element. More... | |
void | setColor (video::SColor color) |
void | setFromState () |
Set element properties from a StyleSpec corresponding to the button state. More... | |
virtual void | setFromStyle (const StyleSpec &style) |
Set element properties from a StyleSpec. More... | |
void | setStyles (const std::array< StyleSpec, StyleSpec::NUM_STATES > &styles) |
Set the styles used for each state. More... | |
Static Public Member Functions | |
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"") |
Do not drop returned handle. More... | |
Protected Member Functions | |
void | drawSprite (gui::EGUI_BUTTON_STATE state, u32 startTime, const core::position2di ¢er) |
gui::EGUI_BUTTON_IMAGE_STATE | getImageState (bool pressed) const |
ISimpleTextureSource * | getTextureSource () |
gui::EGUI_BUTTON_IMAGE_STATE | getImageState (bool pressed, const ButtonImage *images) const |
Private Attributes | |
ButtonSprite | ButtonSprites [gui::EGBS_COUNT] |
gui::IGUISpriteBank * | SpriteBank |
ButtonImage | ButtonImages [gui::EGBIS_COUNT] |
std::array< StyleSpec, StyleSpec::NUM_STATES > | Styles |
gui::IGUIFont * | OverrideFont |
bool | OverrideColorEnabled |
video::SColor | OverrideColor |
u32 | ClickTime |
u32 | HoverTime |
u32 | FocusTime |
bool | ClickShiftState |
bool | ClickControlState |
bool | IsPushButton |
bool | Pressed |
bool | UseAlphaChannel |
bool | DrawBorder |
bool | ScaleImage |
video::SColor | Colors [4] |
bool | WasHovered = false |
ISimpleTextureSource * | TSrc |
gui::IGUIStaticText * | StaticText |
core::rect< s32 > | BgMiddle |
core::rect< s32 > | Padding |
core::vector2d< s32 > | ContentOffset |
video::SColor | BgColor |
GUIButton::GUIButton | ( | gui::IGUIEnvironment * | environment, |
gui::IGUIElement * | parent, | ||
s32 | id, | ||
core::rect< s32 > | rectangle, | ||
ISimpleTextureSource * | tsrc, | ||
bool | noclip = false |
||
) |
constructor
References Colors, and StaticText.
Referenced by addButton().
|
virtual |
destructor
References OverrideFont, and SpriteBank.
|
static |
Do not drop returned handle.
References GUIButton(), and setText().
Referenced by GUIFormSpecMenu::parseButton(), GUIConfirmRegistration::regenerateGui(), GUIFormSpecMenu::regenerateGui(), GUIKeyChangeMenu::regenerateGui(), GUIPasswordChange::regenerateGui(), and GUIVolumeChange::regenerateGui().
|
overridevirtual |
Reads attributes of the element.
References IsPushButton, Pressed, setDrawBorder(), setImage(), setPressedImage(), setScaleImage(), and setUseAlphaChannel().
|
overridevirtual |
draws the element and its children
References BgColor, BgMiddle, ButtonImages, ClickTime, Colors, draw2DImage9Slice(), DrawBorder, drawSprite(), FocusTime, getImageState(), HoverTime, isHovered(), Pressed, ScaleImage, setFromState(), SpriteBank, UseAlphaChannel, and WasHovered.
|
protected |
References ButtonSprites, GUIButton::ButtonSprite::Color, porting::getTimeMs(), GUIButton::ButtonSprite::Loop, and SpriteBank.
Referenced by draw().
|
virtual |
Sets if the button text should use the override color or the color in the gui skin.
References OverrideColorEnabled.
|
overridevirtual |
Get the font which is used right now for drawing.
References OverrideFont.
Referenced by GUIButtonItemImage::GUIButtonItemImage().
|
inlinevirtual |
Get if the control key was pressed in last EGET_BUTTON_CLICKED event.
|
inlinevirtual |
Get if the shift key was pressed in last EGET_BUTTON_CLICKED event.
|
protected |
|
protected |
|
virtual |
Gets the override color.
References OverrideColor.
|
overridevirtual |
Gets the override font (if any)
References OverrideFont.
|
virtual |
Get the sprite color for the given state. Color is only used when a sprite is set.
References ButtonSprites.
|
virtual |
Get the sprite-index for the given state or -1 when no sprite is set.
References ButtonSprites.
|
virtual |
Returns if the sprite in the given state does loop.
References ButtonSprites.
|
virtual |
Returns if the sprite in the given state is scaled.
References ButtonSprites.
|
inlineprotected |
Referenced by setFromStyle(), and GUIButtonImage::setFromStyle().
|
overridevirtual |
Checks if the alpha channel should be used for drawing images on the button.
Returns if the alpha channel should be used for drawing images on the button.
References UseAlphaChannel.
|
overridevirtual |
Checks if the button face and border are being drawn.
References DrawBorder.
bool GUIButton::isHovered | ( | ) | const |
Returns if this element (or one of its direct children) is hovered.
Referenced by draw(), getImageState(), and setFromState().
|
virtual |
Checks if an override color is enabled.
References OverrideColorEnabled.
|
overridevirtual |
Returns if the button is currently pressed.
References Pressed.
Referenced by setFromState(), and setFromStyle().
|
overridevirtual |
Checks whether the button is a push button.
Returns whether the button is a push button.
References IsPushButton.
Referenced by setIsPushButton().
|
overridevirtual |
Checks whether the button scales the used images.
Returns whether the button scale the used images.
References ScaleImage.
Referenced by GUIButtonImage::GUIButtonImage().
|
overridevirtual |
called if an event happened.
References ClickControlState, ClickShiftState, FocusTime, porting::getTimeMs(), HoverTime, IsPushButton, Pressed, and setPressed().
|
overridevirtual |
Writes attributes of the element.
References ButtonImages, ButtonSprites, GUIButton::ButtonSprite::Color, DrawBorder, GUIButton::ButtonSprite::Index, IsPushButton, GUIButton::ButtonSprite::Loop, Pressed, GUIButton::ButtonSprite::Scale, ScaleImage, GUIButton::ButtonImage::SourceRect, GUIButton::ButtonImage::Texture, and UseAlphaChannel.
void GUIButton::setColor | ( | video::SColor | color | ) |
References BgColor, and Colors.
Referenced by setFromStyle().
|
overridevirtual |
Sets if the button should use the skin to draw its border.
References DrawBorder.
Referenced by deserializeAttributes(), and setFromStyle().
void GUIButton::setFromState | ( | ) |
Set element properties from a StyleSpec corresponding to the button state.
References StyleSpec::getStyleFromStatePropagation(), isHovered(), isPressed(), setFromStyle(), StyleSpec::STATE_DEFAULT, StyleSpec::STATE_HOVERED, StyleSpec::STATE_PRESSED, and Styles.
Referenced by draw(), setPressed(), and setStyles().
|
virtual |
Set element properties from a StyleSpec.
Reimplemented in GUIButtonImage.
References StyleSpec::ALPHA, BgColor, StyleSpec::BGCOLOR, StyleSpec::BGIMG, StyleSpec::BGIMG_MIDDLE, BgMiddle, StyleSpec::BORDER, COLOR_HOVERED_MOD, COLOR_PRESSED_MOD, Colors, StyleSpec::CONTENT_OFFSET, ContentOffset, StyleSpec::getBool(), StyleSpec::getColor(), StyleSpec::getFont(), StyleSpec::getRect(), StyleSpec::getState(), StyleSpec::getTexture(), getTextureSource(), StyleSpec::getVector2i(), guiScalingImageButton(), StyleSpec::isNotDefault(), isPressed(), multiplyColorValue(), StyleSpec::NOCLIP, OverrideColorEnabled, Padding, StyleSpec::PADDING, setColor(), setDrawBorder(), setImage(), setOverrideColor(), setOverrideFont(), setScaleImage(), setUseAlphaChannel(), StyleSpec::STATE_HOVERED, StyleSpec::STATE_PRESSED, Styles, and StyleSpec::TEXTCOLOR.
Referenced by setFromState(), and GUIButtonImage::setFromStyle().
|
virtual |
Sets an image which should be displayed on the button when it is in the given state.
Referenced by deserializeAttributes(), setFromStyle(), setImage(), and setPressedImage().
|
overridevirtual |
Sets an image which should be displayed on the button when it is in normal state.
References setImage().
|
overridevirtual |
Sets an image which should be displayed on the button when it is in normal state.
References setImage().
|
overridevirtual |
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.
References isPushButton(), and IsPushButton.
|
virtual |
Sets another color for the button text.
Sets another color for the text.
References OverrideColor, OverrideColorEnabled, and StaticText.
Referenced by setFromStyle().
|
overridevirtual |
sets another skin independent font. if this is set to zero, the button uses the font of the skin.
References OverrideFont, and StaticText.
Referenced by setFromStyle().
|
overridevirtual |
Sets the pressed state of the button if this is a pushbutton.
References ClickTime, porting::getTimeMs(), Pressed, and setFromState().
Referenced by OnEvent().
|
overridevirtual |
Sets an image which should be displayed on the button when it is in pressed state.
References setImage().
|
overridevirtual |
Sets an image which should be displayed on the button when it is in pressed state.
References setImage().
Referenced by deserializeAttributes().
|
overridevirtual |
Sets if the button should scale the button images to fit.
Sets if the images should be scaled to fit the button.
Reimplemented in GUIButtonImage.
References ScaleImage.
Referenced by deserializeAttributes(), setFromStyle(), and GUIButtonImage::setScaleImage().
|
virtual |
Sets the animated sprite for a specific button state.
index | Number of the sprite within the sprite bank, use -1 for no sprite |
state | State of the button to set the sprite for |
index | The sprite number from the current sprite bank |
color | The color of the sprite |
References ButtonSprites.
|
overridevirtual |
Sets the sprite bank used by the button.
References SpriteBank.
void GUIButton::setStyles | ( | const std::array< StyleSpec, StyleSpec::NUM_STATES > & | styles | ) |
Set the styles used for each state.
References setFromState(), and Styles.
Referenced by GUIFormSpecMenu::parseButton(), GUIFormSpecMenu::parseImageButton(), and GUIFormSpecMenu::parseItemImageButton().
|
overridevirtual |
Sets the text displayed by the button.
References StaticText.
Referenced by addButton(), GUIButtonImage::addButton(), and GUIButtonItemImage::addButton().
|
overridevirtual |
Sets if the alpha channel should be used for drawing images on the button (default is false)
References UseAlphaChannel.
Referenced by deserializeAttributes(), and setFromStyle().
|
private |
Referenced by draw(), setColor(), and setFromStyle().
|
private |
Referenced by draw(), and setFromStyle().
|
private |
Referenced by draw(), getImageState(), and serializeAttributes().
|
private |
Referenced by drawSprite(), getSpriteColor(), getSpriteIndex(), getSpriteLoop(), getSpriteScale(), serializeAttributes(), and setSprite().
|
private |
Referenced by OnEvent().
|
private |
Referenced by OnEvent().
|
private |
Referenced by draw(), and setPressed().
|
private |
Referenced by GUIButton(), draw(), setColor(), and setFromStyle().
|
private |
Referenced by setFromStyle().
|
private |
Referenced by draw(), isDrawingBorder(), serializeAttributes(), and setDrawBorder().
|
private |
Referenced by deserializeAttributes(), isPushButton(), OnEvent(), serializeAttributes(), and setIsPushButton().
|
private |
Referenced by getOverrideColor(), and setOverrideColor().
|
private |
Referenced by enableOverrideColor(), isOverrideColorEnabled(), setFromStyle(), and setOverrideColor().
|
private |
Referenced by ~GUIButton(), getActiveFont(), getOverrideFont(), and setOverrideFont().
|
private |
Referenced by setFromStyle().
|
private |
Referenced by deserializeAttributes(), draw(), isPressed(), OnEvent(), serializeAttributes(), and setPressed().
|
private |
Referenced by draw(), isScalingImage(), serializeAttributes(), and setScaleImage().
|
private |
Referenced by ~GUIButton(), draw(), drawSprite(), and setSpriteBank().
|
private |
Referenced by GUIButton(), setOverrideColor(), setOverrideFont(), and setText().
|
private |
Referenced by setFromState(), setFromStyle(), and setStyles().
|
private |
|
private |
Referenced by draw(), isAlphaChannelUsed(), serializeAttributes(), and setUseAlphaChannel().
|
private |
Referenced by draw().