diff --git a/css/main.css b/css/main.css index 0bf4b6fd90254610a1cd062ffea87a7cd052d334..4aa6ef33891624346eb950d35285a1e2ad0f2332 100644 --- a/css/main.css +++ b/css/main.css @@ -357,4 +357,8 @@ label { label.colorSwatches>span.icons{ margin: 5px 0; +} + +#navViewMenu span{ + margin-right:10px; } \ No newline at end of file diff --git a/index.html b/index.html index 91e9dc769b2e7c1e78255d6ce3186b5761b05064..2a48be00d9f17b13e33259bae1ffa82b00fb0164 100644 --- a/index.html +++ b/index.html @@ -96,6 +96,7 @@ <!--views--> <script src="js/menus/MenuWrapperView.js"></script> <script src="js/menus/Navbar.js"></script> + <script src="js/menus/NavViewMenu.js"></script> <script src="js/menus/Ribbon.js"></script> <script src="js/menus/LatticeMenuView.js"></script> <script src="js/menus/ImportMenuView.js"></script> @@ -157,20 +158,9 @@ </ul> </li> <li class="dropdown navDropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown">View <b class="caret"></b></a> + <a href="#" class="dropdown-toggle" id="viewMenuDropdown" data-toggle="dropdown">View <b class="caret"></b></a> <span class="dropdown-arrow"></span> - <ul class="dropdown-menu"> - <li><a href="#">Menu</a></li> - <li><a href="#">Script</a></li> - <li><a href="#">Console</a></li> - <li class="divider"></li> - <li><a href="#">Ambient Occlusion</a></li> - <li><a href="#">Realistic Material Colors</a></li> - <li><a href="#">BasePlane</a></li> - <li><a href="#">Hover Tool</a></li> - <li class="divider"></li> - <li><a href="#">Reset 3D Navigation</a></li> - </ul> + <ul id="navViewMenu" class="dropdown-menu"></ul> </li> <li><a data-menu-id="about" class="menuHoverControls" target="_blank" href="http://dma.cba.mit.edu/">About</a></li> </ul> diff --git a/js/main.js b/js/main.js index c6507724834ac96fd8d3c8e270608e58284cada6..7bfbac32543ea639f0591ace74ac16210add237f 100644 --- a/js/main.js +++ b/js/main.js @@ -16,6 +16,8 @@ $(function(){ globals.plist = AppPList(); globals.appState = new AppState(); globals.lattice = new Lattice(); + globals.basePlane = null; + globals.highlighter = null; globals.lattice.delayedInit();//todo need this? globals.cam = new Cam({appState: globals.appState, lattice:globals.lattice}); globals.fileSaver = GlobalFilesaver(); diff --git a/js/menus/NavViewMenu.js b/js/menus/NavViewMenu.js new file mode 100644 index 0000000000000000000000000000000000000000..5859af1bc12eccd08dce7dd5ce1c696b8614081d --- /dev/null +++ b/js/menus/NavViewMenu.js @@ -0,0 +1,65 @@ +/** + * Created by aghassaei on 5/27/15. + */ + + +//model is appState +//not templating this view yet + +NavViewMenu = Backbone.View.extend({ + + el: "#navViewMenu", + + events: { + "click a.boolProperty": "_makeSelection", + "click #reset3DView": "_reset3DNavigation" + }, + + initialize: function(){ + + _.bindAll(this, "render"); + }, + + + _makeSelection: function(e){ + e.preventDefault(); + var $target = $(e.target); + var property = $target.data("property"); + var owner = this._getPropertyOwner($target); + owner.set(property, !owner.get(property)); + }, + + _getPropertyOwner: function($target){ + if ($target.hasClass("appState")) return globals.appState; + console.warn("no owner found for " + $target); + return null; + }, + + _reset3DNavigation: function(){ + e.preventDefault(); + }, + + render: function(){ + console.log("render"); + this.$el.html(this.template(this.model.toJSON())); + + _.each($(".boolProperty"), function(item){ + var $item = $(item); + if (globals.appState.get($item.data("property"))) $item.html('<span class="fui-check"></span>' + $item.html()); + }) + }, + + template: _.template('\ + <li><a class="appState boolProperty" data-property="menuIsVisible" href="#">Menu</a></li>\ + <li><a class="appState boolProperty" data-property="scriptIsVisible" href="#">Script</a></li>\ + <li><a class="appState boolProperty" data-property="consoleIsVisible" href="#">Console</a></li>\ + <li class="divider"></li>\ + <li><a class="appState boolProperty" data-property="renderAmbientOcclusion" href="#">Ambient Occlusion</a></li>\ + <li><a class="appState boolProperty" data-property="realisticColorScheme" href="#">Realistic Color Scheme</a></li>\ + <li><a class="appState boolProperty" data-property="basePlaneIsVisible" href="#">BasePlane</a></li>\ + <li><a class="appState boolProperty" data-property="highlighterIsVisible" href="#">Hover Tool</a></li>\ + <li class="divider"></li>\ + <li><a id="reset3DView" href="#">Reset 3D Navigation</a></li>\ + ') + +}); \ No newline at end of file diff --git a/js/menus/Navbar.js b/js/menus/Navbar.js index f2be62bef10d66f264c1199427b41e73458ae86f..95f62eb8e7c98e58a86eec7631151e244a5387f8 100644 --- a/js/menus/Navbar.js +++ b/js/menus/Navbar.js @@ -25,11 +25,15 @@ NavBar = Backbone.View.extend({ "click .importJSON": "_importJSON", "change #jsonInput": "_selectJSONFiles", "click .loadUser": "_loadUser", - "click .loadDemo": "_loadDemo" + "click .loadDemo": "_loadDemo", + + "click #viewMenuDropdown": "_renderViewMenu" }, initialize: function(){ + this.viewMenu = new NavViewMenu({model:globals.appState}); + _.bindAll(this, "_setMenuVisibility", "_setNavSelection"); this.listenTo(this.model, "change:menuIsVisible", this._updateShowHideButton); @@ -101,6 +105,10 @@ NavBar = Backbone.View.extend({ }, + _renderViewMenu: function(){ + this.viewMenu.render(); + }, + _save: function(e){ diff --git a/js/models/AllAppPLists.js b/js/models/AllAppPLists.js index ad0c995b8021b213093a432343eb5a3d3550a165..cdf797cedef0d5df2b1d98a3e291d0698e345358 100644 --- a/js/models/AllAppPLists.js +++ b/js/models/AllAppPLists.js @@ -7,7 +7,7 @@ function AppPList(){ allMenuTabs: { navDesign:{ lattice:"Lattice", - import:"Import", +// import:"Import", //sketch:"Sketch", part:"Part", script:"Script" @@ -44,24 +44,19 @@ function AppPList(){ octa:{ face: { triangle:"Triangle" - //beam:"Beam", - //truss:"Truss" }, freeformFace: { trox:"Troxes" - //beam:"Beam" }, edge: null, edgeRot: { vox: "Snap Voxel (high res)", voxLowPoly: "Snap Voxel (low res)" - //beam:"Beam" }, - vertex: null//{ - //beam:"Beam", -// square:"Square", -// xShape:"X" -// } + vertex: { + square:"Square", + xShape:"X" + } }, tetra: {vertex: null}, cube: {face: null, @@ -70,7 +65,12 @@ function AppPList(){ legoLowPoly: "Micro LEGO (low res)" } }, - truncatedCube: {face: null}, + truncatedCube: { + face: { + square:"Square", + xShape:"X" + } + }, kelvin: {face: null} }, @@ -80,11 +80,7 @@ function AppPList(){ freeformFace: null, edge: null, edgeRot: null, - vertex: null//{ - //beam:"Beam", -// square:"Square", -// xShape:"X" -// } + vertex: null }, tetra: {vertex: null}, cube: {face: null, diff --git a/js/models/AppState.js b/js/models/AppState.js index 7ca3e8127bef0207e7a17d41deae65cf5d22144a..1f28c18c78470f714e1c1baaf13bc3aa6e10834d 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -18,6 +18,11 @@ AppState = Backbone.Model.extend({ lastAssembleTab: "assembler", menuIsVisible: true, + scriptIsVisible: false, + consoleIsVisible: false, + + basePlaneIsVisible:true, + highlighterIsVisible:true, //key bindings shift: false, diff --git a/js/parts/GIKPart.js b/js/parts/GIKPart.js index d0a2582c55dfcf17409eee444ba277b84a7a7757..53a56741e96a48f187defbf6eee45276c8ff7555 100644 --- a/js/parts/GIKPart.js +++ b/js/parts/GIKPart.js @@ -40,7 +40,7 @@ return unitPartGeo;//this.parentCell.getMaterialType() }; - DMAPart.prototype.getMaterial = function(){ + DMAGIKPart.prototype.getMaterial = function(){ return this.parentCell.getMaterial(); };