Merge pull request #14254 from samcake/black-bis

Case 19140: Clean up Luci ui to aggregate more tools
This commit is contained in:
Shannon Romano 2018-11-07 15:10:48 -08:00 committed by GitHub
commit 7e96ceb222
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 130 additions and 105 deletions

View file

@ -279,6 +279,7 @@ Rectangle {
} }
} }
Separator {} Separator {}
Row {
HifiControls.Button { HifiControls.Button {
text: "Engine" text: "Engine"
// activeFocusOnPress: false // activeFocusOnPress: false
@ -286,5 +287,20 @@ Rectangle {
sendToScript({method: "openEngineView"}); sendToScript({method: "openEngineView"});
} }
} }
HifiControls.Button {
text: "LOD"
// activeFocusOnPress: false
onClicked: {
sendToScript({method: "openEngineLODView"});
}
}
HifiControls.Button {
text: "Cull"
// activeFocusOnPress: false
onClicked: {
sendToScript({method: "openCullInspectorView"});
}
}
}
} }
} }

View file

@ -11,122 +11,131 @@
// //
(function() { (function() {
var TABLET_BUTTON_NAME = "LUCI"; var AppUi = Script.require('appUi');
var QMLAPP_URL = Script.resolvePath("./deferredLighting.qml");
var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg");
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg");
var onLuciScreen = false;
function onClicked() {
if (onLuciScreen) {
tablet.gotoHomeScreen();
} else {
tablet.loadQMLSource(QMLAPP_URL);
}
}
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
text: TABLET_BUTTON_NAME,
icon: ICON_URL,
activeIcon: ACTIVE_ICON_URL
});
var hasEventBridge = false;
function wireEventBridge(on) {
if (!tablet) {
print("Warning in wireEventBridge(): 'tablet' undefined!");
return;
}
if (on) {
if (!hasEventBridge) {
tablet.fromQml.connect(fromQml);
hasEventBridge = true;
}
} else {
if (hasEventBridge) {
tablet.fromQml.disconnect(fromQml);
hasEventBridge = false;
}
}
}
function onScreenChanged(type, url) {
if (url === QMLAPP_URL) {
onLuciScreen = true;
} else {
onLuciScreen = false;
}
button.editProperties({isActive: onLuciScreen});
wireEventBridge(onLuciScreen);
}
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
var moveDebugCursor = false; var moveDebugCursor = false;
Controller.mousePressEvent.connect(function (e) { var onMousePressEvent = function (e) {
if (e.isMiddleButton) { if (e.isMiddleButton) {
moveDebugCursor = true; moveDebugCursor = true;
setDebugCursor(e.x, e.y); setDebugCursor(e.x, e.y);
} }
}); };
Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; }); Controller.mousePressEvent.connect(onMousePressEvent);
Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); });
var onMouseReleaseEvent = function () {
moveDebugCursor = false;
};
Controller.mouseReleaseEvent.connect(onMouseReleaseEvent);
var onMouseMoveEvent = function (e) {
if (moveDebugCursor) {
setDebugCursor(e.x, e.y);
}
};
Controller.mouseMoveEvent.connect(onMouseMoveEvent);
function setDebugCursor(x, y) { function setDebugCursor(x, y) {
nx = 2.0 * (x / Window.innerWidth) - 1.0; var nx = 2.0 * (x / Window.innerWidth) - 1.0;
ny = 1.0 - 2.0 * ((y) / (Window.innerHeight)); var ny = 1.0 - 2.0 * ((y) / (Window.innerHeight));
Render.getConfig("RenderMainView").getConfig("DebugDeferredBuffer").size = { x: nx, y: ny, z: 1.0, w: 1.0 }; Render.getConfig("RenderMainView").getConfig("DebugDeferredBuffer").size = { x: nx, y: ny, z: 1.0, w: 1.0 };
} }
function Page(title, qmlurl, width, height) {
this.title = title;
this.qml = qmlurl;
this.width = width;
this.height = height;
this.window;
print("Page: New Page:" + JSON.stringify(this));
}
Page.prototype.killView = function () {
print("Page: Kill window for page:" + JSON.stringify(this));
if (this.window) {
print("Page: Kill window for page:" + this.title);
//this.window.closed.disconnect(function () {
// this.killView();
//});
this.window.close();
this.window = false;
}
};
Page.prototype.createView = function () {
var that = this;
if (!this.window) {
print("Page: New window for page:" + this.title);
this.window = Desktop.createWindow(Script.resolvePath(this.qml), {
title: this.title,
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: this.width, y: this.height}
});
this.window.closed.connect(function () {
that.killView();
});
}
};
var Pages = function () {
this._pages = {};
};
Pages.prototype.addPage = function (command, title, qmlurl, width, height) {
this._pages[command] = new Page(title, qmlurl, width, height);
};
Pages.prototype.open = function (command) {
print("Pages: command = " + command);
if (!this._pages[command]) {
print("Pages: unknown command = " + command);
return;
}
this._pages[command].createView();
};
Pages.prototype.clear = function () {
for (var p in this._pages) {
print("Pages: kill page: " + p);
this._pages[p].killView();
delete this._pages[p];
}
this._pages = {};
};
var pages = new Pages();
pages.addPage('openEngineView', 'Render Engine', 'engineInspector.qml', 300, 400);
pages.addPage('openEngineLODView', 'Render LOD', 'lod.qml', 300, 400);
pages.addPage('openCullInspectorView', 'Cull Inspector', 'culling.qml', 300, 400);
function fromQml(message) { function fromQml(message) {
switch (message.method) { if (pages.open(message.method)) {
case "openEngineView": return;
openEngineTaskView();
break;
} }
} }
var ui;
var engineInspectorView = null function startup() {
function openEngineTaskView() { ui = new AppUi({
if (engineInspectorView == null) { buttonName: "LUCI",
var qml = Script.resolvePath('engineInspector.qml'); home: Script.resolvePath("deferredLighting.qml"),
var window = new OverlayWindow({ additionalAppScreens: Script.resolvePath("engineInspector.qml"),
title: 'Render Engine', onMessage: fromQml,
source: qml, normalButton: Script.resolvePath("../../../system/assets/images/luci-i.svg"),
width: 300, activeButton: Script.resolvePath("../../../system/assets/images/luci-a.svg")
height: 400
}); });
window.setPosition(200, 50);
engineInspectorView = window
window.closed.connect(function() { engineInspectorView = null; });
} else {
engineInspectorView.setPosition(200, 50);
} }
} startup();
Script.scriptEnding.connect(function () { Script.scriptEnding.connect(function () {
if (onLuciScreen) { Controller.mousePressEvent.disconnect(onMousePressEvent);
tablet.gotoHomeScreen(); Controller.mouseReleaseEvent.disconnect(onMouseReleaseEvent);
} Controller.mouseMoveEvent.disconnect(onMouseMoveEvent);
button.clicked.disconnect(onClicked); pages.clear();
tablet.screenChanged.disconnect(onScreenChanged); // killEngineInspectorView();
tablet.removeButton(button); // killCullInspectorView();
// killEngineLODWindow();
if (engineInspectorView !== null) {
engineInspectorView.close()
}
}); });
}()); }());