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);
109 void add(const std::shared_ptr<T>& widget)
111 auto p = std::dynamic_pointer_cast<Widget>(widget);
133 auto w = std::shared_ptr<Widget>(&widget, [](
Widget*) {});
144 return Widget::to_subordinate(p);
149 return Widget::to_subordinate(rect);
166 using Widget::children;
176 EGT_NODISCARD std::shared_ptr<Widget>
child_at(
size_t index)
const
178 if (index >= children().size())
181 return *std::next(children().begin(), index);
207 auto i = std::find_if(children().begin(), children().end(),
208 [&name](
const auto & obj)
210 return obj->name() == name;
214 if (i != children().end())
215 return std::dynamic_pointer_cast<T>(*i);
217 i = std::find_if(children().begin(), children().end(),
223 for (; i != children().end(); ++i)
225 auto frame =
dynamic_cast<Frame*
>((*i).get());
249 using Widget::zorder;
250 using Widget::zorder_down;
251 using Widget::zorder_up;
252 using Widget::zorder_bottom;
253 using Widget::zorder_top;
284 template<
typename T,
typename... Args>
285 std::shared_ptr<T>
spawn(Args&& ... args)
287 auto w = std::make_shared<T>(std::forward<Args>(args)...);
292 using Widget::special_child_draw_callback;
305 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:187
EGT_NODISCARD size_t count_children() const
Get the number of children widgets.
Definition frame.h:171
void serialize_children(Serializer &serializer) const override
Serialize the widget's children to the specified serializer.
virtual EGT_NODISCARD Point to_child(const Point &p) const
Definition frame.h:142
Frame(Serializer::Properties &props) noexcept
Definition frame.h:66
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:128
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:202
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:285
EGT_NODISCARD Rect to_child(Rect rect) const
Definition frame.h:147
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
Widget * hit_test(const DisplayPoint &point)
Get the widget under the given DisplayPoint.
void show() override
Show the Widget.
Definition frame.h:255
EGT_NODISCARD std::shared_ptr< Widget > child_at(size_t index) const
Get a child widget at a specific index.
Definition frame.h:176
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 paint_to_file(const std::string &filename={}) override
Save the entire frame surface to a file.
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