From 231499f24cf505f719c7ce11576b3975ab87026e Mon Sep 17 00:00:00 2001 From: Andrea Blankenstijn Date: Wed, 16 Feb 2022 17:48:25 +0100 Subject: [PATCH] layout: + remove_widget --- inc/basic_widgets/w/aligned_layout_impl.hpp | 10 ++++++++++ inc/basic_widgets/w/base/layout.hpp | 1 + 2 files changed, 11 insertions(+) diff --git a/inc/basic_widgets/w/aligned_layout_impl.hpp b/inc/basic_widgets/w/aligned_layout_impl.hpp index fbc3066..12c6d04 100644 --- a/inc/basic_widgets/w/aligned_layout_impl.hpp +++ b/inc/basic_widgets/w/aligned_layout_impl.hpp @@ -43,6 +43,16 @@ namespace bwidgets for (const auto& w : _widgets) f(w.get()); } + void remove_widget(const std::shared_ptr& widget) override + { + for (auto i = _widgets.cbegin(); i != _widgets.cend(); i++) { + if (*i == widget) { + _widgets.erase(i); + break; + } + } + } + // Return smallest usable size. [[nodiscard]] auto size() const noexcept -> Size override { diff --git a/inc/basic_widgets/w/base/layout.hpp b/inc/basic_widgets/w/base/layout.hpp index 06e198e..cd2897f 100644 --- a/inc/basic_widgets/w/base/layout.hpp +++ b/inc/basic_widgets/w/base/layout.hpp @@ -15,6 +15,7 @@ namespace bwidgets // Apply a function to every layout widget. virtual void for_widgets(const std::function&) = 0; virtual void for_widgets(const std::function&) const = 0; + virtual void remove_widget(const std::shared_ptr&) = 0; }; }