From c197c1831d1af48cf769f271a126af2c2eaf8185 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 29 Nov 2022 14:10:47 +0300 Subject: [PATCH] Added ability to clear items in vertical layout. --- ui/wrap/vertical_layout.cpp | 6 ++++++ ui/wrap/vertical_layout.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ui/wrap/vertical_layout.cpp b/ui/wrap/vertical_layout.cpp index 37ec354..4ebdeb9 100644 --- a/ui/wrap/vertical_layout.cpp +++ b/ui/wrap/vertical_layout.cpp @@ -198,4 +198,10 @@ void VerticalLayout::removeChild(RpWidget *child) { resize(width(), margins.top() + top + margins.bottom()); } +void VerticalLayout::clear() { + while (!_rows.empty()) { + removeChild(_rows.front().widget.data()); + } +} + } // namespace Ui diff --git a/ui/wrap/vertical_layout.h b/ui/wrap/vertical_layout.h index 6df45c8..d736ba4 100644 --- a/ui/wrap/vertical_layout.h +++ b/ui/wrap/vertical_layout.h @@ -54,6 +54,8 @@ public: void setVerticalShift(int index, int shift); void reorderRows(int oldIndex, int newIndex); + void clear(); + protected: int resizeGetHeight(int newWidth) override; void visibleTopBottomUpdated(