#include using namespace bwidgets; const Size Layout::default_margins {8, 8}; auto Layout::add_widget(std::unique_ptr widget_ptr) -> Layout* { widget_ptr->renderer(_renderer); _widgets.emplace_back(std::move(widget_ptr)); _update_layout(_viewport); return this; } void Layout::for_widgets(const std::function& f) { for (const auto& w : _widgets) f(w.get()); } void Layout::handle_event(const SDL_Event& ev) { EventHandlerImpl::handle_event(ev); for (const auto& w : _widgets) w->handle_event(ev); } void Layout::_handle_geometry_change(const SDL_Rect& vp) { _update_layout(vp); } void Layout::_handle_renderer_change(const std::shared_ptr& r) { for (const auto& w : _widgets) w->renderer(r); } void Layout::_handle_rendering() { for (const auto& w : _widgets) w->render(); }