TGUI 1.x-dev
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
31
32namespace tgui
33{
42 class TGUI_API Tabs : public TabsBase
43 {
44 public:
45 using Ptr = std::shared_ptr<Tabs>;
46 using ConstPtr = std::shared_ptr<const Tabs>;
47
48 static constexpr char StaticWidgetType[] = "Tabs";
49
57 explicit Tabs(const char* typeName = StaticWidgetType, bool initRenderer = true);
58
64 [[nodiscard]] static Tabs::Ptr create();
65
73 [[nodiscard]] static Tabs::Ptr copy(const Tabs::ConstPtr& tab);
74
85 void setSize(const Layout2d& size) override;
86 using Widget::setSize;
87
98 void setAutoSize(bool autoSize);
99
105 [[nodiscard]] bool getAutoSize() const;
106
115 void setTabHeight(float height);
116
127 void setMaximumTabWidth(float maximumWidth);
128
139 [[nodiscard]] float getMaximumTabWidth() const;
140
150 void setMinimumTabWidth(float minimumWidth);
151
161 [[nodiscard]] float getMinimumTabWidth() const;
162
166 bool leftMousePressed(Vector2f pos) override;
167
171 void mouseMoved(Vector2f pos) override;
172
179 void draw(BackendRenderTarget& target, RenderStates states) const override;
180
182
183 protected:
185 // Recalculates the size of each tab image.
187 void recalculateTabsSize() override;
188
192 [[nodiscard]] std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
193
197 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
198
200 // Makes a copy of the widget
202 [[nodiscard]] Widget::Ptr clone() const override;
203
205
206 protected:
207 float m_maximumTabWidth = 0;
208 float m_minimumTabWidth = 0;
209 bool m_autoSize = true;
210 };
211} // namespace tgui
212
213#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:48
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:46
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:45
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