* viewer/image_region.cc,
* viewer/image_region.hxx:
Improve selection highlighting (more readable).
---
viewer/image_region.cc | 41 ++++++++++++++++++++++++++++++++++++++---
viewer/image_region.hxx | 24 ------------------------
2 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/viewer/image_region.cc b/viewer/image_region.cc
index bef30fc..7761065 100644
--- a/viewer/image_region.cc
+++ b/viewer/image_region.cc
@@ -70,11 +70,10 @@ ImageRegion::paint(QPainter* painter,
width = 1;
if (outline_)
- painter->setPen(QPen(QBrush(color_), width));
+ painter->setPen(QPen(QBrush(color_), width, Qt::SolidLine,
+ Qt::SquareCap, Qt::MiterJoin));
else
painter->setPen(QColor(0, 0, 0, 0));
- if (selected_)
- painter->setPen(QPen(QBrush(QColor("red")), width));
QColor brush = color_;
if (fill_)
@@ -84,4 +83,40 @@ ImageRegion::paint(QPainter* painter,
painter->setBrush(brush);
painter->drawPath(shape_);
+
+ if (selected_)
+ {
+ QPolygonF sceneRect = mapFromScene(scene()->sceneRect());
+ QPainterPath path;
+ path.addPolygon(sceneRect);
+ QColor brush(255, 255, 255);
+ brush.setAlpha(120);
+ painter->setBrush(brush);
+ painter->setPen(QColor(0, 0, 0, 0));
+ painter->drawPath(path.subtracted(shape_));
+ }
+}
+
+void
+ImageRegion::select()
+{
+ if (!selected_)
+ {
+ selected_ = true;
+ setZValue(2);
+ scene()->invalidate();
+ update();
+ }
+}
+
+void
+ImageRegion::deselect()
+{
+ if (selected_)
+ {
+ selected_ = false;
+ scene()->invalidate();
+ setZValue(1);
+ update();
+ }
}
diff --git a/viewer/image_region.hxx b/viewer/image_region.hxx
index 35634f7..b15615c 100644
--- a/viewer/image_region.hxx
+++ b/viewer/image_region.hxx
@@ -87,28 +87,4 @@ ImageRegion::index() const
return index_;
}
-inline
-void
-ImageRegion::select()
-{
- if (!selected_)
- {
- selected_ = true;
- setZValue(2);
- update();
- }
-}
-
-inline
-void
-ImageRegion::deselect()
-{
- if (selected_)
- {
- selected_ = false;
- setZValue(1);
- update();
- }
-}
-
#endif /* !IMAGE_REGION_HXX_ */
--
1.5.6.5
Show replies by date