mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Tweak right-click to inspect
This commit is contained in:
parent
7ba05e3a5b
commit
1f3063193a
2 changed files with 34 additions and 1 deletions
|
@ -50,7 +50,9 @@ ContextOverlayInterface::ContextOverlayInterface() {
|
||||||
_entityPropertyFlags += PROP_OWNING_AVATAR_ID;
|
_entityPropertyFlags += PROP_OWNING_AVATAR_ID;
|
||||||
|
|
||||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>().data();
|
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>().data();
|
||||||
connect(entityScriptingInterface, &EntityScriptingInterface::mousePressOnEntity, this, &ContextOverlayInterface::createOrDestroyContextOverlay);
|
connect(entityScriptingInterface, &EntityScriptingInterface::clickDownOnEntity, this, &ContextOverlayInterface::clickDownOnEntity);
|
||||||
|
connect(entityScriptingInterface, &EntityScriptingInterface::holdingClickOnEntity, this, &ContextOverlayInterface::holdingClickOnEntity);
|
||||||
|
connect(entityScriptingInterface, &EntityScriptingInterface::mouseReleaseOnEntity, this, &ContextOverlayInterface::mouseReleaseOnEntity);
|
||||||
connect(entityScriptingInterface, &EntityScriptingInterface::hoverEnterEntity, this, &ContextOverlayInterface::contextOverlays_hoverEnterEntity);
|
connect(entityScriptingInterface, &EntityScriptingInterface::hoverEnterEntity, this, &ContextOverlayInterface::contextOverlays_hoverEnterEntity);
|
||||||
connect(entityScriptingInterface, &EntityScriptingInterface::hoverLeaveEntity, this, &ContextOverlayInterface::contextOverlays_hoverLeaveEntity);
|
connect(entityScriptingInterface, &EntityScriptingInterface::hoverLeaveEntity, this, &ContextOverlayInterface::contextOverlays_hoverLeaveEntity);
|
||||||
connect(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"), &TabletProxy::tabletShownChanged, this, [&]() {
|
connect(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"), &TabletProxy::tabletShownChanged, this, [&]() {
|
||||||
|
@ -97,6 +99,31 @@ void ContextOverlayInterface::setEnabled(bool enabled) {
|
||||||
_enabled = enabled;
|
_enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContextOverlayInterface::clickDownOnEntity(const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||||
|
if (_enabled && event.getButton() == PointerEvent::SecondaryButton && contextOverlayFilterPassed(entityItemID)) {
|
||||||
|
_mouseDownEntity = entityItemID;
|
||||||
|
_mouseDownEntityTimestamp = usecTimestampNow();
|
||||||
|
} else {
|
||||||
|
if (!_currentEntityWithContextOverlay.isNull()) {
|
||||||
|
disableEntityHighlight(_currentEntityWithContextOverlay);
|
||||||
|
destroyContextOverlay(_currentEntityWithContextOverlay, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const float CONTEXT_OVERLAY_CLICK_HOLD_TIME_MSEC = 400.0f;
|
||||||
|
void ContextOverlayInterface::holdingClickOnEntity(const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||||
|
if (!_mouseDownEntity.isNull() && ((usecTimestampNow() - _mouseDownEntityTimestamp) > (CONTEXT_OVERLAY_CLICK_HOLD_TIME_MSEC * USECS_PER_MSEC))) {
|
||||||
|
_mouseDownEntity = EntityItemID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextOverlayInterface::mouseReleaseOnEntity(const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||||
|
if (_enabled && event.getButton() == PointerEvent::SecondaryButton && contextOverlayFilterPassed(entityItemID) && _mouseDownEntity == entityItemID) {
|
||||||
|
createOrDestroyContextOverlay(entityItemID, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event) {
|
bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||||
if (_enabled && event.getButton() == PointerEvent::SecondaryButton) {
|
if (_enabled && event.getButton() == PointerEvent::SecondaryButton) {
|
||||||
if (contextOverlayFilterPassed(entityItemID)) {
|
if (contextOverlayFilterPassed(entityItemID)) {
|
||||||
|
|
|
@ -64,6 +64,10 @@ signals:
|
||||||
void contextOverlayClicked(const QUuid& currentEntityWithContextOverlay);
|
void contextOverlayClicked(const QUuid& currentEntityWithContextOverlay);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void clickDownOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
|
void holdingClickOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
|
void mouseReleaseOnEntity(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
|
|
||||||
bool createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
|
bool createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
bool destroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
|
bool destroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
|
||||||
bool destroyContextOverlay(const EntityItemID& entityItemID);
|
bool destroyContextOverlay(const EntityItemID& entityItemID);
|
||||||
|
@ -84,6 +88,8 @@ private:
|
||||||
};
|
};
|
||||||
bool _verboseLogging{ true };
|
bool _verboseLogging{ true };
|
||||||
bool _enabled { true };
|
bool _enabled { true };
|
||||||
|
EntityItemID _mouseDownEntity{};
|
||||||
|
quint64 _mouseDownEntityTimestamp;
|
||||||
EntityItemID _currentEntityWithContextOverlay{};
|
EntityItemID _currentEntityWithContextOverlay{};
|
||||||
EntityItemID _lastInspectedEntity{};
|
EntityItemID _lastInspectedEntity{};
|
||||||
QString _entityMarketplaceID;
|
QString _entityMarketplaceID;
|
||||||
|
|
Loading…
Reference in a new issue