From c98428b89756aaf774347aaf00d428d3095aeebb Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Sun, 24 Dec 2017 18:20:36 +0100 Subject: [PATCH] Fix button positions based on selection --- src/capture/widget/buttonhandler.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/capture/widget/buttonhandler.cpp b/src/capture/widget/buttonhandler.cpp index d8655981..e67e8c0b 100644 --- a/src/capture/widget/buttonhandler.cpp +++ b/src/capture/widget/buttonhandler.cpp @@ -81,12 +81,12 @@ void ButtonHandler::updatePosition(const QRect &selection) { } // Copy of the selection area for internal modifications m_selection = selection; + updateBlockedSides(); ensureSelectionMinimunSize(); // Indicates the actual button to be moved int elemIndicator = 0; while (elemIndicator < vecLength) { - updateBlockedSides(); // Add them inside the area when there is no more space if (m_allSidesBlocked) { @@ -161,6 +161,7 @@ void ButtonHandler::updatePosition(const QRect &selection) { if (elemIndicator < vecLength && !(m_allSidesBlocked)) { expandSelection(); } + updateBlockedSides(); } } @@ -275,20 +276,16 @@ void ButtonHandler::ensureSelectionMinimunSize() { // Detect if a side is smaller than a button in order to prevent collision // and redimension the base area the the base size of a single button per side if (m_selection.width() < m_buttonBaseSize) { - if (m_blockedRight && !m_blockedLeft) { - m_selection.setX(m_selection.x() - (m_buttonBaseSize-m_selection.width())); - } else if (!m_blockedLeft && !m_blockedRight) { - // When not close to the left side (because the rect grows to the right) - m_selection.setX(m_selection.x() - (m_buttonBaseSize-m_selection.width()) / 2); + if (!m_blockedLeft) { + m_selection.setX(m_selection.x() - + (m_buttonBaseSize-m_selection.width()) / 2); } m_selection.setWidth(m_buttonBaseSize); } if (m_selection.height() < m_buttonBaseSize) { - if (m_blockedBotton && !m_blockedTop) { - m_selection.setY(m_selection.y() - (m_buttonBaseSize-m_selection.height())); - } else if (!m_blockedTop && !m_blockedBotton) { - // When not close to the top (because the rect grows to the bottom) - m_selection.setY(m_selection.y() - (m_buttonBaseSize-m_selection.height()) / 2); + if (!m_blockedTop) { + m_selection.setY(m_selection.y() - + (m_buttonBaseSize-m_selection.height()) / 2); } m_selection.setHeight(m_buttonBaseSize); }