Fix edit buttons appearing inside selection (#1856)

* Fix edit buttons appearing inside selection

* Reformat files
This commit is contained in:
James Tai
2021-09-01 04:48:19 -07:00
committed by GitHub
parent df20c7ec8f
commit ec70df1067
2 changed files with 12 additions and 10 deletions

View File

@@ -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<QRect>& 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 };
}

View File

@@ -48,7 +48,7 @@ private:
QVector<CaptureToolButton*> m_vectorButtons;
QRegion m_screenRegions;
QVector<QRect> m_screenRegions;
QRect m_selection;