MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / mouseMoveEvent

Method mouseMoveEvent

Telegram/SourceFiles/boxes/background_box.cpp:724–768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

722}
723
724void BackgroundBox::Inner::mouseMoveEvent(QMouseEvent *e) {
725 const auto newOver = [&] {
726 const auto x = e->pos().x();
727 const auto y = e->pos().y();
728 const auto width = st::backgroundSize.width();
729 const auto height = st::backgroundSize.height();
730 const auto skip = st::backgroundPadding;
731 const auto row = int((y - skip) / (height + skip));
732 const auto column = int((x - skip) / (width + skip));
733 const auto result = row * kBackgroundsInRow + column;
734 if (y - row * (height + skip) > skip + height) {
735 return Selection();
736 } else if (x - column * (width + skip) > skip + width) {
737 return Selection();
738 } else if (result >= _papers.size()) {
739 return Selection();
740 }
741 auto &data = _papers[result].data;
742 const auto deleteLeft = (column + 1) * (width + skip)
743 - st::stickerPanDeleteIconBg.width();
744 const auto deleteBottom = row * (height + skip) + skip
745 + st::stickerPanDeleteIconBg.height();
746 const auto inDelete = !forChannel()
747 && (x >= deleteLeft)
748 && (y < deleteBottom)
749 && Data::IsCloudWallPaper(data)
750 && !Data::IsDefaultWallPaper(data)
751 && !Data::IsLegacy2DefaultWallPaper(data)
752 && !Data::IsLegacy3DefaultWallPaper(data)
753 && (_currentId != data.id());
754 return (result >= _papers.size())
755 ? Selection()
756 : inDelete
757 ? Selection(DeleteSelected{ result })
758 : Selection(Selected{ result });
759 }();
760 if (_over != newOver) {
761 repaintPaper(getSelectionIndex(_over));
762 _over = newOver;
763 repaintPaper(getSelectionIndex(_over));
764 setCursor((!v::is_null(_over) || !v::is_null(_overDown))
765 ? style::cur_pointer
766 : style::cur_default);
767 }
768}
769
770void BackgroundBox::Inner::repaintPaper(int index) {
771 if (index < 0 || index >= _papers.size()) {

Callers

nothing calls this directly

Calls 10

IsCloudWallPaperFunction · 0.85
IsDefaultWallPaperFunction · 0.85
SelectionClass · 0.70
yMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
sizeMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected