14#include <egt/detail/meta.h>
16#include <egt/signal.h>
36 name(
"NotebookTab" + std::to_string(m_widgetid));
39 fill_flags(Theme::FillFlag::solid);
48 void add(
const std::shared_ptr<Widget>& widget)
override
53 if (widget.get() ==
this)
54 throw std::runtime_error(
"cannot add a widget to itself");
56 assert(!widget->parent() &&
"widget already has parent!");
58 auto cell = std::dynamic_pointer_cast<NotebookTab>(widget);
60 throw std::invalid_argument(
"cannot have nested NotebookTab");
71 deserialize_leaf(props);
143 void add(
const std::shared_ptr<Widget>& widget)
override;
160 EGT_NODISCARD ssize_t
selected()
const {
return m_selected; }
179 using CellArray = std::vector<std::weak_ptr<NotebookTab>>;
185 ssize_t m_selected{-1};
A Frame is a Widget that has children widgets.
Definition frame.h:45
A single layer of a Notebook.
Definition notebook.h:31
NotebookTab(Serializer::Properties &props, bool is_derived) noexcept
Definition notebook.h:67
virtual void enter()
Called when this tab is entered and before show() is invoked.
Definition notebook.h:87
void add(const std::shared_ptr< Widget > &widget) override
Add a child widget.
Definition notebook.h:48
virtual bool leave()
Definition notebook.h:79
NotebookTab()
Definition notebook.h:34
void select()
Select this tab.
NotebookTab(Serializer::Properties &props) noexcept
Definition notebook.h:42
Allows a collection of NotebookTab widgets to be shown one at a time.
Definition notebook.h:103
Notebook(Serializer::Properties &props, bool is_derived) noexcept
Notebook(const Rect &rect={}) noexcept
EGT_NODISCARD NotebookTab * get(size_t index) const
Get a widget at the specified index.
Signal on_selected_changed
Event signal.
Definition notebook.h:113
EGT_NODISCARD ssize_t selected() const
Get the currently selected index.
Definition notebook.h:160
CellArray m_cells
Array of notebook tabs.
Definition notebook.h:182
Notebook(Serializer::Properties &props) noexcept
Definition notebook.h:130
void add(const std::shared_ptr< Widget > &widget) override
Add a child widget.
void post_deserialize(Serializer::Properties &props) override
Resume deserializing of the widget after its children have been deserialized.
Notebook(Frame &parent, const Rect &rect={}) noexcept
void selected(size_t index)
Set the selected widget by index.
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
void remove(Widget *widget) override
Remove a child widget.
void selected(Widget *widget)
Set the selected widget by widget.
std::vector< std::weak_ptr< NotebookTab > > CellArray
Type of array of notebook tabs.
Definition notebook.h:179
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
EGT framework namespace.
Definition animation.h:24