[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 2cf97815e81742c38cb4fdfac148a651cc5fd446
Eugeniy Meshcheryakov
eugen at debian.org
Mon Apr 28 23:58:51 UTC 2008
The following commit has been merged in the master branch:
commit 48f277da8ace90761d95a54b561b4de6d6df234e
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Mon Apr 28 16:37:09 2008 +0200
reimplement rubber band (for different edit modes)
diff --git a/gui/glyphcell.cxx b/gui/glyphcell.cxx
index 38b167a..bf5d3f3 100644
--- a/gui/glyphcell.cxx
+++ b/gui/glyphcell.cxx
@@ -24,16 +24,17 @@
#include "glyphgraphics.h"
#include "glyph.h"
#include <QIcon>
+#include <QRubberBand>
#include "fontdocument.h"
-GlyphCell::GlyphCell(Glyph *glyph) : QGraphicsView(), m_glyph(glyph)
+GlyphCell::GlyphCell(Glyph *glyph) : QGraphicsView(), m_glyph(glyph),
+ m_rubberBand(0), m_rubberActive(false)
{
Q_ASSERT(m_glyph);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setRenderHint(QPainter::Antialiasing);
- setDragMode(RubberBandDrag);
QGraphicsScene *scene = new QGraphicsScene(this);
scene->setSceneRect(-5000, -5000, 10000, 10000);
@@ -178,3 +179,32 @@ void GlyphCell::moveSelection(const QPointF &offset)
}
}
}
+
+void GlyphCell::mousePressEvent(QMouseEvent *event)
+{
+ m_actionOrigin = event->pos();
+ if (!m_rubberBand)
+ m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
+ m_rubberBand->setGeometry(QRect(m_actionOrigin, QSize()));
+ m_rubberBand->show();
+ m_rubberActive = true;
+}
+
+void GlyphCell::mouseMoveEvent(QMouseEvent *event)
+{
+ if (m_rubberActive) {
+ Q_ASSERT(m_rubberBand);
+ m_rubberBand->setGeometry(QRect(m_actionOrigin, event->pos()).normalized());
+ }
+}
+
+void GlyphCell::mouseReleaseEvent(QMouseEvent *event)
+{
+ Q_UNUSED(event);
+ if (m_rubberActive) {
+ Q_ASSERT(m_rubberBand);
+ m_rubberBand->hide();
+ m_rubberActive = false;
+ }
+ // TODO
+}
diff --git a/gui/glyphcell.h b/gui/glyphcell.h
index 9373460..12e8cf0 100644
--- a/gui/glyphcell.h
+++ b/gui/glyphcell.h
@@ -19,6 +19,7 @@
class GlyphGraphics;
class Glyph;
+class QRubberBand;
class GlyphCell : public QGraphicsView
{
@@ -33,9 +34,16 @@ protected:
void mouseDoubleClickEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
void moveSelection(const QPointF &offset);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
private:
GlyphGraphics *gg;
Glyph *m_glyph;
+ QRubberBand *m_rubberBand;
+ QPoint m_actionOrigin;
+
+ bool m_rubberActive;
};
#endif
--
Fondue Font Editor
More information about the fondue-commits
mailing list