[Uml-devel] kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sun Nov 16 06:00:14 UTC 2003
CVS commit by okellogg:
snapped{X,Y}: New methods fix bug 68095 (snap to grid broken.)
M +15 -8 umlwidget.cpp 1.65
M +10 -0 umlwidget.h 1.22
--- kdesdk/umbrello/umbrello/umlwidget.cpp #1.64:1.65
@@ -243,6 +243,6 @@ QPoint UMLWidget::doMouseMove(QMouseEven
}
}
- newX = getX() + moveX;
- newY = getY() + moveY;
+ newX = snappedX( getX() + moveX );
+ newY = snappedY( getY() + moveY );
newX = newX<0 ? 0 : newX;
@@ -810,24 +810,31 @@ void UMLWidget::setView(UMLView * v) {
void UMLWidget::setX( int x ) {
+ QCanvasItem::setX( (double)snappedX(x) );
+}
+
+void UMLWidget::setY( int y ) {
+ QCanvasItem::setY( (double)snappedY(y) );
+}
+
+int UMLWidget::snappedX( int x ) {
if( !m_bIgnoreSnapToGrid && m_pView -> getSnapToGrid() ) {
int gridX = m_pView -> getSnapX();
-
- int modX = getX() % gridX;
+ int modX = x % gridX;
x -= modX;
if( modX >= ( gridX / 2 ) )
x += gridX;
}
- QCanvasItem::setX( (double)x );
+ return x;
}
-void UMLWidget::setY( int y ) {
+int UMLWidget::snappedY( int y ) {
if( !m_bIgnoreSnapToGrid && m_pView -> getSnapToGrid() ) {
int gridY = m_pView -> getSnapY();
- int modY = getY() % gridY;
+ int modY = y % gridY;
y -= modY;
if( modY >= ( gridY / 2 ) )
y += gridY;
}
- QCanvasItem::setY( (double)y );
+ return y;
}
--- kdesdk/umbrello/umbrello/umlwidget.h #1.21:1.22
@@ -315,4 +315,14 @@ public:
/**
+ * Returns the input coordinate with possible grid-snap applied.
+ */
+ int snappedX( int x );
+
+ /**
+ * Returns the input coordinate with possible grid-snap applied.
+ */
+ int snappedY( int y );
+
+ /**
* Sets the x-coordinate.
*
More information about the umbrello-devel
mailing list