From b9f0212c9b27f7ff68d01d8d7f041fe850c7f0ac Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Feb 2015 16:43:38 +0100 Subject: [PATCH] Clamp the zoneviewwidget's topleft point to the scene view area; fix #754 --- cockatrice/src/zoneviewwidget.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cockatrice/src/zoneviewwidget.cpp b/cockatrice/src/zoneviewwidget.cpp index dab5f862..f687b604 100644 --- a/cockatrice/src/zoneviewwidget.cpp +++ b/cockatrice/src/zoneviewwidget.cpp @@ -185,6 +185,24 @@ void ZoneViewWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *op void ZoneViewWidget::moveWidget(QPointF scenePos) { + if(scenePos.x() < 0) + { + scenePos.setX(0); + } else { + qreal maxw = scene()->sceneRect().width() - 100; + if(scenePos.x() > maxw) + scenePos.setX(maxw); + } + + if(scenePos.y() < 0) + { + scenePos.setY(0); + } else { + qreal maxh = scene()->sceneRect().height() - 100; + if(scenePos.y() > maxh) + scenePos.setY(maxh); + } + setPos(scenePos); }