Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ime::ui::TabsContainer Class Reference

A widget which acts as a container for Tabs widget. More...

#include <TabsContainer.h>

Inheritance diagram for ime::ui::TabsContainer:
ime::ui::Widget ime::ITransformable

Public Types

using Ptr = std::shared_ptr< TabsContainer >
 Shared widget pointer. More...
 
using ConstPtr = std::shared_ptr< const TabsContainer >
 const shared widget pointer More...
 

Public Member Functions

 TabsContainer (const TabsContainer &)
 Copy constructor. More...
 
TabsContaineroperator= (const TabsContainer &)
 Copy assignment operator. More...
 
 TabsContainer (TabsContainer &&) noexcept
 Move constructor. More...
 
TabsContaineroperator= (TabsContainer &&) noexcept
 Move assignment operator. More...
 
TabsContainer::Ptr copy () const
 Create a copy of this widget. More...
 
TabsRenderer::Ptr getRenderer ()
 Get the tabs renderer. More...
 
const TabsRenderer::Ptr getRenderer () const
 
void setTabsHeight (float height)
 Set the height of the tabs part of the widget. More...
 
void addPanel (Panel::Ptr panel, const std::string &text, bool select=true)
 Add a panel. More...
 
bool insertPanel (Panel::Ptr panel, const std::string &text, std::size_t index, bool select=true)
 Insert a panel between other panels. More...
 
void removePanel (Panel::Ptr panel)
 Remove a panel from the container. More...
 
void select (std::size_t index)
 Select a panel. More...
 
std::size_t getPanelCount () const
 Get the number of panel in the container. More...
 
int getIndex (Panel::Ptr panel)
 Get the index of a given panel. More...
 
Panel::Ptr getSelected ()
 Get the currently selected panel. More...
 
int getSelectedIndex () const
 Get the index of the currently selected panel. More...
 
Panel::Ptr getPanel (int index)
 Get a panel with a given index. More...
 
std::string getTabText (std::size_t index) const
 Get the text of a container. More...
 
bool changeTabText (std::size_t index, const std::string &text)
 Set the text of a container. More...
 
Widget::Ptr clone () const override
 Make a copy of the widget. More...
 
std::string getWidgetType () const override
 Get the type of the container. More...
 
 ~TabsContainer () override
 Destructor. More...
 
void setRenderer (IWidgetRenderer::Ptr renderer)
 Set the widgets renderer. More...
 
void setPosition (float x, float y) override
 Set the position of the widget. More...
 
void setPosition (Vector2f position) override
 Set the position of the widget. More...
 
void setPosition (const std::string &x, const std::string &y)
 Set the position of the widget relative to the size of its parent. More...
 
Vector2f getPosition () const override
 Get the position of the widget. More...
 
Vector2f getAbsolutePosition () const
 Get the absolute position of the widget. More...
 
void setRotation (float angle) override
 Set the orientation of the widget. More...
 
void rotate (float angle) override
 Rotate the widget. More...
 
float getRotation () const override
 Get the orientation of the widget. More...
 
void setScale (float factorX, float factorY) override
 Set the scale factors of the widget. More...
 
void setScale (Vector2f scale) override
 Set the scale factor of the widget. More...
 
void scale (float factorX, float factorY) override
 Scale the widget by an offset. More...
 
void scale (Vector2f factor) override
 Scale the widget by an offset. More...
 
Vector2f getScale () const override
 Get the current scale of the widget. More...
 
void setOrigin (float x, float y) override
 Set the local origin of the widget. More...
 
void setOrigin (Vector2f origin) override
 Set the local origin of the widget. More...
 
Vector2f getOrigin () const override
 Get the local origin of the widget. More...
 
void move (float offsetX, float offsetY) override
 Move the widget by a given offset. More...
 
void move (Vector2f offset) override
 Move the widget by a given offset. More...
 
void setTextSize (unsigned int size)
 Set the character size of the text. More...
 
unsigned int getTextSize () const
 Get the character size of the text. More...
 
void setSize (float width, float height)
 Set the size of the widget. More...
 
void setSize (const std::string &width, const std::string &height)
 Set the size of the widget relative to the size of its parent. More...
 
Vector2f getSize () const
 Get the size of the widget. More...
 
Vector2f getAbsoluteSize ()
 Get the absolute size of the widget. More...
 
void setWidth (float width)
 Set the width of the widget. More...
 
void setWidth (const std::string &width)
 Set the width of the widget relative to its parent. More...
 
void setHeight (float height)
 Set the height of the widget. More...
 
void setHeight (const std::string &height)
 Set the height of the widget relative to its parent. More...
 
void setMouseCursor (CursorType cursor)
 Set the mouse cursor that is displayed when the mouse is on top of the widget. More...
 
CursorType getMouseCursor () const
 Get the mouse cursor that is displayed when the mouse is on top of the widget. More...
 
void showWithEffect (ShowAnimationType type, Time duration)
 Show the widget with an animation. More...
 
void hideWithEffect (ShowAnimationType type, Time duration)
 Hide the widget with an animation. More...
 
bool isAnimationPlaying () const
 Check whether or not an animation is currently playing. More...
 
void setVisible (bool visible)
 Show or hide a widget. More...
 
bool isVisible () const
 Check if the widget is visible or not. More...
 
void toggleVisibility ()
 Toggle the visibility of the widget. More...
 
bool isContainer () const
 Check if the widget is a container or not. More...
 
bool contains (float x, float y) const
 Check if coordinates lie inside the widget. More...
 
template<typename... Args>
int on (const std::string &event, Callback< Args... > callback)
 Add an event listener to a widget event. More...
 
bool unsubscribe (const std::string &event, int id)
 Remove an event listener from a widget event. More...
 
const std::shared_ptr< void > getInternalPtr () const
 

Static Public Member Functions

static TabsContainer::Ptr create (const std::string &width="100%", const std::string &height="100%")
 Create a new TabsContainer widget. More...
 

Protected Member Functions

template<typename... Args>
void emit (const std::string &event, Args &&...args)
 Emit a widget event. More...
 
void setAsContainer (bool container)
 Set whether or not the widget is a container. More...
 

Detailed Description

A widget which acts as a container for Tabs widget.

This widget can hold multiple panels which are displayed one panel at a time. The widget uses Tabs to switch between panels

If you are looking for Tabs without a panel, check out the Tabs class

Definition at line 46 of file TabsContainer.h.

Member Typedef Documentation

◆ ConstPtr

using ime::ui::TabsContainer::ConstPtr = std::shared_ptr<const TabsContainer>

const shared widget pointer

Definition at line 49 of file TabsContainer.h.

◆ Ptr

using ime::ui::TabsContainer::Ptr = std::shared_ptr<TabsContainer>

Shared widget pointer.

Definition at line 48 of file TabsContainer.h.

Constructor & Destructor Documentation

◆ TabsContainer() [1/2]

ime::ui::TabsContainer::TabsContainer ( const TabsContainer )

Copy constructor.

◆ TabsContainer() [2/2]

ime::ui::TabsContainer::TabsContainer ( TabsContainer &&  )
noexcept

Move constructor.

◆ ~TabsContainer()

ime::ui::TabsContainer::~TabsContainer ( )
override

Destructor.

Member Function Documentation

◆ addPanel()

void ime::ui::TabsContainer::addPanel ( Panel::Ptr  panel,
const std::string &  text,
bool  select = true 
)

Add a panel.

Parameters
panelPanel to be added
textText for the container
selectTrue to immediately select the panel, otherwise false

The panel is added after the panel that was added during the last call to this function

By default, the panel is selected after being added

◆ changeTabText()

bool ime::ui::TabsContainer::changeTabText ( std::size_t  index,
const std::string &  text 
)

Set the text of a container.

Parameters
indexThe index of the container whose text is to be ste
textThe new text of the container
Returns
True if the text was successfully changed or false if the index is out of bounds

The index of the first container is 0

◆ clone()

Widget::Ptr ime::ui::TabsContainer::clone ( ) const
overridevirtual

Make a copy of the widget.

Returns
A copy of the widget

You should use this function if you don't care about the type of the widget, otherwise use the widgets copy function for copying purposes

Implements ime::ui::Widget.

◆ contains()

bool ime::ui::Widget::contains ( float  x,
float  y 
) const
inherited

Check if coordinates lie inside the widget.

Parameters
xX coordinate to be checked
yY coordinate to be checked
Returns
true if coordinates lie inside the widget, false if coordinates do not lie inside the widget

◆ copy()

TabsContainer::Ptr ime::ui::TabsContainer::copy ( ) const

Create a copy of this widget.

Returns
A copy of this widget
See also
clone

◆ create()

static TabsContainer::Ptr ime::ui::TabsContainer::create ( const std::string &  width = "100%",
const std::string &  height = "100%" 
)
static

Create a new TabsContainer widget.

Parameters
widthWidth of the panel relative to the size of its parent
heightHeight of the panel relative to the size of its parent
Returns
The new TabsContainer
  • The relative size is specified in percentages as shown:
TabsContainer::create({"50%", "20%"});

By default, the new panel is the same size as its parent

◆ emit()

template<typename... Args>
void ime::ui::Widget::emit ( const std::string &  event,
Args &&...  args 
)
inlineprotectedinherited

Emit a widget event.

Parameters
eventName of the event to be emitted
argsArguments to pass to event listeners

This function will invoke all event listeners of the given event

Definition at line 636 of file Widget.h.

◆ getAbsolutePosition()

Vector2f ime::ui::Widget::getAbsolutePosition ( ) const
inherited

Get the absolute position of the widget.

Returns
The absolute position of the widget

Unlike getPosition, this function returns the absolute position of the top-left point of the widget instead of the relative position to its parent

See also
setPosition

◆ getAbsoluteSize()

Vector2f ime::ui::Widget::getAbsoluteSize ( )
inherited

Get the absolute size of the widget.

Returns
The absolute size of the widget

The absolute size includes the size of the widget, the padding, margin and outline thickness

See also
getSize

◆ getIndex()

int ime::ui::TabsContainer::getIndex ( Panel::Ptr  panel)

Get the index of a given panel.

Parameters
panelPanel to get the index for
Returns
The index of the panel or -1 if the panel does not exist in the container

◆ getMouseCursor()

CursorType ime::ui::Widget::getMouseCursor ( ) const
inherited

Get the mouse cursor that is displayed when the mouse is on top of the widget.

Returns
The cursor shown when hovering above the widget

◆ getOrigin()

Vector2f ime::ui::Widget::getOrigin ( ) const
overridevirtualinherited

Get the local origin of the widget.

Returns
Local origin of the widget

Implements ime::ITransformable.

◆ getPanel()

Panel::Ptr ime::ui::TabsContainer::getPanel ( int  index)

Get a panel with a given index.

Parameters
indexThe index of the panel to retrieve
Returns
Panel with the given index or a nullptr if the index is out of bounds

◆ getPanelCount()

std::size_t ime::ui::TabsContainer::getPanelCount ( ) const

Get the number of panel in the container.

Returns
The current number of panels in the container

◆ getPosition()

Vector2f ime::ui::Widget::getPosition ( ) const
overridevirtualinherited

Get the position of the widget.

Returns
Current position of the widget

Implements ime::ITransformable.

◆ getRenderer()

TabsRenderer::Ptr ime::ui::TabsContainer::getRenderer ( )

Get the tabs renderer.

Returns
The tabs renderer

The renderer gives access to functions that determine how the container is displayed. It allows you to manipulate things such as the background colour, border colour etc...

See also
setRenderer

◆ getRotation()

float ime::ui::Widget::getRotation ( ) const
overridevirtualinherited

Get the orientation of the widget.

Returns
Current rotation, in degrees

The rotation is always in the range [0, 360]

Implements ime::ITransformable.

◆ getScale()

Vector2f ime::ui::Widget::getScale ( ) const
overridevirtualinherited

Get the current scale of the widget.

Returns
Current scale of the widget

Implements ime::ITransformable.

◆ getSelected()

Panel::Ptr ime::ui::TabsContainer::getSelected ( )

Get the currently selected panel.

Returns
The panel that is selected or a nullptr if no panel is selected

◆ getSelectedIndex()

int ime::ui::TabsContainer::getSelectedIndex ( ) const

Get the index of the currently selected panel.

Returns
The index of the selected panel or -1 if not panel is selected

◆ getSize()

Vector2f ime::ui::Widget::getSize ( ) const
inherited

Get the size of the widget.

Returns
Current size of the widget

This function only returns the size of the widget (It does not accommodate margin, outline thickness etc ...)

See also
getAbsoluteSize

◆ getTabText()

std::string ime::ui::TabsContainer::getTabText ( std::size_t  index) const

Get the text of a container.

Parameters
indexIndex of the container to get the index of
Returns
The text on the container or an empty string if the index is out of bounds

The index of the first container is 0

◆ getTextSize()

unsigned int ime::ui::Widget::getTextSize ( ) const
inherited

Get the character size of the text.

Returns
The character size of the text

◆ getWidgetType()

std::string ime::ui::TabsContainer::getWidgetType ( ) const
overridevirtual

Get the type of the container.

Returns
The type of the container

Implements ime::ui::Widget.

◆ hideWithEffect()

void ime::ui::Widget::hideWithEffect ( ShowAnimationType  type,
Time  duration 
)
inherited

Hide the widget with an animation.

Parameters
typeType of the animation
durationDuration of the animation

The animation will also be played if the widget currently hidden but it will not be seen

Note
During the animation the position, size and/or opacity opacity may change. Once the animation is done the widget will be back in the state in which it was when this function was called
See also
showWithEffect
isAnimationPlaying

◆ insertPanel()

bool ime::ui::TabsContainer::insertPanel ( Panel::Ptr  panel,
const std::string &  text,
std::size_t  index,
bool  select = true 
)

Insert a panel between other panels.

Parameters
panelPanel to be added
textText for the container
indexIndex where the panel should be inserted
selectTrue to immediately select the panel, otherwise false
Returns
True if the panel was inserted or false if the given index is out of bounds

By default, the panel is selected after successful insertion

Warning
This function os experimental

◆ isAnimationPlaying()

bool ime::ui::Widget::isAnimationPlaying ( ) const
inherited

Check whether or not an animation is currently playing.

Returns
True if an animation is playing, otherwise false
See also
showWithEffect
hideWithEffect

◆ isContainer()

bool ime::ui::Widget::isContainer ( ) const
inherited

Check if the widget is a container or not.

Returns
True if the widget is a container, otherwise false

A container widget is a widget that can store other widgets inside it. Such widgets inherit from IWidget class

◆ isVisible()

bool ime::ui::Widget::isVisible ( ) const
inherited

Check if the widget is visible or not.

Returns
True if the widget is visible or false if hidden

◆ move() [1/2]

void ime::ui::Widget::move ( float  offsetX,
float  offsetY 
)
overridevirtualinherited

Move the widget by a given offset.

Parameters
offsetXHorizontal offset
offsetYVertical offset

This function adds to the current position of the widget, unlike setPosition which overwrites it

See also
setPosition

Implements ime::ITransformable.

◆ move() [2/2]

void ime::ui::Widget::move ( Vector2f  offset)
overridevirtualinherited

Move the widget by a given offset.

Parameters
offsetOffset to apply

This function adds to the current position of the widget, unlike setPosition which overwrites it

See also
setPosition

Implements ime::ITransformable.

◆ on()

template<typename... Args>
int ime::ui::Widget::on ( const std::string &  event,
Callback< Args... >  callback 
)
inlineinherited

Add an event listener to a widget event.

Parameters
eventEvent to add an event listener to
callbackFunction to execute when the event is fired
Returns
The event listeners identification number

The id must if the event listener is to be removed later

See also
unsubscribe

Definition at line 582 of file Widget.h.

◆ operator=() [1/2]

TabsContainer& ime::ui::TabsContainer::operator= ( const TabsContainer )

Copy assignment operator.

◆ operator=() [2/2]

TabsContainer& ime::ui::TabsContainer::operator= ( TabsContainer &&  )
noexcept

Move assignment operator.

◆ removePanel()

void ime::ui::TabsContainer::removePanel ( Panel::Ptr  panel)

Remove a panel from the container.

Parameters
panelPanel to remove

◆ rotate()

void ime::ui::Widget::rotate ( float  angle)
overridevirtualinherited

Rotate the widget.

Parameters
angleAngle of rotation, in degrees

This function adds to the current rotation of the widget, unlike setRotation which overwrites it

See also
setRotation

Implements ime::ITransformable.

◆ scale() [1/2]

void ime::ui::Widget::scale ( float  factorX,
float  factorY 
)
overridevirtualinherited

Scale the widget by an offset.

Parameters
factorXHorizontal scale factor
factorYVertical scale factor

This function multiplies the current scale of the widget, unlike setScale which overwrites it

See also
setScale

Implements ime::ITransformable.

◆ scale() [2/2]

void ime::ui::Widget::scale ( Vector2f  factor)
overridevirtualinherited

Scale the widget by an offset.

Parameters
factorOffset to apply

This function multiplies the current scale of the widget, unlike setScale which overwrites it

See also
setScale

Implements ime::ITransformable.

◆ select()

void ime::ui::TabsContainer::select ( std::size_t  index)

Select a panel.

Parameters
indexIndex of the panel to select

◆ setAsContainer()

void ime::ui::Widget::setAsContainer ( bool  container)
protectedinherited

Set whether or not the widget is a container.

Parameters
containerTrue to flag as container, otherwise false

A container widget is a widget that can store other widgets inside it. Such widgets inherit from IWidget class

All widgets are not containers by default

◆ setHeight() [1/2]

void ime::ui::Widget::setHeight ( const std::string &  height)
inherited

Set the height of the widget relative to its parent.

Parameters
heightNew height

The relative height is given in percentages as shown:

widget->setHeight("10%");

This function sets the height of the widget while keeping the width the same

See also
setSize

◆ setHeight() [2/2]

void ime::ui::Widget::setHeight ( float  height)
inherited

Set the height of the widget.

Parameters
heightNew height of the widget

This function sets the height while keeping the width the same

See also
setSize

◆ setMouseCursor()

void ime::ui::Widget::setMouseCursor ( CursorType  cursor)
inherited

Set the mouse cursor that is displayed when the mouse is on top of the widget.

Parameters
cursorThe cursor to be shown

By default, the arrow cursor is shown

◆ setOrigin() [1/2]

void ime::ui::Widget::setOrigin ( float  x,
float  y 
)
overridevirtualinherited

Set the local origin of the widget.

Parameters
xX coordinate of the new origin
yY coordinate of the new origin

The origin of the widget defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the widget, and ignore all transformations (position, scale, rotation).

The default origin of the widget is (0, 0)

Implements ime::ITransformable.

◆ setOrigin() [2/2]

void ime::ui::Widget::setOrigin ( Vector2f  origin)
overridevirtualinherited

Set the local origin of the widget.

Parameters
originNew origin

The origin of the widget defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the widget, and ignore all transformations (position, scale, rotation).

The default origin of the widget is (0, 0)

Implements ime::ITransformable.

◆ setPosition() [1/3]

void ime::ui::Widget::setPosition ( const std::string &  x,
const std::string &  y 
)
inherited

Set the position of the widget relative to the size of its parent.

Parameters
xNew x coordinate of the widget
yNew y coordinate of the widget

The position is specified in percentages as shown below:

widget->setPosition("5%", "10%");

This function completely overwrites the previous position. Use the move function to apply an offset based on the previous position instead.

The default position of the widget is (0, 0)

See also
move

◆ setPosition() [2/3]

void ime::ui::Widget::setPosition ( float  x,
float  y 
)
overridevirtualinherited

Set the position of the widget.

Parameters
xX coordinate of the new position
yY coordinate of the new position

This function completely overwrites the previous position. use move function to apply an offset based on the previous position instead

The default position of a the widget is (0, 0)

See also
move

Implements ime::ITransformable.

◆ setPosition() [3/3]

void ime::ui::Widget::setPosition ( Vector2f  position)
overridevirtualinherited

Set the position of the widget.

Parameters
positionNew position

This function completely overwrites the previous position. Use the move function to apply an offset based on the previous position instead.

The default position of the widget is (0, 0)

See also
move

Implements ime::ITransformable.

◆ setRenderer()

void ime::ui::Widget::setRenderer ( IWidgetRenderer::Ptr  renderer)
inherited

Set the widgets renderer.

Parameters
rendererThe new renderer

The renderer determines how the widget is displayed.

See also
getRenderer

◆ setRotation()

void ime::ui::Widget::setRotation ( float  angle)
overridevirtualinherited

Set the orientation of the widget.

Parameters
angleNew rotation, in degrees

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead.

The default rotation of the widget is 0

See also
rotate

Implements ime::ITransformable.

◆ setScale() [1/2]

void ime::ui::Widget::setScale ( float  factorX,
float  factorY 
)
overridevirtualinherited

Set the scale factors of the widget.

Parameters
factorXNew horizontal scale factor
factorYNew vertical scale factor

This function completely overwrites the previous scale

See also
scale

Implements ime::ITransformable.

◆ setScale() [2/2]

void ime::ui::Widget::setScale ( Vector2f  scale)
overridevirtualinherited

Set the scale factor of the widget.

Parameters
scaleNew scale

This function completely overwrites the previous scale

See also
scale

Implements ime::ITransformable.

◆ setSize() [1/2]

void ime::ui::Widget::setSize ( const std::string &  width,
const std::string &  height 
)
inherited

Set the size of the widget relative to the size of its parent.

Parameters
widthThe new width of the widget
heightThe new height of the widget

The size is specified in percentages as shown below:

widget->setSize("20%", "5%");

◆ setSize() [2/2]

void ime::ui::Widget::setSize ( float  width,
float  height 
)
inherited

Set the size of the widget.

Parameters
widthThe width of the widget
heightThe height of the widget

◆ setTabsHeight()

void ime::ui::TabsContainer::setTabsHeight ( float  height)

Set the height of the tabs part of the widget.

Parameters
heightNew height of the tabs part of the widget

◆ setTextSize()

void ime::ui::Widget::setTextSize ( unsigned int  size)
inherited

Set the character size of the text.

Parameters
sizeNew character size

◆ setVisible()

void ime::ui::Widget::setVisible ( bool  visible)
inherited

Show or hide a widget.

Parameters
visibleTrue to show or false to hide

If the widget is hidden, it won't receive events (and thus won't send callbacks) nor will it be drawn

The widget is visible by default.

◆ setWidth() [1/2]

void ime::ui::Widget::setWidth ( const std::string &  width)
inherited

Set the width of the widget relative to its parent.

Parameters
widthNew width

The relative width is given in percentages as shown:

widget->setWidth("10%");

This function sets the width of the widget while keeping the height the same

See also
setSize

◆ setWidth() [2/2]

void ime::ui::Widget::setWidth ( float  width)
inherited

Set the width of the widget.

Parameters
widthNew width of the widget

This function sets the width while keeping the height the same

See also
setSize

◆ showWithEffect()

void ime::ui::Widget::showWithEffect ( ShowAnimationType  type,
Time  duration 
)
inherited

Show the widget with an animation.

Parameters
typeType of the animation
durationDuration of the animation

The animation will be played if the widget currently visible

Note
During the animation the position, size and/or opacity opacity may change. Once the animation is done the widget will be back in the state in which it was when this function was called
See also
hideWithEffect
isAnimationPlaying

◆ toggleVisibility()

void ime::ui::Widget::toggleVisibility ( )
inherited

Toggle the visibility of the widget.

This function will hide the widget if its currently visible and vice versa

See also
setVisible

◆ unsubscribe()

bool ime::ui::Widget::unsubscribe ( const std::string &  event,
int  id 
)
inherited

Remove an event listener from a widget event.

Parameters
eventEvent to remove event listener from
idId number of the event listener
Returns
True if the event listener was removed or false if the given event does not exist or the event does not have an event listener with the given id

The id is the number given when the event listener was registered

See also
on

The documentation for this class was generated from the following file:
ime::ui::TabsContainer::create
static TabsContainer::Ptr create(const std::string &width="100%", const std::string &height="100%")
Create a new TabsContainer widget.