Added ability to set padding for background in Info::ContentWidget.

This commit is contained in:
23rd 2022-05-21 09:11:24 +03:00
parent 9236dd3acb
commit 6a8ccde527
2 changed files with 20 additions and 1 deletions

View File

@ -114,7 +114,17 @@ bool ContentWidget::isStackBottom() const {
void ContentWidget::paintEvent(QPaintEvent *e) {
Painter p(this);
if (_paintPadding.isNull()) {
p.fillRect(e->rect(), _bg);
} else {
const auto &r = e->rect();
const auto padding = QMargins(
0,
std::min(0, (r.top() - _paintPadding.top())),
0,
std::min(0, (r.bottom() - _paintPadding.bottom())));
p.fillRect(r + padding, _bg);
}
}
void ContentWidget::setGeometryWithTopMoved(
@ -249,6 +259,10 @@ rpl::producer<SelectedItems> ContentWidget::selectedListValue() const {
return rpl::single(SelectedItems(Storage::SharedMediaType::Photo));
}
void ContentWidget::setPaintPadding(const style::margins &padding) {
_paintPadding = padding;
}
void ContentWidget::saveChanges(FnMut<void()> done) {
done();
}

View File

@ -103,6 +103,8 @@ protected:
void scrollTo(const Ui::ScrollToRequest &request);
[[nodiscard]] rpl::producer<int> scrollTopValue() const;
void setPaintPadding(const style::margins &padding);
private:
RpWidget *doSetInnerWidget(object_ptr<RpWidget> inner);
void updateControlsGeometry();
@ -126,6 +128,9 @@ private:
// Saving here topDelta in setGeometryWithTopMoved() to get it passed to resizeEvent().
int _topDelta = 0;
// To paint round edges from content.
style::margins _paintPadding;
};
class ContentMemento {