TGUI 1.13
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/Text.hpp>
29#include <TGUI/Widgets/TabsBase.hpp>
30
32
33namespace tgui
34{
43 class TGUI_API Tabs : public TabsBase
44 {
45 public:
46 using Ptr = std::shared_ptr<Tabs>;
47 using ConstPtr = std::shared_ptr<const Tabs>;
48
49 static constexpr char StaticWidgetType[] = "Tabs";
50
58 explicit Tabs(const char* typeName = StaticWidgetType, bool initRenderer = true);
59
65 [[nodiscard]] static Tabs::Ptr create();
66
74 [[nodiscard]] static Tabs::Ptr copy(const Tabs::ConstPtr& tab);
75
86 void setSize(const Layout2d& size) override;
87 using Widget::setSize;
88
99 void setAutoSize(bool autoSize);
100
106 [[nodiscard]] bool getAutoSize() const;
107
116 void setTabHeight(float height);
117
128 void setMaximumTabWidth(float maximumWidth);
129
140 [[nodiscard]] float getMaximumTabWidth() const;
141
151 void setMinimumTabWidth(float minimumWidth);
152
162 [[nodiscard]] float getMinimumTabWidth() const;
163
167 bool leftMousePressed(Vector2f pos) override;
168
172 void mouseMoved(Vector2f pos) override;
173
180 void draw(BackendRenderTarget& target, RenderStates states) const override;
181
183
184 protected:
186 // Recalculates the size of each tab image.
188 void recalculateTabsSize() override;
189
193 [[nodiscard]] std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
194
198 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
199
201 // Makes a copy of the widget
203 [[nodiscard]] Widget::Ptr clone() const override;
204
206
207 protected:
208 float m_maximumTabWidth = 0;
209 float m_minimumTabWidth = 0;
210 bool m_autoSize = true;
211 };
212} // namespace tgui
213
214#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:320
void setAutoSize(bool autoSize)
Changes whether the tabs are auto-sized or not.
static Tabs::Ptr create()
Creates a new tabs widget.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
static constexpr char StaticWidgetType[]
Type name of the widget.
Definition Tabs.hpp:49
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:47
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:46
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:85
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
States used for drawing.
Definition RenderStates.hpp:38