[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 8421a8499180144f1980fbff2a44fee85e0887ba

Eugeniy Meshcheryakov eugen at debian.org
Tue Sep 30 13:59:40 UTC 2008


The following commit has been merged in the master branch:
commit 8421a8499180144f1980fbff2a44fee85e0887ba
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Sep 30 15:59:13 2008 +0200

    make it possible to close open contours in editor

diff --git a/gui/glyphcell.cxx b/gui/glyphcell.cxx
index 3fd9023..7b0f6d9 100644
--- a/gui/glyphcell.cxx
+++ b/gui/glyphcell.cxx
@@ -232,11 +232,40 @@ void GlyphCell::mousePressEvent(QMouseEvent *event)
 			}
 		}
 		if (pt) {
-			// oh! select this point
+			// User cliked on a point.
+			// Check if previously only one point was selected...
+			QList<QGraphicsItem *> sel = scene()->selectedItems();
+			ControlPoint *oldPt = 0;
+			if (sel.size() == 1)
+				oldPt = qgraphicsitem_cast<ControlPoint *>(sel.first());
+
+			if (oldPt) {
+				// ...Yes. Then check if this point belongs to the same
+				// controur as one that user cliked on...
+				if (pt->contour() == oldPt->contour()) {
+					// Maybe user wants to close the contour?
+					// Check if the contour is open
+					GlyphContour *theContour = pt->contour();
+					Q_ASSERT(theContour);
+					if (theContour->isOpen()) {
+						// Check if points are first and last points of the contour.
+						int nPoints = theContour->points().size();
+						if ((nPoints > 1) && (
+								((pt->pointNumber() == 0) && (oldPt->pointNumber() == nPoints - 1)) ||
+								((pt->pointNumber() == nPoints - 1) && (oldPt->pointNumber() == 0)))) {
+							// close the contour, at last
+							qDebug() << "Closing the contour...";
+							theContour->setOpen(false);
+						}
+					}
+				}
+			}
+			// in any case select the point user clicked on
 			scene()->clearSelection();
 			pt->setSelected(true);
 		}
 		else {
+			// User clicked on empty space
 			bool startContour = false;
 			ControlPoint *pt = 0;
 			int firstPoint = false;

-- 
Fondue Font Editor



More information about the fondue-commits mailing list