Added ability to append pinned to top content to generic box.
This commit is contained in:
parent
35c84d7d54
commit
9d07d6a476
2 changed files with 30 additions and 5 deletions
|
|
@ -16,15 +16,36 @@ namespace Ui {
|
|||
void GenericBox::prepare() {
|
||||
_init(this);
|
||||
|
||||
const auto currentWidth = width();
|
||||
if (_pinnedToTopContent) {
|
||||
_pinnedToTopContent->resizeToWidth(currentWidth);
|
||||
}
|
||||
|
||||
auto wrap = object_ptr<Ui::OverrideMargins>(this, std::move(_owned));
|
||||
setDimensionsToContent(_width ? _width : st::boxWidth, wrap.data());
|
||||
setInnerWidget(std::move(wrap));
|
||||
setDimensionsToContent(currentWidth, wrap.data());
|
||||
setInnerWidget(
|
||||
std::move(wrap),
|
||||
_pinnedToTopContent ? _pinnedToTopContent->height() : 0);
|
||||
}
|
||||
|
||||
void GenericBox::addSkip(int height) {
|
||||
addRow(object_ptr<Ui::FixedHeightWidget>(this, height));
|
||||
}
|
||||
|
||||
not_null<Ui::VerticalLayout*> GenericBox::setPinnedToTopContent(
|
||||
object_ptr<Ui::VerticalLayout> layout) {
|
||||
_pinnedToTopContent = std::move(layout);
|
||||
return _pinnedToTopContent.data();
|
||||
}
|
||||
|
||||
int GenericBox::rowsCount() const {
|
||||
return _content->count();
|
||||
}
|
||||
|
||||
int GenericBox::width() const {
|
||||
return _width ? _width : st::boxWidth;
|
||||
}
|
||||
|
||||
not_null<Ui::VerticalLayout*> GenericBox::verticalLayout() {
|
||||
return _content;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,8 @@ public:
|
|||
_showFinished = callback;
|
||||
}
|
||||
|
||||
int rowsCount() const {
|
||||
return _content->count();
|
||||
}
|
||||
[[nodiscard]] int rowsCount() const;
|
||||
[[nodiscard]] int width() const;
|
||||
|
||||
template <
|
||||
typename Widget,
|
||||
|
|
@ -85,6 +84,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
not_null<Ui::VerticalLayout*> setPinnedToTopContent(
|
||||
object_ptr<Ui::VerticalLayout> layout);
|
||||
|
||||
[[nodiscard]] not_null<Ui::VerticalLayout*> verticalLayout();
|
||||
|
||||
using BoxContent::setNoContentMargin;
|
||||
|
|
@ -124,6 +126,8 @@ private:
|
|||
not_null<Ui::VerticalLayout*> _content;
|
||||
int _width = 0;
|
||||
|
||||
object_ptr<Ui::VerticalLayout> _pinnedToTopContent = { nullptr };
|
||||
|
||||
};
|
||||
|
||||
template <typename InitMethod, typename ...InitArgs>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue