TGUI 1.12
Loading...
Searching...
No Matches
Tabs.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2026 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef TGUI_TABS_HPP
26#define TGUI_TABS_HPP
27
28#include <TGUI/Widgets/TabsBase.hpp>
29#include <TGUI/Text.hpp>
30
32
33namespace tgui
34{
43 class TGUI_API Tabs : public TabsBase
44 {
45 public:
46
47 using Ptr = std::shared_ptr<Tabs>;
48 using ConstPtr = std::shared_ptr<const Tabs>;
49
50 static constexpr const char StaticWidgetType[] = "Tabs";
51
59 explicit Tabs(const char* typeName = StaticWidgetType, bool initRenderer = true);
60
66 TGUI_NODISCARD static Tabs::Ptr create();
67
75 TGUI_NODISCARD static Tabs::Ptr copy(const Tabs::ConstPtr& tab);
76
87 void setSize(const Layout2d& size) override;
88 using Widget::setSize;
89
100 void setAutoSize(bool autoSize);
101
107 TGUI_NODISCARD bool getAutoSize() const;
108
117 void setTabHeight(float height);
118
129 void setMaximumTabWidth(float maximumWidth);
130
141 TGUI_NODISCARD float getMaximumTabWidth() const;
142
152 void setMinimumTabWidth(float minimumWidth);
153
163 TGUI_NODISCARD float getMinimumTabWidth() const;
164
168 bool leftMousePressed(Vector2f pos) override;
169
173 void mouseMoved(Vector2f pos) override;
174
181 void draw(BackendRenderTarget& target, RenderStates states) const override;
182
184 protected:
185
187 // Recalculates the size of each tab image.
189 void recalculateTabsSize() override;
190
194 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
195
199 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
200
202 // Makes a copy of the widget
204 TGUI_NODISCARD Widget::Ptr clone() const override;
205
207 protected:
208
209 float m_maximumTabWidth = 0;
210 float m_minimumTabWidth = 0;
211 bool m_autoSize = true;
212
214 };
215
217}
218
220
221#endif // TGUI_TABS_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Class to store the position or size of a widget.
Definition Layout.hpp:321
void setAutoSize(bool autoSize)
Changes whether the tabs are auto-sized or not.
static constexpr const char StaticWidgetType[]
Type name of the widget.
Definition Tabs.hpp:50
static Tabs::Ptr create()
Creates a new tabs widget.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
std::shared_ptr< const Tabs > ConstPtr
Shared constant widget pointer.
Definition Tabs.hpp:48
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.
std::shared_ptr< Tabs > Ptr
Shared widget pointer.
Definition Tabs.hpp:47
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.
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::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
float getMaximumTabWidth() const
Returns the maximum tab width of the tabs.
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:87
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition RenderStates.hpp:38