From ce60a410cf7fbecee248124ec8ed3e06ba39a23f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 13 Jan 2015 15:34:26 -0800 Subject: [PATCH 01/14] Reenable entity list tools --- examples/editEntities.js | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index 172089ed62..24b658dfcd 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -232,6 +232,7 @@ var toolBar = (function () { cameraManager.disable(); } else { hasShownPropertiesTool = false; + entityListTool.setVisible(true); cameraManager.enable(); gridTool.setVisible(true); grid.setEnabled(true); From 9e8458edd92162f7074e3dc77af22714a90791b2 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 13 Jan 2015 15:35:19 -0800 Subject: [PATCH 02/14] Add support for teleport, delete, and filtering in entity list --- examples/html/entityList.html | 140 +++++++++++++++++++++++++------ examples/html/style.css | 26 +++++- examples/libraries/entityList.js | 49 +++++++---- 3 files changed, 171 insertions(+), 44 deletions(-) diff --git a/examples/html/entityList.html b/examples/html/entityList.html index 7caa45f19d..26a302cb41 100644 --- a/examples/html/entityList.html +++ b/examples/html/entityList.html @@ -2,13 +2,30 @@ +
- + + +
- - - - - - - - - -
TypeURL
+
+ + + + + + + + + + +
Type  ▾URL
+
diff --git a/examples/html/style.css b/examples/html/style.css index 7ffbacb15e..12e87baee5 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -114,6 +114,7 @@ table#entity-table { #entity-table tr { cursor: pointer; + border-bottom: 1px solid #e5e5e5; } #entity-table tr.selected { @@ -133,14 +134,18 @@ table#entity-table { border: 0px black solid; word-wrap: nowrap; white-space: nowrap; + text-overflow: ellipsis; +} + +#entity-table td.url { + white-space: nowrap; + overflow: hidden; } th#entity-type { width: 60px; } -th#entity-url { -} div.input-area { @@ -186,3 +191,20 @@ table#properties-table { col#col-label { width: 130px; } + +div.outer { + position: relative; +} +div.inner { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + position: absolute; + width: 100%; +} + +td { + + + vertical-align: top; +} diff --git a/examples/libraries/entityList.js b/examples/libraries/entityList.js index eb01295d97..10a2209309 100644 --- a/examples/libraries/entityList.js +++ b/examples/libraries/entityList.js @@ -24,10 +24,38 @@ EntityListTool = function(opts) { type: 'selectionUpdate', selectedIDs: selectedIDs, }; + print("Sending: " + JSON.stringify(data)); webView.eventBridge.emitScriptEvent(JSON.stringify(data)); }); + function sendUpdate() { + var entities = []; + var ids = Entities.findEntities(MyAvatar.position, 100); + for (var i = 0; i < ids.length; i++) { + var id = ids[i]; + var properties = Entities.getEntityProperties(id); + entities.push({ + id: id.id, + type: properties.type, + url: properties.type == "Model" ? properties.modelURL : "", + }); + } + + var selectedIDs = []; + for (var i = 0; i < selectionManager.selections.length; i++) { + selectedIDs.push(selectionManager.selections[i].id); + } + + var data = { + type: "update", + entities: entities, + selectedIDs: selectedIDs, + }; + webView.eventBridge.emitScriptEvent(JSON.stringify(data)); + } + webView.eventBridge.webEventReceived.connect(function(data) { + print("Got: " + data); data = JSON.parse(data); if (data.type == "selectionUpdate") { var ids = data.entityIds; @@ -46,22 +74,13 @@ EntityListTool = function(opts) { Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); } } else if (data.type == "refresh") { - var entities = []; - var ids = Entities.findEntities(MyAvatar.position, 100); - for (var i = 0; i < ids.length; i++) { - var id = ids[i]; - var properties = Entities.getEntityProperties(id); - entities.push({ - id: id.id, - type: properties.type, - url: properties.type == "Model" ? properties.modelURL : "", - }); + sendUpdate(); + } else if (data.type == "teleport") { + if (selectionManager.hasSelection()) { + MyAvatar.position = selectionManager.worldPosition; } - var data = { - type: "update", - entities: entities, - }; - webView.eventBridge.emitScriptEvent(JSON.stringify(data)); + } else if (data.type == "delete") { + deleteSelectedEntities(); } }); From 7ddec78cd52a1ec98a3757efd33a936250ce55d3 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 13 Jan 2015 15:36:25 -0800 Subject: [PATCH 03/14] Add list.min.js for entity list tool --- examples/html/list.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/html/list.min.js diff --git a/examples/html/list.min.js b/examples/html/list.min.js new file mode 100644 index 0000000000..56c17e398d --- /dev/null +++ b/examples/html/list.min.js @@ -0,0 +1 @@ +!function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];if(!g._resolving&&!g.exports){var h={};h.exports={},h.client=h.component=!0,g._resolving=!0,g.call(this,h.exports,a.relative(e),h),delete g._resolving,g.exports=h.exports}return g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],d=0;di;i++)if(h.test(f[i].className)){if(c)return f[i];d[j]=f[i],j++}return d}}()}),a.register("javve-get-attribute/index.js",function(a,b,c){c.exports=function(a,b){var c=a.getAttribute&&a.getAttribute(b)||null;if(!c)for(var d=a.attributes,e=d.length,f=0;e>f;f++)void 0!==b[f]&&b[f].nodeName===b&&(c=b[f].nodeValue);return c}}),a.register("javve-natural-sort/index.js",function(a,b,c){c.exports=function(a,b,c){var d,e,f=/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,g=/(^[ ]*|[ ]*$)/g,h=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,i=/^0x[0-9a-f]+$/i,j=/^0/,c=c||{},k=function(a){return c.insensitive&&(""+a).toLowerCase()||""+a},l=k(a).replace(g,"")||"",m=k(b).replace(g,"")||"",n=l.replace(f,"\x00$1\x00").replace(/\0$/,"").replace(/^\0/,"").split("\x00"),o=m.replace(f,"\x00$1\x00").replace(/\0$/,"").replace(/^\0/,"").split("\x00"),p=parseInt(l.match(i))||1!=n.length&&l.match(h)&&Date.parse(l),q=parseInt(m.match(i))||p&&m.match(h)&&Date.parse(m)||null,r=c.desc?-1:1;if(q){if(q>p)return-1*r;if(p>q)return 1*r}for(var s=0,t=Math.max(n.length,o.length);t>s;s++){if(d=!(n[s]||"").match(j)&&parseFloat(n[s])||n[s]||0,e=!(o[s]||"").match(j)&&parseFloat(o[s])||o[s]||0,isNaN(d)!==isNaN(e))return isNaN(d)?1:-1;if(typeof d!=typeof e&&(d+="",e+=""),e>d)return-1*r;if(d>e)return 1*r}return 0}}),a.register("javve-to-string/index.js",function(a,b,c){c.exports=function(a){return a=void 0===a?"":a,a=null===a?"":a,a=a.toString()}}),a.register("component-type/index.js",function(a,b,c){var d=Object.prototype.toString;c.exports=function(a){switch(d.call(a)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===a?"null":void 0===a?"undefined":a!==a?"nan":a&&1===a.nodeType?"element":typeof a.valueOf()}}),a.register("list.js/index.js",function(a,b,c){!function(a,d){"use strict";var e=a.document,f=b("get-by-class"),g=b("extend"),h=b("indexof"),i=function(a,c,i){var j,k=this,l=b("./src/item")(k),m=b("./src/add-async")(k),n=b("./src/parse")(k);j={start:function(){k.listClass="list",k.searchClass="search",k.sortClass="sort",k.page=200,k.i=1,k.items=[],k.visibleItems=[],k.matchingItems=[],k.searched=!1,k.filtered=!1,k.handlers={updated:[]},k.plugins={},k.helpers={getByClass:f,extend:g,indexOf:h},g(k,c),k.listContainer="string"==typeof a?e.getElementById(a):a,k.listContainer&&(k.list=f(k.listContainer,k.listClass,!0),k.templater=b("./src/templater")(k),k.search=b("./src/search")(k),k.filter=b("./src/filter")(k),k.sort=b("./src/sort")(k),this.items(),k.update(),this.plugins())},items:function(){n(k.list),i!==d&&k.add(i)},plugins:function(){for(var a=0;af;f++){var h=null;a[f]instanceof l?(h=a[f],h.reload()):(e=k.items.length>k.page?!0:!1,h=new l(a[f],d,e)),k.items.push(h),c.push(h)}return k.update(),c},this.show=function(a,b){return this.i=a,this.page=b,k.update(),k},this.remove=function(a,b,c){for(var d=0,e=0,f=k.items.length;f>e;e++)k.items[e].values()[a]==b&&(k.templater.remove(k.items[e],c),k.items.splice(e,1),f--,e--,d++);return k.update(),d},this.get=function(a,b){for(var c=[],d=0,e=k.items.length;e>d;d++){var f=k.items[d];f.values()[a]==b&&c.push(f)}return c},this.size=function(){return k.items.length},this.clear=function(){return k.templater.clear(),k.items=[],k},this.on=function(a,b){return k.handlers[a].push(b),k},this.off=function(a,b){var c=k.handlers[a],d=h(c,b);return d>-1&&c.splice(d,1),k},this.trigger=function(a){for(var b=k.handlers[a].length;b--;)k.handlers[a][b](k);return k},this.reset={filter:function(){for(var a=k.items,b=a.length;b--;)a[b].filtered=!1;return k},search:function(){for(var a=k.items,b=a.length;b--;)a[b].found=!1;return k}},this.update=function(){var a=k.items,b=a.length;k.visibleItems=[],k.matchingItems=[],k.templater.clear();for(var c=0;b>c;c++)a[c].matching()&&k.matchingItems.length+1>=k.i&&k.visibleItems.lengthb;b++)j.item(a.items[b])},item:function(a){a.found=!1;for(var b=0,d=c.length;d>b;b++)if(j.values(a.values(),c[b]))return a.found=!0,void 0},values:function(a,c){return a.hasOwnProperty(c)&&(b=f(a[c]).toLowerCase(),""!==g&&b.search(g)>-1)?!0:!1},reset:function(){a.reset.search(),a.searched=!1}},k=function(b){return a.trigger("searchStart"),i.resetList(),i.setSearchString(b),i.setOptions(arguments),i.setColumns(),""===g?j.reset():(a.searched=!0,h?h(g,c):j.list()),a.update(),a.trigger("searchComplete"),a.visibleItems};return a.handlers.searchStart=a.handlers.searchStart||[],a.handlers.searchComplete=a.handlers.searchComplete||[],d.bind(e(a.listContainer,a.searchClass),"keyup",function(b){var c=b.target||b.srcElement,d=""===c.value&&!a.searched;d||k(c.value)}),d.bind(e(a.listContainer,a.searchClass),"input",function(a){var b=a.target||a.srcElement;""===b.value&&k("")}),a.helpers.toString=f,k}}),a.register("list.js/src/sort.js",function(a,b,c){var d=b("natural-sort"),e=b("classes"),f=b("events"),g=b("get-by-class"),h=b("get-attribute");c.exports=function(a){a.sortFunction=a.sortFunction||function(a,b,c){return c.desc="desc"==c.order?!0:!1,d(a.values()[c.valueName],b.values()[c.valueName],c)};var b={els:void 0,clear:function(){for(var a=0,c=b.els.length;c>a;a++)e(b.els[a]).remove("asc"),e(b.els[a]).remove("desc")},getOrder:function(a){var b=h(a,"data-order");return"asc"==b||"desc"==b?b:e(a).has("desc")?"asc":e(a).has("asc")?"desc":"asc"},getInSensitive:function(a,b){var c=h(a,"data-insensitive");b.insensitive="true"===c?!0:!1},setOrder:function(a){for(var c=0,d=b.els.length;d>c;c++){var f=b.els[c];if(h(f,"data-sort")===a.valueName){var g=h(f,"data-order");"asc"==g||"desc"==g?g==a.order&&e(f).add(a.order):e(f).add(a.order)}}}},c=function(){a.trigger("sortStart"),options={};var c=arguments[0].currentTarget||arguments[0].srcElement||void 0;c?(options.valueName=h(c,"data-sort"),b.getInSensitive(c,options),options.order=b.getOrder(c)):(options=arguments[1]||options,options.valueName=arguments[0],options.order=options.order||"asc",options.insensitive="undefined"==typeof options.insensitive?!0:options.insensitive),b.clear(),b.setOrder(options),options.sortFunction=options.sortFunction||a.sortFunction,a.items.sort(function(a,b){return options.sortFunction(a,b,options)}),a.update(),a.trigger("sortComplete")};return a.handlers.sortStart=a.handlers.sortStart||[],a.handlers.sortComplete=a.handlers.sortComplete||[],b.els=g(a.listContainer,a.sortClass),f.bind(b.els,"click",c),a.on("searchStart",b.clear),a.on("filterStart",b.clear),a.helpers.classes=e,a.helpers.naturalSort=d,a.helpers.events=f,a.helpers.getAttribute=h,c}}),a.register("list.js/src/item.js",function(a,b,c){c.exports=function(a){return function(b,c,d){var e=this;this._values={},this.found=!1,this.filtered=!1;var f=function(b,c,d){if(void 0===c)d?e.values(b,d):e.values(b);else{e.elm=c;var f=a.templater.get(e,b);e.values(f)}};this.values=function(b,c){if(void 0===b)return e._values;for(var d in b)e._values[d]=b[d];c!==!0&&a.templater.set(e,e.values())},this.show=function(){a.templater.show(e)},this.hide=function(){a.templater.hide(e)},this.matching=function(){return a.filtered&&a.searched&&e.found&&e.filtered||a.filtered&&!a.searched&&e.filtered||!a.filtered&&a.searched&&e.found||!a.filtered&&!a.searched},this.visible=function(){return e.elm.parentNode==a.list?!0:!1},f(b,c,d)}}}),a.register("list.js/src/templater.js",function(a,b,c){var d=b("get-by-class"),e=function(a){function b(b){if(void 0===b){for(var c=a.list.childNodes,d=0,e=c.length;e>d;d++)if(void 0===c[d].data)return c[d];return null}if(-1!==b.indexOf("<")){var f=document.createElement("div");return f.innerHTML=b,f.firstChild}return document.getElementById(a.item)}var c=b(a.item),e=this;this.get=function(a,b){e.create(a);for(var c={},f=0,g=b.length;g>f;f++){var h=d(a.elm,b[f],!0);c[b[f]]=h?h.innerHTML:""}return c},this.set=function(a,b){if(!e.create(a))for(var c in b)if(b.hasOwnProperty(c)){var f=d(a.elm,c,!0);f&&("IMG"===f.tagName&&""!==b[c]?f.src=b[c]:f.innerHTML=b[c])}},this.create=function(a){if(void 0!==a.elm)return!1;var b=c.cloneNode(!0);return b.removeAttribute("id"),a.elm=b,e.set(a,a.values()),!0},this.remove=function(b){a.list.removeChild(b.elm)},this.show=function(b){e.create(b),a.list.appendChild(b.elm)},this.hide=function(b){void 0!==b.elm&&b.elm.parentNode===a.list&&a.list.removeChild(b.elm)},this.clear=function(){if(a.list.hasChildNodes())for(;a.list.childNodes.length>=1;)a.list.removeChild(a.list.firstChild)}};c.exports=function(a){return new e(a)}}),a.register("list.js/src/filter.js",function(a,b,c){c.exports=function(a){return a.handlers.filterStart=a.handlers.filterStart||[],a.handlers.filterComplete=a.handlers.filterComplete||[],function(b){if(a.trigger("filterStart"),a.i=1,a.reset.filter(),void 0===b)a.filtered=!1;else{a.filtered=!0;for(var c=a.items,d=0,e=c.length;e>d;d++){var f=c[d];f.filtered=b(f)?!0:!1}}return a.update(),a.trigger("filterComplete"),a.visibleItems}}}),a.register("list.js/src/add-async.js",function(a,b,c){c.exports=function(a){return function(b,c,d){var e=b.splice(0,100);d=d||[],d=d.concat(a.add(e)),b.length>0?setTimeout(function(){addAsync(b,c,d)},10):(a.update(),c(d))}}}),a.register("list.js/src/parse.js",function(a,b,c){c.exports=function(a){var c=b("./item")(a),d=function(a){for(var b=a.childNodes,c=[],d=0,e=b.length;e>d;d++)void 0===b[d].data&&c.push(b[d]);return c},e=function(b,d){for(var e=0,f=b.length;f>e;e++)a.items.push(new c(d,b[e]))},f=function(b,c){var d=b.splice(0,100);e(d,c),b.length>0?setTimeout(function(){init.items.indexAsync(b,c)},10):a.update()};return function(){var b=d(a.list),c=a.valueNames;a.indexAsync?f(b,c):e(b,c)}}}),a.alias("component-classes/index.js","list.js/deps/classes/index.js"),a.alias("component-classes/index.js","classes/index.js"),a.alias("component-indexof/index.js","component-classes/deps/indexof/index.js"),a.alias("segmentio-extend/index.js","list.js/deps/extend/index.js"),a.alias("segmentio-extend/index.js","extend/index.js"),a.alias("component-indexof/index.js","list.js/deps/indexof/index.js"),a.alias("component-indexof/index.js","indexof/index.js"),a.alias("javve-events/index.js","list.js/deps/events/index.js"),a.alias("javve-events/index.js","events/index.js"),a.alias("component-event/index.js","javve-events/deps/event/index.js"),a.alias("timoxley-to-array/index.js","javve-events/deps/to-array/index.js"),a.alias("javve-get-by-class/index.js","list.js/deps/get-by-class/index.js"),a.alias("javve-get-by-class/index.js","get-by-class/index.js"),a.alias("javve-get-attribute/index.js","list.js/deps/get-attribute/index.js"),a.alias("javve-get-attribute/index.js","get-attribute/index.js"),a.alias("javve-natural-sort/index.js","list.js/deps/natural-sort/index.js"),a.alias("javve-natural-sort/index.js","natural-sort/index.js"),a.alias("javve-to-string/index.js","list.js/deps/to-string/index.js"),a.alias("javve-to-string/index.js","list.js/deps/to-string/index.js"),a.alias("javve-to-string/index.js","to-string/index.js"),a.alias("javve-to-string/index.js","javve-to-string/index.js"),a.alias("component-type/index.js","list.js/deps/type/index.js"),a.alias("component-type/index.js","type/index.js"),"object"==typeof exports?module.exports=a("list.js"):"function"==typeof define&&define.amd?define(function(){return a("list.js")}):this.List=a("list.js")}(); \ No newline at end of file From c51cac6381e836371c8559f977dd56387b1c115e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 13 Jan 2015 15:38:28 -0800 Subject: [PATCH 04/14] Remove Model List dialog --- examples/editEntities.js | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 24b658dfcd..38d3d3af75 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -672,8 +672,7 @@ function setupModelMenus() { print("delete exists... don't add ours"); } - Menu.addMenuItem({ menuName: "Edit", menuItemName: "Model List...", afterItem: "Models" }); - Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste Models", shortcutKey: "CTRL+META+V", afterItem: "Model List..." }); + Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste Models", shortcutKey: "CTRL+META+V", afterItem: "Models" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Large Models", shortcutKey: "CTRL+META+L", afterItem: "Paste Models", isCheckable: true, isChecked: true }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Small Models", shortcutKey: "CTRL+META+S", @@ -700,7 +699,6 @@ function cleanupModelMenus() { Menu.removeMenuItem("Edit", "Delete"); } - Menu.removeMenuItem("Edit", "Model List..."); Menu.removeMenuItem("Edit", "Paste Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Large Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Small Models"); @@ -764,38 +762,6 @@ function handeMenuEvent(menuItem) { } else { print(" Delete Entity.... not holding..."); } - } else if (menuItem == "Model List...") { - var models = new Array(); - models = Entities.findEntities(MyAvatar.position, Number.MAX_VALUE); - for (var i = 0; i < models.length; i++) { - models[i].properties = Entities.getEntityProperties(models[i]); - models[i].toString = function() { - var modelname; - if (this.properties.type == "Model") { - modelname = decodeURIComponent( - this.properties.modelURL.indexOf("/") != -1 ? - this.properties.modelURL.substring(this.properties.modelURL.lastIndexOf("/") + 1) : - this.properties.modelURL); - } else { - modelname = this.properties.id; - } - return "[" + this.properties.type + "] " + modelname; - }; - } - var form = [{label: "Model: ", options: models}]; - form.push({label: "Action: ", options: ["Properties", "Delete", "Teleport"]}); - form.push({ button: "Cancel" }); - if (Window.form("Model List", form)) { - var selectedModel = form[0].value; - if (form[1].value == "Properties") { - editModelID = selectedModel; - entityPropertyDialogBox.openDialog(editModelID); - } else if (form[1].value == "Delete") { - Entities.deleteEntity(selectedModel); - } else if (form[1].value == "Teleport") { - MyAvatar.position = selectedModel.properties.position; - } - } } else if (menuItem == "Paste Models") { modelImporter.paste(); } else if (menuItem == "Export Models") { From 705e6181a11202189376f3b93fa34f724259c4a6 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 15 Jan 2015 11:12:42 -0800 Subject: [PATCH 05/14] Move entity delete action to function --- examples/editEntities.js | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 38d3d3af75..369ab73d17 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -735,6 +735,28 @@ Script.update.connect(function (deltaTime) { selectionDisplay.checkMove(); }); +function deleteSelectedEntities() { + if (SelectionManager.hasSelection()) { + print(" Delete Entities"); + SelectionManager.saveProperties(); + var savedProperties = []; + for (var i = 0; i < selectionManager.selections.length; i++) { + var entityID = SelectionManager.selections[i]; + var initialProperties = SelectionManager.savedProperties[entityID.id]; + SelectionManager.savedProperties[entityID.id]; + savedProperties.push({ + entityID: entityID, + properties: initialProperties + }); + Entities.deleteEntity(entityID); + } + SelectionManager.clearSelections(); + pushCommandForSelections([], savedProperties); + } else { + print(" Delete Entity.... not holding..."); + } +} + function handeMenuEvent(menuItem) { if (menuItem == "Allow Selecting of Small Models") { allowSmallModels = Menu.isOptionChecked("Allow Selecting of Small Models"); @@ -743,25 +765,7 @@ function handeMenuEvent(menuItem) { } else if (menuItem == "Allow Selecting of Lights") { Entities.setLightsArePickable(Menu.isOptionChecked("Allow Selecting of Lights")); } else if (menuItem == "Delete") { - if (SelectionManager.hasSelection()) { - print(" Delete Entities"); - SelectionManager.saveProperties(); - var savedProperties = []; - for (var i = 0; i < selectionManager.selections.length; i++) { - var entityID = SelectionManager.selections[i]; - var initialProperties = SelectionManager.savedProperties[entityID.id]; - SelectionManager.savedProperties[entityID.id]; - savedProperties.push({ - entityID: entityID, - properties: initialProperties - }); - Entities.deleteEntity(entityID); - } - SelectionManager.clearSelections(); - pushCommandForSelections([], savedProperties); - } else { - print(" Delete Entity.... not holding..."); - } + deleteSelectedEntities(); } else if (menuItem == "Paste Models") { modelImporter.paste(); } else if (menuItem == "Export Models") { @@ -790,7 +794,7 @@ Controller.keyPressEvent.connect(function(event) { Controller.keyReleaseEvent.connect(function (event) { // since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items if (event.text == "BACKSPACE" || event.text == "DELETE") { - handeMenuEvent("Delete"); + deleteSelectedEntities(); } else if (event.text == "TAB") { selectionDisplay.toggleSpaceMode(); } else if (event.text == "f") { From d3a6a411fb74d6acdedf1e515f838564a77b1068 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 16 Jan 2015 16:23:29 -0800 Subject: [PATCH 06/14] Update entity list to use list.js more directly --- examples/html/entityList.html | 61 ++++++++++++++++------------------- examples/html/style.css | 16 ++++----- 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/examples/html/entityList.html b/examples/html/entityList.html index 26a302cb41..6c9846f5e4 100644 --- a/examples/html/entityList.html +++ b/examples/html/entityList.html @@ -1,4 +1,3 @@ - @@ -14,6 +13,8 @@ var DESC_STRING = ' ▴'; function loaded() { + entityList = new List('entity-list', { valueNames: ['type', 'url']}); + entityList.clear(); elEntityTable = document.getElementById("entity-table"); elEntityTableBody = document.getElementById("entity-table-body"); elRefresh = document.getElementById("refresh"); @@ -37,7 +38,8 @@ selectedEntities = selection; - entities[id].el.className = 'selected'; + this.className = 'selected'; + EventBridge.emitWebEvent(JSON.stringify({ type: "selectionUpdate", focus: false, @@ -46,8 +48,6 @@ } function onRowDoubleClicked() { - var id = this.dataset.entityId; - EventBridge.emitWebEvent(JSON.stringify({ type: "selectionUpdate", focus: true, @@ -60,21 +60,21 @@ var urlParts = url.split('/'); var filename = urlParts[urlParts.length - 1]; - var el = document.createElement('tr'); - el.setAttribute('id', 'entity_' + id); - el.innerHTML += "" + type + ""; - el.innerHTML += "
" + filename + "
"; - el.dataset.entityId = id; - el.onclick = onRowClicked; - el.ondblclick = onRowDoubleClicked; - elEntityTableBody.appendChild(el); - - // Add element to local dict - entities[id] = { - id: id, - name: id, - el: el, - }; + entityList.add([{ id: id, type: type, url: filename }], function(items) { + var el = items[0].elm; + var id = items[0]._values.id; + entities[id] = { + id: id, + name: id, + el: el, + }; + el.setAttribute('id', 'entity_' + id); + el.setAttribute('title', url); + el.dataset.entityId = id; + el.onclick = onRowClicked; + el.ondblclick = onRowDoubleClicked; + el.innerHTML + }); if (refreshEntityListTimer) { clearTimeout(refreshEntityListTimer); @@ -91,10 +91,8 @@ } function clearEntities() { - for (id in entities) { - elEntityTableBody.removeChild(entities[id].el); - } entities = {}; + entityList.clear(); } var elSortOrder = { @@ -122,7 +120,6 @@ function refreshEntityListObject() { refreshEntityListTimer = null; - entityList = new List('entity-list', { valueNames: ['type', 'url']}); entityList.sort(currentSortColumn, { order: currentSortOrder }); entityList.search(document.getElementById("filter").value); } @@ -174,15 +171,6 @@ } }); } - - // var _id = 0; - // setInterval(function() { - // for(var i = 0; i < 2; i++) { - // addEntity(_id, ['Model', 'Light'][i], 'http' + _id); - // _id++; - // } - // }, 5000); - setTimeout(refreshEntities, 1); } @@ -198,11 +186,16 @@ - - + + + + + + +
Type  ▾URL Type  ▾URL
Type
URL
diff --git a/examples/html/style.css b/examples/html/style.css index 42cf37d34a..ad78d0234c 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -5,9 +5,10 @@ body { margin: 0; padding: 0; - background-color: #efefef; + background-color: rgb(76, 76, 76); + color: rgb(204, 204, 204); font-family: Arial; - font-size: 11.5px; + font-size: 11px; -webkit-touch-callout: none; -webkit-user-select: none; @@ -17,12 +18,6 @@ body { user-select: none; } -body.properties { - background-color: rgb(76, 76, 76); - color: rgb(204, 204, 204); - font-size: 11px; -} - .selectable { -webkit-touch-callout: text; -webkit-user-select: text; @@ -117,13 +112,13 @@ input.coord { table#entity-table { border-collapse: collapse; font-family: Sans-Serif; - /* font-size: 12px; */ + font-size: 10px; width: 100%; } #entity-table tr { cursor: pointer; - border-bottom: 1px solid #e5e5e5; + border-bottom: 1px solid rgb(63, 63, 63) } #entity-table tr.selected { @@ -140,6 +135,7 @@ table#entity-table { } #entity-table td { + font-size: 11px; border: 0px black solid; word-wrap: nowrap; white-space: nowrap; From ba752040ddfad0437b33c989504e43cb330cc603 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 16 Jan 2015 16:24:19 -0800 Subject: [PATCH 07/14] Update WebWindow to redefine EventBridge after refresh --- interface/src/scripting/WebWindowClass.cpp | 16 ++++++++++++---- interface/src/scripting/WebWindowClass.h | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/interface/src/scripting/WebWindowClass.cpp b/interface/src/scripting/WebWindowClass.cpp index cc6f4fbfff..be87870f26 100644 --- a/interface/src/scripting/WebWindowClass.cpp +++ b/interface/src/scripting/WebWindowClass.cpp @@ -41,19 +41,27 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid _dockWidget = new QDockWidget(title, toolWindow); _dockWidget->setFeatures(QDockWidget::DockWidgetMovable); - QWebView* webView = new QWebView(_dockWidget); - webView->page()->mainFrame()->addToJavaScriptWindowObject("EventBridge", _eventBridge); - webView->setUrl(url); - _dockWidget->setWidget(webView); + + _webView = new QWebView(_dockWidget); + _webView->setUrl(url); + addEventBridgeToWindowObject(); + + _dockWidget->setWidget(_webView); toolWindow->addDockWidget(Qt::RightDockWidgetArea, _dockWidget); + connect(_webView->page()->mainFrame(), &QWebFrame::javaScriptWindowObjectCleared, + this, &WebWindowClass::addEventBridgeToWindowObject); connect(this, &WebWindowClass::destroyed, _dockWidget, &QWidget::deleteLater); } WebWindowClass::~WebWindowClass() { } +void WebWindowClass::addEventBridgeToWindowObject() { + _webView->page()->mainFrame()->addToJavaScriptWindowObject("EventBridge", _eventBridge); +} + void WebWindowClass::setVisible(bool visible) { if (visible) { QMetaObject::invokeMethod( diff --git a/interface/src/scripting/WebWindowClass.h b/interface/src/scripting/WebWindowClass.h index ae0d14ae06..0fa88804f2 100644 --- a/interface/src/scripting/WebWindowClass.h +++ b/interface/src/scripting/WebWindowClass.h @@ -14,6 +14,7 @@ #include #include +#include class ScriptEventBridge : public QObject { Q_OBJECT @@ -42,9 +43,11 @@ public: public slots: void setVisible(bool visible); ScriptEventBridge* getEventBridge() const { return _eventBridge; } + void addEventBridgeToWindowObject(); private: QDockWidget* _dockWidget; + QWebView* _webView; ScriptEventBridge* _eventBridge; }; From 8202c84c794a7231c4cf44d3475db8ae2780821c Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 20 Jan 2015 12:37:39 -0800 Subject: [PATCH 08/14] Add entity list menu option --- examples/editEntities.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 4e06125ea1..ad064d269b 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -44,10 +44,16 @@ var entityListTool = EntityListTool(); var hasShownPropertiesTool = false; +var entityListVisible = false; + selectionManager.addEventListener(function() { selectionDisplay.updateHandles(); if (selectionManager.hasSelection() && !hasShownPropertiesTool) { + // Open properties and model list, but force selection of model list tab + propertiesTool.setVisible(false); + entityListTool.setVisible(false); propertiesTool.setVisible(true); + entityListTool.setVisible(true); hasShownPropertiesTool = true; } }); @@ -232,7 +238,6 @@ var toolBar = (function () { cameraManager.disable(); } else { hasShownPropertiesTool = false; - entityListTool.setVisible(true); cameraManager.enable(); gridTool.setVisible(true); grid.setEnabled(true); @@ -703,6 +708,8 @@ function setupModelMenus() { Menu.addMenuItem({ menuName: "File", menuItemName: "Export Models", shortcutKey: "CTRL+META+E", afterItem: "Models" }); Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" }); + Menu.addMenuItem({ menuName: "Tools", menuItemName: "Entity List...", shortcutKey: "CTRL+META+L", afterItem: "Tool Window" }); + Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_INSPECT_TOOL_ENABLED, isCheckable: true, isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) == "true" }); @@ -727,6 +734,8 @@ function cleanupModelMenus() { Menu.removeMenuItem("File", "Export Models"); Menu.removeMenuItem("File", "Import Models"); + Menu.removeMenuItem("Tools", "Entity List..."); + Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED); Menu.removeMenuItem("View", MENU_EASE_ON_FOCUS); } @@ -797,6 +806,10 @@ function handeMenuEvent(menuItem) { } } else if (menuItem == "Import Models") { modelImporter.doImport(); + } else if (menuItem == "Entity List...") { + if (isActive) { + entityListTool.toggleVisible(); + } } tooltip.show(false); } From 891f6fa5138e46dea5c9772c2b5d2135e11c5a26 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 20 Jan 2015 12:40:16 -0800 Subject: [PATCH 09/14] Move entity list to edit menu --- examples/editEntities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index ad064d269b..3c11b2d7eb 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -696,7 +696,8 @@ function setupModelMenus() { print("delete exists... don't add ours"); } - Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste Models", shortcutKey: "CTRL+META+V", afterItem: "Models" }); + Menu.addMenuItem({ menuName: "Edit", menuItemName: "Entity List...", shortcutKey: "CTRL+META+L", afterItem: "Models" }); + Menu.addMenuItem({ menuName: "Edit", menuItemName: "Paste Models", shortcutKey: "CTRL+META+V", afterItem: "Entity List..." }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Large Models", shortcutKey: "CTRL+META+L", afterItem: "Paste Models", isCheckable: true, isChecked: true }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Small Models", shortcutKey: "CTRL+META+S", @@ -708,7 +709,6 @@ function setupModelMenus() { Menu.addMenuItem({ menuName: "File", menuItemName: "Export Models", shortcutKey: "CTRL+META+E", afterItem: "Models" }); Menu.addMenuItem({ menuName: "File", menuItemName: "Import Models", shortcutKey: "CTRL+META+I", afterItem: "Export Models" }); - Menu.addMenuItem({ menuName: "Tools", menuItemName: "Entity List...", shortcutKey: "CTRL+META+L", afterItem: "Tool Window" }); Menu.addMenuItem({ menuName: "View", menuItemName: MENU_EASE_ON_FOCUS, afterItem: MENU_INSPECT_TOOL_ENABLED, isCheckable: true, isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) == "true" }); From 903921e11f590ad460b6e658429a75a23c4c022d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 20 Jan 2015 12:40:31 -0800 Subject: [PATCH 10/14] Update entity list to auto-refresh list on start --- examples/html/entityList.html | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/html/entityList.html b/examples/html/entityList.html index 6c9846f5e4..e1318a225c 100644 --- a/examples/html/entityList.html +++ b/examples/html/entityList.html @@ -170,6 +170,7 @@ updateSelectedEntities(data.selectedIDs); } }); + setTimeout(refreshEntities, 1000); } } From bc21faeefb4120dc1a0895c032b937539509228d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 20 Jan 2015 12:41:58 -0800 Subject: [PATCH 11/14] Add entityListTool.toggleVisible --- examples/libraries/entityList.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/libraries/entityList.js b/examples/libraries/entityList.js index 10a2209309..8fbc40698f 100644 --- a/examples/libraries/entityList.js +++ b/examples/libraries/entityList.js @@ -13,6 +13,10 @@ EntityListTool = function(opts) { webView.setVisible(visible); }; + that.toggleVisible = function() { + that.setVisible(!visible); + } + selectionManager.addEventListener(function() { var selectedIDs = []; From 3a287a08aba52f4359ca6937059b2b62ee380302 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 20 Jan 2015 12:43:49 -0800 Subject: [PATCH 12/14] Fix removal of entity list menu item --- examples/editEntities.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 3c11b2d7eb..9187b624fd 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -725,6 +725,7 @@ function cleanupModelMenus() { Menu.removeMenuItem("Edit", "Delete"); } + Menu.removeMenuItem("Edit", "Entity List..."); Menu.removeMenuItem("Edit", "Paste Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Large Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Small Models"); @@ -734,8 +735,6 @@ function cleanupModelMenus() { Menu.removeMenuItem("File", "Export Models"); Menu.removeMenuItem("File", "Import Models"); - Menu.removeMenuItem("Tools", "Entity List..."); - Menu.removeMenuItem("View", MENU_INSPECT_TOOL_ENABLED); Menu.removeMenuItem("View", MENU_EASE_ON_FOCUS); } From 1a6557c72d0431fafd2771da2cfd3c35d8b988fd Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 20 Jan 2015 12:46:26 -0800 Subject: [PATCH 13/14] Remove removeEntity from entityList.html --- examples/html/entityList.html | 7 ------- 1 file changed, 7 deletions(-) diff --git a/examples/html/entityList.html b/examples/html/entityList.html index e1318a225c..6e7795a3f0 100644 --- a/examples/html/entityList.html +++ b/examples/html/entityList.html @@ -83,13 +83,6 @@ } } - function removeEntity(id) { - if (entities[id] !== undefined) { - elEntityTableBody.removeChild(entities[id].el); - delete entities[id]; - } - } - function clearEntities() { entities = {}; entityList.clear(); From 1f86edbfbf04621baf7234223a6cc1f1fe6cda59 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 20 Jan 2015 12:47:19 -0800 Subject: [PATCH 14/14] Remove console.log from entityList.html --- examples/html/entityList.html | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/html/entityList.html b/examples/html/entityList.html index 6e7795a3f0..01061f1eb0 100644 --- a/examples/html/entityList.html +++ b/examples/html/entityList.html @@ -101,7 +101,6 @@ currentSortColumn = column; currentSortOrder = "asc"; } - console.log(currentSortColumn, currentSortOrder); elSortOrder[column].innerHTML = currentSortOrder == "asc" ? ASC_STRING : DESC_STRING; entityList.sort(currentSortColumn, { order: currentSortOrder }); }