Added ability to change width between pinned bar animation entries.

This commit is contained in:
23rd 2022-04-22 16:07:10 +03:00 committed by John Preston
parent 16f616c5e0
commit 1710890886
3 changed files with 9 additions and 3 deletions

View file

@ -222,7 +222,7 @@ QRect MessageBar::bodyRect(bool withImage) const {
const auto top = st::msgReplyPadding.top();
const auto width = _widget.width() - left - st::msgReplyPadding.right();
const auto height = st::msgReplyBarSize.height();
return QRect(left, top, width, height);
return QRect(left, top, width, height) - _content.margins;
}
QRect MessageBar::bodyRect() const {

View file

@ -24,6 +24,7 @@ struct MessageBarContent {
QString title;
TextWithEntities text;
QImage preview;
style::margins margins;
};
class MessageBar final {

View file

@ -51,6 +51,12 @@ void PinnedBar::setContent(rpl::producer<Ui::MessageBarContent> content) {
if (creating) {
createControls();
}
// In most cases the new right button should arrive
// before we want to get its width.
const auto right = _right.button ? _right.button->width() : 0;
content.margins = { 0, 0, right, 0 };
_bar->set(std::move(content));
if (creating) {
_bar->finishAnimating();
@ -96,8 +102,7 @@ void PinnedBar::setRightButton(object_ptr<Ui::RpWidget> button) {
}
void PinnedBar::updateControlsGeometry(QRect wrapGeometry) {
_bar->widget()->resizeToWidth(
wrapGeometry.width() - (_right.button ? _right.button->width() : 0));
_bar->widget()->resizeToWidth(wrapGeometry.width());
const auto hidden = _wrap.isHidden() || !wrapGeometry.height();
if (_shadow->isHidden() != hidden) {
_shadow->setVisible(!hidden);