mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Improve message part highlighting.
This commit is contained in:
parent
2b53df98cd
commit
48d9f10f5b
2 changed files with 24 additions and 10 deletions
|
@ -2019,16 +2019,26 @@ int FindViewY(not_null<Element*> view, uint16 symbol, int yfrom) {
|
|||
auto request = HistoryView::StateRequest();
|
||||
request.flags = Ui::Text::StateRequest::Flag::LookupSymbol;
|
||||
const auto single = st::messageTextStyle.font->height;
|
||||
const auto inner = view->innerGeometry();
|
||||
const auto origin = inner.topLeft();
|
||||
const auto top = 0;
|
||||
const auto bottom = view->height();
|
||||
if (origin.y() < top
|
||||
|| origin.y() + inner.height() > bottom
|
||||
|| inner.height() <= 0) {
|
||||
return yfrom;
|
||||
}
|
||||
const auto fory = [&](int y) {
|
||||
return view->textState(QPoint(0, y), request).symbol;
|
||||
return view->textState(origin + QPoint(0, y), request).symbol;
|
||||
};
|
||||
auto ytill = view->height() - 1;
|
||||
yfrom = std::max(yfrom - origin.y(), 0);
|
||||
auto ytill = inner.height() - 1;
|
||||
auto symbolfrom = fory(yfrom);
|
||||
auto symboltill = fory(ytill);
|
||||
if ((yfrom >= ytill) || (symbolfrom >= symbol)) {
|
||||
return yfrom;
|
||||
return origin.y() + yfrom;
|
||||
} else if (symboltill <= symbol) {
|
||||
return ytill;
|
||||
return origin.y() + ytill;
|
||||
}
|
||||
while (ytill - yfrom >= 2 * single) {
|
||||
const auto middle = (yfrom + ytill) / 2;
|
||||
|
@ -2045,7 +2055,7 @@ int FindViewY(not_null<Element*> view, uint16 symbol, int yfrom) {
|
|||
symboltill = found;
|
||||
}
|
||||
}
|
||||
return (yfrom + ytill) / 2;
|
||||
return origin.y() + (yfrom + ytill) / 2;
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -4299,14 +4299,18 @@ QRect Message::innerGeometry() const {
|
|||
width()));
|
||||
}
|
||||
if (hasBubble()) {
|
||||
result.translate(0, st::msgPadding.top() + st::mediaInBubbleSkip);
|
||||
const auto cut = [&](int amount) {
|
||||
amount = std::min(amount, result.height());
|
||||
result.setTop(result.top() + amount);
|
||||
};
|
||||
cut(st::msgPadding.top() + st::mediaInBubbleSkip);
|
||||
|
||||
if (displayFromName()) {
|
||||
// See paintFromName().
|
||||
result.translate(0, st::msgNameFont->height);
|
||||
cut(st::msgNameFont->height);
|
||||
}
|
||||
if (displayedTopicButton()) {
|
||||
result.translate(0, st::topicButtonSkip
|
||||
cut(st::topicButtonSkip
|
||||
+ st::topicButtonPadding.top()
|
||||
+ st::msgNameFont->height
|
||||
+ st::topicButtonPadding.bottom()
|
||||
|
@ -4315,13 +4319,13 @@ QRect Message::innerGeometry() const {
|
|||
if (!displayFromName() && !displayForwardedFrom()) {
|
||||
// See paintViaBotIdInfo().
|
||||
if (data()->Has<HistoryMessageVia>()) {
|
||||
result.translate(0, st::msgServiceNameFont->height);
|
||||
cut(st::msgServiceNameFont->height);
|
||||
}
|
||||
}
|
||||
// Skip displayForwardedFrom() until there are no animations for it.
|
||||
if (const auto reply = Get<Reply>()) {
|
||||
// See paintReplyInfo().
|
||||
result.translate(0, reply->height());
|
||||
cut(reply->height());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue