From d537c5efdba71aa5891c92f41be1a0c4cecf5c8b Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 11 Nov 2014 09:56:02 -0800 Subject: [PATCH] Add grid tool menu option --- examples/libraries/entitySelectionTool.js | 1 + examples/newEditEntities.js | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 980689d625..7ae4068e12 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -399,6 +399,7 @@ SelectionDisplay = (function () { alpha: 0.5, solid: true, visible: false, + width: 300, height: 200, rotation: baseOverlayRotation, ignoreRayIntersection: true, // always ignore this }); diff --git a/examples/newEditEntities.js b/examples/newEditEntities.js index b8e7a6174e..039771a752 100644 --- a/examples/newEditEntities.js +++ b/examples/newEditEntities.js @@ -38,8 +38,6 @@ var cameraManager = new CameraManager(); Script.include("libraries/gridTool.js"); var grid = Grid(); gridTool = GridTool({ horizontalGrid: grid }); -gridTool.addListener(function(data) { -}); selectionManager.setEventListener(selectionDisplay.updateHandles); @@ -57,9 +55,12 @@ var wantEntityGlow = false; var SPAWN_DISTANCE = 1; var DEFAULT_DIMENSION = 0.20; +var MENU_GRID_TOOL_ENABLED = 'Grid Tool'; var MENU_INSPECT_TOOL_ENABLED = 'Inspect Tool'; var MENU_EASE_ON_FOCUS = 'Ease Orientation on Focus'; +var SETTING_GRID_TOOL_ENABLED = 'GridToolEnabled'; + var modelURLs = [ HIFI_PUBLIC_BUCKET + "meshes/Feisar_Ship.FBX", HIFI_PUBLIC_BUCKET + "meshes/birarda/birarda_head.fbx", @@ -264,12 +265,13 @@ var toolBar = (function () { if (activeButton === toolBar.clicked(clickedOverlay)) { isActive = !isActive; - gridTool.setVisible(isActive); if (!isActive) { + gridTool.setVisible(false); selectionManager.clearSelections(); cameraManager.disable(); } else { cameraManager.enable(); + gridTool.setVisible(Menu.isOptionChecked(MENU_GRID_TOOL_ENABLED)); } return true; } @@ -597,7 +599,9 @@ function setupModelMenus() { Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" }); Menu.addMenuItem({ menuName: "Developer", menuItemName: "Debug Ryans Rotation Problems", isCheckable: true }); - Menu.addMenuItem({ menuName: "View", menuItemName: MENU_INSPECT_TOOL_ENABLED, afterItem: "Edit Entities Help...", isCheckable: true }); + Menu.addMenuItem({ menuName: "View", menuItemName: MENU_GRID_TOOL_ENABLED, afterItem: "Edit Entities Help...", isCheckable: true, + isChecked: Settings.getValue(SETTING_GRID_TOOL_ENABLED) == 'true'}); + Menu.addMenuItem({ menuName: "View", menuItemName: MENU_INSPECT_TOOL_ENABLED, afterItem: MENU_GRID_TOOL_ENABLED, isCheckable: true }); Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_INSPECT_TOOL_ENABLED, isCheckable: true }); } @@ -621,6 +625,8 @@ function cleanupModelMenus() { Menu.removeMenuItem("File", "Import Models"); Menu.removeMenuItem("Developer", "Debug Ryans Rotation Problems"); + Settings.setValue(SETTING_GRID_TOOL_ENABLED, Menu.isOptionChecked(MENU_GRID_TOOL_ENABLED)); + Menu.removeMenuItem("View", MENU_GRID_TOOL_ENABLED); Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED); Menu.removeMenuItem("View", MENU_EASE_ON_FOCUS); } @@ -729,6 +735,10 @@ function handeMenuEvent(menuItem) { } } else if (menuItem == "Import Models") { modelImporter.doImport(); + } else if (menuItem == MENU_GRID_TOOL_ENABLED) { + if (isActive) { + gridTool.setVisible(Menu.isOptionChecked(MENU_GRID_TOOL_ENABLED)); + } } tooltip.show(false); }