diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index a62b49d9a..9479db3fa 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1867,11 +1867,16 @@ Reactions::ButtonParameters Message::reactionButtonParameters( st::reactionCornerCenter.y())) : (QPoint(contentRect.width(), innerHeight) + st::reactionCornerCenter)); - if (reactionState.itemId != result.context) { - if (!contentRect.contains(position)) { - return {}; - } + if (reactionState.itemId != result.context + && !contentRect.contains(position)) { + result.outside = true; } + const auto minSkip = (st::reactionCornerShadow.left() + + st::reactionCornerSize.width() + + st::reactionCornerShadow.right()) / 2; + result.center = QPoint( + std::min(std::max(result.center.x(), minSkip), width() - minSkip), + result.center.y()); return result; } diff --git a/Telegram/SourceFiles/history/view/history_view_react_button.cpp b/Telegram/SourceFiles/history/view/history_view_react_button.cpp index b23cc6164..f59cd600c 100644 --- a/Telegram/SourceFiles/history/view/history_view_react_button.cpp +++ b/Telegram/SourceFiles/history/view/history_view_react_button.cpp @@ -32,6 +32,7 @@ constexpr auto kMaskCacheIndex = 2; constexpr auto kCacheColumsCount = 3; constexpr auto kButtonShowDelay = crl::time(300); constexpr auto kButtonExpandDelay = crl::time(300); +constexpr auto kButtonHideDelay = crl::time(200); [[nodiscard]] QPoint LocalPosition(not_null e) { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -60,11 +61,13 @@ constexpr auto kButtonExpandDelay = crl::time(300); Button::Button( Fn update, - ButtonParameters parameters) + ButtonParameters parameters, + Fn hideMe) : _update(std::move(update)) , _collapsed(QPoint(), CountOuterSize()) , _finalHeight(_collapsed.height()) -, _expandTimer([=] { applyState(State::Inside, _update); }) { +, _expandTimer([=] { applyState(State::Inside, _update); }) +, _hideTimer(hideMe) { applyParameters(parameters, nullptr); } @@ -152,6 +155,11 @@ void Button::applyParameters( update(_geometry); } } + if (parameters.outside && _state == State::Shown) { + _hideTimer.callOnce(kButtonHideDelay); + } else { + _hideTimer.cancel(); + } } void Button::updateExpandDirection(const ButtonParameters ¶meters) { @@ -202,6 +210,7 @@ void Button::applyState(State state) { void Button::applyState(State state, Fn update) { if (state == State::Hidden) { _expandTimer.cancel(); + _hideTimer.cancel(); } const auto finalHeight = (state == State::Inside) ? _expandedHeight @@ -332,6 +341,10 @@ void Manager::updateButton(ButtonParameters parameters) { } else if (_button) { _button->applyParameters(parameters); return; + } else if (parameters.outside) { + _buttonShowTimer.cancel(); + _scheduledParameters = std::nullopt; + return; } const auto globalPositionChanged = _scheduledParameters && (_scheduledParameters->globalPointer != parameters.globalPointer); @@ -345,7 +358,10 @@ void Manager::updateButton(ButtonParameters parameters) { } void Manager::showButtonDelayed() { - _button = std::make_unique