25#ifndef TGUI_TABS_BASE_HPP
26#define TGUI_TABS_BASE_HPP
28#include <TGUI/Widget.hpp>
29#include <TGUI/Renderers/TabsRenderer.hpp>
30#include <TGUI/Text.hpp>
42 class TGUI_API TabsBase :
public Widget
46 using Ptr = std::shared_ptr<TabsBase>;
47 using ConstPtr = std::shared_ptr<const TabsBase>;
56 explicit TabsBase(
const char* typeName,
bool initRenderer);
238 void rightMousePressed(Vector2f pos)
override;
243 void mouseNoLongerOnWidget()
override;
262 virtual void recalculateTabsSize() = 0;
267 void updateTextColors();
279 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
284 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
300 int m_selectedTab = -1;
301 int m_hoveringTab = -1;
310 std::vector<Tab> m_tabs;
314 Sprite m_spriteSelectedTab;
315 Sprite m_spriteSelectedTabHover;
316 Sprite m_spriteDisabledTab;
319 Borders m_bordersCached;
320 Color m_borderColorCached;
321 Color m_borderColorHoverCached;
322 Color m_selectedBorderColorCached;
323 Color m_selectedBorderColorHoverCached;
324 Color m_backgroundColorCached;
325 Color m_backgroundColorHoverCached;
326 Color m_backgroundColorDisabledCached;
327 Color m_selectedBackgroundColorCached;
328 Color m_selectedBackgroundColorHoverCached;
329 Color m_textColorCached;
330 Color m_textColorHoverCached;
331 Color m_textColorDisabledCached;
332 Color m_selectedTextColorCached;
333 Color m_selectedTextColorHoverCached;
334 float m_distanceToSideCached = 0;
335 float m_roundedBorderRadiusCached = 0;
Wrapper for colors.
Definition Color.hpp:71
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:59
Wrapper class to store strings.
Definition String.hpp:93
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.
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.
SignalString onTabRightClick
Right mouse pressed on a tab. Optional parameter: selected item.
Definition TabsBase.hpp:295
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.
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:47
int getSelectedIndex() const
Gets the index of the currently selected tab.
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...
void removeAll()
Removes all tabs.
std::shared_ptr< TabsBase > Ptr
Shared widget pointer.
Definition TabsBase.hpp:46
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.
SignalString onTabSelect
A tab that was selected. Optional parameter: selected item.
Definition TabsBase.hpp:294
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:36
SignalTyped< const String & > SignalString
Signal with one "String" as optional unbound parameter.
Definition Signal.hpp:426
Definition TabsBase.hpp:304