mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Show repost header in stories.
This commit is contained in:
parent
78897dd143
commit
11ea5e61cf
6 changed files with 30 additions and 15 deletions
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/elastic_scroll.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/click_handler.h"
|
||||
#include "ui/painter.h"
|
||||
#include "styles/style_media_view.h"
|
||||
|
||||
namespace Media::Stories {
|
||||
|
@ -100,6 +101,18 @@ CaptionFullView::CaptionFullView(not_null<Controller*> controller)
|
|||
}
|
||||
}, _scroll->lifetime());
|
||||
|
||||
_wrap->paintRequest() | rpl::start_with_next([=] {
|
||||
if (_controller->repost()) {
|
||||
auto p = Painter(_wrap.get());
|
||||
_controller->drawRepostInfo(
|
||||
p,
|
||||
st::mediaviewCaptionPadding.left(),
|
||||
(_wrap->padding().top()
|
||||
- _controller->repostCaptionPadding().top()),
|
||||
_wrap->width());
|
||||
}
|
||||
}, _wrap->lifetime());
|
||||
|
||||
_scroll->show();
|
||||
_scroll->setOverscrollBg(QColor(0, 0, 0, 0));
|
||||
_scroll->setOverscrollTypes(Type::Real, Type::Real);
|
||||
|
@ -131,7 +144,8 @@ void CaptionFullView::updateGeometry() {
|
|||
return;
|
||||
}
|
||||
const auto lineHeight = st::mediaviewCaptionStyle.font->height;
|
||||
const auto padding = st::mediaviewCaptionPadding;
|
||||
const auto padding = st::mediaviewCaptionPadding
|
||||
+ _controller->repostCaptionPadding();
|
||||
_text->resizeToWidth(_outer.width() - padding.left() - padding.right());
|
||||
const auto add = padding.top() + padding.bottom();
|
||||
const auto maxShownHeight = lineHeight * kMaxShownCaptionLines;
|
||||
|
|
|
@ -604,9 +604,8 @@ int Controller::repostSkipTop() const {
|
|||
: 0;
|
||||
}
|
||||
|
||||
QRect Controller::captionWithRepostGeometry(QRect caption) const {
|
||||
return caption.marginsAdded(st::mediaviewCaptionPadding).marginsAdded(
|
||||
{ 0, repostSkipTop(), 0, 0 });
|
||||
QMargins Controller::repostCaptionPadding() const {
|
||||
return { 0, repostSkipTop(), 0, 0 };
|
||||
}
|
||||
|
||||
void Controller::drawRepostInfo(
|
||||
|
@ -616,7 +615,7 @@ void Controller::drawRepostInfo(
|
|||
int availableWidth) const {
|
||||
Expects(_repostView != nullptr);
|
||||
|
||||
_repostView->draw(p, x, y - repostSkipTop(), availableWidth);
|
||||
_repostView->draw(p, x, y, availableWidth);
|
||||
}
|
||||
|
||||
void Controller::toggleLiked() {
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
void captionClosing();
|
||||
void captionClosed();
|
||||
|
||||
[[nodiscard]] QRect captionWithRepostGeometry(QRect caption) const;
|
||||
[[nodiscard]] QMargins repostCaptionPadding() const;
|
||||
void drawRepostInfo(Painter &p, int x, int y, int availableWidth) const;
|
||||
|
||||
[[nodiscard]] std::shared_ptr<ChatHelpers::Show> uiShow() const;
|
||||
|
|
|
@ -150,8 +150,8 @@ bool View::repost() const {
|
|||
return _controller->repost();
|
||||
}
|
||||
|
||||
QRect View::captionWithRepostGeometry(QRect caption) const {
|
||||
return _controller->captionWithRepostGeometry(caption);
|
||||
QMargins View::repostCaptionPadding() const {
|
||||
return _controller->repostCaptionPadding();
|
||||
}
|
||||
|
||||
void View::drawRepostInfo(
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
[[nodiscard]] bool repost() const;
|
||||
void showFullCaption();
|
||||
|
||||
[[nodiscard]] QRect captionWithRepostGeometry(QRect caption) const;
|
||||
[[nodiscard]] QMargins repostCaptionPadding() const;
|
||||
void drawRepostInfo(Painter &p, int x, int y, int availableWidth) const;
|
||||
|
||||
void updatePlayback(const Player::TrackState &state);
|
||||
|
|
|
@ -5020,11 +5020,12 @@ void OverlayWidget::paintCaptionContent(
|
|||
QRect outer,
|
||||
QRect clip,
|
||||
float64 opacity) {
|
||||
auto inner = outer.marginsRemoved(st::mediaviewCaptionPadding);
|
||||
inner.setTop(inner.top() + inner.height() - _captionRect.height());
|
||||
const auto full = outer.marginsRemoved(st::mediaviewCaptionPadding);
|
||||
const auto inner = full.marginsRemoved(
|
||||
_stories ? _stories->repostCaptionPadding() : QMargins());
|
||||
if (_stories) {
|
||||
if (_stories->repost()) {
|
||||
_stories->drawRepostInfo(p, inner.x(), inner.y(), inner.width());
|
||||
_stories->drawRepostInfo(p, full.x(), full.y(), full.width());
|
||||
}
|
||||
} else {
|
||||
p.setOpacity(opacity);
|
||||
|
@ -5073,9 +5074,10 @@ void OverlayWidget::paintCaptionContent(
|
|||
}
|
||||
|
||||
QRect OverlayWidget::captionGeometry() const {
|
||||
return (_stories && _stories->repost())
|
||||
? _stories->captionWithRepostGeometry(_captionRect)
|
||||
: _captionRect.marginsAdded(st::mediaviewCaptionPadding);
|
||||
return _captionRect.marginsAdded(
|
||||
st::mediaviewCaptionPadding
|
||||
).marginsAdded(
|
||||
_stories ? _stories->repostCaptionPadding() : QMargins());
|
||||
}
|
||||
|
||||
void OverlayWidget::paintGroupThumbsContent(
|
||||
|
|
Loading…
Add table
Reference in a new issue