30#include <TGUI/Widgets/Label.hpp>
53 typedef std::shared_ptr<Tab>
Ptr;
91 return std::static_pointer_cast<TabRenderer>(m_renderer);
135 return {m_width, m_tabHeight};
161 std::size_t
add(
const sf::String& text,
bool select =
true);
172 void insert(std::size_t index,
const sf::String& text,
bool select =
true);
274 return (m_selectedTab >= 0) ? m_tabTexts[m_selectedTab].getText() :
"";
289 return m_selectedTab;
358 return m_maximumTabWidth;
370 return m_tabTexts.size();
397 virtual bool mouseOnWidget(
float x,
float y)
const override;
402 virtual void leftMousePressed(
float x,
float y)
override;
412 void recalculateTabsWidth();
427 virtual void reload(
const std::string& primary =
"",
const std::string& secondary =
"",
bool force =
false)
override;
435 return std::make_shared<Tab>(*
this);
442 virtual void draw(sf::RenderTarget& target, sf::RenderStates states)
const override;
447 unsigned int m_requestedTextSize = 0;
448 unsigned int m_textSize = 22;
450 float m_maximumTabWidth = 0;
451 int m_selectedTab = -1;
454 float m_tabHeight = 0;
455 std::vector<float> m_tabWidth;
457 std::vector<Label> m_tabTexts;
490 virtual void setProperty(std::string property,
const std::string& value)
override;
613 void draw(sf::RenderTarget& target, sf::RenderStates states)
const;
622 virtual std::shared_ptr<WidgetRenderer> clone(
Widget* widget)
override;
632 std::vector<Texture> m_texturesNormal;
633 std::vector<Texture> m_texturesSelected;
635 sf::Color m_textColor;
636 sf::Color m_selectedTextColor;
638 sf::Color m_backgroundColor;
639 sf::Color m_selectedBackgroundColor;
641 sf::Color m_borderColor;
644 float m_distanceToSide = 5;
Implicit converter for colors.
Definition: Color.hpp:40
Class to store the position or size of a widget.
Definition: Layout.hpp:255
Implicit converter for settable properties.
Definition: ObjectConverter.hpp:43
TabRenderer(Tab *tab)
Constructor.
Definition: Tab.hpp:477
void setSelectedTextColor(const Color &color)
Set the text color that will be used for the selected tab.
void setSelectedTexture(const Texture &texture)
Change the image that is displayed when the tab is selected.
void setNormalTexture(const Texture &texture)
Change the image that is displayed when the tab is not selected.
void setBorderColor(const Color &color)
Set the color of the borders.
virtual void setProperty(std::string property, const std::string &value) override
Change a property of the renderer.
virtual std::map< std::string, ObjectConverter > getPropertyValuePairs() const override
Get a map with all properties and their values.
void setSelectedBackgroundColor(const Color &color)
Set the background color of the selected tab.
void setBackgroundColor(const Color &color)
Set the background color of the tabs.
virtual void setProperty(std::string property, ObjectConverter &&value) override
Change a property of the renderer.
void setDistanceToSide(float distanceToSide)
Changes the distance between the text and the side of the tab.
virtual ObjectConverter getProperty(std::string property) const override
Retrieve the value of a certain property.
void setTextColor(const Color &color)
Set the text color that will be used inside the tabs.
Tab widget.
Definition: Tab.hpp:50
void insert(std::size_t index, const sf::String &text, bool select=true)
Insert a new tab somewhere between the other tabs.
virtual void setFont(const Font &font) override
Changes the font of the text in the widget.
std::size_t getTabsCount() const
Returns the amount of tabs.
Definition: Tab.hpp:368
sf::String getSelected() const
Get the text that is drawn on the currently selected tab.
Definition: Tab.hpp:272
void setMaximumTabWidth(float maximumWidth)
Changes the maximum tab width of the tabs.
void select(const sf::String &text)
Selects the tab with a given text.
void remove(const sf::String &text)
Removes a tab with a given text.
virtual sf::Vector2f getSize() const override
Returns the size of the tabs.
Definition: Tab.hpp:133
std::size_t add(const sf::String &text, bool select=true)
Adds a new tab.
virtual void setOpacity(float opacity) override
Changes the opacity of the widget.
static Tab::Ptr create()
Creates a new tabs widget.
void select(std::size_t index)
Selects the tab with a given index.
sf::String getText(std::size_t index) const
Get the text of one of the tabs.
void setTextSize(unsigned int size)
Changes the character size of the text.
void setTabHeight(float height)
Changes the height of the tabs.
void remove(std::size_t index)
Removes a tab with a given index.
std::shared_ptr< const Tab > ConstPtr
Shared constant widget pointer.
Definition: Tab.hpp:54
int getSelectedIndex() const
Get the index of the currently selected tab.
Definition: Tab.hpp:287
float getMaximumTabWidth() const
Returns the maximum tab width of the tabs.
Definition: Tab.hpp:356
std::shared_ptr< TabRenderer > getRenderer() const
Returns the renderer, which gives access to functions that determine how the widget is displayed.
Definition: Tab.hpp:89
unsigned int getTextSize() const
Returns the character size of the text.
static Tab::Ptr copy(Tab::ConstPtr tab)
Makes a copy of another tab.
std::shared_ptr< Tab > Ptr
Shared widget pointer.
Definition: Tab.hpp:53
void deselect()
Deselects the selected tab.
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: Tab.hpp:433
bool changeText(std::size_t index, const sf::String &text)
Change the text of one of the tabs.
float getTabHeight() const
Returns the height of the tabs.
Definition: Tab.hpp:329
virtual void reload(const std::string &primary="", const std::string &secondary="", bool force=false) override
Reload the widget.
void removeAll()
Removes all tabs.
virtual void setSize(const Layout2d &size) override
This function currently does nothing.
virtual void setPosition(const Layout2d &position) override
Set the position of the widget.
virtual sf::Vector2f getWidgetOffset() const override
Returns the distance between the position where the widget is drawn and where the widget is placed.
Definition: Texture.hpp:45
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:34