From f0f12b047951eaf9bfdbdb6c622dfa98b78a38ca Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 11 Nov 2014 17:32:37 -0800 Subject: [PATCH] Auto-size load URL and file menu items in editModels and newEditEntities And fix a couple of typos --- examples/editModels.js | 15 +++++++++------ examples/newEditEntities.js | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/examples/editModels.js b/examples/editModels.js index d26a6e14b0..7538a83fef 100644 --- a/examples/editModels.js +++ b/examples/editModels.js @@ -1125,12 +1125,12 @@ var toolBar = (function () { browseModelsButton, loadURLMenuItem, loadFileMenuItem, - menuItemWidth = 125, + menuItemWidth, menuItemOffset, menuItemHeight, menuItemMargin = 5, menuTextColor = { red: 255, green: 255, blue: 255 }, - menuBackgoundColor = { red: 18, green: 66, blue: 66 }; + menuBackgroundColor = { red: 18, green: 66, blue: 66 }; function initialize() { toolBar = new ToolBar(0, 0, ToolBar.VERTICAL); @@ -1167,9 +1167,8 @@ var toolBar = (function () { loadURLMenuItem = Overlays.addOverlay("text", { x: newModelButton.x - menuItemWidth, y: newModelButton.y + menuItemOffset, - width: menuItemWidth, height: menuItemHeight, - backgroundColor: menuBackgoundColor, + backgroundColor: menuBackgroundColor, topMargin: menuItemMargin, text: "Model URL", alpha: 0.9, @@ -1179,15 +1178,19 @@ var toolBar = (function () { loadFileMenuItem = Overlays.addOverlay("text", { x: newModelButton.x - menuItemWidth, y: newModelButton.y + menuItemOffset + menuItemHeight, - width: menuItemWidth, height: menuItemHeight, - backgroundColor: menuBackgoundColor, + backgroundColor: menuBackgroundColor, topMargin: menuItemMargin, text: "Model File", alpha: 0.9, visible: false }); + menuItemWidth = Math.max(Overlays.textWidth(loadURLMenuItem, "Model URL"), + Overlays.textWidth(loadFileMenuItem, "Model File")) + 20; + Overlays.editOverlay(loadURLMenuItem, { width: menuItemWidth }); + Overlays.editOverlay(loadFileMenuItem, { width: menuItemWidth }); + newCubeButton = toolBar.addTool({ imageURL: toolIconUrl + "add-cube.svg", subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT }, diff --git a/examples/newEditEntities.js b/examples/newEditEntities.js index 57f3f29670..20359d9718 100644 --- a/examples/newEditEntities.js +++ b/examples/newEditEntities.js @@ -83,12 +83,12 @@ var toolBar = (function () { browseModelsButton, loadURLMenuItem, loadFileMenuItem, - menuItemWidth = 125, + menuItemWidth, menuItemOffset, menuItemHeight, menuItemMargin = 5, menuTextColor = { red: 255, green: 255, blue: 255 }, - menuBackgoundColor = { red: 18, green: 66, blue: 66 }; + menuBackgroundColor = { red: 18, green: 66, blue: 66 }; function initialize() { toolBar = new ToolBar(0, 0, ToolBar.VERTICAL); @@ -125,9 +125,8 @@ var toolBar = (function () { loadURLMenuItem = Overlays.addOverlay("text", { x: newModelButton.x - menuItemWidth, y: newModelButton.y + menuItemOffset, - width: menuItemWidth, height: menuItemHeight, - backgroundColor: menuBackgoundColor, + backgroundColor: menuBackgroundColor, topMargin: menuItemMargin, text: "Model URL", alpha: 0.9, @@ -137,15 +136,19 @@ var toolBar = (function () { loadFileMenuItem = Overlays.addOverlay("text", { x: newModelButton.x - menuItemWidth, y: newModelButton.y + menuItemOffset + menuItemHeight, - width: menuItemWidth, height: menuItemHeight, - backgroundColor: menuBackgoundColor, + backgroundColor: menuBackgroundColor, topMargin: menuItemMargin, text: "Model File", alpha: 0.9, visible: false }); + menuItemWidth = Math.max(Overlays.textWidth(loadURLMenuItem, "Model URL"), + Overlays.textWidth(loadFileMenuItem, "Model File")) + 20; + Overlays.editOverlay(loadURLMenuItem, { width: menuItemWidth }); + Overlays.editOverlay(loadFileMenuItem, { width: menuItemWidth }); + newCubeButton = toolBar.addTool({ imageURL: toolIconUrl + "add-cube.svg", subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },