From f588443996c3a115748d0d712ed73ca4a4fd6e8a Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 23 Aug 2022 03:47:04 +0100 Subject: [PATCH] Add SubWidget::toBottom --- dgl/SubWidget.hpp | 6 ++++++ dgl/src/SubWidget.cpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/dgl/SubWidget.hpp b/dgl/SubWidget.hpp index eefb4c5a..28119842 100644 --- a/dgl/SubWidget.hpp +++ b/dgl/SubWidget.hpp @@ -137,6 +137,12 @@ public: */ void repaint() noexcept override; + /** + Pushes this widget to the "bottom" of the parent widget. + Makes the widget behave as if it was the first to be registered on the parent widget, thus being "on bottom". + */ + virtual void toBottom(); + /** Bring this widget to the "front" of the parent widget. Makes the widget behave as if it was the last to be registered on the parent widget, thus being "in front". diff --git a/dgl/src/SubWidget.cpp b/dgl/src/SubWidget.cpp index d0f38917..75ca4dad 100644 --- a/dgl/src/SubWidget.cpp +++ b/dgl/src/SubWidget.cpp @@ -145,6 +145,14 @@ void SubWidget::repaint() noexcept } } +void SubWidget::toBottom() +{ + std::list& subwidgets(pData->parentWidget->pData->subWidgets); + + subwidgets.remove(this); + subwidgets.insert(subwidgets.begin(), this); +} + void SubWidget::toFront() { std::list& subwidgets(pData->parentWidget->pData->subWidgets);