TGUI  0.9-dev
Inheritance diagram for tgui::Grid:
tgui::Container tgui::Widget

Public Types

enum  Alignment {
  Alignment::Center, Alignment::UpperLeft, Alignment::Up, Alignment::UpperRight,
  Alignment::Right, Alignment::BottomRight, Alignment::Bottom, Alignment::BottomLeft,
  Alignment::Left
}
 The alignment of the widget in its cell. More...
 
typedef std::shared_ptr< GridPtr
 Shared widget pointer.
 
typedef std::shared_ptr< const GridConstPtr
 Shared constant widget pointer.
 
- Public Types inherited from tgui::Container
typedef std::shared_ptr< ContainerPtr
 Shared widget pointer.
 
typedef std::shared_ptr< const ContainerConstPtr
 Shared constant widget pointer.
 
- Public Types inherited from tgui::Widget
typedef std::shared_ptr< WidgetPtr
 Shared widget pointer.
 
typedef std::shared_ptr< const WidgetConstPtr
 Shared constant widget pointer.
 

Public Member Functions

 Grid (const Grid &copy)
 Copy constructor.
 
 Grid (Grid &&copy)
 Move constructor.
 
Gridoperator= (const Grid &right)
 Overload of assignment operator.
 
Gridoperator= (Grid &&right)
 Overload of move assignment operator.
 
void setSize (const Layout2d &size) override
 Changes the size of the grid. More...
 
void setAutoSize (bool autoSize)
 Changes whether the grid is auto-sized or not. More...
 
bool getAutoSize () const
 Returns whether the grid is auto-sized or not. More...
 
bool remove (const Widget::Ptr &widget) override
 Removes a single widget that was added to the container. More...
 
void removeAllWidgets () override
 Removes all widgets that were added to the container. More...
 
void addWidget (const Widget::Ptr &widget, std::size_t row, std::size_t column, Alignment alignment=Alignment::Center, const Padding &padding=Padding{0})
 Adds a widget to the grid. More...
 
Widget::Ptr getWidget (std::size_t row, std::size_t column) const
 Returns the widget in a specific cell of the grid. More...
 
std::map< Widget::Ptr, std::pair< std::size_t, std::size_t > > getWidgetLocations () const
 Returns a list of widgets and the cell they are in. More...
 
void setWidgetPadding (const Widget::Ptr &widget, const Padding &padding=Padding(0, 0, 0, 0))
 Changes padding of a given widget. More...
 
void setWidgetPadding (std::size_t row, std::size_t column, const Padding &padding=Padding(0, 0, 0, 0))
 Changes padding of a widget in a certain cell. More...
 
Padding getWidgetPadding (const Widget::Ptr &widget) const
 Returns the padding around a widget. More...
 
Padding getWidgetPadding (std::size_t row, std::size_t column) const
 Returns the padding around a widget in a specific cell of the grid. More...
 
void setWidgetAlignment (const Widget::Ptr &widget, Alignment alignment=Alignment::Center)
 Changes the alignment of a given widget in its cell. More...
 
void setWidgetAlignment (std::size_t row, std::size_t column, Alignment alignment=Alignment::Center)
 Changes the alignment of a given widget in its cell. More...
 
Alignment getWidgetAlignment (const Widget::Ptr &widget) const
 Returns the alignment of a given widget. More...
 
Alignment getWidgetAlignment (std::size_t row, std::size_t column) const
 Returns the alignment of a given widget in its cell. More...
 
const std::vector< std::vector< Widget::Ptr > > & getGridWidgets () const
 Returns the widgets and their positions in the grid. More...
 
bool mouseOnWidget (Vector2f pos) const override
 Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget. More...
 
void draw (sf::RenderTarget &target, sf::RenderStates states) const override
 Draw the widget to a render target. More...
 
virtual void setSize (const Layout2d &size)
 Changes the size of the widget. More...
 
void setSize (Layout width, Layout height)
 Changes the size of the widget. More...
 
- Public Member Functions inherited from tgui::Container
 Container (const Container &copy)
 Copy constructor.
 
 Container (Container &&copy)
 Move constructor.
 
 ~Container ()
 Destructor.
 
Containeroperator= (const Container &right)
 Overload of copy assignment operator.
 
Containeroperator= (Container &&right)
 Overload of move assignment operator.
 
const std::vector< Widget::Ptr > & getWidgets () const
 Returns a list of all the widgets in this container. More...
 
virtual void add (const Widget::Ptr &widgetPtr, const String &widgetName="")
 Adds a widget to the container. More...
 
Widget::Ptr get (const String &widgetName) const
 Returns a pointer to a widget that was added earlier. More...
 
template<class T >
T::Ptr get (const String &widgetName) const
 Returns a pointer to a widget that was added earlier. More...
 
void uncheckRadioButtons ()
 Unchecks all the radio buttons. More...
 
virtual Vector2f getInnerSize () const
 Returns the space available for widgets inside the container. More...
 
virtual Vector2f getChildWidgetsOffset () const
 Returns the distance between the position of the container and a widget that would be drawn inside this container on relative position (0,0) More...
 
void setTextSize (unsigned int size) override
 Changes the character size of all existing and future child widgets. More...
 
void loadWidgetsFromFile (const String &filename, bool replaceExisting=true)
 Loads the child widgets from a text file. More...
 
void saveWidgetsToFile (const String &filename)
 Saves the child widgets to a text file. More...
 
void loadWidgetsFromStream (std::stringstream &stream, bool replaceExisting=true)
 Loads the child widgets from a string stream. More...
 
void loadWidgetsFromStream (std::stringstream &&stream, bool replaceExisting=true)
 Loads the child widgets from a string stream. More...
 
void saveWidgetsToStream (std::stringstream &stream) const
 Saves the child widgets to a text file. More...
 
void moveWidgetToFront (const Widget::Ptr &widget)
 Places a widget before all other widgets. More...
 
void moveWidgetToBack (const Widget::Ptr &widget)
 Places a widget behind all other widgets. More...
 
bool focusNextWidget ()
 Focuses the next widget in this container. More...
 
bool focusPreviousWidget ()
 Focuses the previous widget in this container. More...
 
void setFocused (bool focused) override
 Focus or unfocus the widget. More...
 
virtual void setSize (const Layout2d &size)
 Changes the size of the widget. More...
 
void setSize (Layout width, Layout height)
 Changes the size of the widget. More...
 
- Public Member Functions inherited from tgui::Widget
 Widget ()
 Default constructor.
 
 Widget (const Widget &)
 Copy constructor.
 
 Widget (Widget &&)
 Move constructor.
 
virtual ~Widget ()
 Destructor.
 
Widgetoperator= (const Widget &)
 Overload of copy assignment operator.
 
Widgetoperator= (Widget &&)
 Move assignment.
 
void setRenderer (std::shared_ptr< RendererData > rendererData)
 Sets a new renderer for the widget. The renderer determines how the widget looks. More...
 
WidgetRenderergetSharedRenderer ()
 Returns the renderer, which gives access to functions that determine how the widget is displayed. More...
 
WidgetRenderergetRenderer ()
 Returns the renderer, which gives access to functions that determine how the widget is displayed. More...
 
virtual void setPosition (const Layout2d &position)
 sets the position of the widget More...
 
void setPosition (Layout x, Layout y)
 Sets the position of the widget. More...
 
Vector2f getPosition () const
 Gets the position of the widget. More...
 
void setSize (Layout width, Layout height)
 Changes the size of the widget. More...
 
Vector2f getSize () const
 Returns the size of the widget. More...
 
virtual Vector2f getFullSize () const
 Returns the entire size that the widget is using. More...
 
virtual Vector2f getAbsolutePosition () const
 Get the absolute position of the widget instead of the relative position to its parent. More...
 
virtual Vector2f getWidgetOffset () const
 Returns the distance between the position where the widget is drawn and where the widget is placed. More...
 
void showWithEffect (ShowAnimationType type, Duration duration)
 Shows the widget by introducing it with an animation. More...
 
void hideWithEffect (ShowAnimationType type, Duration duration)
 Hides the widget by making it leave with an animation. More...
 
virtual void setVisible (bool visible)
 Shows or hides a widget. More...
 
bool isVisible () const
 Returns true when the widget is visible. More...
 
virtual void setEnabled (bool enabled)
 Enables or disables the widget. More...
 
bool isEnabled () const
 Returns true when the widget is enabled. More...
 
bool isFocused () const
 Returns true when the widget is focused and false otherwise. More...
 
const StringgetWidgetType () const
 Returns the type of the widget. More...
 
ContainergetParent () const
 Returns a pointer to the parent widget. More...
 
bool isAnimationPlaying () const
 Returns whether there is an active animation (started with showWithEffect or hideWithEffect) More...
 
void moveToFront ()
 Places the widget before all other widgets. More...
 
void moveToBack ()
 Places the widget behind all other widgets. More...
 
void setUserData (Any userData)
 Stores some data into the widget. More...
 
template<typename T >
getUserData () const
 Returns data stored in the widget. More...
 
void setInheritedFont (const Font &font)
 Sets the font of the widget that is used when no font is set in the renderer. More...
 
const FontgetInheritedFont () const
 Returns the font of the widget that is used when no font is set in the renderer. More...
 
void setInheritedOpacity (float opacity)
 Sets the opacity of the widget that will be multiplied with the opacity set in the renderer. More...
 
float getInheritedOpacity () const
 Returns the opacity of the widget that is multiplied with the opacity set in the renderer. More...
 
virtual unsigned int getTextSize () const
 Returns the character size of text in this widget. More...
 
void setToolTip (Widget::Ptr toolTip)
 Sets the tool tip that should be displayed when hovering over the widget. More...
 
Widget::Ptr getToolTip () const
 Returns the tool tip that is displayed when hovering over the widget. More...
 
void setWidgetName (const String &name)
 Changes the name of a widget. More...
 
String getWidgetName () const
 Returns the name of a widget. More...
 
void setFocusable (bool focusable)
 Changes whether a widget could be focused. More...
 
bool isFocusable () const
 Returns whether a widget could be focused. More...
 
virtual bool canGainFocus () const
 Returns whether the widget can currently gain focus. More...
 
bool isContainer () const
 Returns whether the widget is a container widget or not. More...
 
virtual SignalgetSignal (String signalName)
 Retrieves a signal based on its name. More...
 
template<typename WidgetType >
std::shared_ptr< const WidgetType > cast () const
 Downcast const widget.
 
template<typename WidgetType >
std::shared_ptr< WidgetType > cast ()
 Downcast widget.
 

Static Public Member Functions

static Grid::Ptr create ()
 Creates a new grid widget. More...
 
static Grid::Ptr copy (Grid::ConstPtr grid)
 Makes a copy of another grid. More...
 

Protected Member Functions

std::unique_ptr< DataIO::Node > save (SavingRenderersMap &renderers) const override
 Saves the widget as a tree node in order to save it to a file.
 
void load (const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
 Loads the widget from a tree of nodes.
 
Widget::Ptr clone () const override
 Makes a copy of the widget if you don't know its exact type. More...
 
- Protected Member Functions inherited from tgui::Container
void rendererChanged (const String &property) override
 Function called when one of the properties of the renderer is changed. More...
 
- Protected Member Functions inherited from tgui::Widget
virtual void mouseEnteredWidget ()
 This function is called when the mouse enters the widget.
 
virtual void mouseLeftWidget ()
 This function is called when the mouse leaves the widget.
 

Additional Inherited Members

- Public Attributes inherited from tgui::Widget
SignalVector2f onPositionChange = {"PositionChanged"}
 The position of the widget changed. Optional parameter: new position.
 
SignalVector2f onSizeChange = {"SizeChanged"}
 The size of the widget changed. Optional parameter: new size.
 
Signal onFocus = {"Focused"}
 The widget was focused.
 
Signal onUnfocus = {"Unfocused"}
 The widget was unfocused.
 
Signal onMouseEnter = {"MouseEntered"}
 The mouse entered the widget.
 
Signal onMouseLeave = {"MouseLeft"}
 The mouse left the widget.
 
SignalAnimation onAnimationFinish = {"AnimationFinished"}
 A show or hide animation finished. Optional parameters: animation type, new widget visibility or both.
 

Member Enumeration Documentation

◆ Alignment

enum tgui::Grid::Alignment
strong

The alignment of the widget in its cell.

Where in the cell is the widget located? The widget is centered by default.

Enumerator
Center 

Center the widget in the cell.

UpperLeft 

Draw the widget in the upper left corner of the cell.

Up 

Draw the widget at the upper side of the cell (horizontally centered)

UpperRight 

Draw the widget in the upper right corner of the cell.

Right 

Draw the widget at the right side of the cell (vertically centered)

BottomRight 

Draw the widget in the bottom right corner of the cell.

Bottom 

Draw the widget at the bottom of the cell (horizontally centered)

BottomLeft 

Draw the widget in the bottom left corner of the cell.

Left 

Draw the widget at the left side of the cell (vertically centered)

Member Function Documentation

◆ addWidget()

void tgui::Grid::addWidget ( const Widget::Ptr widget,
std::size_t  row,
std::size_t  column,
Alignment  alignment = Alignment::Center,
const Padding padding = Padding{0} 
)

Adds a widget to the grid.

Parameters
widgetPointer to a fully created widget that will be added to the grid
rowThe row in which the widget should be placed
columnThe column in which the widget should be placed
paddingDistance from the grid cell to the widget (left, top, right, bottom)
alignmentWhere the widget is located in the cell

◆ clone()

Widget::Ptr tgui::Grid::clone ( ) const
inlineoverrideprotectedvirtual

Makes a copy of the widget if you don't know its exact type.

This function should only be used when you don't know the type of the widget. If you know what kind of widget you are copying, you should use the copy function.

Returns
Copy of the widget

Implements tgui::Widget.

◆ copy()

static Grid::Ptr tgui::Grid::copy ( Grid::ConstPtr  grid)
static

Makes a copy of another grid.

Parameters
gridThe other grid
Returns
The new grid

◆ create()

static Grid::Ptr tgui::Grid::create ( )
static

Creates a new grid widget.

Returns
The new grid

◆ draw()

void tgui::Grid::draw ( sf::RenderTarget &  target,
sf::RenderStates  states 
) const
overridevirtual

Draw the widget to a render target.

Parameters
targetRender target to draw to
statesCurrent render states

Reimplemented from tgui::Container.

◆ getAutoSize()

bool tgui::Grid::getAutoSize ( ) const

Returns whether the grid is auto-sized or not.

Returns
Does the size of the grid depend on the widgets inside it?
See also
setAutoSize

◆ getGridWidgets()

const std::vector<std::vector<Widget::Ptr> >& tgui::Grid::getGridWidgets ( ) const

Returns the widgets and their positions in the grid.

Returns
grid of widgets

◆ getWidget()

Widget::Ptr tgui::Grid::getWidget ( std::size_t  row,
std::size_t  column 
) const

Returns the widget in a specific cell of the grid.

Parameters
rowThe row that the widget is in
columnThe column that the widget is in
Returns
The widget inside the given cell, or nullptr when the cell doesn't contain a widget

◆ getWidgetAlignment() [1/2]

Alignment tgui::Grid::getWidgetAlignment ( const Widget::Ptr widget) const

Returns the alignment of a given widget.

Parameters
widgetThe widget to get the alignment from
Returns
The alignment inside the cell, or Grid::Alignment::Center when the widget wasn't part of the grid

◆ getWidgetAlignment() [2/2]

Alignment tgui::Grid::getWidgetAlignment ( std::size_t  row,
std::size_t  column 
) const

Returns the alignment of a given widget in its cell.

Parameters
rowThe row that the widget is in
columnThe column that the widget is in
Returns
The alignment inside the given cell, or Grid::Alignment::Center when the cell doesn't contain a widget

◆ getWidgetLocations()

std::map<Widget::Ptr, std::pair<std::size_t, std::size_t> > tgui::Grid::getWidgetLocations ( ) const

Returns a list of widgets and the cell they are in.

Returns
A mapping of each widget to its row and cell. The first element of the pair is the row while the second element in the pair is the column.

◆ getWidgetPadding() [1/2]

Padding tgui::Grid::getWidgetPadding ( const Widget::Ptr widget) const

Returns the padding around a widget.

Parameters
widgetThe widget to get the padding from
Returns
The padding inside the around the widget, or Padding{0} when the widget wasn't part of the grid

◆ getWidgetPadding() [2/2]

Padding tgui::Grid::getWidgetPadding ( std::size_t  row,
std::size_t  column 
) const

Returns the padding around a widget in a specific cell of the grid.

Parameters
rowThe row that the widget is in
columnThe column that the widget is in
Returns
The padding inside the given cell, or Padding{0} when the cell doesn't contain a widget

◆ mouseOnWidget()

bool tgui::Grid::mouseOnWidget ( Vector2f  pos) const
overridevirtual

Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget.

Returns
Is the mouse on top of the widget?

Implements tgui::Widget.

◆ remove()

bool tgui::Grid::remove ( const Widget::Ptr widget)
overridevirtual

Removes a single widget that was added to the container.

Parameters
widgetPointer to the widget to remove

Reimplemented from tgui::Container.

◆ removeAllWidgets()

void tgui::Grid::removeAllWidgets ( )
overridevirtual

Removes all widgets that were added to the container.

Reimplemented from tgui::Container.

◆ setAutoSize()

void tgui::Grid::setAutoSize ( bool  autoSize)

Changes whether the grid is auto-sized or not.

Parameters
autoSizeShould the size of the grid depend on the widgets inside it?

When the grid is in auto-size mode, size is defined by the widgets that were added to the grid. Otherwise, the size is given and the widgets are positioned to fill the provided size.

The grid is auto-sized by default.

◆ setSize() [1/3]

virtual void tgui::Widget::setSize

Changes the size of the widget.

Parameters
sizeSize of the widget

Usage examples:

// Give the widget an exact size
widget->setSize({40, 30});
// Give the widget a size relative to the size of its parent
widget->setSize({"20%", "5%"});
// Make the widget 50 pixels higher than some other widget and automatically resize it when the other widget resizes
widget->setSize({200, tgui::bindHeight(otherWidget) + 50});

◆ setSize() [2/3]

void tgui::Grid::setSize ( const Layout2d size)
overridevirtual

Changes the size of the grid.

Parameters
sizeNew size of the grid

When this function is called, the grid will no longer be auto-sizing and widgets in the grid will be repositioned to fill the available space.

See also
setAutoSize

Reimplemented from tgui::Container.

◆ setSize() [3/3]

void tgui::Widget::setSize
inline

Changes the size of the widget.

Parameters
widthWidth of the widget
heightHeight of the widget
Warning
This setSize overload must never be used from internal TGUI code or by custom widget implementations

◆ setWidgetAlignment() [1/2]

void tgui::Grid::setWidgetAlignment ( const Widget::Ptr widget,
Alignment  alignment = Alignment::Center 
)

Changes the alignment of a given widget in its cell.

Parameters
widgetThe widget for which the alignment should be changed
alignmentThe new alignment

◆ setWidgetAlignment() [2/2]

void tgui::Grid::setWidgetAlignment ( std::size_t  row,
std::size_t  column,
Alignment  alignment = Alignment::Center 
)

Changes the alignment of a given widget in its cell.

Parameters
rowThe row that the widget is in
columnThe column that the widget is in
alignmentThe new alignment

◆ setWidgetPadding() [1/2]

void tgui::Grid::setWidgetPadding ( const Widget::Ptr widget,
const Padding padding = Padding(0, 0, 0, 0) 
)

Changes padding of a given widget.

Parameters
widgetThe widget to which padding should be added
paddingThe new padding around the widget

◆ setWidgetPadding() [2/2]

void tgui::Grid::setWidgetPadding ( std::size_t  row,
std::size_t  column,
const Padding padding = Padding(0, 0, 0, 0) 
)

Changes padding of a widget in a certain cell.

Parameters
rowThe row that the widget is in
columnThe column that the widget is in
paddingThe new padding around the widget

The documentation for this class was generated from the following file:
TGUI_API Layout bindHeight(Gui &gui)
Bind to the height of the gui view.