From f067a00d783c7f965d12ed165c208d4d5ee80a38 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 10 Jun 2015 17:07:33 -0700 Subject: [PATCH] added composite menu --- css/main.css | 12 +++++++ js/cells/supercells/DMASuperCell.js | 3 +- js/main.js | 1 + js/menus/CompositeMenu.js | 50 +++++++++++++++++++++++++++++ js/menus/MaterialMenuView.js | 2 +- js/models/AppState.js | 4 +-- 6 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 js/menus/CompositeMenu.js diff --git a/css/main.css b/css/main.css index 502a81c5..e6dea439 100644 --- a/css/main.css +++ b/css/main.css @@ -278,6 +278,11 @@ input.intInput, input.floatInput{ width: 47%; } +.halfWidth { + width: 47%; + display: inline-block; +} + #navRibbon{ height: 49px; width: 270px; @@ -392,4 +397,11 @@ label.colorSwatches>span.icons{ .CodeMirror { opacity: 0.6; margin: 0 20px 0 -10px; +} + +#compositeDisplayColor { + width: 100px; + height: 40px; + display: inline-block; + margin: 5px; } \ No newline at end of file diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index a0d89863..6c8b8cb4 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -13,7 +13,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], DMACell.call(this, index, superCell); - var range = appState.get("superCellRange"); + var material = this.getMaterial(); + var range = material.dimensions || appState.get("superCellRange"); this.cells = this._makeChildCells(range, this.getMaterial()); if (!superCell || superCell === undefined) this.setMode();//don't pass a call down to children again diff --git a/js/main.js b/js/main.js index dd462c28..bcabeb36 100644 --- a/js/main.js +++ b/js/main.js @@ -98,6 +98,7 @@ require.config({ camMenu: 'menus/CamMenuView', animateMenu: 'menus/AnimationMenuView', sendMenu: 'menus/SendMenuView', + compositeMenu: 'menus/CompositeMenu', //stls octaFaceTrianglePartSTL: '../assets/stls/parts/OctaFaceTrianglePart.stl', diff --git a/js/menus/CompositeMenu.js b/js/menus/CompositeMenu.js new file mode 100644 index 00000000..8ab79c59 --- /dev/null +++ b/js/menus/CompositeMenu.js @@ -0,0 +1,50 @@ +/** + * Created by aghassaei on 6/10/15. + */ + +define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _, MenuParentView, plist, lattice){ + + return MenuParentView.extend({ + + events: { + "click #newRandomColor": "_changeRandomColor" + }, + + _initialize: function(){ + this.material = { + color: this._makeRandomColor(), + dimensions: {x:0,y:0,z:0} + } + }, + + _updateDimensions: function(cells){ + this.material.dimensions.x = cells.length; + this.material.dimensions.y = cells[0].length; + this.material.dimensions.z = cells[0][0].length; + }, + + _changeRandomColor: function(e){ + e.preventDefault(); + this.material.color = this._makeRandomColor(); + this.render(); + }, + + _makeRandomColor: function(){ + return '#' + Math.floor(Math.random()*16777215).toString(16); + }, + + _makeTemplateJSON: function(){ + return _.extend(this.material); + }, + + template: _.template('\ + Name: <input value="" placeholder="Enter Name" class="halfWidth form-control" type="text"><br/><br/>\ + Bounding Box: ()<br/><br/>\ + Display Color:<br/>\ + <div style="background-color: <%= color %> ;" id="compositeDisplayColor"></div>\ + <input value="<%= color %>" placeholder="Enter HEX" class="halfWidth form-control" type="text"><br/>\ + <a id="newRandomColor" href="#" class="btn btn-block btn-lg btn-default">New Random Color</a><br/>\ + ') + + }); +}); \ No newline at end of file diff --git a/js/menus/MaterialMenuView.js b/js/menus/MaterialMenuView.js index 432875ac..bc2654d6 100644 --- a/js/menus/MaterialMenuView.js +++ b/js/menus/MaterialMenuView.js @@ -53,7 +53,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ <% } %>\ <br/><br/>\ Composite Materials:<br/><br/>\ - <a href="#" class="btn btn-block btn-lg btn-default">+ Create New Composite Material</a><br/>\ + <a id="navToCompositeMenu" href="#" class="btn btn-block btn-lg btn-default">+ Create New Composite Material</a><br/>\ ') }); diff --git a/js/models/AppState.js b/js/models/AppState.js index 41971c24..4154fb40 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -14,8 +14,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist'], function(_, B currentNav:"navDesign",// design, sim, assemble currentTab:"lattice", - //last tab that one open in each of the main menus - lastNavTab: {}, + lastNavTab: {},//last tab that one open in each of the main menus menuIsVisible: true, scriptIsVisible: false, @@ -141,6 +140,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist'], function(_, B case 8://delete key - causes back nav in chrome, super annoying e.preventDefault(); e.stopPropagation(); + break; case 16://shift // this.set("shift", state); break; -- GitLab