summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-04-19 08:06:38 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-04-19 08:06:38 -0400
commitbcbc927136b64a271400337fb4a93fc3a2201509 (patch)
tree68591551af54a9168ee83c5907b6f4e6dcc3c628
parent898f374c8b601bead7050d2cbd30a00547125eaa (diff)
Add hover/select feedback
-rw-r--r--sigmodr/widgets/mapeditor/ShapeItem.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/sigmodr/widgets/mapeditor/ShapeItem.cpp b/sigmodr/widgets/mapeditor/ShapeItem.cpp
index e2f5cbfd..0250112b 100644
--- a/sigmodr/widgets/mapeditor/ShapeItem.cpp
+++ b/sigmodr/widgets/mapeditor/ShapeItem.cpp
@@ -18,9 +18,13 @@
// Header include
#include "ShapeItem.h"
+// KDE includes
+#include <KColorScheme>
+
// Qt includes
#include <QtGui/QPainter>
#include <QtGui/QPainterPathStroker>
+#include <QtGui/QStyleOptionGraphicsItem>
using namespace Sigmodr::Widgets;
@@ -33,6 +37,8 @@ ShapeItem::ShapeItem(const Shape shape) :
m_yShear(1)
{
recreatePath();
+ setFlags(ItemIsMovable | ItemIsSelectable);
+ setOpacity(.5);
}
ShapeItem::ShapeItem(const QPainterPath& path) :
@@ -49,8 +55,19 @@ ShapeItem::ShapeItem(const QPainterPath& path) :
void ShapeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
- Q_UNUSED(option)
Q_UNUSED(widget)
+ if (option->state & QStyle::State_MouseOver)
+ {
+ painter->setPen(QPen(KStatefulBrush(KColorScheme::View, KColorScheme::HoverColor).brush(QPalette::Active), 3));
+ painter->drawRect(boundingRect());
+ }
+ if (option->state & QStyle::State_Selected)
+ {
+ painter->setPen(QPen(KStatefulBrush(KColorScheme::Selection, KColorScheme::ActiveBackground).brush(QPalette::Active), 3));
+ painter->drawRect(boundingRect());
+ }
+ painter->setPen(QPen());
+ painter->setBrush(QBrush(Qt::red));
painter->drawPath(m_strokePath);
}
@@ -161,5 +178,5 @@ void ShapeItem::restroke()
QPainterPathStroker stroke;
stroke.setWidth(m_thickness);
m_strokePath = stroke.createStroke(m_path * QMatrix(m_xShear, m_yShear, 1, 1, -m_rect.left(), -m_rect.top()).rotate(m_rotation));
- m_boundingRect = m_strokePath.boundingRect();
+ m_boundingRect = m_strokePath.boundingRect().adjusted(-2, -2, 2, 2);
}