Life comp shift buttons and Show Grid option
This commit is contained in:
parent
bdb006f25d
commit
c3f128806b
|
@ -323,7 +323,9 @@ class Component(QtCore.QObject, metaclass=ComponentMetaclass):
|
|||
else:
|
||||
# Normal tracked widget
|
||||
setattr(self, attr, getWidgetValue(widget))
|
||||
self.sendUpdateSignal()
|
||||
|
||||
def sendUpdateSignal(self):
|
||||
if not self.core.openingProject:
|
||||
self.parent.drawPreview()
|
||||
saveValueStore = self.savePreset()
|
||||
|
|
|
@ -25,10 +25,24 @@ class Component(Component):
|
|||
'shapeType': self.page.comboBox_shapeType,
|
||||
'shadow': self.page.checkBox_shadow,
|
||||
'customImg': self.page.checkBox_customImg,
|
||||
'showGrid': self.page.checkBox_showGrid,
|
||||
'image': self.page.lineEdit_image,
|
||||
}, colorWidgets={
|
||||
'color': self.page.pushButton_color,
|
||||
})
|
||||
self.shiftButtons = (
|
||||
self.page.toolButton_up,
|
||||
self.page.toolButton_down,
|
||||
self.page.toolButton_left,
|
||||
self.page.toolButton_right,
|
||||
)
|
||||
def shiftFunc(i):
|
||||
def shift():
|
||||
self.shiftGrid(i)
|
||||
return shift
|
||||
shiftFuncs = [shiftFunc(i) for i in range(len(self.shiftButtons))]
|
||||
for i, widget in enumerate(self.shiftButtons):
|
||||
widget.clicked.connect(shiftFuncs[i])
|
||||
self.page.spinBox_scale.setValue(self.scale)
|
||||
self.page.spinBox_scale.valueChanged.connect(self.updateGridSize)
|
||||
|
||||
|
@ -42,6 +56,24 @@ class Component(Component):
|
|||
self.page.lineEdit_image.setText(filename)
|
||||
self.update()
|
||||
|
||||
def shiftGrid(self, d):
|
||||
def newGrid(Xchange, Ychange):
|
||||
return {
|
||||
(x + Xchange, y + Ychange): True
|
||||
for x, y in self.startingGrid
|
||||
}
|
||||
|
||||
if d == 0:
|
||||
newGrid = newGrid(0, -1)
|
||||
elif d == 1:
|
||||
newGrid = newGrid(0, 1)
|
||||
elif d == 2:
|
||||
newGrid = newGrid(-1, 0)
|
||||
elif d == 3:
|
||||
newGrid = newGrid(1, 0)
|
||||
self.startingGrid = newGrid
|
||||
self.sendUpdateSignal()
|
||||
|
||||
def update(self):
|
||||
self.updateGridSize()
|
||||
if self.page.checkBox_customImg.isChecked():
|
||||
|
@ -62,6 +94,9 @@ class Component(Component):
|
|||
self.page.label_image.setVisible(False)
|
||||
self.page.lineEdit_image.setVisible(False)
|
||||
self.page.pushButton_pickImage.setVisible(False)
|
||||
enabled = (len(self.startingGrid) > 0)
|
||||
for widget in self.shiftButtons:
|
||||
widget.setEnabled(enabled)
|
||||
super().update()
|
||||
|
||||
def previewClickEvent(self, pos, size, button):
|
||||
|
@ -298,6 +333,22 @@ class Component(Component):
|
|||
shadImg = ImageChops.offset(shadImg, -2, 2)
|
||||
shadImg.paste(frame, box=(0, 0), mask=frame)
|
||||
frame = shadImg
|
||||
if self.showGrid:
|
||||
drawer = ImageDraw.Draw(frame)
|
||||
w, h = scale(0.05, self.width, self.height, int)
|
||||
for x in range(self.pxWidth, self.width, self.pxWidth):
|
||||
drawer.rectangle(
|
||||
((x, 0),
|
||||
(x + w, self.height)),
|
||||
fill=self.color,
|
||||
)
|
||||
for y in range(self.pxHeight, self.height, self.pxHeight):
|
||||
drawer.rectangle(
|
||||
((0, y),
|
||||
(self.width, y + h)),
|
||||
fill=self.color,
|
||||
)
|
||||
|
||||
return frame
|
||||
|
||||
def gridForTick(self, tick):
|
||||
|
@ -334,8 +385,11 @@ class Component(Component):
|
|||
return pr
|
||||
|
||||
def loadPreset(self, pr, *args):
|
||||
super().loadPreset(pr, *args)
|
||||
self.startingGrid = dict(pr['GRID'])
|
||||
if self.startingGrid:
|
||||
for widget in self.shiftButtons:
|
||||
widget.setEnabled(True)
|
||||
super().loadPreset(pr, *args)
|
||||
|
||||
|
||||
def nearbyCoords(x, y):
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_scale">
|
||||
<property name="minimum">
|
||||
<number>24</number>
|
||||
<number>22</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>128</number>
|
||||
|
@ -279,6 +279,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_showGrid">
|
||||
<property name="text">
|
||||
<string>Show Grid</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
|
@ -296,6 +303,46 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_up">
|
||||
<property name="text">
|
||||
<string>Up</string>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::UpArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_down">
|
||||
<property name="text">
|
||||
<string>Down</string>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_left">
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::LeftArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_right">
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::RightArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_9">
|
||||
<property name="orientation">
|
||||
|
|
Reference in New Issue