mirror of
https://github.com/rbreu/beeref.git
synced 2026-03-11 08:54:28 +00:00
Add scaling for single item via bottom right handle
This commit is contained in:
parent
268d00af32
commit
4ec5ed0a13
2 changed files with 16 additions and 2 deletions
|
|
@ -43,6 +43,8 @@ class BeePixmapItem(QtWidgets.QGraphicsPixmapItem):
|
|||
| QtWidgets.QGraphicsItem.GraphicsItemFlags.ItemIsSelectable)
|
||||
|
||||
def setScale(self, factor):
|
||||
if factor <= 0:
|
||||
return
|
||||
self.scale_factor = factor
|
||||
logger.debug(f'Setting scale for image "{self.filename}" to {factor}')
|
||||
super().setScale(factor)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class SelectionItem(QtWidgets.QGraphicsItem):
|
|||
| QtWidgets.QGraphicsItem.GraphicsItemFlags.ItemIsMovable)
|
||||
bounds = self.parentItem().boundingRect()
|
||||
pos = bounds.bottomRight()
|
||||
self.scale_active = False
|
||||
|
||||
# The intercatable shape of the bottom right scale handle:
|
||||
self.bottom_right_scale_bounds = QtCore.QRectF(
|
||||
|
|
@ -100,10 +101,21 @@ class SelectionItem(QtWidgets.QGraphicsItem):
|
|||
self.setCursor(Qt.CursorShape.ArrowCursor)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
print('********mousepress')
|
||||
if event.button() == Qt.MouseButtons.LeftButton:
|
||||
self.scale_active = True
|
||||
self.orig_scale_factor = self.parentItem().scale()
|
||||
self.scale_start = event.scenePos()
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
print('*******mousemove')
|
||||
if self.scale_active:
|
||||
imgsize = self.parentItem().width + self.parentItem().height
|
||||
p = event.scenePos() - self.scale_start
|
||||
mousemove = p.x() + p.y()
|
||||
scale = self.orig_scale_factor + mousemove / imgsize
|
||||
self.parentItem().setScale(scale)
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
self.scale_active = False
|
||||
|
||||
@classmethod
|
||||
def activate_selection(cls, item):
|
||||
|
|
|
|||
Loading…
Reference in a new issue