-
Notifications
You must be signed in to change notification settings - Fork 7
/
spritelib.py
805 lines (653 loc) · 24.2 KB
/
spritelib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
#!/usr/bin/python
# -*- coding: latin-1 -*-
# Reggie Next - New Super Mario Bros. Wii / New Super Mario Bros 2 Level Editor
# Milestone 2 Alpha 4
# Copyright (C) 2009-2014 Treeki, Tempus, angelsl, JasonP27, Kamek64,
# MalStar1000, RoadrunnerWMC
# This file is part of Reggie Next.
# Reggie Next is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Reggie Next is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Reggie Next. If not, see <http://www.gnu.org/licenses/>.
# spritelib.py
# Contains general code to render sprite images in the editor UI
################################################################
################################################################
# Imports
import os.path
from PyQt5 import QtCore, QtGui, QtWidgets
Qt = QtCore.Qt
OutlineColor = None
OutlinePen = None
OutlineBrush = None
ImageCache = {}
Tiles = {}
SpriteImagesLoaded = set()
SpritesFolders = []
RealViewEnabled = False
Area = None
MapPositionToZoneID = None
################################################################
################################################################
################################################################
########################## Functions ###########################
def main():
"""
Resets Sprites.py to its original settings
"""
global OutlineColor, OutlinePen, OutlineBrush, ImageCache, SpritesFolders
OutlinePen = QtGui.QPen(OutlineColor, 4)
OutlineBrush = QtGui.QBrush(OutlineColor)
for i in range(256):
Tiles[i] = None
# Don't make a new dict instance for ImageCache because sprites.py
# won't receive it, which causes bugs.
ImageCache.clear()
SpriteImagesLoaded.clear()
SpritesFolders = []
def GetImg(imgname, image=False):
"""
Returns the image path from the PNG filename imgname
"""
imgname = str(imgname)
# Try to find the best path
path = os.path.join(GameDataFolders[CurrentGame], 'sprites', imgname)
for folder in reversed(SpritesFolders): # find the most recent copy
tryPath = os.path.join(folder, imgname)
if os.path.isfile(tryPath):
path = tryPath
break
# Return the appropriate object
if os.path.isfile(path):
if image: return QtGui.QImage(path)
else: return QtGui.QPixmap(path)
def loadIfNotInImageCache(name, filename):
"""
If name is not in ImageCache, loads the image
referenced by 'filename' and puts it there
"""
if name not in ImageCache:
ImageCache[name] = GetImg(filename)
def getNearestZoneTo(objx, objy):
"""
Returns the nearest zone to the given position
"""
print('getNearestZoneTo(%d, %d):' % (objx, objy))
if not hasattr(Area, 'zones'):
print(' not hasattr; bye bye')
return None
id = MapPositionToZoneID(Area.zones, objx, objy, True)
for z in Area.zones:
if z.id == id:
print((' Found something for id %d; returning ' % id) + str(z))
return z
print(' Found nothing for id %d; bye bye' % id)
################################################################
################################################################
################################################################
##################### SpriteImage Classes ######################
class SpriteImage():
"""
Class that contains information about a sprite image
"""
def __init__(self, parent, scale=1.5):
"""
Intializes the sprite image
"""
self.parent = parent
self.alpha = 1.0
self.image = None
if not isinstance(scale, float):
print('Tell RoadrunnerWMC that he missed the __init__ API change for NSMBW sprite %d.' % self.parent.type)
self.spritebox = Spritebox(scale)
self.dimensions = 0, 0, 16, 16
self.scale = scale
self.aux = []
@staticmethod
def loadImages():
"""
Loads all images needed by the sprite
"""
pass
def dataChanged(self):
"""
Called whenever the sprite data changes
"""
pass
def positionChanged(self):
"""
Called whenever the sprite position changes
"""
pass
def paint(self, painter):
"""
Paints the sprite
"""
pass
# Offset property
def getOffset(self):
return (self.xOffset, self.yOffset)
def setOffset(self, new):
self.xOffset, self.yOffset = new[0], new[1]
def delOffset(self):
self.xOffset, self.yOffset = 0, 0
offset = property(
getOffset, setOffset, delOffset,
'Convenience property that provides access to self.xOffset and self.yOffset in one tuple',
)
# Size property
def getSize(self):
return (self.width, self.height)
def setSize(self, new):
self.width, self.height = new[0], new[1]
def delSize(self):
self.width, self.height = 16, 16
size = property(
getSize, setSize, delSize,
'Convenience property that provides access to self.width and self.height in one tuple',
)
# Dimensions property
def getDimensions(self):
return (self.xOffset, self.yOffset, self.width, self.height)
def setDimensions(self, new):
self.xOffset, self.yOffset, self.width, self.height = new[0], new[1], new[2], new[3]
def delDimensions(self):
self.xOffset, self.yOffset, self.width, self.height = 0, 0, 16, 16
dimensions = property(
getDimensions, setDimensions, delDimensions,
'Convenience property that provides access to self.xOffset, self.yOffset, self.width and self.height in one tuple',
)
class SpriteImage_Static(SpriteImage):
"""
A simple class for drawing a static sprite image
"""
def __init__(self, parent, scale=1.5, image=None, offset=None):
super().__init__(parent, scale)
self.image = image
self.spritebox.shown = False
if self.image is not None:
self.width = (self.image.width() / self.scale) + 1
self.height = (self.image.height() / self.scale) + 2
if offset is not None:
self.xOffset = offset[0]
self.yOffset = offset[1]
def dataChanged(self):
super().dataChanged()
if self.image is not None:
self.size = (
(self.image.width() / self.scale) + 1,
(self.image.height() / self.scale) + 2,
)
else:
del self.size
def paint(self, painter):
super().paint(painter)
if self.image is None: return
painter.save()
painter.setOpacity(self.alpha)
painter.scale(1.5 / self.scale, 1.5 / self.scale) # rescale images not based on a 24x24 block size
painter.setRenderHint(painter.SmoothPixmapTransform)
painter.drawPixmap(0, 0, self.image)
painter.restore()
class SpriteImage_StaticMultiple(SpriteImage_Static):
"""
A class that acts like a SpriteImage_Static but lets you change
the image with the dataChanged() function
"""
def __init__(self, parent, scale=1.5, image=None, offset=None):
super().__init__(parent, scale, image, offset)
# no other changes needed yet
################################################################
################################################################
################################################################
####################### Spritebox Class ########################
class Spritebox():
"""
Contains size and other information for a spritebox
"""
def __init__(self, scale=1.5):
super().__init__()
self.shown = True
self.xOffset = 0
self.yOffset = 0
self.width = 16
self.height = 16
self.scale = scale
# Offset property
def getOffset(self):
return (self.xOffset, self.yOffset)
def setOffset(self, new):
self.xOffset, self.yOffset = new[0], new[1]
def delOffset(self):
self.xOffset, self.yOffset = 0, 0
offset = property(
getOffset, setOffset, delOffset,
'Convenience property that provides access to self.xOffset and self.yOffset in one tuple',
)
# Size property
def getSize(self):
return (self.width, self.height)
def setSize(self, new):
self.width, self.height = new[0], new[1]
def delSize(self):
self.width, self.height = 16, 16
size = property(
getSize, setSize, delSize,
'Convenience property that provides access to self.width and self.height in one tuple',
)
# Dimensions property
def getDimensions(self):
return (self.xOffset, self.yOffset, self.width, self.height)
def setDimensions(self, new):
self.xOffset, self.yOffset, self.width, self.height = new[0], new[1], new[2], new[3]
def delDimensions(self):
self.xOffset, self.yOffset, self.width, self.height = 0, 0, 16, 16
dimensions = property(
getDimensions, setDimensions, delDimensions,
'Convenience property that provides access to self.xOffset, self.yOffset, self.width and self.height in one tuple',
)
# RoundedRect property
def getRR(self):
return QtCore.QRectF(
(self.xOffset * self.scale) + 1,
(self.yOffset * self.scale) + 1,
(self.width * self.scale) - 2,
(self.height * self.scale) - 2,
)
def setRR(self, new):
self.dimensions = (
(new.x() / self.scale) - 1,
(new.y() / self.scale) - 1,
(new.width() / self.scale) + 2,
(new.height() / self.scale) + 2,
)
def delRR(self):
self.dimensions = 0, 0, 16, 16
RoundedRect = property(
getRR, setRR, delRR,
'Property that contains the rounded rect for the spritebox',
)
# BoundingRect property
def getBR(self):
return QtCore.QRectF(
self.xOffset * self.scale,
self.yOffset * self.scale,
self.width * self.scale,
self.height * self.scale,
)
def setBR(self, new):
self.dimensions = (
new.x() * self.scale,
new.y() * self.scale,
new.width() * self.scale,
new.height() * self.scale,
)
def delBR(self):
self.dimensions = 0, 0, 16, 16
BoundingRect = property(
getBR, setBR, delBR,
'Property that contains the bounding rect for the spritebox',
)
################################################################
################################################################
################################################################
#################### AuxiliarySpriteItem Classes #####################
class AuxiliaryItem():
"""
Base class for all auxiliary things
"""
pass
class AuxiliarySpriteItem(AuxiliaryItem, QtWidgets.QGraphicsItem):
"""
Base class for auxiliary objects that accompany specific sprite types
"""
def __init__(self, parent):
"""
Generic constructor for auxiliary items
"""
super().__init__(parent)
self.parent = parent
self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, True)
self.setParentItem(parent)
self.hover = False
self.BoundingRect = QtCore.QRectF(0, 0, 24, 24)
def setIsBehindSprite(self, behind):
"""
This allows you to choose whether the auiliary item will display
behind the sprite or in front of it. Default is for the item to
be behind the sprite.
"""
self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, behind)
def boundingRect(self):
"""
Required for Qt
"""
return self.BoundingRect
class AuxiliaryTrackObject(AuxiliarySpriteItem):
"""
Track shown behind moving platforms to show where they can move
"""
Horizontal = 1
Vertical = 2
def __init__(self, parent, width, height, direction):
"""
Constructor
"""
super().__init__(parent)
self.BoundingRect = QtCore.QRectF(0, 0, width * 1.5, height * 1.5)
self.setPos(0, 0)
self.width = width
self.height = height
self.direction = direction
self.hover = False
def setSize(self, width, height):
self.prepareGeometryChange()
self.BoundingRect = QtCore.QRectF(0, 0, width * 1.5, height * 1.5)
self.width = width
self.height = height
def paint(self, painter, option, widget=None):
if option is not None:
painter.setClipRect(option.exposedRect)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.setPen(OutlinePen)
if self.direction == self.Horizontal:
lineY = self.height * 0.75
painter.drawLine(20, lineY, (self.width * 1.5) - 20, lineY)
painter.drawEllipse(8, lineY - 4, 8, 8)
painter.drawEllipse((self.width * 1.5) - 16, lineY - 4, 8, 8)
else:
lineX = self.width * 0.75
painter.drawLine(lineX, 20, lineX, (self.height * 1.5) - 20)
painter.drawEllipse(lineX - 4, 8, 8, 8)
painter.drawEllipse(lineX - 4, (self.height * 1.5) - 16, 8, 8)
class AuxiliaryCircleOutline(AuxiliarySpriteItem):
def __init__(self, parent, width, alignMode=Qt.AlignHCenter):
"""
Constructor
"""
super().__init__(parent)
self.hover = False
self.alignMode = alignMode
self.setSize(width)
def setSize(self, width):
self.prepareGeometryChange()
self.BoundingRect = QtCore.QRectF(0, 0, width * 1.5, width * 1.5)
centerOffset = (8 - (width / 2)) * 1.5
fullOffset = -(width * 1.5) + 24
xval = 0
if self.alignMode & Qt.AlignHCenter:
xval = centerOffset
elif self.alignMode & Qt.AlignRight:
xval = fullOffset
yval = 0
if self.alignMode & Qt.AlignVCenter:
yval = centerOffset
elif self.alignMode & Qt.AlignBottom:
yval = fullOffset
self.setPos(xval, yval)
self.width = width
def paint(self, painter, option, widget=None):
if option is not None:
painter.setClipRect(option.exposedRect)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.setPen(OutlinePen)
painter.setBrush(OutlineBrush)
painter.drawEllipse(self.BoundingRect)
class AuxiliaryRotationAreaOutline(AuxiliarySpriteItem):
def __init__(self, parent, width):
"""
Constructor
"""
super().__init__(parent)
self.BoundingRect = QtCore.QRectF(0, 0, width * 1.5, width * 1.5)
self.setPos((8 - (width / 2)) * 1.5, (8 - (width / 2)) * 1.5)
self.width = width
self.startAngle = 0
self.spanAngle = 0
self.hover = False
def SetAngle(self, startAngle, spanAngle):
self.startAngle = startAngle * 16
self.spanAngle = spanAngle * 16
def paint(self, painter, option, widget=None):
if option is not None:
painter.setClipRect(option.exposedRect)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.setPen(OutlinePen)
painter.setBrush(OutlineBrush)
painter.drawPie(self.BoundingRect, self.startAngle, self.spanAngle)
class AuxiliaryRectOutline(AuxiliarySpriteItem):
def __init__(self, parent, width, height, xoff=0, yoff=0):
"""
Constructor
"""
super().__init__(parent)
self.BoundingRect = QtCore.QRectF(0, 0, width, height)
self.setPos(xoff, yoff)
self.hover = False
def setSize(self, width, height, xoff=0, yoff=0):
self.BoundingRect = QtCore.QRectF(0, 0, width, height)
self.setPos(xoff, yoff)
def paint(self, painter, option, widget=None):
if option is not None:
painter.setClipRect(option.exposedRect)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.setPen(OutlinePen)
painter.setBrush(OutlineBrush)
painter.drawRect(self.BoundingRect)
class AuxiliaryPainterPath(AuxiliarySpriteItem):
def __init__(self, parent, path, width, height, xoff=0, yoff=0):
"""
Constructor
"""
super().__init__(parent)
self.PainterPath = path
self.setPos(xoff, yoff)
self.fillFlag = True
self.BoundingRect = QtCore.QRectF(0, 0, width, height)
self.hover = False
def SetPath(self, path):
self.PainterPath = path
def setSize(self, width, height, xoff=0, yoff=0):
self.BoundingRect = QtCore.QRectF(0, 0, width, height)
self.setPos(xoff, yoff)
def paint(self, painter, option, widget=None):
if option is not None:
painter.setClipRect(option.exposedRect)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
painter.setPen(OutlinePen)
if self.fillFlag: painter.setBrush(OutlineBrush)
painter.drawPath(self.PainterPath)
class AuxiliaryImage(AuxiliarySpriteItem):
def __init__(self, parent, width, height):
"""
Constructor
"""
super().__init__(parent)
self.BoundingRect = QtCore.QRectF(0, 0, width, height)
self.width = width
self.height = height
self.image = None
self.hover = True
def setSize(self, width, height, xoff=0, yoff=0):
self.prepareGeometryChange()
self.BoundingRect = QtCore.QRectF(0, 0, width, height)
self.setPos(xoff, yoff)
self.width = width
self.height = height
def paint(self, painter, option, widget=None):
if option is not None:
painter.setClipRect(option.exposedRect)
if self.image is not None:
painter.drawPixmap(0, 0, self.image)
class AuxiliaryImage_FollowsRect(AuxiliaryImage):
def __init__(self, parent, width, height):
"""
Constructor
"""
super().__init__(parent, width, height)
self.alignment = Qt.AlignTop | Qt.AlignLeft
self.realwidth = self.width
self.realheight = self.height
self.realimage = None
# Doing it this way may provide a slight speed boost?
self.flagPresent = lambda flags, flag: flags | flag == flags
def setSize(self, width, height):
super().setSize(width, height)
self.realwidth = width
self.realheight = height
def paint(self, painter, option, widget=None):
if not RealViewEnabled: return
super().paint(painter, option, widget)
if self.realimage is None:
try: self.realimage = self.image
except: pass
def move(self, x, y, w, h):
"""
Repositions the auxiliary image
"""
# This will be used later
oldx, oldy = self.x(), self.y()
# Decide on the height to use
# This solves the problem of "what if
# agument w is smaller than self.width?"
self.width = self.realwidth
self.height = self.realheight
changedSize = False
if w < self.width:
self.width = w
changedSize = True
if h < self.height:
self.height = h
changedSize = True
if self.realimage is not None:
if changedSize:
self.image = self.realimage.copy(0, 0, w, h)
else:
self.image = self.realimage
# Find the absolute X-coord
if self.flagPresent(self.alignment, Qt.AlignLeft):
newx = x
elif self.flagPresent(self.alignment, Qt.AlignRight):
newx = x + w - self.width
else:
newx = x + (w/2) - (self.width/2)
# Find the absolute Y-coord
if self.flagPresent(self.alignment, Qt.AlignTop):
newy = y
elif self.flagPresent(self.alignment, Qt.AlignBottom):
newy = y + h - self.height
else:
newy = y + (h / 2) - (self.height / 2)
# Translate that to relative coords
parent = self.parent
newx = newx - parent.x()
newy = newy - parent.y()
# Set the pos
self.setPos(newx, newy)
# Update the affected area of the scene
if self.scene() is not None:
self.scene().update(oldx + parent.x(), oldy + parent.y(), self.width, self.height)
class AuxiliaryZoneItem(AuxiliaryItem, QtWidgets.QGraphicsItem):
"""
An auxiliary item that can have a zone as its parent
"""
def __init__(self, parent, imageObj):
"""
Generic constructor for auxiliary zone items
"""
super().__init__(parent)
self.parent = parent
self.imageObj = imageObj
self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, False)
self.setParentItem(parent)
self.hover = False
if parent is not None:
parent.aux.add(self)
self.BoundingRect = QtCore.QRectF(0, 0, 24, 24)
def setIsBehindZone(self, behind):
"""
This allows you to choose whether the auiliary item will display
behind the zone or in front of it. Default is for the item to
be in front of the zone.
"""
self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, behind)
def setZoneID(self, id):
"""
Changes this aux item's parent to zone with the given id.
Raises ValueError if no zone with this id exists.
"""
if not hasattr(Area, 'zones'): return
z = None
for iterz in Area.zones:
if iterz.id == id: z = iterz
if z is None:
raise ValueError('No zone with this ID exists.')
if self.parent is not None:
self.parent.aux.remove(self)
self.setParentItem(z)
self.parent = z
z.aux.add(self)
def alignToZone(self):
"""
Resets the position and size of the AuxiliaryZoneItem to that of the zone
"""
self.setPos(0, 0)
if self.parent is not None:
self.BoundingRect = QtCore.QRectF(self.parent.BoundingRect)
else:
self.BoundingRect = QtCore.QRectF(0, 0, 24, 24)
def zoneRepositioned(self):
"""
Called when the zone is repositioned or resized
"""
pass
def boundingRect(self):
"""
Required for Qt
"""
return self.BoundingRect
class AuxiliaryLocationItem(AuxiliaryItem, QtWidgets.QGraphicsItem):
"""
An auxiliary item that can have a location as its parent
"""
def __init__(self, parent, imageObj):
"""
Generic constructor for auxiliary items
"""
super().__init__(parent)
self.parent = parent
self.imageObj = imageObj
self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, False)
self.setParentItem(parent)
self.hover = False
self.BoundingRect = QtCore.QRectF(0, 0, 24, 24)
def setIsBehindLocation(self, behind):
"""
This allows you to choose whether the auiliary item will display
behind the zone or in front of it. Default is for the item to
be in front of the location.
"""
self.setFlag(QtWidgets.QGraphicsItem.ItemStacksBehindParent, behind)
def alignToLocation(self):
"""
Resets the position and size of the AuxiliaryLocationItem to that of the location
"""
self.setPos(0, 0)
self.setSize(self.parent.width(), self.parent.height())
def boundingRect(self):
"""
Required for Qt
"""
return self.BoundingRect