Allow any RpWidget as a GenericBox::pinnedTopContent.

This commit is contained in:
John Preston 2022-05-06 17:40:33 +04:00
parent 83553d0826
commit b97c0cadcb
2 changed files with 13 additions and 9 deletions

View file

@ -32,9 +32,9 @@ void GenericBox::addSkip(int height) {
addRow(object_ptr<Ui::FixedHeightWidget>(this, height)); addRow(object_ptr<Ui::FixedHeightWidget>(this, height));
} }
not_null<Ui::VerticalLayout*> GenericBox::setPinnedToTopContent( not_null<Ui::RpWidget*> GenericBox::doSetPinnedToTopContent(
object_ptr<Ui::VerticalLayout> layout) { object_ptr<Ui::RpWidget> content) {
_pinnedToTopContent = std::move(layout); _pinnedToTopContent = std::move(content);
return _pinnedToTopContent.data(); return _pinnedToTopContent.data();
} }

View file

@ -84,16 +84,16 @@ public:
} }
} }
not_null<Ui::VerticalLayout*> setPinnedToTopContent( template <typename Widget>
object_ptr<Ui::VerticalLayout> layout); not_null<Widget*> setPinnedToTopContent(object_ptr<Widget> content) {
return static_cast<Widget*>(
doSetPinnedToTopContent(std::move(content)).get());
}
[[nodiscard]] not_null<Ui::VerticalLayout*> verticalLayout(); [[nodiscard]] not_null<Ui::VerticalLayout*> verticalLayout();
using BoxContent::setNoContentMargin; using BoxContent::setNoContentMargin;
protected:
void prepare() override;
private: private:
template <typename InitMethod, typename ...InitArgs> template <typename InitMethod, typename ...InitArgs>
struct Initer { struct Initer {
@ -119,6 +119,10 @@ private:
auto MakeIniter(InitMethod &&method, InitArgs &&...args) auto MakeIniter(InitMethod &&method, InitArgs &&...args)
-> Initer<std::decay_t<InitMethod>, std::decay_t<InitArgs>...>; -> Initer<std::decay_t<InitMethod>, std::decay_t<InitArgs>...>;
void prepare() override;
not_null<Ui::RpWidget*> doSetPinnedToTopContent(
object_ptr<Ui::RpWidget> content);
FnMut<void(not_null<GenericBox*>)> _init; FnMut<void(not_null<GenericBox*>)> _init;
Fn<void()> _focus; Fn<void()> _focus;
Fn<void()> _showFinished; Fn<void()> _showFinished;
@ -126,7 +130,7 @@ private:
not_null<Ui::VerticalLayout*> _content; not_null<Ui::VerticalLayout*> _content;
int _width = 0; int _width = 0;
object_ptr<Ui::VerticalLayout> _pinnedToTopContent = { nullptr }; object_ptr<Ui::RpWidget> _pinnedToTopContent = { nullptr };
}; };