Loading...
Searching...
No Matches
ml::Tab Class Reference

A single tab entry for TabbedPanel. More...

#include <Malena/Graphics/Controls/Tab.h>

Public Member Functions

template<typename T>
 Tab (const std::string &label, std::unique_ptr< T > content, const sf::Texture *icon=nullptr, bool closeable=false)
 Construct a tab with owned content.
void setCloseable (bool c)
void setIcon (const sf::Texture *icon_)
void setLabel (const std::string &l)

Public Attributes

bool closeable = false
std::unique_ptr< ml::Corecontent
const sf::Textureicon = nullptr
std::string label
std::function< void(sf::Vector2f)> resizeFn
float width = 0.f
 computed by TabbedPanel
float x = 0.f
 computed by TabbedPanel

Detailed Description

A single tab entry for TabbedPanel.

Can be built ahead of time and passed to TabbedPanel::addTab(Tab):

ml::Tab tab("Notes", std::make_unique<ml::TextArea>());
tab.setCloseable(true);
tab.setIcon(&myIcon);
tabbedPanel.addTab(std::move(tab));
A single tab entry for TabbedPanel.
Definition Tab.h:40

Or created inline via the TabbedPanel::addTab convenience overload:

tabbedPanel.addTab("Notes", std::make_unique<ml::TextArea>());
See also
TabbedPanel

Definition at line 39 of file Tab.h.

Constructor & Destructor Documentation

◆ Tab()

template<typename T>
ml::Tab::Tab ( const std::string & label,
std::unique_ptr< T > content,
const sf::Texture * icon = nullptr,
bool closeable = false )
inline

Construct a tab with owned content.

Template Parameters
TAny ml::Core-derived type.
Parameters
labelTab label text.
contentOwned content component. TabbedPanel takes ownership on addTab.
iconOptional icon texture. Pass nullptr for none.
closeableWhether this tab shows a close button.

Definition at line 60 of file Tab.h.

Member Function Documentation

◆ setCloseable()

void ml::Tab::setCloseable ( bool c)
inline

Definition at line 74 of file Tab.h.

◆ setIcon()

void ml::Tab::setIcon ( const sf::Texture * icon_)
inline

Definition at line 73 of file Tab.h.

◆ setLabel()

void ml::Tab::setLabel ( const std::string & l)
inline

Definition at line 72 of file Tab.h.

Member Data Documentation

◆ closeable

bool ml::Tab::closeable = false

Definition at line 46 of file Tab.h.

◆ content

std::unique_ptr<ml::Core> ml::Tab::content

Definition at line 43 of file Tab.h.

◆ icon

const sf::Texture* ml::Tab::icon = nullptr

Definition at line 45 of file Tab.h.

◆ label

std::string ml::Tab::label

Definition at line 42 of file Tab.h.

◆ resizeFn

std::function<void(sf::Vector2f)> ml::Tab::resizeFn

Definition at line 44 of file Tab.h.

◆ width

float ml::Tab::width = 0.f

computed by TabbedPanel

Definition at line 48 of file Tab.h.

◆ x

float ml::Tab::x = 0.f

computed by TabbedPanel

Definition at line 47 of file Tab.h.


The documentation for this class was generated from the following file: