Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_guides = Value(factory=lambda: {
QGuideRose.Guide.CompassNorth: GuideImage('arrow_north'),
QGuideRose.Guide.CompassEast: GuideImage('arrow_east'),
QGuideRose.Guide.CompassSouth: GuideImage('arrow_south'),
QGuideRose.Guide.CompassWest: GuideImage('arrow_west'),
QGuideRose.Guide.CompassCenter: GuideImage('center'),
})
Instances of this class should be used once and discarded.
"""
BAR_POSITIONS = {
'top': QDockBar.North,
'right': QDockBar.East,
'bottom': QDockBar.South,
'left': QDockBar.West,
}
BORDER_GUIDES = {
'top': QGuideRose.Guide.BorderNorth,
'right': QGuideRose.Guide.BorderEast,
'bottom': QGuideRose.Guide.BorderSouth,
'left': QGuideRose.Guide.BorderWest,
}
ITEM_GUIDES = {
'top': QGuideRose.Guide.CompassNorth,
'right': QGuideRose.Guide.CompassEast,
'bottom': QGuideRose.Guide.CompassSouth,
'left': QGuideRose.Guide.CompassWest,
}
TAB_GUIDES = {
'default': QGuideRose.Guide.CompassCenter,
'top': QGuideRose.Guide.CompassExNorth,
'right': QGuideRose.Guide.CompassExEast,
'bottom': QGuideRose.Guide.CompassExSouth,
'left': QGuideRose.Guide.CompassExWest,
}
def layout(self, pos):
""" Layout the guides for the extended compass.
Parameters
----------
pos : QPoint
The center point of the compass.
"""
x = pos.x()
y = pos.y()
Guide = QGuideRose.Guide
guides = self._guides
guides[Guide.CompassNorth].rect = QRect(x - 15, y - 64, 31, 31)
guides[Guide.CompassEast].rect = QRect(x + 34, y - 15, 31, 31)
guides[Guide.CompassSouth].rect = QRect(x - 15, y + 34, 31, 31)
guides[Guide.CompassWest].rect = QRect(x - 64, y - 15, 31, 31)
guides[Guide.CompassCenter].rect = QRect(x - 15, y - 15, 31, 31)
guides[Guide.CompassExNorth].rect = QRect(x - 15, y - 29, 31, 10)
guides[Guide.CompassExEast].rect = QRect(x + 20, y - 15, 10, 31)
guides[Guide.CompassExSouth].rect = QRect(x - 15, y + 20, 31, 10)
guides[Guide.CompassExWest].rect = QRect(x - 29, y - 15, 10, 31)
self._box.rect = QRect(x - 69, y - 69, 139, 139)
_guides = Value(factory=lambda: {
QGuideRose.Guide.BorderNorth: GuideImage('thin_horizontal'),
QGuideRose.Guide.BorderExNorth: GuideImage('bar_horizontal'),
QGuideRose.Guide.BorderEast: GuideImage('thin_vertical'),
QGuideRose.Guide.BorderExEast: GuideImage('bar_vertical'),
QGuideRose.Guide.BorderSouth: GuideImage('thin_horizontal'),
QGuideRose.Guide.BorderExSouth: GuideImage('bar_horizontal'),
QGuideRose.Guide.BorderWest: GuideImage('thin_vertical'),
QGuideRose.Guide.BorderExWest: GuideImage('bar_vertical'),
})
guides[Guide.CompassEast].rect = QRect(x + 34, y - 15, 31, 31)
guides[Guide.CompassSouth].rect = QRect(x - 15, y + 34, 31, 31)
guides[Guide.CompassWest].rect = QRect(x - 64, y - 15, 31, 31)
guides[Guide.CompassCenter].rect = QRect(x - 15, y - 15, 31, 31)
guides[Guide.CompassExNorth].rect = QRect(x - 15, y - 29, 31, 10)
guides[Guide.CompassExEast].rect = QRect(x + 20, y - 15, 10, 31)
guides[Guide.CompassExSouth].rect = QRect(x - 15, y + 20, 31, 10)
guides[Guide.CompassExWest].rect = QRect(x - 29, y - 15, 10, 31)
self._box.rect = QRect(x - 69, y - 69, 139, 139)
class SingleGuide(GuideHandler):
""" A base class for defining a single guide.
"""
guide_enum = Int(QGuideRose.Guide.NoGuide)
image_name = Str('')
_box = Value(factory=lambda: GuideImage('guide_box'))
_guide = Typed(GuideImage)
def _default__guide(self):
""" The default value handler for the '_guide' attribute.
"""
return GuideImage(self.image_name)
def iterguides(self):
""" Iterate the guides for the compass.
_guides = Value(factory=lambda: {
QGuideRose.Guide.CompassNorth: GuideImage('arrow_north'),
QGuideRose.Guide.CompassEast: GuideImage('arrow_east'),
QGuideRose.Guide.CompassSouth: GuideImage('arrow_south'),
QGuideRose.Guide.CompassWest: GuideImage('arrow_west'),
QGuideRose.Guide.CompassCenter: GuideImage('center'),
})
class SplitHorizontalGuide(SingleGuide):
""" A single guide which uses the horizontal split image.
"""
guide_enum = set_default(QGuideRose.Guide.SplitHorizontal)
image_name = set_default('split_horizontal')
class SplitVerticalGuide(SingleGuide):
""" A single guide which uses the vertical split image.
"""
guide_enum = set_default(QGuideRose.Guide.SplitVertical)
image_name = set_default('split_vertical')
class AreaCenterGuide(SingleGuide):
""" A single guide which uses the area center image.
"""
guide_enum = set_default(QGuideRose.Guide.AreaCenter)
image_name = set_default('center')
Parameters
----------
pos : QPoint
The point of interest, expressed in layout coordinates.
Returns
-------
result : Guide
The enum value for the guide at the given position.
"""
for enum, guide in self.iterguides():
if guide.contains(pos):
return enum
return QGuideRose.Guide.NoGuide
_boxes = Value(factory=lambda: {
QGuideRose.Guide.BorderNorth: GuideImage('guide_box'),
QGuideRose.Guide.BorderEast: GuideImage('guide_box'),
QGuideRose.Guide.BorderSouth: GuideImage('guide_box'),
QGuideRose.Guide.BorderWest: GuideImage('guide_box'),
})
_guides = Value(factory=lambda: {
QGuideRose.Guide.CompassNorth: GuideImage('arrow_north'),
QGuideRose.Guide.CompassEast: GuideImage('arrow_east'),
QGuideRose.Guide.CompassSouth: GuideImage('arrow_south'),
QGuideRose.Guide.CompassWest: GuideImage('arrow_west'),
QGuideRose.Guide.CompassCenter: GuideImage('center'),
QGuideRose.Guide.CompassExNorth: GuideImage('bar_horizontal'),
QGuideRose.Guide.CompassExEast: GuideImage('bar_vertical'),
QGuideRose.Guide.CompassExSouth: GuideImage('bar_horizontal'),
QGuideRose.Guide.CompassExWest: GuideImage('bar_vertical'),
})