15#include <egt/detail/alignment.h>
16#include <egt/detail/meta.h>
17#include <egt/screen.h>
18#include <egt/widget.h>
53 const Flags& flags = {})
noexcept;
61 const Flags& flags = {})
noexcept;
101 virtual
void add(const std::shared_ptr<
Widget>& widget);
120 virtual
void add_at(const std::shared_ptr<
Widget>& widget,
size_t pos);
128 void add(const std::shared_ptr<T>& widget)
130 auto p = std::dynamic_pointer_cast<Widget>(widget);
141 void add_at(
const std::shared_ptr<T>& widget,
size_t pos)
143 auto p = std::dynamic_pointer_cast<Widget>(widget);
165 auto w = std::shared_ptr<Widget>(&widget, [](
Widget*) {});
188 auto w = std::shared_ptr<Widget>(&widget, [](
Widget*) {});
199 return Widget::to_subordinate(p);
204 return Widget::to_subordinate(rect);
232 using Widget::children;
242 EGT_NODISCARD std::shared_ptr<Widget>
child_at(
size_t index)
const
244 if (index >= children().size())
247 return *std::next(children().begin(), index);
273 auto i = std::find_if(children().begin(), children().end(),
274 [&name](
const auto & obj)
276 return obj->name() == name;
280 if (i != children().end())
281 return std::dynamic_pointer_cast<T>(*i);
283 i = std::find_if(children().begin(), children().end(),
289 for (; i != children().end(); ++i)
291 auto frame =
dynamic_cast<Frame*
>((*i).get());
310 using Widget::zorder;
311 using Widget::zorder_down;
312 using Widget::zorder_up;
313 using Widget::zorder_bottom;
314 using Widget::zorder_top;
345 template<
typename T,
typename... Args>
346 std::shared_ptr<T>
spawn(Args&& ... args)
348 auto w = std::make_shared<T>(std::forward<Args>(args)...);
353 using Widget::special_child_draw_callback;
367 void add_private(
const std::shared_ptr<Widget>& widget, ssize_t pos = -1);
368 void remove_all_basic();
Definition serialize.h:200
Utility class for managing a set of flags with the ability to observe changes to the flags.
Definition flags.h:40
A Frame is a Widget that has children widgets.
Definition frame.h:45
Frame & operator=(const Frame &)=delete
EGT_NODISCARD bool top_level() const override
Return true if this is a top level frame, with no parent.
Definition frame.h:253
EGT_NODISCARD size_t count_children() const
Get the number of children widgets.
Definition frame.h:237
void serialize_children(Serializer &serializer) const override
Serialize the widget's children to the specified serializer.
void add_at(const std::shared_ptr< T > &widget, size_t pos)
Utility wrapper around add_at()
Definition frame.h:141
virtual EGT_NODISCARD Point to_child(const Point &p) const
Definition frame.h:197
Frame(Serializer::Properties &props) noexcept
Definition frame.h:66
virtual void remove_at(size_t pos)
Remove the child widget at the specified position.
void walk(const WalkCallback &callback, int level=0) override
Walk the Widget tree and call callback with each Widget.
void add(Widget &widget)
Add a child widget.
Definition frame.h:160
virtual void remove(Widget *widget)
Remove a child widget.
std::shared_ptr< T > find_child(const std::string &name)
Find a child Widget in the entire tree by name.
Definition frame.h:268
Frame(Frame &&) noexcept=default
void remove_all()
Remove all child widgets.
std::shared_ptr< T > spawn(Args &&... args)
Create a child widget of the specified type.
Definition frame.h:346
EGT_NODISCARD Rect to_child(Rect rect) const
Definition frame.h:202
void deserialize_children(const Deserializer &deserializer) override
Deserialize the children of this widget.
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
Frame(const Frame &)=delete
void add_at(Widget &widget, size_t pos)
Add a child widget at the specified position.
Definition frame.h:183
Widget * hit_test(const DisplayPoint &point)
Get the widget under the given DisplayPoint.
void show() override
Show the Widget.
Definition frame.h:316
EGT_NODISCARD std::shared_ptr< Widget > child_at(size_t index) const
Get a child widget at a specific index.
Definition frame.h:242
Frame(Frame &parent, const Rect &rect, const Flags &flags={}) noexcept
Frame(Serializer::Properties &props, bool is_derived) noexcept
bool is_child(Widget *widget) const
Returns true if the child exists.
void on_screen_resized() override
Overridden to be called recursively on all children.
Frame(const Rect &rect={}, const Flags &flags={}) noexcept
void paint_children_to_file()
Paint individual children to file.
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
EGT framework namespace.
Definition animation.h:24