Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/GafferUI/PopupWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def popup( self, center = None, parent = None ) :

self.setVisible( True )
size = self._qtWidget().sizeHint()
print( "PopupWindow.popup : Attempting to move popup to {}".format( center - imath.V2i( size.width() / 2, size.height() / 2 ) ) )
self.setPosition( center - imath.V2i( size.width() / 2, size.height() / 2 ) )
print( "PopupWindow.popup : Popup moved to {}".format( self.getPosition() ) )

## Reimplemented from Widget to report the parent passed to `popup()`.
def parent( self ) :
Expand Down
33 changes: 21 additions & 12 deletions python/GafferUI/Window.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import warnings
import imath

import IECore

import GafferUI
import Gaffer

Expand Down Expand Up @@ -299,22 +301,29 @@ def __constrainToScreen( self, position ) :
windowRect = self._qtWidget().frameGeometry()
windowRect.moveTo( position )

# Determine the offset and which direction to move to stay on screen,
# based on this size difference and which co-ordinate changed in the
# intersected frame
if windowRect.intersects( screenRect ) :

intersection = windowRect.intersected( screenRect )
difference = windowRect.size() - intersection.size()
# Determine the offset and which direction to move to stay on screen,
# based on this size difference and which co-ordinate changed in the
# intersected frame

signX = -1 if intersection.left() == windowRect.left() else 1
signY = -1 if intersection.top() == windowRect.top() else 1
intersection = windowRect.intersected( screenRect )
difference = windowRect.size() - intersection.size()

offset = QtCore.QPoint(
signX * difference.width(),
signY * difference.height()
)
signX = -1 if intersection.left() == windowRect.left() else 1
signY = -1 if intersection.top() == windowRect.top() else 1

offset = QtCore.QPoint(
signX * difference.width(),
signY * difference.height()
)

newPosition = position + offset

else :

newPosition = position + offset
IECore.msg( IECore.Msg.Level.Warning, "Window.__constrainToScreen", "Window is outside screen's available geometry. screen: {} screenRect: {} windowRect: {}".format( screen.name(), screenRect, windowRect ) )
newPosition = position

# Bottom-right corrections may have moved us off to the top-left,
# constrain to the screen origin.
Expand Down
Loading