mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Version 4.3: Fix rounding with inline keyboard markup.
This commit is contained in:
parent
efc06b7951
commit
29e30d2d00
2 changed files with 20 additions and 13 deletions
|
@ -485,13 +485,15 @@ auto Message::takeReactionAnimations()
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize Message::performCountOptimalSize() {
|
QSize Message::performCountOptimalSize() {
|
||||||
|
const auto item = message();
|
||||||
|
const auto markup = item->inlineReplyMarkup();
|
||||||
validateText();
|
validateText();
|
||||||
|
validateInlineKeyboard(markup);
|
||||||
updateViewButtonExistence();
|
updateViewButtonExistence();
|
||||||
updateMediaInBubbleState();
|
updateMediaInBubbleState();
|
||||||
refreshRightBadge();
|
refreshRightBadge();
|
||||||
refreshInfoSkipBlock();
|
refreshInfoSkipBlock();
|
||||||
|
|
||||||
const auto item = message();
|
|
||||||
const auto media = this->media();
|
const auto media = this->media();
|
||||||
|
|
||||||
auto maxWidth = 0;
|
auto maxWidth = 0;
|
||||||
|
@ -642,18 +644,10 @@ QSize Message::performCountOptimalSize() {
|
||||||
maxWidth = st::msgMinWidth;
|
maxWidth = st::msgMinWidth;
|
||||||
minHeight = 0;
|
minHeight = 0;
|
||||||
}
|
}
|
||||||
if (const auto markup = item->inlineReplyMarkup()) {
|
// if we have a text bubble we can resize it to fit the keyboard
|
||||||
if (!markup->inlineKeyboard && !markup->hiddenBy(item->media())) {
|
// but if we have only media we don't do that
|
||||||
markup->inlineKeyboard = std::make_unique<ReplyKeyboard>(
|
if (markup && markup->inlineKeyboard && hasVisibleText()) {
|
||||||
item,
|
accumulate_max(maxWidth, markup->inlineKeyboard->naturalWidth());
|
||||||
std::make_unique<KeyboardStyle>(st::msgBotKbButton));
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we have a text bubble we can resize it to fit the keyboard
|
|
||||||
// but if we have only media we don't do that
|
|
||||||
if (hasVisibleText() && markup->inlineKeyboard) {
|
|
||||||
accumulate_max(maxWidth, markup->inlineKeyboard->naturalWidth());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return QSize(maxWidth, minHeight);
|
return QSize(maxWidth, minHeight);
|
||||||
}
|
}
|
||||||
|
@ -2414,6 +2408,17 @@ void Message::refreshReactions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Message::validateInlineKeyboard(HistoryMessageReplyMarkup *markup) {
|
||||||
|
if (!markup
|
||||||
|
|| markup->inlineKeyboard
|
||||||
|
|| markup->hiddenBy(data()->media())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
markup->inlineKeyboard = std::make_unique<ReplyKeyboard>(
|
||||||
|
data(),
|
||||||
|
std::make_unique<KeyboardStyle>(st::msgBotKbButton));
|
||||||
|
}
|
||||||
|
|
||||||
void Message::validateFromNameText(PeerData *from) const {
|
void Message::validateFromNameText(PeerData *from) const {
|
||||||
if (!from) {
|
if (!from) {
|
||||||
if (_fromNameStatus) {
|
if (_fromNameStatus) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
class HistoryMessage;
|
class HistoryMessage;
|
||||||
struct HistoryMessageEdited;
|
struct HistoryMessageEdited;
|
||||||
struct HistoryMessageForwarded;
|
struct HistoryMessageForwarded;
|
||||||
|
struct HistoryMessageReplyMarkup;
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
struct ReactionId;
|
struct ReactionId;
|
||||||
|
@ -256,6 +257,7 @@ private:
|
||||||
[[nodiscard]] int plainMaxWidth() const;
|
[[nodiscard]] int plainMaxWidth() const;
|
||||||
[[nodiscard]] int monospaceMaxWidth() const;
|
[[nodiscard]] int monospaceMaxWidth() const;
|
||||||
|
|
||||||
|
void validateInlineKeyboard(HistoryMessageReplyMarkup *markup);
|
||||||
void updateViewButtonExistence();
|
void updateViewButtonExistence();
|
||||||
[[nodiscard]] int viewButtonHeight() const;
|
[[nodiscard]] int viewButtonHeight() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue