r15393 by jghali - #9292 : Line end points position is too sensible to mouse clicks

scribus-commit scribus-commit at lists.scribus.net
Sat Jul 31 14:08:27 CEST 2010


Author: jghali
Date: Sat Jul 31 12:08:26 2010
New Revision: 15393

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15393
Log:
#9292 : Line end points position is too sensible to mouse clicks

Modified:
    branches/Version135/Scribus/scribus/canvasgesture_linemove.cpp
    branches/Version135/Scribus/scribus/canvasgesture_linemove.h

Modified: branches/Version135/Scribus/scribus/canvasgesture_linemove.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15393&path=/branches/Version135/Scribus/scribus/canvasgesture_linemove.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/canvasgesture_linemove.cpp (original)
+++ branches/Version135/Scribus/scribus/canvasgesture_linemove.cpp Sat Jul 31 12:08:26 2010
@@ -121,45 +121,31 @@
 	p->restore();
 }
 
-
-
-void LineMove::mouseReleaseEvent(QMouseEvent *m)
-{
-	adjustBounds(m);
+void LineMove::mousePressEvent(QMouseEvent *m)
+{
+	PageItem_Line* line = m_doc->m_Selection->count() == 1 ? m_doc->m_Selection->itemAt(0)->asLine() : NULL;
+	if (line)
+	{
+		bool hitsOrigin = m_canvas->hitsCanvasPoint(m->globalPos(), line->xyPos());
+		prepare(line, hitsOrigin);
+		// now we also know the line's endpoint:
+		bool hitsEnd = m_canvas->hitsCanvasPoint(m->globalPos(), endPoint());
+		m_haveLineItem = hitsOrigin || hitsEnd;
+	}
+	else
+	{
+		FPoint point = m_canvas->globalToCanvas(m->globalPos());
+		setStartPoint(QPointF(point.x(), point.y()));
+		setEndPoint(QPointF(point.x(), point.y()));
+		m_haveLineItem = false;
+	}
 	if (m_haveLineItem)
 	{
-		doResize();
-		m_doc->setRedrawBounding(m_line);
-		m_view->resetMousePressed();
-		m_line->checkChanges();
-		m_line->update();
-	}
-	m->accept();
-	m_canvas->update();
-//	qDebug() << "LineMove::mouseRelease" << m_line->xPos() << "," << m_line->yPos() << "@" << m_line->rotation() << m_line->width() << "x" << m_line->height();
-	m_view->stopGesture();
-}
-
-
-void LineMove::doResize()
-{
-	if (m_useOriginAsEndpoint)
-	{
-		m_line->setXYPos(m_bounds.right(), m_bounds.bottom());
-		double rot = rotation();
-		m_line->setRotation(rot < 180? rot + 180 : rot - 180);
-	}
-	else
-	{
-		m_line->setXYPos(m_bounds.x(), m_bounds.y());
-		m_line->setRotation(rotation());
-	}
-	m_line->setWidth(length());
-	m_line->setHeight(1.0);
-	m_line->updateClip();
-//	qDebug() << "LineMove::doresize" << m_line->xPos() << "," << m_line->yPos() << "@" << m_line->rotation() << m_line->width() << "x" << m_line->height();
-}
-
+		adjustBounds(m, false);
+		m_initialBounds = m_bounds;
+		m->accept();
+	}
+}
 
 void LineMove::mouseMoveEvent(QMouseEvent *m)
 {
@@ -176,9 +162,45 @@
 	m_canvas->repaint();
 }
 
-
-
-void LineMove::adjustBounds(QMouseEvent *m)
+void LineMove::mouseReleaseEvent(QMouseEvent *m)
+{
+	adjustBounds(m);
+	if (m_haveLineItem)
+	{
+		if (m_bounds != m_initialBounds)
+			doResize();
+		m_doc->setRedrawBounding(m_line);
+		m_view->resetMousePressed();
+		m_line->checkChanges();
+		m_line->update();
+	}
+	m->accept();
+	m_canvas->update();
+//	qDebug() << "LineMove::mouseRelease" << m_line->xPos() << "," << m_line->yPos() << "@" << m_line->rotation() << m_line->width() << "x" << m_line->height();
+	m_view->stopGesture();
+}
+
+
+void LineMove::doResize()
+{
+	if (m_useOriginAsEndpoint)
+	{
+		m_line->setXYPos(m_bounds.right(), m_bounds.bottom());
+		double rot = rotation();
+		m_line->setRotation(rot < 180? rot + 180 : rot - 180);
+	}
+	else
+	{
+		m_line->setXYPos(m_bounds.x(), m_bounds.y());
+		m_line->setRotation(rotation());
+	}
+	m_line->setWidth(length());
+	m_line->setHeight(1.0);
+	m_line->updateClip();
+//	qDebug() << "LineMove::doresize" << m_line->xPos() << "," << m_line->yPos() << "@" << m_line->rotation() << m_line->width() << "x" << m_line->height();
+}
+
+void LineMove::adjustBounds(QMouseEvent *m, bool updateCanvas)
 {
 	FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
 	bool constrainRatio = ((m->modifiers() & Qt::ControlModifier) != Qt::NoModifier);
@@ -201,8 +223,6 @@
 	//>>#8099
 
 	m_bounds.setBottomRight(QPointF(newX, newY));
-//	qDebug() << "LineMove::adjustBounds" << m_bounds << rotation() << length() << m_bounds.bottomRight();
-
 	//Constrain rotation angle, when the mouse is being dragged around for a new line
 	if (constrainRatio)
 	{
@@ -210,29 +230,8 @@
 		newRot = constrainAngle(newRot, m_doc->toolSettings.constrain);
 		setRotation(newRot);
 	}
-	m_view->updateCanvas(m_bounds.normalized().adjusted(-10, -10, 20, 20));
-}
-
-
-
-void LineMove::mousePressEvent(QMouseEvent *m)
-{
-	PageItem_Line* line = m_doc->m_Selection->count() == 1 ? m_doc->m_Selection->itemAt(0)->asLine() : NULL;
-	if (line)
-	{
-		bool hitsOrigin = m_canvas->hitsCanvasPoint(m->globalPos(), line->xyPos());
-		prepare(line, hitsOrigin);
-		// now we also know the line's endpoint:
-		bool hitsEnd = m_canvas->hitsCanvasPoint(m->globalPos(), endPoint());
-		m_haveLineItem = hitsOrigin || hitsEnd;
-	}
-	else
-	{
-		FPoint point = m_canvas->globalToCanvas(m->globalPos());
-		setStartPoint(QPointF(point.x(), point.y()));
-		setEndPoint(QPointF(point.x(), point.y()));
-		m_haveLineItem = false;
-	}
-	if (m_haveLineItem)
-		m->accept();
-}
+	if (updateCanvas)
+	{
+		m_view->updateCanvas(m_bounds.normalized().adjusted(-10, -10, 20, 20));
+	}
+}

Modified: branches/Version135/Scribus/scribus/canvasgesture_linemove.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15393&path=/branches/Version135/Scribus/scribus/canvasgesture_linemove.h
==============================================================================
--- branches/Version135/Scribus/scribus/canvasgesture_linemove.h (original)
+++ branches/Version135/Scribus/scribus/canvasgesture_linemove.h Sat Jul 31 12:08:26 2010
@@ -84,11 +84,12 @@
 	bool haveLineItem() const { return m_haveLineItem; }
 	
 private:
-	bool m_haveLineItem;
-	bool m_useOriginAsEndpoint;
-	QRectF m_bounds;
+	bool      m_haveLineItem;
+	bool      m_useOriginAsEndpoint;
+	QRectF    m_bounds;
+	QRectF    m_initialBounds;
 	PageItem* m_line;
-	void adjustBounds(QMouseEvent* m);
+	void adjustBounds(QMouseEvent* m, bool updateCanvas = true);
 	void doResize();
 	void setRotation(double rot);
 	double rotation() const;




More information about the scribus-commit mailing list