mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 19:01:14 +02:00
add support for double click messages to overlays and entities
This commit is contained in:
parent
1e51ae62b1
commit
8ae6f2727d
8 changed files with 99 additions and 5 deletions
|
@ -3174,7 +3174,23 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::mouseDoublePressEvent(QMouseEvent* event) const {
|
void Application::mouseDoublePressEvent(QMouseEvent* event) {
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
|
||||||
|
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
|
||||||
|
QMouseEvent mappedEvent(event->type(),
|
||||||
|
transformedPos,
|
||||||
|
event->screenPos(), event->button(),
|
||||||
|
event->buttons(), event->modifiers());
|
||||||
|
|
||||||
|
if (!_aboutToQuit) {
|
||||||
|
getOverlays().mouseDoublePressEvent(&mappedEvent);
|
||||||
|
if (!_controllerScriptingInterface->areEntityClicksCaptured()) {
|
||||||
|
getEntities()->mouseDoublePressEvent(&mappedEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// if one of our scripts have asked to capture this event, then stop processing it
|
// if one of our scripts have asked to capture this event, then stop processing it
|
||||||
if (_controllerScriptingInterface->isMouseCaptured()) {
|
if (_controllerScriptingInterface->isMouseCaptured()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -494,7 +494,7 @@ private:
|
||||||
|
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
void mouseMoveEvent(QMouseEvent* event);
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent* event);
|
||||||
void mouseDoublePressEvent(QMouseEvent* event) const;
|
void mouseDoublePressEvent(QMouseEvent* event);
|
||||||
void mouseReleaseEvent(QMouseEvent* event);
|
void mouseReleaseEvent(QMouseEvent* event);
|
||||||
|
|
||||||
void touchBeginEvent(QTouchEvent* event);
|
void touchBeginEvent(QTouchEvent* event);
|
||||||
|
|
|
@ -769,6 +769,26 @@ bool Overlays::mousePressEvent(QMouseEvent* event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Overlays::mouseDoublePressEvent(QMouseEvent* event) {
|
||||||
|
PerformanceTimer perfTimer("Overlays::mouseDoublePressEvent");
|
||||||
|
|
||||||
|
PickRay ray = qApp->computePickRay(event->x(), event->y());
|
||||||
|
RayToOverlayIntersectionResult rayPickResult = findRayIntersectionForMouseEvent(ray);
|
||||||
|
if (rayPickResult.intersects) {
|
||||||
|
_currentClickingOnOverlayID = rayPickResult.overlayID;
|
||||||
|
|
||||||
|
// Only Web overlays can have focus.
|
||||||
|
auto thisOverlay = std::dynamic_pointer_cast<Web3DOverlay>(getOverlay(_currentClickingOnOverlayID));
|
||||||
|
if (thisOverlay) {
|
||||||
|
auto pointerEvent = calculatePointerEvent(thisOverlay, ray, rayPickResult, event, PointerEvent::Press);
|
||||||
|
emit mouseDoublePressOnOverlay(_currentClickingOnOverlayID, pointerEvent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit mouseDoublePressOffOverlay();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Overlays::mouseReleaseEvent(QMouseEvent* event) {
|
bool Overlays::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
PerformanceTimer perfTimer("Overlays::mouseReleaseEvent");
|
PerformanceTimer perfTimer("Overlays::mouseReleaseEvent");
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ public:
|
||||||
OverlayID addOverlay(Overlay::Pointer overlay);
|
OverlayID addOverlay(Overlay::Pointer overlay);
|
||||||
|
|
||||||
bool mousePressEvent(QMouseEvent* event);
|
bool mousePressEvent(QMouseEvent* event);
|
||||||
|
bool mouseDoublePressEvent(QMouseEvent* event);
|
||||||
bool mouseReleaseEvent(QMouseEvent* event);
|
bool mouseReleaseEvent(QMouseEvent* event);
|
||||||
bool mouseMoveEvent(QMouseEvent* event);
|
bool mouseMoveEvent(QMouseEvent* event);
|
||||||
|
|
||||||
|
@ -300,9 +301,11 @@ signals:
|
||||||
void panelDeleted(OverlayID id);
|
void panelDeleted(OverlayID id);
|
||||||
|
|
||||||
void mousePressOnOverlay(OverlayID overlayID, const PointerEvent& event);
|
void mousePressOnOverlay(OverlayID overlayID, const PointerEvent& event);
|
||||||
|
void mouseDoublePressOnOverlay(OverlayID overlayID, const PointerEvent& event);
|
||||||
void mouseReleaseOnOverlay(OverlayID overlayID, const PointerEvent& event);
|
void mouseReleaseOnOverlay(OverlayID overlayID, const PointerEvent& event);
|
||||||
void mouseMoveOnOverlay(OverlayID overlayID, const PointerEvent& event);
|
void mouseMoveOnOverlay(OverlayID overlayID, const PointerEvent& event);
|
||||||
void mousePressOffOverlay();
|
void mousePressOffOverlay();
|
||||||
|
void mouseDoublePressOffOverlay();
|
||||||
|
|
||||||
void hoverEnterOverlay(OverlayID overlayID, const PointerEvent& event);
|
void hoverEnterOverlay(OverlayID overlayID, const PointerEvent& event);
|
||||||
void hoverOverOverlay(OverlayID overlayID, const PointerEvent& event);
|
void hoverOverOverlay(OverlayID overlayID, const PointerEvent& event);
|
||||||
|
|
|
@ -735,6 +735,52 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityTreeRenderer::mouseDoublePressEvent(QMouseEvent* event) {
|
||||||
|
// If we don't have a tree, or we're in the process of shutting down, then don't
|
||||||
|
// process these events.
|
||||||
|
if (!_tree || _shuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PerformanceTimer perfTimer("EntityTreeRenderer::mouseDoublePressEvent");
|
||||||
|
PickRay ray = _viewState->computePickRay(event->x(), event->y());
|
||||||
|
|
||||||
|
bool precisionPicking = !_dontDoPrecisionPicking;
|
||||||
|
RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::Lock, precisionPicking);
|
||||||
|
if (rayPickResult.intersects) {
|
||||||
|
//qCDebug(entitiesrenderer) << "mouseDoublePressEvent over entity:" << rayPickResult.entityID;
|
||||||
|
|
||||||
|
QString urlString = rayPickResult.properties.getHref();
|
||||||
|
QUrl url = QUrl(urlString, QUrl::StrictMode);
|
||||||
|
if (url.isValid() && !url.isEmpty()){
|
||||||
|
DependencyManager::get<AddressManager>()->handleLookupString(urlString);
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec2 pos2D = projectOntoEntityXYPlane(rayPickResult.entity, ray, rayPickResult);
|
||||||
|
PointerEvent pointerEvent(PointerEvent::Press, MOUSE_POINTER_ID,
|
||||||
|
pos2D, rayPickResult.intersection,
|
||||||
|
rayPickResult.surfaceNormal, ray.direction,
|
||||||
|
toPointerButton(*event), toPointerButtons(*event));
|
||||||
|
|
||||||
|
emit mouseDoublePressOnEntity(rayPickResult.entityID, pointerEvent);
|
||||||
|
|
||||||
|
if (_entitiesScriptEngine) {
|
||||||
|
_entitiesScriptEngine->callEntityScriptMethod(rayPickResult.entityID, "mouseDoublePressOnEntity", pointerEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentClickingOnEntityID = rayPickResult.entityID;
|
||||||
|
emit clickDownOnEntity(_currentClickingOnEntityID, pointerEvent);
|
||||||
|
if (_entitiesScriptEngine) {
|
||||||
|
_entitiesScriptEngine->callEntityScriptMethod(_currentClickingOnEntityID, "doubleclickOnEntity", pointerEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastPointerEvent = pointerEvent;
|
||||||
|
_lastPointerEventValid = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
emit mouseDoublePressOffEntity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) {
|
void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
// If we don't have a tree, or we're in the process of shutting down, then don't
|
// If we don't have a tree, or we're in the process of shutting down, then don't
|
||||||
// process these events.
|
// process these events.
|
||||||
|
|
|
@ -90,6 +90,7 @@ public:
|
||||||
// event handles which may generate entity related events
|
// event handles which may generate entity related events
|
||||||
void mouseReleaseEvent(QMouseEvent* event);
|
void mouseReleaseEvent(QMouseEvent* event);
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent* event);
|
||||||
|
void mouseDoublePressEvent(QMouseEvent* event);
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
void mouseMoveEvent(QMouseEvent* event);
|
||||||
|
|
||||||
/// connect our signals to anEntityScriptingInterface for firing of events related clicking,
|
/// connect our signals to anEntityScriptingInterface for firing of events related clicking,
|
||||||
|
@ -103,9 +104,11 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void mousePressOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
void mousePressOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
|
void mouseDoublePressOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
void mouseMoveOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
void mouseMoveOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
void mouseReleaseOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
void mouseReleaseOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
void mousePressOffEntity();
|
void mousePressOffEntity();
|
||||||
|
void mouseDoublePressOffEntity();
|
||||||
|
|
||||||
void clickDownOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
void clickDownOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
void holdingClickOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
void holdingClickOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
|
|
|
@ -47,6 +47,9 @@ QScriptValue PointerEvent::toScriptValue(QScriptEngine* engine, const PointerEve
|
||||||
case Press:
|
case Press:
|
||||||
obj.setProperty("type", "Press");
|
obj.setProperty("type", "Press");
|
||||||
break;
|
break;
|
||||||
|
case DoublePress:
|
||||||
|
obj.setProperty("type", "DoublePress");
|
||||||
|
break;
|
||||||
case Release:
|
case Release:
|
||||||
obj.setProperty("type", "Release");
|
obj.setProperty("type", "Release");
|
||||||
break;
|
break;
|
||||||
|
@ -128,6 +131,8 @@ void PointerEvent::fromScriptValue(const QScriptValue& object, PointerEvent& eve
|
||||||
QString typeStr = type.isString() ? type.toString() : "Move";
|
QString typeStr = type.isString() ? type.toString() : "Move";
|
||||||
if (typeStr == "Press") {
|
if (typeStr == "Press") {
|
||||||
event._type = Press;
|
event._type = Press;
|
||||||
|
} else if (typeStr == "DoublePress") {
|
||||||
|
event._type = DoublePress;
|
||||||
} else if (typeStr == "Release") {
|
} else if (typeStr == "Release") {
|
||||||
event._type = Release;
|
event._type = Release;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,9 +26,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EventType {
|
enum EventType {
|
||||||
Press, // A button has just been pressed
|
Press, // A button has just been pressed
|
||||||
Release, // A button has just been released
|
DoublePress, // A button has just been double pressed
|
||||||
Move // The pointer has just moved
|
Release, // A button has just been released
|
||||||
|
Move // The pointer has just moved
|
||||||
};
|
};
|
||||||
|
|
||||||
PointerEvent();
|
PointerEvent();
|
||||||
|
|
Loading…
Reference in a new issue