mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Scroll quote selection in the draft options box.
This commit is contained in:
parent
7d67b3d00a
commit
a8b0f2934b
2 changed files with 46 additions and 10 deletions
|
@ -110,6 +110,10 @@ public:
|
|||
const std::vector<MessageLinkRange> &links,
|
||||
const QString &usedLink);
|
||||
|
||||
[[nodiscard]] rpl::producer<int> draggingScrollDelta() const {
|
||||
return _draggingScrollDelta.events();
|
||||
}
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
@ -118,6 +122,11 @@ private:
|
|||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
|
||||
void visibleTopBottomUpdated(int top, int bottom) override {
|
||||
_visibleTop = top;
|
||||
_visibleBottom = bottom;
|
||||
}
|
||||
|
||||
void initElement();
|
||||
void highlightUsedLink(
|
||||
const TextWithTags &message,
|
||||
|
@ -141,6 +150,9 @@ private:
|
|||
rpl::lifetime _elementLifetime;
|
||||
|
||||
QPoint _position;
|
||||
rpl::event_stream<int> _draggingScrollDelta;
|
||||
int _visibleTop = 0;
|
||||
int _visibleBottom = 0;
|
||||
|
||||
base::Timer _trippleClickTimer;
|
||||
ClickHandlerPtr _link;
|
||||
|
@ -423,9 +435,8 @@ void PreviewWrap::mouseMoveEvent(QMouseEvent *e) {
|
|||
: Flag::LookupLink),
|
||||
.onlyMessageText = (_section == Section::Link || _onlyMessageText),
|
||||
};
|
||||
auto resolved = _element->textState(
|
||||
e->pos() - _position,
|
||||
request);
|
||||
const auto position = e->pos();
|
||||
auto resolved = _element->textState(position - _position, request);
|
||||
_over = true;
|
||||
const auto text = (_section == Section::Reply)
|
||||
&& (resolved.cursor == CursorState::Text);
|
||||
|
@ -450,6 +461,17 @@ void PreviewWrap::mouseMoveEvent(QMouseEvent *e) {
|
|||
update();
|
||||
}
|
||||
}
|
||||
|
||||
_draggingScrollDelta.fire([&] {
|
||||
if (!_selecting || _visibleTop >= _visibleBottom) {
|
||||
return 0;
|
||||
} else if (position.y() < _visibleTop) {
|
||||
return position.y() - _visibleTop;
|
||||
} else if (position.y() >= _visibleBottom) {
|
||||
return position.y() + 1 - _visibleBottom;
|
||||
}
|
||||
return 0;
|
||||
}());
|
||||
}
|
||||
|
||||
void PreviewWrap::mousePressEvent(QMouseEvent *e) {
|
||||
|
@ -814,6 +836,11 @@ void DraftOptionsBox(
|
|||
state->wrap = box->addRow(
|
||||
object_ptr<PreviewWrap>(box, args.history),
|
||||
{});
|
||||
state->wrap->draggingScrollDelta(
|
||||
) | rpl::start_with_next([=](int delta) {
|
||||
box->scrollByDraggingDelta(delta);
|
||||
}, state->wrap->lifetime());
|
||||
|
||||
const auto &linkRanges = args.links;
|
||||
state->shown.value() | rpl::start_with_next([=](Section shown) {
|
||||
bottom->clear();
|
||||
|
|
|
@ -2400,8 +2400,10 @@ TextState Message::textState(
|
|||
const auto media = this->media();
|
||||
|
||||
auto result = TextState(item);
|
||||
const auto visibleMediaTextLen = visibleMediaTextLength();
|
||||
const auto visibleTextLen = visibleTextLength();
|
||||
const auto minSymbol = (_invertMedia && request.onlyMessageText)
|
||||
? visibleMediaTextLength()
|
||||
? visibleMediaTextLen
|
||||
: 0;
|
||||
result.symbol = minSymbol;
|
||||
|
||||
|
@ -2428,6 +2430,7 @@ TextState Message::textState(
|
|||
g.setHeight(g.height() - reactionsHeight);
|
||||
const auto reactionsPosition = QPoint(reactionsLeft + g.left(), g.top() + g.height() + st::mediaInBubbleSkip);
|
||||
if (_reactions->getState(point - reactionsPosition, &result)) {
|
||||
result.symbol += visibleMediaTextLen + visibleTextLen;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -2443,6 +2446,7 @@ TextState Message::textState(
|
|||
|
||||
auto inner = g;
|
||||
if (getStateCommentsButton(point, inner, &result)) {
|
||||
result.symbol += visibleMediaTextLen + visibleTextLen;
|
||||
return result;
|
||||
}
|
||||
auto trect = inner.marginsRemoved(st::msgPadding);
|
||||
|
@ -2460,6 +2464,7 @@ TextState Message::textState(
|
|||
trect.setHeight(trect.height() - reactionsHeight);
|
||||
const auto reactionsPosition = QPoint(trect.left(), trect.top() + trect.height() + reactionsTop);
|
||||
if (_reactions->getState(point - reactionsPosition, &result)) {
|
||||
result.symbol += visibleMediaTextLen + visibleTextLen;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -2475,6 +2480,7 @@ TextState Message::textState(
|
|||
? inner
|
||||
: inner - heightMargins),
|
||||
&result)) {
|
||||
result.symbol += visibleMediaTextLen + visibleTextLen;
|
||||
return result;
|
||||
}
|
||||
if (belowInfo) {
|
||||
|
@ -2552,7 +2558,11 @@ TextState Message::textState(
|
|||
result = bottomInfoResult;
|
||||
}
|
||||
};
|
||||
if (result.symbol <= minSymbol && inBubble) {
|
||||
if (!inBubble) {
|
||||
if (point.y() >= g.y() + g.height()) {
|
||||
result.symbol += visibleTextLen + visibleMediaTextLen;
|
||||
}
|
||||
} else if (result.symbol <= minSymbol) {
|
||||
const auto mediaHeight = mediaDisplayed ? media->height() : 0;
|
||||
const auto mediaLeft = trect.x() - st::msgPadding.left();
|
||||
const auto mediaTop = (!mediaDisplayed || _invertMedia)
|
||||
|
@ -2575,22 +2585,21 @@ TextState Message::textState(
|
|||
result.cursor = CursorState::None;
|
||||
}
|
||||
} else if (request.onlyMessageText) {
|
||||
result.symbol = visibleTextLength();
|
||||
result.symbol = visibleTextLen;
|
||||
result.afterSymbol = false;
|
||||
result.cursor = CursorState::None;
|
||||
} else {
|
||||
result.symbol += visibleTextLength();
|
||||
result.symbol += visibleTextLen;
|
||||
}
|
||||
} else if (getStateText(point, trect, &result, request)) {
|
||||
if (_invertMedia) {
|
||||
result.symbol += visibleMediaTextLength();
|
||||
result.symbol += visibleMediaTextLen;
|
||||
}
|
||||
result.overMessageText = true;
|
||||
checkBottomInfoState();
|
||||
return result;
|
||||
} else if (point.y() >= trect.y() + trect.height()) {
|
||||
result.symbol = visibleTextLength()
|
||||
+ visibleMediaTextLength();
|
||||
result.symbol = visibleTextLen + visibleMediaTextLen;
|
||||
}
|
||||
}
|
||||
checkBottomInfoState();
|
||||
|
|
Loading…
Add table
Reference in a new issue