mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Support new rounding in poll bottom button.
This commit is contained in:
parent
09ab83836f
commit
001c46f68a
4 changed files with 41 additions and 34 deletions
|
@ -1448,20 +1448,20 @@ void Message::toggleCommentsButtonRipple(bool pressed) {
|
||||||
if (!_comments->ripple) {
|
if (!_comments->ripple) {
|
||||||
createCommentsRipple();
|
createCommentsRipple();
|
||||||
}
|
}
|
||||||
_comments->ripple->add(_comments->lastPoint);
|
_comments->ripple->add(_comments->lastPoint
|
||||||
|
+ QPoint(_comments->rippleShift, 0));
|
||||||
} else if (_comments->ripple) {
|
} else if (_comments->ripple) {
|
||||||
_comments->ripple->lastStop();
|
_comments->ripple->lastStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Message::createCommentsRipple() {
|
BottomRippleMask Message::bottomRippleMask(int buttonHeight) const {
|
||||||
using namespace Ui;
|
using namespace Ui;
|
||||||
using namespace Images;
|
using namespace Images;
|
||||||
using Radius = CachedCornerRadius;
|
using Radius = CachedCornerRadius;
|
||||||
using Corner = BubbleCornerRounding;
|
using Corner = BubbleCornerRounding;
|
||||||
const auto g = countGeometry();
|
const auto g = countGeometry();
|
||||||
const auto linkWidth = g.width();
|
const auto buttonWidth = g.width();
|
||||||
const auto linkHeight = st::historyCommentsButtonHeight;
|
|
||||||
const auto &large = CachedCornersMasks(Radius::BubbleLarge);
|
const auto &large = CachedCornersMasks(Radius::BubbleLarge);
|
||||||
const auto &small = CachedCornersMasks(Radius::BubbleSmall);
|
const auto &small = CachedCornersMasks(Radius::BubbleSmall);
|
||||||
const auto rounding = countBubbleRounding();
|
const auto rounding = countBubbleRounding();
|
||||||
|
@ -1493,8 +1493,8 @@ void Message::createCommentsRipple() {
|
||||||
const auto height = image->height() / ratio;
|
const auto height = image->height() / ratio;
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
QRect(
|
QRect(
|
||||||
shift + (right ? (linkWidth - width) : 0),
|
shift + (right ? (buttonWidth - width) : 0),
|
||||||
linkHeight - height,
|
buttonHeight - height,
|
||||||
width,
|
width,
|
||||||
height),
|
height),
|
||||||
*image);
|
*image);
|
||||||
|
@ -1503,26 +1503,34 @@ void Message::createCommentsRipple() {
|
||||||
corner(kBottomLeft, false);
|
corner(kBottomLeft, false);
|
||||||
corner(kBottomRight, true);
|
corner(kBottomRight, true);
|
||||||
if (icon) {
|
if (icon) {
|
||||||
const auto left = shift ? 0 : linkWidth;
|
const auto left = shift ? 0 : buttonWidth;
|
||||||
p.fillRect(
|
p.fillRect(
|
||||||
QRect{ left, 0, added, linkHeight },
|
QRect{ left, 0, added, buttonHeight },
|
||||||
Qt::transparent);
|
Qt::transparent);
|
||||||
icon->paint(
|
icon->paint(
|
||||||
p,
|
p,
|
||||||
left,
|
left,
|
||||||
linkHeight - icon->height(),
|
buttonHeight - icon->height(),
|
||||||
linkWidth + shift,
|
buttonWidth + shift,
|
||||||
Qt::white);
|
Qt::white);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
_comments->ripple = std::make_unique<RippleAnimation>(
|
return {
|
||||||
st::defaultRippleAnimation,
|
|
||||||
RippleAnimation::MaskByDrawer(
|
RippleAnimation::MaskByDrawer(
|
||||||
QSize(linkWidth + added, linkHeight),
|
QSize(buttonWidth + added, buttonHeight),
|
||||||
true,
|
true,
|
||||||
drawer),
|
drawer),
|
||||||
|
shift,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Message::createCommentsRipple() {
|
||||||
|
auto mask = bottomRippleMask(st::historyCommentsButtonHeight);
|
||||||
|
_comments->ripple = std::make_unique<Ui::RippleAnimation>(
|
||||||
|
st::defaultRippleAnimation,
|
||||||
|
std::move(mask.image),
|
||||||
[=] { repaint(); });
|
[=] { repaint(); });
|
||||||
_comments->rippleShift = shift;
|
_comments->rippleShift = mask.shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Message::hasHeavyPart() const {
|
bool Message::hasHeavyPart() const {
|
||||||
|
|
|
@ -50,6 +50,11 @@ struct PsaTooltipState : public RuntimeComponent<PsaTooltipState, Element> {
|
||||||
mutable bool buttonVisible = true;
|
mutable bool buttonVisible = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BottomRippleMask {
|
||||||
|
QImage image;
|
||||||
|
int shift = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class Message final : public Element {
|
class Message final : public Element {
|
||||||
public:
|
public:
|
||||||
Message(
|
Message(
|
||||||
|
@ -148,6 +153,7 @@ public:
|
||||||
std::unique_ptr<Reactions::Animation>> override;
|
std::unique_ptr<Reactions::Animation>> override;
|
||||||
|
|
||||||
QRect innerGeometry() const override;
|
QRect innerGeometry() const override;
|
||||||
|
[[nodiscard]] BottomRippleMask bottomRippleMask(int buttonHeight) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void refreshDataIdHook() override;
|
void refreshDataIdHook() override;
|
||||||
|
|
|
@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_message.h"
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "ui/chat/message_bubble.h"
|
#include "ui/chat/message_bubble.h"
|
||||||
|
@ -1568,30 +1568,20 @@ void Poll::toggleLinkRipple(bool pressed) {
|
||||||
const auto linkWidth = width();
|
const auto linkWidth = width();
|
||||||
const auto linkHeight = bottomButtonHeight();
|
const auto linkHeight = bottomButtonHeight();
|
||||||
if (!_linkRipple) {
|
if (!_linkRipple) {
|
||||||
const auto drawMask = [&](QPainter &p) {
|
|
||||||
// #TODO rounding
|
|
||||||
const auto radius = st::bubbleRadiusSmall;
|
|
||||||
p.drawRoundedRect(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
linkWidth,
|
|
||||||
linkHeight,
|
|
||||||
radius,
|
|
||||||
radius);
|
|
||||||
p.fillRect(0, 0, linkWidth, radius * 2, Qt::white);
|
|
||||||
};
|
|
||||||
auto mask = isRoundedInBubbleBottom()
|
auto mask = isRoundedInBubbleBottom()
|
||||||
? Ui::RippleAnimation::MaskByDrawer(
|
? static_cast<Message*>(_parent.get())->bottomRippleMask(
|
||||||
QSize(linkWidth, linkHeight),
|
bottomButtonHeight())
|
||||||
false,
|
: BottomRippleMask{
|
||||||
drawMask)
|
Ui::RippleAnimation::RectMask({ linkWidth, linkHeight }),
|
||||||
: Ui::RippleAnimation::RectMask({ linkWidth, linkHeight });
|
};
|
||||||
_linkRipple = std::make_unique<Ui::RippleAnimation>(
|
_linkRipple = std::make_unique<Ui::RippleAnimation>(
|
||||||
st::defaultRippleAnimation,
|
st::defaultRippleAnimation,
|
||||||
std::move(mask),
|
std::move(mask.image),
|
||||||
[=] { repaint(); });
|
[=] { repaint(); });
|
||||||
|
_linkRippleShift = mask.shift;
|
||||||
}
|
}
|
||||||
_linkRipple->add(_lastLinkPoint - QPoint(0, height() - linkHeight));
|
_linkRipple->add(_lastLinkPoint
|
||||||
|
+ QPoint(_linkRippleShift, linkHeight - height()));
|
||||||
} else if (_linkRipple) {
|
} else if (_linkRipple) {
|
||||||
_linkRipple->lastStop();
|
_linkRipple->lastStop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ class FireworksAnimation;
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
|
||||||
|
class Message;
|
||||||
|
|
||||||
class Poll : public Media, public base::has_weak_ptr {
|
class Poll : public Media, public base::has_weak_ptr {
|
||||||
public:
|
public:
|
||||||
Poll(
|
Poll(
|
||||||
|
@ -213,6 +215,7 @@ private:
|
||||||
ClickHandlerPtr _sendVotesLink;
|
ClickHandlerPtr _sendVotesLink;
|
||||||
mutable ClickHandlerPtr _showSolutionLink;
|
mutable ClickHandlerPtr _showSolutionLink;
|
||||||
mutable std::unique_ptr<Ui::RippleAnimation> _linkRipple;
|
mutable std::unique_ptr<Ui::RippleAnimation> _linkRipple;
|
||||||
|
mutable int _linkRippleShift = 0;
|
||||||
|
|
||||||
mutable std::unique_ptr<AnswersAnimation> _answersAnimation;
|
mutable std::unique_ptr<AnswersAnimation> _answersAnimation;
|
||||||
mutable std::unique_ptr<SendingAnimation> _sendingAnimation;
|
mutable std::unique_ptr<SendingAnimation> _sendingAnimation;
|
||||||
|
|
Loading…
Add table
Reference in a new issue