28#include <TGUI/Widget.hpp>
29#include <TGUI/Renderers/TabsRenderer.hpp>
30#include <TGUI/Text.hpp>
34TGUI_MODULE_EXPORT
namespace tgui
46 using Ptr = std::shared_ptr<Tabs>;
49 static constexpr const char StaticWidgetType[] =
"Tabs";
58 Tabs(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
81 TGUI_NODISCARD
const TabsRenderer* getSharedRenderer()
const override;
101 using Widget::setSize;
141 std::size_t
add(
const String& text,
bool select =
true);
150 void insert(std::size_t index,
const String& text,
bool select =
true);
349 void mouseMoved(
Vector2f pos)
override;
354 void mouseNoLongerOnWidget()
override;
381 void recalculateTabsWidth();
386 void updateTextColors();
398 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
403 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
423 float m_maximumTabWidth = 0;
424 float m_minimumTabWidth = 0;
425 int m_selectedTab = -1;
426 int m_hoveringTab = -1;
427 bool m_autoSize =
true;
436 std::vector<Tab> m_tabs;
440 Sprite m_spriteSelectedTab;
441 Sprite m_spriteSelectedTabHover;
442 Sprite m_spriteDisabledTab;
446 Color m_borderColorCached;
447 Color m_borderColorHoverCached;
448 Color m_selectedBorderColorCached;
449 Color m_selectedBorderColorHoverCached;
450 Color m_backgroundColorCached;
451 Color m_backgroundColorHoverCached;
452 Color m_backgroundColorDisabledCached;
453 Color m_selectedBackgroundColorCached;
454 Color m_selectedBackgroundColorHoverCached;
455 Color m_textColorCached;
456 Color m_textColorHoverCached;
457 Color m_textColorDisabledCached;
458 Color m_selectedTextColorCached;
459 Color m_selectedTextColorHoverCached;
460 float m_distanceToSideCached = 0;
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Wrapper for colors.
Definition Color.hpp:73
Class to store the position or size of a widget.
Definition Layout.hpp:323
Definition Outline.hpp:38
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Wrapper class to store strings.
Definition String.hpp:96
Definition TabsRenderer.hpp:35
Tabs widget.
Definition Tabs.hpp:43
void setAutoSize(bool autoSize)
Changes whether the tabs are auto-sized or not.
static Tabs::Ptr create()
Creates a new tabs widget.
std::size_t add(const String &text, bool select=true)
Adds a new tab.
TabsRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
void insert(std::size_t index, const String &text, bool select=true)
Inserts a new tab somewhere between the other tabs.
bool select(std::size_t index)
Selects the tab with a given index.
bool getTabEnabled(std::size_t index) const
Returns whether the tab is enabled or disabled.
void setTabEnabled(std::size_t index, bool enabled)
Changes whether a tab is enabled.
void setEnabled(bool enabled) override
Enables or disables the widget.
void updateTextSize() override
Called when the text size is changed (either by setTextSize or via the renderer)
String getSelected() const
Gets the text that is drawn on the currently selected tab.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
bool select(const String &text)
Selects the tab with a given text.
bool changeText(std::size_t index, const String &text)
Changes the text of one of the tabs.
std::shared_ptr< const Tabs > ConstPtr
Shared constant widget pointer.
Definition Tabs.hpp:47
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
static Tabs::Ptr copy(const Tabs::ConstPtr &tab)
Makes a copy of another tab.
float getMinimumTabWidth() const
Returns the minimum tab width of the tabs.
void setMaximumTabWidth(float maximumWidth)
Changes the maximum tab width of the tabs.
bool remove(std::size_t index)
Removes a tab with a given index.
int getHoveredIndex() const
Gets the index of the tab below the mouse cursor.
void deselect()
Deselects the selected tab.
std::shared_ptr< Tabs > Ptr
Shared widget pointer.
Definition Tabs.hpp:46
Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
TabsRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void setTabHeight(float height)
Changes the height of the tabs.
void setMinimumTabWidth(float minimumWidth)
Changes the minimum tab width of the tabs.
void setSize(const Layout2d &size) override
Changes the area used by the tabs.
int getSelectedIndex() const
Gets the index of the currently selected tab.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
bool leftMousePressed(Vector2f pos) override
Called by the parent when the left mouse button goes down on top of the widget.
bool getAutoSize() const
Returns whether the tabs are auto-sized or not.
std::size_t getTabsCount() const
Returns the amount of tabs.
bool remove(const String &text)
Removes a tab with a given text.
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 removeAll()
Removes all tabs.
void setTabVisible(std::size_t index, bool visible)
Changes whether a tab is visible.
bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
String getText(std::size_t index) const
Gets the text of one of the tabs.
bool getTabVisible(std::size_t index) const
Returns whether the tab is shown or hidden.
float getMaximumTabWidth() const
Returns the maximum tab width of the tabs.
Backend-independent wrapper around the backend-specific text class.
Definition Text.hpp:48
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
States used for drawing.
Definition RenderStates.hpp:38