25#ifndef TGUI_TABS_BASE_HPP
26#define TGUI_TABS_BASE_HPP
28#include <TGUI/Renderers/TabsRenderer.hpp>
29#include <TGUI/Text.hpp>
30#include <TGUI/Widget.hpp>
42 class TGUI_API TabsBase :
public Widget
45 using Ptr = std::shared_ptr<TabsBase>;
46 using ConstPtr = std::shared_ptr<const TabsBase>;
55 explicit TabsBase(
const char* typeName,
bool initRenderer);
312 void rightMousePressed(Vector2f pos)
override;
317 void mouseNoLongerOnWidget()
override;
336 virtual void recalculateTabsSize() = 0;
341 void updateTextColors();
353 [[nodiscard]] std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
358 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
374 int m_selectedTab = -1;
375 int m_hoveringTab = -1;
385 std::vector<Tab> m_tabs;
389 Sprite m_spriteSelectedTab;
390 Sprite m_spriteSelectedTabHover;
391 Sprite m_spriteDisabledTab;
394 Borders m_bordersCached;
395 Color m_borderColorCached;
396 Color m_borderColorHoverCached;
397 Color m_selectedBorderColorCached;
398 Color m_selectedBorderColorHoverCached;
399 Color m_backgroundColorCached;
400 Color m_backgroundColorHoverCached;
401 Color m_backgroundColorDisabledCached;
402 Color m_selectedBackgroundColorCached;
403 Color m_selectedBackgroundColorHoverCached;
404 Color m_textColorCached;
405 Color m_textColorHoverCached;
406 Color m_textColorDisabledCached;
407 Color m_selectedTextColorCached;
408 Color m_selectedTextColorHoverCached;
409 float m_distanceToSideCached = 0;
410 float m_roundedBorderRadiusCached = 0;
Wrapper for colors.
Definition Color.hpp:63
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:59
Wrapper class to store strings.
Definition String.hpp:94
std::size_t getTabsCount() const
Returns the amount of tabs.
bool getTabEnabled(std::size_t index) const
Returns whether the tab is enabled or disabled.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
bool selectById(const String &id)
Selects the tab with a given id.
Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
void setTabVisible(std::size_t index, bool visible)
Changes whether a tab is visible.
void deselect()
Deselects the selected tab.
bool getTabVisible(std::size_t index) const
Returns whether the tab is shown or hidden.
void updateTextSize() override
Called when the text size is changed (either by setTextSize or via the renderer).
int getHoveredIndex() const
Gets the index of the tab below the mouse cursor.
void setTabId(std::size_t index, const String &id)
Sets a unique id for a tab.
SignalString onTabRightClick
Right mouse pressed on a tab. Optional parameter: selected item.
Definition TabsBase.hpp:369
void setEnabled(bool enabled) override
Enables or disables the widget.
void insert(std::size_t index, const String &text, bool select=true)
Inserts a new tab somewhere between the other tabs.
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.
TabsRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
bool changeTextById(const String &id, const String &text)
Changes the text of one of the tabs.
String getSelected() const
Gets the text that is drawn on the currently selected tab.
std::shared_ptr< const TabsBase > ConstPtr
Shared constant widget pointer.
Definition TabsBase.hpp:46
int getSelectedIndex() const
Gets the index of the currently selected tab.
int getIndexById(const String &id) const
Returns the index of a tab that is uniquely identified by the given id.
bool remove(std::size_t index)
Removes a tab with a given index.
bool changeText(std::size_t index, const String &text)
Changes the text of one of the tabs.
bool remove(const String &text)
Removes a tab with a given text.
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 getTabId(std::size_t index) const
Returns the unique id for a tab.
void removeAll()
Removes all tabs.
std::shared_ptr< TabsBase > Ptr
Shared widget pointer.
Definition TabsBase.hpp:45
bool select(std::size_t index)
Selects the tab with a given index.
void setTabEnabled(std::size_t index, bool enabled)
Changes whether a tab is enabled.
bool select(const String &text)
Selects the tab with a given text.
TabsRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
String getText(std::size_t index) const
Gets the text of one of the tabs.
std::size_t add(const String &text, bool select=true)
Adds a new tab.
String getSelectedId() const
Gets the id assigned to the currently selected tab.
SignalString onTabSelect
A tab that was selected. Optional parameter: selected item.
Definition TabsBase.hpp:368
bool removeById(const String &id)
Removes a tab with a given id.
Definition TabsRenderer.hpp:35
Backend-independent wrapper around the backend-specific text class.
Definition Text.hpp:53
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
SignalTyped< const String & > SignalString
Signal with one "String" as optional unbound parameter.
Definition Signal.hpp:413
Definition TabsBase.hpp:378