For a long time I've been annoyed at how clicking on a chord name wouldn't
select it,
at least not reliably. It turns out this is because QGraphicsItem was
generating a (not very
accurate, even) mask of the text and using that for the hit test.
Changing that to a full-rect hit-test makes it much easier to select chord
names.
Any objections to the patch below?
It does not affect selecting notes (for which the item isn't created in that
method).
===
commit 0eb075d11994becb37e640d480da8ce744284d0f
Author: David Faure <[email protected]>
Date: Sat Nov 21 18:47:10 2015 +0100
Make it easier to select a text item.
Clicking anywhere in the text item's bounding rect should select it,
rather than having to aim for a black pixel.
diff --git a/src/gui/editors/notation/NotePixmapFactory.cpp
b/src/gui/editors/notation/NotePixmapFactory.cpp
index 7d69cce..9632986 100644
--- a/src/gui/editors/notation/NotePixmapFactory.cpp
+++ b/src/gui/editors/notation/NotePixmapFactory.cpp
@@ -3482,6 +3482,12 @@ NotePixmapFactory::makeItem(QPoint hotspot)
p->setPixmap(*m_generatedPixmap);
p->setOffset(QPointF(-hotspot.x(), -hotspot.y()));
+ // The hit test QGraphicsScene::items(), called by
NotationScene::setupMouseEvent,
+ // calls contains() which calls shape(), which by default generates a mask
(slow!).
+ // Change the shape mode to BoundingRectShape to be able to click on text
items anywhere
+ // in the bounding rect, rather than having to aim for a black pixel.
+ p->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
+
// NOTATION_DEBUG << "NotePixmapFactory::makeItem: item = " << p << "
(scene = " << p->scene() << ")" << endl;
delete m_generatedPixmap;
--
David Faure, [email protected], http://www.davidfaure.fr
Working on KDE Frameworks 5
------------------------------------------------------------------------------
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel