[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 08b3bcdfd92d36098f89673d35f5eb6ff5f0559a

Eugeniy Meshcheryakov eugen at debian.org
Thu May 15 13:28:08 UTC 2008


The following commit has been merged in the master branch:
commit 676b341e7e94fb3099752697f90139dc5b4ccafd
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu May 15 13:05:50 2008 +0200

    Make ControlPoint a subclass of QGraphicsEllipseItem

diff --git a/gui/controlpoint.cxx b/gui/controlpoint.cxx
index 2cfeeff..4d650bf 100644
--- a/gui/controlpoint.cxx
+++ b/gui/controlpoint.cxx
@@ -20,7 +20,7 @@
 static const QRectF cpRect(-5, -5, 10, 10);
 
 ControlPoint::ControlPoint(GlyphContour *contour, int pointNumber, QGraphicsItem *parent) :
-	QObject(), QGraphicsItem(parent), m_contour(contour), m_pointNumber(pointNumber)
+	QObject(), QGraphicsEllipseItem(cpRect, parent), m_contour(contour), m_pointNumber(pointNumber)
 {
 	Q_ASSERT(contour);
 	Q_ASSERT(pointNumber < contour->points().size());
@@ -36,35 +36,19 @@ ControlPoint::ControlPoint(GlyphContour *contour, int pointNumber, QGraphicsItem
 	connect(m_contour, SIGNAL(pointChanged(int)), this, SLOT(glyphPointChanged(int)));
 	connect(m_contour, SIGNAL(pointsAdded(int, int)), this, SLOT(glyphPointsAdded(int, int)));
 	connect(m_contour, SIGNAL(pointsRemoved(int, int)), this, SLOT(glyphPointsRemoved(int, int)));
+	setupColors();
 }
 
-QRectF ControlPoint::boundingRect() const
+void ControlPoint::setupColors()
 {
-	return cpRect.adjusted(-2, -2, 2, 2);
-}
-
-QPainterPath ControlPoint::shape() const
-{
-	QPainterPath path;
-
-	path.addEllipse(cpRect);
-	return path;
-}
-
-void ControlPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
-	Q_UNUSED(option);
-	Q_UNUSED(widget);
-
-	if (!m_pointNumber)
-		painter->setPen(QColor(255, 128, 128, 191));
-	else
-		painter->setPen(QColor(255, 255, 255, 191));
-	if (isSelected())
-		painter->setBrush(QColor(191, 191, 86, 160));
-	else
-		painter->setBrush(QColor(191, 191, 191, 160));
-	painter->drawEllipse(cpRect);
+	if (!m_pointNumber) {
+		setPen(QColor(255, 128, 128, 191));
+		setBrush(QColor(191, 191, 86, 160));
+	}
+	else {
+		setPen(QColor(255, 255, 255, 191));
+		setBrush(QColor(191, 191, 191, 160));
+	}
 }
 
 QVariant ControlPoint::itemChange(GraphicsItemChange change, const QVariant &value)
@@ -93,13 +77,17 @@ void ControlPoint::glyphPointChanged(int number)
 void ControlPoint::glyphPointsAdded(int start, int end)
 {
 	// renumber points after first one
-	if (m_pointNumber > start)
+	if (m_pointNumber > start) {
 		m_pointNumber += end - start + 1;
+		setupColors();
+	}
 }
 
 void ControlPoint::glyphPointsRemoved(int start, int end)
 {
 	// renumber points after last one
-	if (m_pointNumber > end)
+	if (m_pointNumber > end) {
 		m_pointNumber -= end - start + 1;
+		setupColors();
+	}
 }
diff --git a/gui/controlpoint.h b/gui/controlpoint.h
index fe0b46c..f798833 100644
--- a/gui/controlpoint.h
+++ b/gui/controlpoint.h
@@ -15,20 +15,17 @@
  */
 #ifndef CONTROLPOINT_H
 #define CONTROLPOINT_H
-#include <QGraphicsItem>
+#include <QGraphicsEllipseItem>
 #include <QObject>
 
 class GlyphContour;
 
-class ControlPoint: public QObject, public QGraphicsItem {
+class ControlPoint: public QObject, public QGraphicsEllipseItem {
 	Q_OBJECT
 public:
 	ControlPoint(GlyphContour *contour, int pointNumber, QGraphicsItem *parent = 0);
 	enum {Type = UserType + 1};
 	int type() const {return Type;}
-	QRectF boundingRect() const;
-	QPainterPath shape() const;
-	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
 
 	GlyphContour *contour() const {return m_contour;}
 	int pointNumber() const {return m_pointNumber;}
@@ -37,6 +34,8 @@ protected:
 private:
 	GlyphContour *m_contour;
 	int m_pointNumber;
+
+	void setupColors();
 private slots:
 	void glyphPointChanged(int number);
 	void glyphPointsAdded(int start, int end);

-- 
Fondue Font Editor



More information about the fondue-commits mailing list