5#ifndef MALENA_TABBEDPANEL_H
6#define MALENA_TABBEDPANEL_H
91 std::vector<Tab> _tabs;
101 std::vector<std::unique_ptr<ml::Core>> _pendingDelete;
103 std::function<void(std::size_t,
const std::string&)> _onTabChanged;
104 std::function<void(std::size_t,
const std::string&)> _onTabClosed;
107 void computeTabLayout();
109 bool hitTestClose(
int tabIdx,
const sf::Vector2f& wp)
const;
118 int idx,
bool active,
bool hovered)
const;
135 static_assert(std::is_base_of_v<TabbedPanelSettings, S>,
136 "applySettings() requires TabbedPanelSettings");
144 static_assert(std::is_base_of_v<TabbedPanelTheme, T>,
145 "applyTheme() requires TabbedPanelTheme");
149 template<
typename St>
152 static_assert(std::is_base_of_v<TabbedPanelSettings, St> &&
153 std::is_base_of_v<TabbedPanelTheme, St>,
154 "applyStyle() requires TabbedPanelSettings and TabbedPanelTheme");
187 std::unique_ptr<T> content,
191 T* ptr = content.get();
209 [[nodiscard]]
int activeTab()
const {
return _activeIdx; }
212 [[nodiscard]] std::size_t
tabCount()
const {
return _tabs.size(); }
231 void onTabChanged(std::function<
void(std::size_t,
const std::string&)> cb);
234 void onTabClosed(std::function<
void(std::size_t,
const std::string&)> cb);
247 template<
typename MANIFEST>
static const sf::Font & getDefault()
Return the built-in Arial font.
Base class for all Malena manifests.
A single tab entry for TabbedPanel.
T & addTab(const std::string &label, std::unique_ptr< T > content, const sf::Texture *icon=nullptr, bool closeable=false)
Convenience overload — constructs a Tab with owned content inline.
TabbedPanelSettings::TabPosition TabPosition
sf::FloatRect getGlobalBounds() const override
TabbedPanel(const TabbedPanel &)=delete
void applySettings(const S &s)
void addTab(Tab tab)
Add a pre-built Tab.
TabbedPanel & operator=(const TabbedPanel &)=delete
sf::Vector2f contentSize() const
Return the content area size.
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
TabbedPanel(const sf::Font &font=FontManager<>::getDefault())
TabbedPanelManifest::State State
void onTabClosed(std::function< void(std::size_t, const std::string &)> cb)
Fired when a tab is closed via the × button.
void selectTab(std::size_t index)
Programmatically select a tab by index.
void applyStyle(const St &s)
TabbedPanelManifest::Flag Flag
sf::Vector2f getPosition() const override
void onThemeApplied(const Theme &theme) override
Called by ThemeManager when the active theme changes.
int activeTab() const
Return the currently active tab index, or -1 if no tabs.
std::size_t tabCount() const
Return the number of tabs.
sf::Vector2f getSize() const
void setPosition(const sf::Vector2f &position) override
void setSize(const sf::Vector2f &size)
void onTabChanged(std::function< void(std::size_t, const std::string &)> cb)
Fired when the active tab changes.
void removeTab(std::size_t index)
Remove a tab by index.
void applyTheme(const T &t)
TabbedPanel(const sf::Font &font=FontManager<>::getDefault())
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Vector2< float > Vector2f
bool closeable
show × on all tabs by default
Universal design token set applied across all Themeable components.