aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
authorEric Guzman2012-06-20 12:40:49 -0700
committerEric Guzman2012-06-20 12:40:49 -0700
commit8ac2ce1566995c91fe4721df2b121ed6437b9e1c (patch)
tree5ba6005fd725ad348dd6d9ceb104a9b64c68c102 /js/stage
parente9783135c3a6c95b7ccc3a6e45f40a030a2a067c (diff)
downloadninja-8ac2ce1566995c91fe4721df2b121ed6437b9e1c.tar.gz
Binding HUD - Show hud for "off stage" objects in tray
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/binding-view.reel/binding-hud.reel/binding-hud.js44
-rwxr-xr-xjs/stage/binding-view.reel/binding-view.js8
-rw-r--r--js/stage/objects-tray.reel/objects-tray.html1
-rw-r--r--js/stage/objects-tray.reel/objects-tray.js3
4 files changed, 49 insertions, 7 deletions
diff --git a/js/stage/binding-view.reel/binding-hud.reel/binding-hud.js b/js/stage/binding-view.reel/binding-hud.reel/binding-hud.js
index 4b40d4da..cc94e844 100755
--- a/js/stage/binding-view.reel/binding-hud.reel/binding-hud.js
+++ b/js/stage/binding-view.reel/binding-hud.reel/binding-hud.js
@@ -52,17 +52,35 @@ exports.BindingHud = Montage.create(Component, {
52 return this._userComponent; 52 return this._userComponent;
53 }, 53 },
54 set: function(val) { 54 set: function(val) {
55 if (typeof(val) !== "undefined") { 55 if(!val) { return; }
56 this._userComponent = val; 56
57 var controller = this.application.ninja.objectsController,
58 bindingView = this.parentComponent.parentComponent,
59 isOffStage, icon, iconOffsets;
60
61 this._userComponent = val;
62 this.properties = controller.getPropertiesFromObject(val, true);
63
64 controller.getObjectBindings(this.userComponent).forEach(function(obj) {
65 this.boundProperties.push(obj.sourceObjectPropertyPath);
66 }, this);
67
68 isOffStage = controller.isOffStageObject(val);
69
70 if(isOffStage) {
71 icon = bindingView.getOffStageIcon(val);
72 iconOffsets = this.getElementOffsetToParent(icon.element, bindingView.element);
73 this.title = icon.name;
74 this.x = iconOffsets.x;
75 this.y = iconOffsets.y - 80;
76 } else {
57 this.title = val.identifier; 77 this.title = val.identifier;
58 this.x = val.element.offsetLeft; 78 this.x = val.element.offsetLeft;
59 this.y = val.element.offsetTop; 79 this.y = val.element.offsetTop;
60 this.properties = this.application.ninja.objectsController.getPropertiesFromObject(val, true);
61 this.application.ninja.objectsController.getObjectBindings(this.userComponent).forEach(function(obj) {
62 this.boundProperties.push(obj.sourceObjectPropertyPath);
63 }.bind(this));
64 this.needsDraw = true;
65 } 80 }
81
82 this.needsDraw = true;
83
66 } 84 }
67 }, 85 },
68 86
@@ -111,6 +129,18 @@ exports.BindingHud = Montage.create(Component, {
111 } 129 }
112 }, 130 },
113 131
132 getElementOffsetToParent : {
133 value: function(element, parent) {
134 var nodeToPage = webkitConvertPointFromNodeToPage(element, new WebKitPoint(0, 0)),
135 parentToPage = webkitConvertPointFromNodeToPage(parent, new WebKitPoint(0, 0));
136
137 return {
138 x : nodeToPage.x - parentToPage.x,
139 y : nodeToPage.y - parentToPage.y
140 }
141 }
142 },
143
114 _x: { 144 _x: {
115 value: 20 145 value: 20
116 }, 146 },
diff --git a/js/stage/binding-view.reel/binding-view.js b/js/stage/binding-view.reel/binding-view.js
index 9bd99176..e2bbb60b 100755
--- a/js/stage/binding-view.reel/binding-view.js
+++ b/js/stage/binding-view.reel/binding-view.js
@@ -255,6 +255,14 @@ exports.BindingView = Montage.create(Component, {
255 value:null 255 value:null
256 }, 256 },
257 257
258 getOffStageIcon : {
259 value: function(object) {
260 var index = this.objectsTray.offStageObjectsController.organizedObjects.indexOf(object);
261
262 return this.objectsTray.iconsRepetition.childComponents[index];
263 }
264 },
265
258 266
259 // When mouse pointer is on a hud this value will be set to true 267 // When mouse pointer is on a hud this value will be set to true
260 _mouseOverHud: { value: false }, 268 _mouseOverHud: { value: false },
diff --git a/js/stage/objects-tray.reel/objects-tray.html b/js/stage/objects-tray.reel/objects-tray.html
index 5a0db85e..901f3e58 100644
--- a/js/stage/objects-tray.reel/objects-tray.html
+++ b/js/stage/objects-tray.reel/objects-tray.html
@@ -15,6 +15,7 @@
15 "prototype": "js/stage/objects-tray.reel", 15 "prototype": "js/stage/objects-tray.reel",
16 "properties": { 16 "properties": {
17 "element": {"#": "objects-tray"}, 17 "element": {"#": "objects-tray"},
18 "iconsRepetition": {"@": "repetition" },
18 "offStageObjectsController": {"@": "arrayController"} 19 "offStageObjectsController": {"@": "arrayController"}
19 } 20 }
20 }, 21 },
diff --git a/js/stage/objects-tray.reel/objects-tray.js b/js/stage/objects-tray.reel/objects-tray.js
index 360d6037..75ece4c3 100644
--- a/js/stage/objects-tray.reel/objects-tray.js
+++ b/js/stage/objects-tray.reel/objects-tray.js
@@ -16,6 +16,9 @@ exports.ObjectsTray = Montage.create(Component, {
16 _empty : { value: null }, 16 _empty : { value: null },
17 _workspaceMode : { value: null }, 17 _workspaceMode : { value: null },
18 18
19 iconsRepetition : {
20 value: null
21 },
19 offStageObjectsController : { 22 offStageObjectsController : {
20 value: null 23 value: null
21 }, 24 },