- sf
- ui
- Label
A label which show text or image
. More...
#include <Label.hpp>
Public Member Functions | |
Label () | |
Creates an empty label. More... | |
Label (sf::Texture const &image) | |
Creates a label-image. More... | |
Label (sf::Font const &font, sf::String const &text, int fontSize=35) | |
Creates a text label. More... | |
virtual void | updateEvent (sf::Event const &event) |
Update the component each time an event has been polled. More... | |
virtual void | updateFixed (sf::Time delta) |
Update the component with the main loop's frequency Can be useful for animation, or time's needed stuff. More... | |
virtual const sf::String & | getText () const |
virtual void | setText (sf::String const &text) |
Sets the text's string of the component Don't forget to set the font. More... | |
virtual const sf::Font * | getFont () const |
virtual void | setFont (sf::Font const &font) |
Sets the font of the component's text. More... | |
virtual unsigned int | getFontSize () const |
virtual void | setFontSize (unsigned int size) |
Set the font's size of the component. More... | |
virtual sf::Color | getFontColor () const |
virtual void | setFontColor (sf::Color color) |
Sets the color's font of the text. More... | |
const sf::Texture * | getImage () const |
void | setImage (sf::Texture const &image) |
Sets the label's image Similar to setTexture(sf::Texture const&) More... | |
virtual sf::Vector2f | getSize () const |
void | updateSize () |
Update the size of the component Call it when you update your texture after it was set, to recalculate the component's size with new texture loaded. More... | |
void | move (sf::Vector2f const &vector) |
Move the component. More... | |
void | move (float x, float y) |
Move the component. More... | |
const sf::Texture * | getTexture () const |
void | setTexture (const sf::Texture &texture) |
Set the texture of the component. More... | |
const sf::Vector2f & | getPosition () const |
void | setPosition (sf::Vector2f const &position) |
Set the component's position. More... | |
void | setPosition (float x, float y) |
Set the component's position. More... | |
void | addObserver (sf::ui::ComponentObserver *observer) |
Add an observer. More... | |
std::set < sf::ui::ComponentObserver * > ::const_iterator | getObserversBegin () const |
std::set < sf::ui::ComponentObserver * > ::const_iterator | getObserversEnd () const |
int | countObservers () |
void | removeObserver (sf::ui::ComponentObserver *observer) |
Remove the observer at the given index. More... | |
void | removeAllObservers () |
Remove all the observers. More... | |
Protected Member Functions | |
virtual void | draw (sf::RenderTarget &target, sf::RenderStates states) const |
Draw the component to the render target. More... | |
virtual void | updateCoord () |
Called when the component need update its geometry Inherit when you need to update some sprite. More... | |
void | triggerEvent (const sf::ui::ComponentEvent &event) |
Triggers the event and notify all observers. More... | |
Protected Attributes | |
sf::Text | m_text |
sf::Sprite | m_sprite |
sf::Texture const * | m_texture |
std::set < sf::ui::ComponentObserver * > | m_observers |
sf::ui::Label::Label | ( | ) |
Creates an empty label.
sf::ui::Label::Label | ( | sf::Texture const & | image | ) |
Creates a label-image.
image | the label's image |
sf::ui::Label::Label | ( | sf::Font const & | font, |
sf::String const & | text, | ||
int | fontSize = 35 |
||
) |
Creates a text label.
font | the text's font |
text | the text's string |
fontSize | the fint's size |
|
inherited |
Add an observer.
|
inherited |
|
protectedvirtual |
Draw the component to the render target.
Reimplemented from sf::ui::Component.
|
virtual |
Implements sf::ui::IText.
|
virtual |
Implements sf::ui::IText.
|
virtual |
Implements sf::ui::IText.
const sf::Texture* sf::ui::Label::getImage | ( | ) | const |
|
inherited |
|
inherited |
|
inherited |
|
virtual |
Reimplemented from sf::ui::Component.
|
virtual |
Implements sf::ui::IText.
|
inherited |
|
inherited |
Move the component.
vector | the move's vector |
|
inherited |
Move the component.
x | the x movement |
y | the y movement |
|
inherited |
Remove all the observers.
|
inherited |
Remove the observer at the given index.
observer | the observer to remove |
|
virtual |
Sets the font of the component's text.
Implements sf::ui::IText.
|
virtual |
|
virtual |
void sf::ui::Label::setImage | ( | sf::Texture const & | image | ) |
Sets the label's image Similar to setTexture(sf::Texture const&)
|
inherited |
Set the component's position.
position | - the position vector |
|
inherited |
Set the component's position.
x | - the x coordinate |
y | - the y coordinate |
|
virtual |
Sets the text's string of the component Don't forget to set the font.
text | the new string of the component |
Implements sf::ui::IText.
|
inherited |
Set the texture of the component.
|
protectedinherited |
Triggers the event and notify all observers.
event | - the event to push |
|
protectedvirtual |
Called when the component need update its geometry Inherit when you need to update some sprite.
Reimplemented from sf::ui::Component.
|
virtual |
Update the component each time an event has been polled.
event | the window's event polled |
Implements sf::ui::Component.
|
virtual |
Update the component with the main loop's frequency Can be useful for animation, or time's needed stuff.
delta | - the time between this update and the last |
Implements sf::ui::Component.
|
inherited |
Update the size of the component Call it when you update your texture after it was set, to recalculate the component's size with new texture loaded.
Example: