diff --git a/ui/layers/generic_box.cpp b/ui/layers/generic_box.cpp index 8ce8c16..bbf7109 100644 --- a/ui/layers/generic_box.cpp +++ b/ui/layers/generic_box.cpp @@ -68,6 +68,25 @@ void GenericBox::addSkip(int height) { addRow(object_ptr(this, height)); } +void GenericBox::setInnerFocus() { + if (_focus) { + _focus(); + } else { + BoxContent::setInnerFocus(); + } +} + +void GenericBox::showFinished() { + const auto guard = QPointer(this); + if (const auto onstack = _showFinished) { + onstack(); + if (!guard) { + return; + } + } + _showFinishes.fire({}); +} + not_null GenericBox::doSetPinnedToTopContent( object_ptr content) { _pinnedToTopContent = std::move(content); diff --git a/ui/layers/generic_box.h b/ui/layers/generic_box.h index 3bfd724..4c3baae 100644 --- a/ui/layers/generic_box.h +++ b/ui/layers/generic_box.h @@ -41,6 +41,9 @@ public: void setShowFinishedCallback(Fn callback) { _showFinished = callback; } + [[nodiscard]] rpl::producer<> showFinishes() const { + return _showFinishes.events(); + } [[nodiscard]] int rowsCount() const; [[nodiscard]] int width() const; @@ -81,18 +84,8 @@ public: _scrollSt = &st; } - void setInnerFocus() override { - if (_focus) { - _focus(); - } else { - BoxContent::setInnerFocus(); - } - } - void showFinished() override { - if (_showFinished) { - _showFinished(); - } - } + void setInnerFocus() override; + void showFinished() override; template not_null setPinnedToTopContent(object_ptr content) { @@ -144,6 +137,7 @@ private: FnMut)> _init; Fn _focus; Fn _showFinished; + rpl::event_stream<> _showFinishes; object_ptr _owned; not_null _content; const style::ScrollArea *_scrollSt = nullptr;