Fixed issue #856. Regression in curve control point interaction on macOS.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-06-19 13:08:54 +03:00
parent 0ef32da1d8
commit 21b3f4b5ae

View File

@ -59,6 +59,7 @@
#include "../vmisc/vmath.h"
#include "vmaingraphicsscene.h"
#include "vsimplecurve.h"
#include "vcontrolpointspline.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vsettings.h"
#include "vabstractmainwindow.h"
@ -113,6 +114,26 @@ qreal PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event)
return scheduledScrollings;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief PrioritizeItems helps prioritize some items over others.
*
* In some cases we want items like curve handle points to be selected over other items on scene.
* @param list list of scene items under a mouse pointer
* @return prioritized list where prioritized items goes first
*/
QList<QGraphicsItem *> PrioritizeItems(const QList<QGraphicsItem *> &list)
{
QList<QGraphicsItem *> prioritized;
QList<QGraphicsItem *> nonPrioritized;
for (auto item : list)
{
item && item->type() == VControlPointSpline::Type ? prioritized.append(item) : nonPrioritized.append(item);
}
return prioritized + nonPrioritized;
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -540,13 +561,14 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *event)
if (showToolOptions)
{
bool success = false;
const QList<QGraphicsItem *> list = items(event->pos());
const QList<QGraphicsItem *> list = PrioritizeItems(items(event->pos()));
for (auto item : list)
{
if (item && item->type() > QGraphicsItem::UserType && item->type() <= VSimpleCurve::Type)
{
emit itemClicked(item);
success = true;
break;
}
}