add clear_children function for widget

This commit is contained in:
hippoz 2022-07-26 01:06:40 +03:00
parent 32524f01e2
commit cbbe90f57d
No known key found for this signature in database
GPG key ID: 7C52899193467641
2 changed files with 6 additions and 0 deletions

View file

@ -106,6 +106,11 @@ void Widget::remove_child(std::shared_ptr<Widget> child) {
reflow(); reflow();
} }
void Widget::clear_children() {
m_children.clear();
reflow();
}
void Widget::repaint() { void Widget::repaint() {
if (m_window) if (m_window)
m_window->repaint(this); m_window->repaint(this);

View file

@ -55,6 +55,7 @@ public:
std::vector<std::shared_ptr<Widget>> &children() { return m_children; } std::vector<std::shared_ptr<Widget>> &children() { return m_children; }
bool add_child(std::shared_ptr<Widget> child); bool add_child(std::shared_ptr<Widget> child);
void remove_child(std::shared_ptr<Widget> child); void remove_child(std::shared_ptr<Widget> child);
void clear_children();
Box &rect() { return m_rect; } Box &rect() { return m_rect; }
void set_rect(Box rect) { m_rect = rect; reflow(); } void set_rect(Box rect) { m_rect = rect; reflow(); }