mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Better reaction layout outside of a bubble.
This commit is contained in:
parent
d6edc3728d
commit
ae426a41e0
8 changed files with 44 additions and 6 deletions
|
@ -1025,6 +1025,10 @@ Reactions::ButtonParameters Element::reactionButtonParameters(
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Element::reactionsOptimalWidth() const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Element::clickHandlerActiveChanged(
|
void Element::clickHandlerActiveChanged(
|
||||||
const ClickHandlerPtr &handler,
|
const ClickHandlerPtr &handler,
|
||||||
bool active) {
|
bool active) {
|
||||||
|
|
|
@ -335,6 +335,7 @@ public:
|
||||||
[[nodiscard]] virtual auto reactionButtonParameters(
|
[[nodiscard]] virtual auto reactionButtonParameters(
|
||||||
QPoint position,
|
QPoint position,
|
||||||
const TextState &reactionState) const -> Reactions::ButtonParameters;
|
const TextState &reactionState) const -> Reactions::ButtonParameters;
|
||||||
|
[[nodiscard]] virtual int reactionsOptimalWidth() const;
|
||||||
|
|
||||||
// ClickHandlerHost interface.
|
// ClickHandlerHost interface.
|
||||||
void clickHandlerActiveChanged(
|
void clickHandlerActiveChanged(
|
||||||
|
|
|
@ -2019,6 +2019,10 @@ Reactions::ButtonParameters Message::reactionButtonParameters(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Message::reactionsOptimalWidth() const {
|
||||||
|
return _reactions ? _reactions->countNiceWidth() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Message::drawInfo(
|
void Message::drawInfo(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const PaintContext &context,
|
const PaintContext &context,
|
||||||
|
|
|
@ -91,6 +91,7 @@ public:
|
||||||
Reactions::ButtonParameters reactionButtonParameters(
|
Reactions::ButtonParameters reactionButtonParameters(
|
||||||
QPoint position,
|
QPoint position,
|
||||||
const TextState &reactionState) const override;
|
const TextState &reactionState) const override;
|
||||||
|
int reactionsOptimalWidth() const override;
|
||||||
|
|
||||||
bool hasHeavyPart() const override;
|
bool hasHeavyPart() const override;
|
||||||
void unloadHeavyPart() override;
|
void unloadHeavyPart() override;
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace {
|
||||||
constexpr auto kInNonChosenOpacity = 0.12;
|
constexpr auto kInNonChosenOpacity = 0.12;
|
||||||
constexpr auto kOutNonChosenOpacity = 0.18;
|
constexpr auto kOutNonChosenOpacity = 0.18;
|
||||||
constexpr auto kMaxRecentUserpics = 3;
|
constexpr auto kMaxRecentUserpics = 3;
|
||||||
|
constexpr auto kMaxNicePerRow = 5;
|
||||||
|
|
||||||
[[nodiscard]] QColor AdaptChosenServiceFg(QColor serviceBg) {
|
[[nodiscard]] QColor AdaptChosenServiceFg(QColor serviceBg) {
|
||||||
serviceBg.setAlpha(std::max(serviceBg.alpha(), 192));
|
serviceBg.setAlpha(std::max(serviceBg.alpha(), 192));
|
||||||
|
@ -225,6 +226,25 @@ QSize InlineList::countCurrentSize(int newWidth) {
|
||||||
return { newWidth, height + add };
|
return { newWidth, height + add };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int InlineList::countNiceWidth() const {
|
||||||
|
const auto count = _data.reactions.size();
|
||||||
|
const auto rows = (count + kMaxNicePerRow - 1) / kMaxNicePerRow;
|
||||||
|
const auto columns = (count + rows - 1) / rows;
|
||||||
|
const auto between = st::reactionInlineBetween;
|
||||||
|
auto result = 0;
|
||||||
|
auto inrow = 0;
|
||||||
|
auto x = 0;
|
||||||
|
for (auto &button : _buttons) {
|
||||||
|
if (inrow++ >= columns) {
|
||||||
|
x = 0;
|
||||||
|
inrow = 0;
|
||||||
|
}
|
||||||
|
x += button.geometry.width() + between;
|
||||||
|
accumulate_max(result, x - between);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void InlineList::flipToRight() {
|
void InlineList::flipToRight() {
|
||||||
for (auto &button : _buttons) {
|
for (auto &button : _buttons) {
|
||||||
button.geometry.moveLeft(
|
button.geometry.moveLeft(
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
|
|
||||||
void update(Data &&data, int availableWidth);
|
void update(Data &&data, int availableWidth);
|
||||||
QSize countCurrentSize(int newWidth) override;
|
QSize countCurrentSize(int newWidth) override;
|
||||||
|
[[nodiscard]] int countNiceWidth() const;
|
||||||
[[nodiscard]] int placeAndResizeGetHeight(QRect available);
|
[[nodiscard]] int placeAndResizeGetHeight(QRect available);
|
||||||
void flipToRight();
|
void flipToRight();
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,7 @@ QSize Gif::countOptimalSize() {
|
||||||
forwarded->create(via);
|
forwarded->create(via);
|
||||||
}
|
}
|
||||||
maxWidth += additionalWidth(via, reply, forwarded);
|
maxWidth += additionalWidth(via, reply, forwarded);
|
||||||
|
accumulate_max(maxWidth, _parent->reactionsOptimalWidth());
|
||||||
}
|
}
|
||||||
return { maxWidth, minHeight };
|
return { maxWidth, minHeight };
|
||||||
}
|
}
|
||||||
|
@ -232,6 +233,8 @@ QSize Gif::countCurrentSize(int newWidth) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (isSeparateRoundVideo()) {
|
} else if (isSeparateRoundVideo()) {
|
||||||
|
accumulate_max(newWidth, _parent->reactionsOptimalWidth());
|
||||||
|
|
||||||
const auto item = _parent->data();
|
const auto item = _parent->data();
|
||||||
auto via = item->Get<HistoryMessageVia>();
|
auto via = item->Get<HistoryMessageVia>();
|
||||||
auto reply = _parent->displayedReply();
|
auto reply = _parent->displayedReply();
|
||||||
|
@ -1191,9 +1194,10 @@ QRect Gif::contentRectForReactions() const {
|
||||||
const auto forwarded = item->Get<HistoryMessageForwarded>();
|
const auto forwarded = item->Get<HistoryMessageForwarded>();
|
||||||
if (via || reply || forwarded) {
|
if (via || reply || forwarded) {
|
||||||
usew = maxWidth() - additionalWidth(via, reply, forwarded);
|
usew = maxWidth() - additionalWidth(via, reply, forwarded);
|
||||||
if (rightAligned) {
|
}
|
||||||
usex = width() - usew;
|
accumulate_max(usew, _parent->reactionsOptimalWidth());
|
||||||
}
|
if (rightAligned) {
|
||||||
|
usex = width() - usew;
|
||||||
}
|
}
|
||||||
if (rtl()) usex = width() - usex - usew;
|
if (rtl()) usex = width() - usex - usew;
|
||||||
return style::rtlrect(usex + paintx, painty, usew, painth, width());
|
return style::rtlrect(usex + paintx, painty, usew, painth, width());
|
||||||
|
|
|
@ -57,6 +57,7 @@ QSize UnwrappedMedia::countOptimalSize() {
|
||||||
}
|
}
|
||||||
const auto additional = additionalWidth(via, reply, forwarded);
|
const auto additional = additionalWidth(via, reply, forwarded);
|
||||||
maxWidth += additional;
|
maxWidth += additional;
|
||||||
|
accumulate_max(maxWidth, _parent->reactionsOptimalWidth());
|
||||||
if (const auto surrounding = surroundingInfo(via, reply, forwarded, additional - st::msgReplyPadding.left())) {
|
if (const auto surrounding = surroundingInfo(via, reply, forwarded, additional - st::msgReplyPadding.left())) {
|
||||||
const auto infoHeight = st::msgDateImgPadding.y() * 2
|
const auto infoHeight = st::msgDateImgPadding.y() * 2
|
||||||
+ st::msgDateFont->height;
|
+ st::msgDateFont->height;
|
||||||
|
@ -77,6 +78,7 @@ QSize UnwrappedMedia::countOptimalSize() {
|
||||||
QSize UnwrappedMedia::countCurrentSize(int newWidth) {
|
QSize UnwrappedMedia::countCurrentSize(int newWidth) {
|
||||||
const auto item = _parent->data();
|
const auto item = _parent->data();
|
||||||
accumulate_min(newWidth, maxWidth());
|
accumulate_min(newWidth, maxWidth());
|
||||||
|
accumulate_max(newWidth, _parent->reactionsOptimalWidth());
|
||||||
const auto isPageAttach = (_parent->media() != this);
|
const auto isPageAttach = (_parent->media() != this);
|
||||||
if (!isPageAttach) {
|
if (!isPageAttach) {
|
||||||
const auto via = item->Get<HistoryMessageVia>();
|
const auto via = item->Get<HistoryMessageVia>();
|
||||||
|
@ -416,9 +418,10 @@ QRect UnwrappedMedia::contentRectForReactions() const {
|
||||||
auto usew = maxWidth();
|
auto usew = maxWidth();
|
||||||
if (!inWebPage) {
|
if (!inWebPage) {
|
||||||
usew -= additionalWidth(via, reply, forwarded);
|
usew -= additionalWidth(via, reply, forwarded);
|
||||||
if (rightAligned) {
|
}
|
||||||
usex = width() - usew;
|
accumulate_max(usew, _parent->reactionsOptimalWidth());
|
||||||
}
|
if (rightAligned) {
|
||||||
|
usex = width() - usew;
|
||||||
}
|
}
|
||||||
if (rtl()) {
|
if (rtl()) {
|
||||||
usex = width() - usex - usew;
|
usex = width() - usex - usew;
|
||||||
|
|
Loading…
Add table
Reference in a new issue