Use create app in tablet mode when choosing to use tablet in desktop mode

This commit is contained in:
Thijs Wenker 2018-07-17 02:12:54 +02:00
parent 43435bdeae
commit 09e1090e72
3 changed files with 25 additions and 13 deletions

View file

@ -63,6 +63,15 @@ var createToolsWindow = new CreateWindow(
false false
); );
/**
* @description Returns true in case we should use the tablet version of the CreateApp
* @returns boolean
*/
var shouldUseEditTabletApp = function() {
return HMD.active || (!HMD.active && !Settings.getValue("desktopTabletBecomesToolbar", true));
};
var selectionDisplay = SelectionDisplay; var selectionDisplay = SelectionDisplay;
var selectionManager = SelectionManager; var selectionManager = SelectionManager;
@ -88,11 +97,12 @@ var cameraManager = new CameraManager();
var grid = new Grid(); var grid = new Grid();
var gridTool = new GridTool({ var gridTool = new GridTool({
horizontalGrid: grid, horizontalGrid: grid,
createToolsWindow: createToolsWindow createToolsWindow: createToolsWindow,
shouldUseEditTabletApp: shouldUseEditTabletApp
}); });
gridTool.setVisible(false); gridTool.setVisible(false);
var entityListTool = new EntityListTool(); var entityListTool = new EntityListTool(shouldUseEditTabletApp);
selectionManager.addEventListener(function () { selectionManager.addEventListener(function () {
selectionDisplay.updateHandles(); selectionDisplay.updateHandles();
@ -578,7 +588,8 @@ var toolBar = (function () {
}); });
createButton = activeButton; createButton = activeButton;
tablet.screenChanged.connect(function (type, url) { tablet.screenChanged.connect(function (type, url) {
var isGoingToHomescreenOnDesktop = (!HMD.active && (url === 'hifi/tablet/TabletHome.qml' || url === '')); var isGoingToHomescreenOnDesktop = (!shouldUseEditTabletApp() &&
(url === 'hifi/tablet/TabletHome.qml' || url === ''));
if (isActive && (type !== "QML" || url !== "hifi/tablet/Edit.qml") && !isGoingToHomescreenOnDesktop) { if (isActive && (type !== "QML" || url !== "hifi/tablet/Edit.qml") && !isGoingToHomescreenOnDesktop) {
that.setActive(false); that.setActive(false);
} }
@ -605,7 +616,7 @@ var toolBar = (function () {
}); });
function createNewEntityDialogButtonCallback(entityType) { function createNewEntityDialogButtonCallback(entityType) {
return function() { return function() {
if (HMD.active) { if (shouldUseEditTabletApp()) {
// tablet version of new-model dialog // tablet version of new-model dialog
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.pushOntoStack("hifi/tablet/New" + entityType + "Dialog.qml"); tablet.pushOntoStack("hifi/tablet/New" + entityType + "Dialog.qml");
@ -837,7 +848,7 @@ var toolBar = (function () {
selectionDisplay.triggerMapping.disable(); selectionDisplay.triggerMapping.disable();
tablet.landscape = false; tablet.landscape = false;
} else { } else {
if (HMD.active) { if (shouldUseEditTabletApp()) {
tablet.loadQMLSource("hifi/tablet/Edit.qml", true); tablet.loadQMLSource("hifi/tablet/Edit.qml", true);
} else { } else {
// make other apps inactive while in desktop mode // make other apps inactive while in desktop mode
@ -1989,8 +2000,8 @@ var PropertiesTool = function (opts) {
that.setVisible = function (newVisible) { that.setVisible = function (newVisible) {
visible = newVisible; visible = newVisible;
webView.setVisible(HMD.active && visible); webView.setVisible(shouldUseEditTabletApp() && visible);
createToolsWindow.setVisible(!HMD.active && visible); createToolsWindow.setVisible(!shouldUseEditTabletApp() && visible);
}; };
that.setVisible(false); that.setVisible(false);
@ -2416,7 +2427,7 @@ function selectParticleEntity(entityID) {
// Switch to particle explorer // Switch to particle explorer
var selectTabMethod = { method: 'selectTab', params: { id: 'particle' } }; var selectTabMethod = { method: 'selectTab', params: { id: 'particle' } };
if (HMD.active) { if (shouldUseEditTabletApp()) {
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.sendToQml(selectTabMethod); tablet.sendToQml(selectTabMethod);
} else { } else {

View file

@ -11,7 +11,7 @@
/* global EntityListTool, Tablet, selectionManager, Entities, Camera, MyAvatar, Vec3, Menu, Messages, /* global EntityListTool, Tablet, selectionManager, Entities, Camera, MyAvatar, Vec3, Menu, Messages,
cameraManager, MENU_EASE_ON_FOCUS, deleteSelectedEntities, toggleSelectedEntitiesLocked, toggleSelectedEntitiesVisible */ cameraManager, MENU_EASE_ON_FOCUS, deleteSelectedEntities, toggleSelectedEntitiesLocked, toggleSelectedEntitiesVisible */
EntityListTool = function() { EntityListTool = function(shouldUseEditTabletApp) {
var that = {}; var that = {};
var CreateWindow = Script.require('../modules/createWindow.js'); var CreateWindow = Script.require('../modules/createWindow.js');
@ -55,8 +55,8 @@ EntityListTool = function() {
that.setVisible = function(newVisible) { that.setVisible = function(newVisible) {
visible = newVisible; visible = newVisible;
webView.setVisible(HMD.active && visible); webView.setVisible(shouldUseEditTabletApp() && visible);
entityListWindow.setVisible(!HMD.active && visible); entityListWindow.setVisible(!shouldUseEditTabletApp() && visible);
}; };
that.setVisible(false); that.setVisible(false);

View file

@ -1,6 +1,6 @@
var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html'); var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html');
Grid = function(opts) { Grid = function() {
var that = {}; var that = {};
var gridColor = { red: 0, green: 0, blue: 0 }; var gridColor = { red: 0, green: 0, blue: 0 };
var gridAlpha = 0.6; var gridAlpha = 0.6;
@ -247,6 +247,7 @@ GridTool = function(opts) {
var horizontalGrid = opts.horizontalGrid; var horizontalGrid = opts.horizontalGrid;
var verticalGrid = opts.verticalGrid; var verticalGrid = opts.verticalGrid;
var createToolsWindow = opts.createToolsWindow; var createToolsWindow = opts.createToolsWindow;
var shouldUseEditTabletApp = opts.shouldUseEditTabletApp;
var listeners = []; var listeners = [];
var webView = null; var webView = null;
@ -299,7 +300,7 @@ GridTool = function(opts) {
}; };
that.setVisible = function(visible) { that.setVisible = function(visible) {
webView.setVisible(HMD.active && visible); webView.setVisible(shouldUseEditTabletApp() && visible);
}; };
return that; return that;