TGUI  v0.7.5
tgui::Transformable Class Reference
Inheritance diagram for tgui::Transformable:
tgui::Widget tgui::ChatBox tgui::ClickableWidget tgui::ComboBox tgui::Container tgui::Knob tgui::ListBox tgui::MenuBar tgui::Scrollbar tgui::Slider tgui::Tab tgui::TextBox

Public Member Functions

virtual ~Transformable ()=default
 Virtual destructor.
 
virtual void setPosition (const Layout2d &position)
 set the position of the widget More...
 
void setPosition (const Layout &x, const Layout &y)
 set the position of the widget More...
 
sf::Vector2f getPosition () const
 get the position of the widget More...
 
void move (const Layout2d &offset)
 Move the widget by a given offset. More...
 
void move (const Layout &x, const Layout &y)
 Move the widget by a given offset. More...
 
virtual void setSize (const Layout2d &size)
 Changes the size of the widget. More...
 
void setSize (const Layout &width, const Layout &height)
 Changes the size of the widget. More...
 
virtual sf::Vector2f getSize () const
 Returns the size of the widget. More...
 
virtual sf::Vector2f getFullSize () const
 Returns the entire size that the widget is using. More...
 
void scale (const Layout2d &factors)
 Scale the widget. More...
 
void scale (const Layout &x, const Layout &y)
 Scale the widget. More...
 

Member Function Documentation

◆ getFullSize()

virtual sf::Vector2f tgui::Transformable::getFullSize ( ) const
inlinevirtual

Returns the entire size that the widget is using.

This function will return a value equal or greater than what getSize returns. If the widget would e.g. have borders around it then this function will return the size, including these borders.

Returns
Full size of the widget

Reimplemented in tgui::ListBox, tgui::Label, tgui::EditBox, tgui::ChildWindow, tgui::ComboBox, tgui::TextBox, tgui::ProgressBar, tgui::ChatBox, tgui::RadioButton, tgui::Button, tgui::Slider, tgui::SpinButton, and tgui::Knob.

◆ getPosition()

sf::Vector2f tgui::Transformable::getPosition ( ) const
inline

get the position of the widget

Returns
Current position
See also
setPosition

◆ getSize()

virtual sf::Vector2f tgui::Transformable::getSize ( ) const
inlinevirtual

Returns the size of the widget.

Returns
Size of the widget

Reimplemented in tgui::Grid, and tgui::Tab.

◆ move() [1/2]

void tgui::Transformable::move ( const Layout2d offset)

Move the widget by a given offset.

This function adds to the current position of the widget, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

widget.setPosition(widget.getPosition() + offset);
Parameters
offsetOffset
See also
setPosition

◆ move() [2/2]

void tgui::Transformable::move ( const Layout x,
const Layout y 
)

Move the widget by a given offset.

This function adds to the current position of the widget, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

widget.setPosition(widget.getPosition().x + x, widget.getPosition().y + y);
Parameters
xHorizontal offset
yVertical offset
See also
setPosition

◆ scale() [1/2]

void tgui::Transformable::scale ( const Layout2d factors)

Scale the widget.

Parameters
factorsScale factors

This function multiplies the current size of the widget with the given scale factors. Thus, it is equivalent to the following code:

widget.setSize({getSize().x * factors.x, getSize().y * factors.y});

◆ scale() [2/2]

void tgui::Transformable::scale ( const Layout x,
const Layout y 
)

Scale the widget.

Parameters
xhorizontal scale factor
yvertical scale factor

This function multiplies the current size of the widget with the given scale factors. Thus, it is equivalent to the following code:

widget.setSize(getSize().x * factors.x, getSize().y * factors.y);

◆ setPosition() [1/2]

virtual void tgui::Transformable::setPosition ( const Layout2d position)
virtual

set the position of the widget

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable widget is (0, 0).

Parameters
positionNew position
See also
move, getPosition

Usage examples:

// Place the widget on an exact position
widget->setPosition({40, 30});
// Place the widget 50 pixels below another widget
widget->setPosition(otherWidget->getPosition() + sf::Vector2f{0, otherWidget->getSize().y + 50});
// Place the widget 50 pixels below another widget and automatically move it when the other widget moves
widget->setPosition({tgui::bindLeft(otherWidget), tgui::bindBottom(otherWidget) + 50});

Reimplemented in tgui::Picture, tgui::Widget, tgui::ListBox, tgui::EditBox, tgui::ChildWindow, tgui::Label, tgui::ComboBox, tgui::TextBox, tgui::ProgressBar, tgui::Canvas, tgui::RadioButton, tgui::Button, tgui::Slider, tgui::SpinButton, tgui::MenuBar, tgui::Knob, tgui::Scrollbar, and tgui::Tab.

◆ setPosition() [2/2]

void tgui::Transformable::setPosition ( const Layout x,
const Layout y 
)
inline

set the position of the widget

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable widget is (0, 0).

Parameters
xNew x coordinate
yNew y coordinate
See also
move, getPosition

Usage examples:

// Place the widget on an exact position
widget->setPosition(40, 30);
// Place the widget 50 pixels below another widget
widget->setPosition(otherWidget->getPosition().x, otherWidget->getPosition().y + otherWidget->getSize().y + 50);
// Place the widget 50 pixels below another widget and automatically move it when the other widget moves
widget->setPosition(tgui::bindLeft(otherWidget), tgui::bindBottom(otherWidget) + 50);

◆ setSize() [1/2]

virtual void tgui::Transformable::setSize ( const Layout2d size)
virtual

Changes the size of the widget.

Parameters
sizeSize of the widget

Usage examples:

// Give the widget an exact size
widget->setSize({40, 30});
// Make the widget 50 pixels higher than some other widget
widget->setSize(otherWidget->getSize() + sf::Vector2f{0, 50});
// Make the widget 50 pixels higher than some other widget and automatically resize it when the other widget resizes
widget->setSize(tgui::bindSize(otherWidget) + sf::Vector2f{0, 50});

Reimplemented in tgui::Picture, tgui::Widget, tgui::ListBox, tgui::Label, tgui::EditBox, tgui::ChildWindow, tgui::ComboBox, tgui::TextBox, tgui::ProgressBar, tgui::ChatBox, tgui::Canvas, tgui::Grid, tgui::Tab, tgui::RadioButton, tgui::Button, tgui::MenuBar, tgui::Slider, tgui::SpinButton, tgui::Knob, tgui::Scrollbar, and tgui::BoxLayout.

◆ setSize() [2/2]

void tgui::Transformable::setSize ( const Layout width,
const Layout height 
)
inline

Changes the size of the widget.

Parameters
widthWidth of the widget
heightHeight of the widget

Usage examples:

// Give the widget an exact size
widget->setSize(40, 30);
// Make the widget 50 pixels higher than some other widget
widget->setSize(otherWidget->getSize().x, otherWidget->getSize().y + 50);
// Make the widget 50 pixels higher than some other widget and automatically resize it when the other widget resizes
widget->setSize(tgui::bindWidth(otherWidget), tgui::bindHeight(otherWidget) + 50);

The documentation for this class was generated from the following file: