From cbbe90f57da71e975e57b5fdbcddbdb65bcb7b32 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Tue, 26 Jul 2022 01:06:40 +0300 Subject: [PATCH] add clear_children function for widget --- src/Widget.cpp | 5 +++++ src/Widget.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/src/Widget.cpp b/src/Widget.cpp index 578c41e..c69d08d 100644 --- a/src/Widget.cpp +++ b/src/Widget.cpp @@ -106,6 +106,11 @@ void Widget::remove_child(std::shared_ptr child) { reflow(); } +void Widget::clear_children() { + m_children.clear(); + reflow(); +} + void Widget::repaint() { if (m_window) m_window->repaint(this); diff --git a/src/Widget.hpp b/src/Widget.hpp index 4a43944..92d3f9a 100644 --- a/src/Widget.hpp +++ b/src/Widget.hpp @@ -55,6 +55,7 @@ public: std::vector> &children() { return m_children; } bool add_child(std::shared_ptr child); void remove_child(std::shared_ptr child); + void clear_children(); Box &rect() { return m_rect; } void set_rect(Box rect) { m_rect = rect; reflow(); }