mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Handle click on the reaction once again.
This commit is contained in:
parent
b108e93092
commit
35378e717a
3 changed files with 24 additions and 8 deletions
|
@ -2987,8 +2987,8 @@ void HistoryInner::mouseActionUpdate() {
|
|||
QPoint m;
|
||||
|
||||
adjustCurrent(point.y());
|
||||
const auto reactionItemId = _reactionsManager->lookupButtonId(point);
|
||||
const auto reactionItem = session().data().message(reactionItemId);
|
||||
const auto reactionState = _reactionsManager->buttonTextState(point);
|
||||
const auto reactionItem = session().data().message(reactionState.itemId);
|
||||
const auto reactionView = reactionItem
|
||||
? reactionItem->mainView()
|
||||
: nullptr;
|
||||
|
@ -3034,7 +3034,13 @@ void HistoryInner::mouseActionUpdate() {
|
|||
&& (view == App::hoveredItem())
|
||||
&& !_selected.empty()
|
||||
&& (_selected.cbegin()->second != FullSelection);
|
||||
if (point.y() < _historyPaddingTop) {
|
||||
if (reactionView && reactionState.link) {
|
||||
dragState = reactionState;
|
||||
lnkhost = reactionView;
|
||||
_reactionsManager->showSelector([=](QPoint local) {
|
||||
return mapToGlobal(local);
|
||||
});
|
||||
} else if (point.y() < _historyPaddingTop) {
|
||||
if (_botAbout && !_botAbout->info->text.isEmpty() && _botAbout->height > 0) {
|
||||
dragState = TextState(nullptr, _botAbout->info->text.getState(
|
||||
point - _botAbout->rect.topLeft() - QPoint(st::msgPadding.left(), st::msgPadding.top() + st::botDescSkip + st::msgNameFont->height),
|
||||
|
|
|
@ -376,6 +376,14 @@ Manager::Manager(QWidget *selectorParent, Fn<void(QRect)> buttonUpdate)
|
|||
st::reactionCornerSize.width(),
|
||||
st::reactionCornerSize.height()))
|
||||
, _buttonUpdate(std::move(buttonUpdate))
|
||||
, _buttonLink(std::make_shared<LambdaClickHandler>(crl::guard(this, [=] {
|
||||
if (_buttonContext && !_list.empty()) {
|
||||
_chosen.fire({
|
||||
.context = _buttonContext,
|
||||
.emoji = _list.front().emoji,
|
||||
});
|
||||
}
|
||||
})))
|
||||
, _selectorParent(selectorParent) {
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
_cacheInOut = QImage(
|
||||
|
@ -468,14 +476,16 @@ void Manager::paintButtons(Painter &p, const PaintContext &context) {
|
|||
}
|
||||
}
|
||||
|
||||
FullMsgId Manager::lookupButtonId(QPoint position) const {
|
||||
TextState Manager::buttonTextState(QPoint position) const {
|
||||
if (const auto current = _button.get()) {
|
||||
const auto geometry = current->geometry();
|
||||
if (geometry.contains(position)) {
|
||||
const auto maxInner = QRect({}, CountMaxSizeWithMargins({}));
|
||||
const auto shift = geometry.center() - maxInner.center();
|
||||
if (maxInner.translated(shift).contains(position)) {
|
||||
return _buttonContext;
|
||||
auto result = TextState(nullptr, _buttonLink);
|
||||
result.itemId = _buttonContext;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace HistoryView {
|
|||
using PaintContext = Ui::ChatPaintContext;
|
||||
enum class PointState : char;
|
||||
struct TextState;
|
||||
struct StateRequest;
|
||||
class Message;
|
||||
} // namespace HistoryView
|
||||
|
||||
|
@ -149,7 +148,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class Manager final {
|
||||
class Manager final : public base::has_weak_ptr {
|
||||
public:
|
||||
Manager(QWidget *selectorParent, Fn<void(QRect)> buttonUpdate);
|
||||
~Manager();
|
||||
|
@ -158,7 +157,7 @@ public:
|
|||
|
||||
void showButton(ButtonParameters parameters);
|
||||
void paintButtons(Painter &p, const PaintContext &context);
|
||||
[[nodiscard]] FullMsgId lookupButtonId(QPoint position) const;
|
||||
[[nodiscard]] TextState buttonTextState(QPoint position) const;
|
||||
|
||||
void showSelector(Fn<QPoint(QPoint)> mapToGlobal);
|
||||
void showSelector(FullMsgId context, QRect globalButtonArea);
|
||||
|
@ -227,6 +226,7 @@ private:
|
|||
std::unique_ptr<Button> _button;
|
||||
std::vector<std::unique_ptr<Button>> _buttonHiding;
|
||||
FullMsgId _buttonContext;
|
||||
ClickHandlerPtr _buttonLink;
|
||||
|
||||
QWidget *_selectorParent = nullptr;
|
||||
std::unique_ptr<Selector> _selector;
|
||||
|
|
Loading…
Add table
Reference in a new issue