From 216865a20d191d0419715d15ff48f48ae81e686b Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 5 Sep 2024 12:01:43 +0400 Subject: [PATCH] Fix file albums with inline keyboard buttons. --- .../history/view/history_view_message.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index fd8e104619..6abc382d77 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1142,6 +1142,15 @@ void Message::draw(Painter &p, const PaintContext &context) const { const auto displayInfo = needInfoDisplay(); const auto reactionsInBubble = _reactions && embedReactionsInBubble(); + const auto keyboard = item->inlineReplyKeyboard(); + const auto fullGeometry = g; + if (keyboard) { + // We need to count geometry without keyboard for bubble selection + // intervals counting below. + const auto keyboardHeight = st::msgBotKbButton.margin + keyboard->naturalHeight(); + g.setHeight(g.height() - keyboardHeight); + } + auto mediaSelectionIntervals = (!context.selected() && mediaDisplayed) ? media->getBubbleSelectionIntervals(context.selection) : std::vector(); @@ -1176,25 +1185,22 @@ void Message::draw(Painter &p, const PaintContext &context) const { if (customHighlight) { media->drawHighlight(p, context, localMediaTop); } else { - paintHighlight(p, context, g.height()); + paintHighlight(p, context, fullGeometry.height()); } const auto roll = media ? media->bubbleRoll() : Media::BubbleRoll(); if (roll) { p.save(); - p.translate(g.center()); + p.translate(fullGeometry.center()); p.rotate(roll.rotate); p.scale(roll.scale, roll.scale); - p.translate(-g.center()); + p.translate(-fullGeometry.center()); } p.setTextPalette(stm->textPalette); - const auto keyboard = item->inlineReplyKeyboard(); const auto messageRounding = countMessageRounding(); if (keyboard) { - const auto keyboardHeight = st::msgBotKbButton.margin + keyboard->naturalHeight(); - g.setHeight(g.height() - keyboardHeight); const auto keyboardPosition = QPoint(g.left(), g.top() + g.height() + st::msgBotKbButton.margin); p.translate(keyboardPosition); keyboard->paint(