mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +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();
|
auto request = HistoryView::StateRequest();
|
||||||
request.flags = Ui::Text::StateRequest::Flag::LookupSymbol;
|
request.flags = Ui::Text::StateRequest::Flag::LookupSymbol;
|
||||||
const auto single = st::messageTextStyle.font->height;
|
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) {
|
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 symbolfrom = fory(yfrom);
|
||||||
auto symboltill = fory(ytill);
|
auto symboltill = fory(ytill);
|
||||||
if ((yfrom >= ytill) || (symbolfrom >= symbol)) {
|
if ((yfrom >= ytill) || (symbolfrom >= symbol)) {
|
||||||
return yfrom;
|
return origin.y() + yfrom;
|
||||||
} else if (symboltill <= symbol) {
|
} else if (symboltill <= symbol) {
|
||||||
return ytill;
|
return origin.y() + ytill;
|
||||||
}
|
}
|
||||||
while (ytill - yfrom >= 2 * single) {
|
while (ytill - yfrom >= 2 * single) {
|
||||||
const auto middle = (yfrom + ytill) / 2;
|
const auto middle = (yfrom + ytill) / 2;
|
||||||
|
@ -2045,7 +2055,7 @@ int FindViewY(not_null<Element*> view, uint16 symbol, int yfrom) {
|
||||||
symboltill = found;
|
symboltill = found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (yfrom + ytill) / 2;
|
return origin.y() + (yfrom + ytill) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -4299,14 +4299,18 @@ QRect Message::innerGeometry() const {
|
||||||
width()));
|
width()));
|
||||||
}
|
}
|
||||||
if (hasBubble()) {
|
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()) {
|
if (displayFromName()) {
|
||||||
// See paintFromName().
|
// See paintFromName().
|
||||||
result.translate(0, st::msgNameFont->height);
|
cut(st::msgNameFont->height);
|
||||||
}
|
}
|
||||||
if (displayedTopicButton()) {
|
if (displayedTopicButton()) {
|
||||||
result.translate(0, st::topicButtonSkip
|
cut(st::topicButtonSkip
|
||||||
+ st::topicButtonPadding.top()
|
+ st::topicButtonPadding.top()
|
||||||
+ st::msgNameFont->height
|
+ st::msgNameFont->height
|
||||||
+ st::topicButtonPadding.bottom()
|
+ st::topicButtonPadding.bottom()
|
||||||
|
@ -4315,13 +4319,13 @@ QRect Message::innerGeometry() const {
|
||||||
if (!displayFromName() && !displayForwardedFrom()) {
|
if (!displayFromName() && !displayForwardedFrom()) {
|
||||||
// See paintViaBotIdInfo().
|
// See paintViaBotIdInfo().
|
||||||
if (data()->Has<HistoryMessageVia>()) {
|
if (data()->Has<HistoryMessageVia>()) {
|
||||||
result.translate(0, st::msgServiceNameFont->height);
|
cut(st::msgServiceNameFont->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Skip displayForwardedFrom() until there are no animations for it.
|
// Skip displayForwardedFrom() until there are no animations for it.
|
||||||
if (const auto reply = Get<Reply>()) {
|
if (const auto reply = Get<Reply>()) {
|
||||||
// See paintReplyInfo().
|
// See paintReplyInfo().
|
||||||
result.translate(0, reply->height());
|
cut(reply->height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue