consolidating the tools under luci

This commit is contained in:
sam gateau 2018-10-17 12:12:13 -07:00
parent 4837fd86de
commit 5f22928006

View file

@ -11,210 +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) {
var Page = function(title, qmlurl, width, height) {
this.title = title; this.title = title;
this.qml = Script.resolvePath(qmlurl); this.qml = qmlurl;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.window = null; 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() { Page.prototype.createView = function () {
if (this.window == null) { var that = this;
var window = Desktop.createWindow(this.qml, { if (!this.window) {
print("Page: New window for page:" + this.title);
this.window = Desktop.createWindow(Script.resolvePath(this.qml), {
title: this.title, title: this.title,
presentationMode: Desktop.PresentationMode.NATIVE, presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: this.width, y: this.height} size: {x: this.width, y: this.height}
}); });
this.window = window this.window.closed.connect(function () {
this.window.closed.connect(this.killView); that.killView();
});
} }
}; };
Page.prototype.killView = function() {
if (this.window !== undefined) { var Pages = function () {
this.window.closed.disconnect(this.killView); this._pages = {};
this.window.close()
this.window = undefined
}
}; };
var pages = [] Pages.prototype.addPage = function (command, title, qmlurl, width, height) {
pages.push_back(new Page('Render Engine', 'engineInspector.qml', 300, 400)) 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();
};
var engineInspectorView = null Pages.prototype.clear = function () {
function openEngineInspectorView() { for (var p in this._pages) {
print("Pages: kill page: " + p);
/* if (engineInspectorView == null) { this._pages[p].killView();
var qml = Script.resolvePath('engineInspector.qml'); delete this._pages[p];
var window = Desktop.createWindow(qml, {
title: 'Render Engine',
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: 300, y: 400}
});
engineInspectorView = window
window.closed.connect(killEngineInspectorView);
} }
} this._pages = {};
};
var pages = new Pages();
function killEngineInspectorView() { pages.addPage('openEngineView', 'Render Engine', 'engineInspector.qml', 300, 400);
if (engineInspectorView !== undefined) { pages.addPage('openEngineLODView', 'Render LOD', 'lod.qml', 300, 400);
engineInspectorView.closed.disconnect(killEngineInspectorView); pages.addPage('openCullInspectorView', 'Cull Inspector', 'culling.qml', 300, 400);
engineInspectorView.close()
engineInspectorView = undefined
}
}
*/
var cullInspectorView = null
function openCullInspectorView() {
if (cullInspectorView == null) {
var qml = Script.resolvePath('culling.qml');
var window = Desktop.createWindow(qml, {
title: 'Cull Inspector',
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: 400, y: 600}
});
cullInspectorView = window
window.closed.connect(killCullInspectorView);
}
}
function killCullInspectorView() {
if (cullInspectorView !== undefined) {
cullInspectorView.closed.disconnect(killCullInspectorView);
cullInspectorView.close()
cullInspectorView = undefined
}
}
var engineLODView = null
function openEngineLODView() {
if (engineLODView == null) {
engineLODView = Desktop.createWindow(Script.resolvePath('lod.qml'), {
title: 'Render LOD',
flags: Desktop.ALWAYS_ON_TOP,
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: 300, y: 500},
});
engineLODView.closed.connect(killEngineLODView);
}
}
function killEngineLODView() {
if (engineLODView !== undefined) {
engineLODView.closed.disconnect(killEngineLODView);
engineLODView.close()
engineLODView = undefined
}
}
function fromQml(message) { function fromQml(message) {
switch (message.method) { if (pages.open(message.method)) {
case "openEngineView": return;
openEngineInspectorView(); }
break;
case "openCullInspectorView":
openCullInspectorView();
break;
case "openEngineLODView":
openEngineLODView();
break;
}
} }
var ui;
function startup() {
ui = new AppUi({
buttonName: "LUCI",
home: Script.resolvePath("deferredLighting.qml"),
additionalAppScreens: Script.resolvePath("engineInspector.qml"),
onMessage: fromQml,
normalButton: Script.resolvePath("../../../system/assets/images/luci-i.svg"),
activeButton: Script.resolvePath("../../../system/assets/images/luci-a.svg")
});
}
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();
killEngineInspectorView();
killCullInspectorView();
killEngineLODWindow();
}); });
}()); }());