From b592346ce13b15aa420f55d93b1f51c166f3e00e Mon Sep 17 00:00:00 2001 From: Rodney Date: Mar 24 2020 16:43:35 +0000 Subject: Merge pull request #3121 from martinvanzijl/issue-1752-keep-opacity-slider-on-screen (WIP) Make sure opacity slider doesn't go off screen --- diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp index 5fb402e..ec038a4 100644 --- a/toonz/sources/toonz/xshcolumnviewer.cpp +++ b/toonz/sources/toonz/xshcolumnviewer.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include //============================================================================= @@ -2329,6 +2330,21 @@ void ColumnArea::mouseReleaseEvent(QMouseEvent *event) { m_columnTransparencyPopup->move(event->globalPos().x() + x, event->globalPos().y() - y); + // make sure the popup doesn't go off the screen to the right + QDesktopWidget *desktop = qApp->desktop(); + QRect screenRect = desktop->screenGeometry(app->getMainWindow()); + + int popupLeft = event->globalPos().x() + x; + int popupRight = popupLeft + m_columnTransparencyPopup->width(); + + // first condition checks if popup is on same monitor as main app; + // if popup is on different monitor, leave as is + if (popupLeft < screenRect.right() && popupRight > screenRect.right()) { + int distance = popupRight - screenRect.right(); + m_columnTransparencyPopup->move(m_columnTransparencyPopup->x() - distance, + m_columnTransparencyPopup->y()); + } + openTransparencyPopup(); } } else if (m_doOnRelease == ToggleAllPreviewVisible) {