saving work

This commit is contained in:
druiz17 2017-09-29 16:48:25 -07:00
parent da3d5a92d9
commit 20918641f4
6 changed files with 36 additions and 3 deletions

View file

@ -223,7 +223,7 @@ FocusScope {
//offscreenWindow.activeFocusItemChanged.connect(onWindowFocusChanged);
focusHack.start();
}
function onWindowFocusChanged() {
//console.log("Focus item is " + offscreenWindow.activeFocusItem);
@ -298,6 +298,23 @@ FocusScope {
pinned = !pinned
}
function isPointOnWindow(point) {
for (var i = 0; i < desktop.visibleChildren.length; i++) {
var child = desktop.visibleChildren[i];
if (child.visible) {
if (child.hasOwnProperty("modality")) {
var mappedPoint = child.mapFromGlobal(point.x, point.y);
console.log(mappedPoint);
if (child.contains(mappedPoint)) {
return true;
console.log(child);
}
}
}
}
return false;
}
function setPinned(newPinned) {
pinned = newPinned
}

View file

@ -171,6 +171,11 @@ void WindowScriptingInterface::setPreviousBrowseAssetLocation(const QString& loc
Setting::Handle<QVariant>(LAST_BROWSE_ASSETS_LOCATION_SETTING).set(location);
}
bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
return offscreenUi->isPointOnDesktopWindow(point);
}
/// Makes sure that the reticle is visible, use this in blocking forms that require a reticle and
/// might be in same thread as a script that sets the reticle to invisible
void WindowScriptingInterface::ensureReticleVisible() const {

View file

@ -72,6 +72,7 @@ public slots:
void shareSnapshot(const QString& path, const QUrl& href = QUrl(""));
bool isPhysicsEnabled();
bool setDisplayTexture(const QString& name);
bool isPointOnDesktopWindow(QVariant point);
int openMessageBox(QString title, QString text, int buttons, int defaultButton);
void updateMessageBox(int id, QString title, QString text, int buttons, int defaultButton);

View file

@ -136,6 +136,15 @@ void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<voi
shownProperty.write(!shownProperty.read().toBool());
}
bool OffscreenUi::isPointOnDesktopWindow(QVariant point) {
QVariant result;
BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow",
Q_RETURN_ARG(QVariant, result),
Q_ARG(QVariant, point));
qDebug() << "------> invoke method isPointOnWindow <------";
return result.toBool();
}
void OffscreenUi::hide(const QString& name) {
QQuickItem* item = getRootItem()->findChild<QQuickItem*>(name);
if (item) {

View file

@ -78,6 +78,7 @@ public:
bool eventFilter(QObject* originalDestination, QEvent* event) override;
void addMenuInitializer(std::function<void(VrMenu*)> f);
QObject* getFlags();
Q_INVOKABLE bool isPointOnDesktopWindow(QVariant point);
QQuickItem* getDesktop();
QQuickItem* getToolWindow();
QObject* getRootMenu();

View file

@ -178,11 +178,11 @@
}
var hudRayPick = controllerData.hudRayPicks[this.hand];
var point2d = this.calculateNewReticlePosition(hudRayPick.intersection);
this.setReticlePosition(point2d);
if (!Reticle.isPointingAtSystemOverlay(point2d)) {
if (!Window.isPointOnDesktopWindow(point2d)) {
this.exitModule();
return false;
}
this.setReticlePosition(point2d);
Reticle.visible = false;
this.movedAway = false;
this.triggerClicked = controllerData.triggerClicks[this.hand];