diff options
Diffstat (limited to 'js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js')
-rw-r--r-- | js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js b/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js index 175b77f9..690c912b 100644 --- a/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js +++ b/js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js | |||
@@ -15,7 +15,231 @@ var PropertyTrack = exports.PropertyTrack = Montage.create(Component, { | |||
15 | 15 | ||
16 | prepareForDraw:{ | 16 | prepareForDraw:{ |
17 | value:function(){ | 17 | value:function(){ |
18 | this.element.addEventListener("click", this, false); | ||
19 | this.trackID = this.parentComponent.parentComponent.parentComponent.trackID; | ||
20 | this.animatedElement = this.parentComponent.parentComponent.parentComponent.animatedElement; | ||
18 | 21 | ||
19 | } | 22 | } |
23 | }, | ||
24 | |||
25 | draw:{ | ||
26 | value:function(){ | ||
27 | |||
28 | } | ||
29 | }, | ||
30 | |||
31 | trackEditorProperty:{ | ||
32 | value:"" | ||
33 | }, | ||
34 | |||
35 | _propTweenRepetition:{ | ||
36 | value:null | ||
37 | }, | ||
38 | |||
39 | animatedElement:{ | ||
40 | value:null | ||
41 | }, | ||
42 | |||
43 | isSubproperty:{ | ||
44 | value:true | ||
45 | }, | ||
46 | |||
47 | propTweenRepetition:{ | ||
48 | serializable:true, | ||
49 | get:function () { | ||
50 | return this._propTweenRepetition; | ||
51 | }, | ||
52 | set:function (newVal) { | ||
53 | this._propTweenRepetition = newVal; | ||
54 | } | ||
55 | }, | ||
56 | |||
57 | _propTweens:{ | ||
58 | value:[] | ||
59 | }, | ||
60 | |||
61 | propTweens:{ | ||
62 | serializable:true, | ||
63 | get:function () { | ||
64 | return this._propTweens; | ||
65 | }, | ||
66 | set:function (newVal) { | ||
67 | this._propTweens = newVal; | ||
68 | } | ||
69 | }, | ||
70 | |||
71 | _propTrackData:{ | ||
72 | value:false | ||
73 | }, | ||
74 | |||
75 | propTrackData:{ | ||
76 | serializable:true, | ||
77 | get:function () { | ||
78 | return this._propTrackData; | ||
79 | }, | ||
80 | set:function (val) { | ||
81 | this._propTrackData = val; | ||
82 | if (this._propTrackData) { | ||
83 | this.setData(); | ||
84 | } | ||
85 | } | ||
86 | }, | ||
87 | |||
88 | nextKeyframe:{ | ||
89 | value:1 | ||
90 | }, | ||
91 | |||
92 | _trackID:{ | ||
93 | value:null | ||
94 | }, | ||
95 | |||
96 | trackID:{ | ||
97 | serializable:true, | ||
98 | get:function () { | ||
99 | return this._trackID; | ||
100 | }, | ||
101 | set:function (value) { | ||
102 | if (value !== this._trackID) { | ||
103 | this._trackID = value; | ||
104 | } | ||
105 | } | ||
106 | }, | ||
107 | |||
108 | _trackType:{ | ||
109 | value:null | ||
110 | }, | ||
111 | |||
112 | trackType:{ | ||
113 | serializable:true, | ||
114 | get:function () { | ||
115 | return this._trackType; | ||
116 | }, | ||
117 | set:function (value) { | ||
118 | if (value !== this._trackType) { | ||
119 | this._trackType = value; | ||
120 | } | ||
121 | } | ||
122 | }, | ||
123 | |||
124 | _styleIndex:{ | ||
125 | value:null | ||
126 | }, | ||
127 | |||
128 | styleIndex:{ | ||
129 | serializable:true, | ||
130 | get:function () { | ||
131 | return this._styleIndex; | ||
132 | }, | ||
133 | set:function (value) { | ||
134 | if (value !== this._styleIndex) { | ||
135 | this._styleIndex = value; | ||
136 | } | ||
137 | } | ||
138 | }, | ||
139 | |||
140 | setData:{ | ||
141 | value:function () { | ||
142 | if (typeof(this.propTrackData) === "undefined") { | ||
143 | return; | ||
144 | } | ||
145 | |||
146 | this.styleIndex = this.propTrackData.styleIndex; | ||
147 | this.propTweens = this.propTrackData.propTweens; | ||
148 | this.trackType = this.propTrackData.trackType; | ||
149 | this.trackEditorProperty = this.propTrackData.trackEditorProperty; | ||
150 | this.needsDraw = true; | ||
151 | } | ||
152 | }, | ||
153 | |||
154 | handleClick:{ | ||
155 | value:function(ev){ | ||
156 | if (ev.shiftKey) { | ||
157 | |||
158 | if (this.propTweens.length < 1) { | ||
159 | |||
160 | // check if there is an editor property assigned yet | ||
161 | // get this property track's editor prop name from layer data arrays | ||
162 | var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); | ||
163 | |||
164 | if (this.trackType === "style") { | ||
165 | if (this.application.ninja.timeline.arrLayers[selectIndex].layerData.arrLayerStyles[this.styleIndex].editorProperty == null) { | ||
166 | console.log("Please enter a style property for this track before adding keyframes."); | ||
167 | return; | ||
168 | } else { | ||
169 | this.trackEditorProperty = this.application.ninja.timeline.arrLayers[selectIndex].layerData.arrLayerStyles[this.styleIndex].editorProperty; | ||
170 | console.log("Property track editorProperty set to: " + this.trackEditorProperty); | ||
171 | } | ||
172 | } else if (this.trackType === "position") { | ||
173 | //console.log("clicking on position track"); | ||
174 | //console.log(this.trackEditorProperty); | ||
175 | } | ||
176 | |||
177 | this.insertPropTween(0); | ||
178 | this.addPropAnimationRuleToElement(ev); | ||
179 | this.updatePropKeyframeRule(); | ||
180 | } else { | ||
181 | this.handleNewPropTween(ev); | ||
182 | this.updatePropKeyframeRule(); | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | }, | ||
187 | |||
188 | handleNewPropTween:{ | ||
189 | value:function(ev){ | ||
190 | this.insertPropTween(ev.offsetX); | ||
191 | } | ||
192 | }, | ||
193 | |||
194 | insertPropTween:{ | ||
195 | value:function(clickPos){ | ||
196 | var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); | ||
197 | this.application.ninja.timeline.selectLayer(selectedIndex, true); | ||
198 | |||
199 | var currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); | ||
200 | var currentMillisec = currentMillisecPerPixel * clickPos; | ||
201 | |||
202 | var newTween = {}; | ||
203 | newTween.tweenData = {}; | ||
204 | |||
205 | if (clickPos == 0) { | ||
206 | newTween.tweenData.spanWidth = 0; | ||
207 | newTween.tweenData.keyFramePosition = 0; | ||
208 | newTween.tweenData.keyFrameMillisec = 0; | ||
209 | newTween.tweenData.tweenID = 0; | ||
210 | newTween.tweenData.spanPosition = 0; | ||
211 | newTween.tweenData.tweenedProperties = []; | ||
212 | |||
213 | this.propTweens.push(newTween); | ||
214 | |||
215 | } else { | ||
216 | newTween.tweenData.spanWidth = clickPos - this.propTweens[this.propTweens.length - 1].tweenData.keyFramePosition; | ||
217 | newTween.tweenData.keyFramePosition = clickPos; | ||
218 | newTween.tweenData.keyFrameMillisec = currentMillisec; | ||
219 | newTween.tweenData.tweenID = this.nextKeyframe; | ||
220 | newTween.tweenData.spanPosition = clickPos - newTween.tweenData.spanWidth; | ||
221 | newTween.tweenData.tweenedProperties = []; | ||
222 | |||
223 | this.propTweens.push(newTween); | ||
224 | |||
225 | this.nextKeyframe += 1; | ||
226 | } | ||
227 | |||
228 | this.application.ninja.documentController.activeDocument.needsSave = true; | ||
229 | } | ||
230 | }, | ||
231 |