diff --git a/examples/run.hpp b/examples/run.hpp index 7bb0b03..8d7f607 100644 --- a/examples/run.hpp +++ b/examples/run.hpp @@ -25,7 +25,7 @@ concept WidgetType = std::derived_from; template void run_example( - const std::function&, std::shared_ptr, + const std::function, int, int)>& setup, int w = 3, int h = 3) { @@ -54,14 +54,14 @@ void run_example( bwidgets::AlignedLayout layout(bwidgets::AlignedLayout::Alignment::HORIZONTAL); for (auto x = 0; x < w; x++) { - auto col = std::make_shared( + auto col = std::make_unique( bwidgets::AlignedLayout::Alignment::VERTICAL); for (auto y = 0; y < h; y++) { - auto widget = std::make_shared(); - setup(widget, font, x, y); - col->add_widget(widget); + auto widget = std::make_unique(); + setup(widget.get(), font, x, y); + col->add_widget(std::move(widget)); } - layout.add_widget(col); + layout.add_widget(std::move(col)); } layout.renderer(renderer); diff --git a/inc/basic_widgets/w/base/layout.hpp b/inc/basic_widgets/w/base/layout.hpp index 0066630..028547b 100644 --- a/inc/basic_widgets/w/base/layout.hpp +++ b/inc/basic_widgets/w/base/layout.hpp @@ -17,7 +17,7 @@ namespace bwidgets class Layout : public Widget { protected: - std::vector> _widgets; + std::vector> _widgets; void _handle_geometry_change(const SDL_Rect&) override; void _handle_renderer_change(const std::shared_ptr&) override; @@ -35,7 +35,7 @@ namespace bwidgets auto handle_event(const SDL_Event&) -> Layout* override; [[nodiscard]] auto size() const noexcept -> Size override = 0; - virtual auto add_widget(const std::shared_ptr&) -> Layout*; + virtual auto add_widget(std::unique_ptr) -> Layout*; virtual void for_widgets(const std::function&); }; }