From b97c0cadcb2ab3dff75d26b482a4a4e750a1c0e7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 6 May 2022 17:40:33 +0400 Subject: [PATCH] Allow any RpWidget as a GenericBox::pinnedTopContent. --- ui/layers/generic_box.cpp | 6 +++--- ui/layers/generic_box.h | 16 ++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ui/layers/generic_box.cpp b/ui/layers/generic_box.cpp index fe90bce..beb32e5 100644 --- a/ui/layers/generic_box.cpp +++ b/ui/layers/generic_box.cpp @@ -32,9 +32,9 @@ void GenericBox::addSkip(int height) { addRow(object_ptr(this, height)); } -not_null GenericBox::setPinnedToTopContent( - object_ptr layout) { - _pinnedToTopContent = std::move(layout); +not_null GenericBox::doSetPinnedToTopContent( + object_ptr content) { + _pinnedToTopContent = std::move(content); return _pinnedToTopContent.data(); } diff --git a/ui/layers/generic_box.h b/ui/layers/generic_box.h index 4214375..60bf1ef 100644 --- a/ui/layers/generic_box.h +++ b/ui/layers/generic_box.h @@ -84,16 +84,16 @@ public: } } - not_null setPinnedToTopContent( - object_ptr layout); + template + not_null setPinnedToTopContent(object_ptr content) { + return static_cast( + doSetPinnedToTopContent(std::move(content)).get()); + } [[nodiscard]] not_null verticalLayout(); using BoxContent::setNoContentMargin; -protected: - void prepare() override; - private: template struct Initer { @@ -119,6 +119,10 @@ private: auto MakeIniter(InitMethod &&method, InitArgs &&...args) -> Initer, std::decay_t...>; + void prepare() override; + not_null doSetPinnedToTopContent( + object_ptr content); + FnMut)> _init; Fn _focus; Fn _showFinished; @@ -126,7 +130,7 @@ private: not_null _content; int _width = 0; - object_ptr _pinnedToTopContent = { nullptr }; + object_ptr _pinnedToTopContent = { nullptr }; };