diff options
author | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
commit | 03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch) | |
tree | c51112223ceb9121cd595a60335eb2795215590f /js/panels/Timeline/Track.reel/Track.js | |
parent | fcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff) | |
parent | 053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff) | |
download | ninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz |
Merge branch 'pentool' into brushtool
Conflicts:
imports/codemirror/mode/scheme/scheme.js
js/tools/BrushTool.js
Diffstat (limited to 'js/panels/Timeline/Track.reel/Track.js')
-rw-r--r-- | js/panels/Timeline/Track.reel/Track.js | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/js/panels/Timeline/Track.reel/Track.js b/js/panels/Timeline/Track.reel/Track.js new file mode 100644 index 00000000..cfc2541b --- /dev/null +++ b/js/panels/Timeline/Track.reel/Track.js | |||
@@ -0,0 +1,192 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage; | ||
8 | var Component = require("montage/ui/component").Component; | ||
9 | var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; | ||
10 | |||
11 | var Track = exports.Track = Montage.create(Component, { | ||
12 | |||
13 | hasTemplate:{ | ||
14 | value: true | ||
15 | }, | ||
16 | |||
17 | _trackID:{ | ||
18 | value:null, | ||
19 | writable:true, | ||
20 | enumerable:true | ||
21 | }, | ||
22 | |||
23 | trackID:{ | ||
24 | get:function(){ | ||
25 | return this._trackID; | ||
26 | }, | ||
27 | set:function(value){ | ||
28 | this._trackID = value; | ||
29 | } | ||
30 | }, | ||
31 | |||
32 | _spans:{ | ||
33 | serializable:true, | ||
34 | value:[] | ||
35 | }, | ||
36 | |||
37 | spans:{ | ||
38 | serializable:true, | ||
39 | get:function () { | ||
40 | return this._spans; | ||
41 | }, | ||
42 | set:function (newVal) { | ||
43 | this._spans = newVal; | ||
44 | } | ||
45 | }, | ||
46 | |||
47 | _spanRepetition:{ | ||
48 | serializable:true, | ||
49 | value:null | ||
50 | }, | ||
51 | |||
52 | spanRepetition:{ | ||
53 | serializable:true, | ||
54 | get:function () { | ||
55 | return this._spanRepetition; | ||
56 | }, | ||
57 | set:function (newVal) { | ||
58 | this._spanRepetition = newVal; | ||
59 | } | ||
60 | }, | ||
61 | |||
62 | trackDuration:{ | ||
63 | value:0 | ||
64 | }, | ||
65 | |||
66 | currentKeyframe:{ | ||
67 | value:0 | ||
68 | }, | ||
69 | |||
70 | currentMillisecClicked:{ | ||
71 | value: 0 | ||
72 | }, | ||
73 | |||
74 | isAnimated:{ | ||
75 | value:false | ||
76 | }, | ||
77 | |||
78 | animatedElement:{ | ||
79 | value:null | ||
80 | }, | ||
81 | |||
82 | ninjaStylesContoller:{ | ||
83 | value: null | ||
84 | }, | ||
85 | |||
86 | //TEMP | ||
87 | keyFrames:{ | ||
88 | value:[], | ||
89 | writable:true, | ||
90 | enumerable:true | ||
91 | }, | ||
92 | |||
93 | prepareForDraw: { | ||
94 | value: function() { | ||
95 | this.keyFrames = new Array(); | ||
96 | this.spans = new Array(); | ||
97 | this.track_lane.addEventListener("click", this, false); | ||
98 | this.addNewEndPoint(0); | ||
99 | |||
100 | this.ninjaStylesContoller = this.application.ninja.stylesController; | ||
101 | } | ||
102 | }, | ||
103 | |||
104 | handleNewTween:{ | ||
105 | value: function(event){ | ||
106 | var newTween = Tween.create(); | ||
107 | } | ||
108 | }, | ||
109 | |||
110 | handleClick:{ | ||
111 | value:function (ev) { | ||
112 | var currentMillisecPerPixel = Math.floor(this.application.ninja.timeline.millisecondsOffset / 80); | ||
113 | this.currentMillisecClicked = currentMillisecPerPixel * (ev.offsetX + parseInt(ev.target.style.left)); | ||
114 | |||
115 | // TEMP - if the SHIFT key is down, add a new keyframe or split an existing span | ||
116 | // This needs to move to a keyboard shortcut that is TBD | ||
117 | if (ev.shiftKey) { | ||
118 | var prevFrame = this.keyFrames[this.keyFrames.length - 1][0]; | ||
119 | if (ev.offsetX > prevFrame) { | ||
120 | this.addNewEndPoint(ev.offsetX); | ||
121 | this.currentMillisecClicked = currentMillisecPerPixel * ev.offsetX; | ||
122 | } else { | ||
123 | this.currentMillisecClicked = currentMillisecPerPixel * (ev.offsetX + parseInt(ev.target.style.left)); | ||
124 | this.splitSpan(ev); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | console.log("currentMillisecClicked = " + this.currentMillisecClicked); | ||
129 | } | ||
130 | }, | ||
131 | |||
132 | addNewEndPoint : { | ||
133 | value: function(xpos){ | ||
134 | var newKeyFrame = document.createElement("div"); | ||
135 | newKeyFrame.className = "keyframe"; | ||
136 | newKeyFrame.style.left = (xpos - 2) + "px"; | ||
137 | this.track_lane.appendChild(newKeyFrame); | ||
138 | |||
139 | if(xpos > 0){ | ||
140 | var prevFrame = this.keyFrames[this.keyFrames.length - 1][0]; | ||
141 | |||
142 | var newDefaultSpan = document.createElement("div"); | ||
143 | newDefaultSpan.className = "defaultSpan"; | ||
144 | newDefaultSpan.style.left = prevFrame + "px"; | ||
145 | newDefaultSpan.style.width = (xpos - prevFrame) + "px"; | ||
146 | this.track_lane.appendChild(newDefaultSpan); | ||
147 | |||
148 | this.spans.push(newDefaultSpan); | ||
149 | } | ||
150 | |||
151 | var keyframePercent = this.currentMillisecClicked / this.application.ninja.timeline.totalDuration; | ||
152 | var keyframeProperties; | ||
153 | |||
154 | //console.log(keyframePercent); | ||
155 | |||
156 | this.keyFrames.push([xpos, keyframePercent, keyframeProperties]); | ||
157 | //console.log(this.keyFrames) | ||
158 | } | ||
159 | }, | ||
160 | |||
161 | splitSpan: { | ||
162 | value: function(ev){ | ||
163 | console.log("splitting span at span offsetX: " + ev.offsetX); | ||
164 | |||
165 | //this.track_lane.removeChild(ev.target); | ||
166 | } | ||
167 | }, | ||
168 | |||
169 | updateKeyframePercents:{ | ||
170 | value:function(){ | ||
171 | |||
172 | } | ||
173 | }, | ||
174 | |||
175 | addAnimationRuleToElement:{ | ||
176 | value: function(){ | ||
177 | |||
178 | } | ||
179 | }, | ||
180 | |||
181 | calculateKeyframePercent:{ | ||
182 | value:function() { | ||
183 | |||
184 | } | ||
185 | }, | ||
186 | |||
187 | buildKeyframesString:{ | ||
188 | value:function(){ | ||
189 | |||
190 | } | ||
191 | } | ||
192 | }); \ No newline at end of file | ||