From ec70df10671d5ebb4890bf5fd52c6fd4c955fb65 Mon Sep 17 00:00:00 2001 From: James Tai <45131430+j-tai@users.noreply.github.com> Date: Wed, 1 Sep 2021 04:48:19 -0700 Subject: [PATCH] Fix edit buttons appearing inside selection (#1856) * Fix edit buttons appearing inside selection * Reformat files --- src/widgets/capture/buttonhandler.cpp | 20 +++++++++++--------- src/widgets/capture/buttonhandler.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/widgets/capture/buttonhandler.cpp b/src/widgets/capture/buttonhandler.cpp index c3f030e6..18935258 100644 --- a/src/widgets/capture/buttonhandler.cpp +++ b/src/widgets/capture/buttonhandler.cpp @@ -246,27 +246,32 @@ void ButtonHandler::resetRegionTrack() void ButtonHandler::updateBlockedSides() { + QRegion screenRegion{}; + for (const QRect& rect : m_screenRegions) { + screenRegion += rect; + } + const int EXTENSION = m_separator * 2 + m_buttonBaseSize; // Right QPoint pointA(m_selection.right() + EXTENSION, m_selection.bottom()); QPoint pointB(pointA.x(), m_selection.top()); m_blockedRight = - !(m_screenRegions.contains(pointA) && m_screenRegions.contains(pointB)); + !(screenRegion.contains(pointA) && screenRegion.contains(pointB)); // Left pointA.setX(m_selection.left() - EXTENSION); pointB.setX(pointA.x()); m_blockedLeft = - !(m_screenRegions.contains(pointA) && m_screenRegions.contains(pointB)); + !(screenRegion.contains(pointA) && screenRegion.contains(pointB)); // Bottom pointA = QPoint(m_selection.left(), m_selection.bottom() + EXTENSION); pointB = QPoint(m_selection.right(), pointA.y()); m_blockedBotton = - !(m_screenRegions.contains(pointA) && m_screenRegions.contains(pointB)); + !(screenRegion.contains(pointA) && screenRegion.contains(pointB)); // Top pointA.setY(m_selection.top() - EXTENSION); pointB.setY(pointA.y()); m_blockedTop = - !(m_screenRegions.contains(pointA) && m_screenRegions.contains(pointB)); + !(screenRegion.contains(pointA) && screenRegion.contains(pointB)); // Auxiliary m_oneHorizontalBlocked = (!m_blockedRight && m_blockedLeft) || (m_blockedRight && !m_blockedLeft); @@ -377,13 +382,10 @@ bool ButtonHandler::contains(const QPoint& p) const void ButtonHandler::updateScreenRegions(const QVector& rects) { - m_screenRegions = QRegion(); - for (const QRect& rect : rects) { - m_screenRegions += rect; - } + m_screenRegions = rects; } void ButtonHandler::updateScreenRegions(const QRect& rect) { - m_screenRegions = QRegion(rect); + m_screenRegions = { rect }; } diff --git a/src/widgets/capture/buttonhandler.h b/src/widgets/capture/buttonhandler.h index e7fb4041..839e3009 100644 --- a/src/widgets/capture/buttonhandler.h +++ b/src/widgets/capture/buttonhandler.h @@ -48,7 +48,7 @@ private: QVector m_vectorButtons; - QRegion m_screenRegions; + QVector m_screenRegions; QRect m_selection;