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