TGUI  0.7.8
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 ()
 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::Button, tgui::ChatBox, tgui::ChildWindow, tgui::ComboBox, tgui::EditBox, tgui::Knob, tgui::Label, tgui::ListBox, tgui::ProgressBar, tgui::RadioButton, tgui::Slider, tgui::SpinButton, and tgui::TextBox.

◆ 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 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

◆ move() [2/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

◆ scale() [1/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);
virtual sf::Vector2f getSize() const
Returns the size of the widget.
Definition: Transformable.hpp:221

◆ scale() [2/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});

◆ setPosition() [1/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);
TGUI_API Layout bindBottom(std::shared_ptr< Widget > widget)
Bind to the bottom of the widget.
TGUI_API Layout bindLeft(std::shared_ptr< Widget > widget)
Bind to the x position of the widget.

◆ setPosition() [2/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::Widget, tgui::Button, tgui::Canvas, tgui::ChildWindow, tgui::ComboBox, tgui::EditBox, tgui::Knob, tgui::Label, tgui::ListBox, tgui::MenuBar, tgui::Picture, tgui::ProgressBar, tgui::RadioButton, tgui::Scrollbar, tgui::Slider, tgui::SpinButton, tgui::Tab, tgui::TextBox, tgui::Widget, tgui::Button, tgui::Canvas, tgui::ChildWindow, tgui::ComboBox, tgui::EditBox, tgui::Knob, tgui::Label, tgui::ListBox, tgui::MenuBar, tgui::Picture, tgui::ProgressBar, tgui::RadioButton, tgui::Scrollbar, tgui::Slider, tgui::SpinButton, tgui::Tab, and tgui::TextBox.

◆ setSize() [1/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);
TGUI_API Layout bindWidth(std::shared_ptr< Widget > widget)
Bind to the width of the widget.
TGUI_API Layout bindHeight(std::shared_ptr< Widget > widget)
Bind to the height of the widget.

◆ setSize() [2/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});
TGUI_API Layout2d bindSize(std::shared_ptr< Widget > widget)
Bind to the size of the widget.

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


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