diff options
author | Ananya Sen | 2012-02-27 17:39:26 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-27 17:39:26 -0800 |
commit | 2edcdd88ffc2f6ff0ea836e4da3e1fd2cb3e856f (patch) | |
tree | 18361c8889884ed9c4eb687182ac42afb0d0f13d /js | |
parent | 51ed781953bc44bba3c70938aa57b856394cbc88 (diff) | |
download | ninja-2edcdd88ffc2f6ff0ea836e4da3e1fd2cb3e856f.tar.gz |
persist undo/redo stack per html document
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/undo-controller.js | 17 | ||||
-rwxr-xr-x | js/document/html-document.js | 29 | ||||
-rwxr-xr-x | js/models/color-model.js | 6 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.js | 3 | ||||
-rwxr-xr-x | js/panels/properties/content.reel/content.js | 4 |
5 files changed, 52 insertions, 7 deletions
diff --git a/js/controllers/undo-controller.js b/js/controllers/undo-controller.js index 926803d3..01853593 100755 --- a/js/controllers/undo-controller.js +++ b/js/controllers/undo-controller.js | |||
@@ -71,22 +71,28 @@ exports.UndoController = Montage.create( Component, { | |||
71 | /** | 71 | /** |
72 | * Undo Queue | 72 | * Undo Queue |
73 | */ | 73 | */ |
74 | _undoQueue: { value: [] }, | 74 | _undoQueue: { value: [], writable:true }, |
75 | 75 | ||
76 | undoQueue: { | 76 | undoQueue: { |
77 | get: function() { | 77 | get: function() { |
78 | return this._undoQueue; | 78 | return this._undoQueue; |
79 | }, | ||
80 | set: function(value){ | ||
81 | this._undoQueue = value; | ||
79 | } | 82 | } |
80 | }, | 83 | }, |
81 | 84 | ||
82 | /** | 85 | /** |
83 | * Redo Queue | 86 | * Redo Queue |
84 | */ | 87 | */ |
85 | _redoQueue: { value: [], enumerable: false }, | 88 | _redoQueue: { value: [], enumerable: false, writable:true }, |
86 | 89 | ||
87 | redoQueue: { | 90 | redoQueue: { |
88 | get: function() { | 91 | get: function() { |
89 | return this._redoQueue; | 92 | return this._redoQueue; |
93 | }, | ||
94 | set: function(value){ | ||
95 | this._redoQueue = value; | ||
90 | } | 96 | } |
91 | }, | 97 | }, |
92 | 98 | ||
@@ -202,5 +208,12 @@ exports.UndoController = Montage.create( Component, { | |||
202 | this.redoQueue.splice(0, this.redoQueue.length); | 208 | this.redoQueue.splice(0, this.redoQueue.length); |
203 | //this.redoQueue = []; | 209 | //this.redoQueue = []; |
204 | } | 210 | } |
211 | }, | ||
212 | |||
213 | clearHistory:{ | ||
214 | value: function(){ | ||
215 | this.undoQueue.splice(0, this.undoQueue.length); | ||
216 | this.redoQueue.splice(0, this.redoQueue.length); | ||
217 | } | ||
205 | } | 218 | } |
206 | }); \ No newline at end of file | 219 | }); \ No newline at end of file |
diff --git a/js/document/html-document.js b/js/document/html-document.js index 75628731..111c491d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -59,6 +59,27 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
59 | _gridVerticalSpacing: {value:0}, | 59 | _gridVerticalSpacing: {value:0}, |
60 | //end - drawUtils state | 60 | //end - drawUtils state |
61 | 61 | ||
62 | _undoStack: { value: [] }, | ||
63 | undoStack: { | ||
64 | get: function() { | ||
65 | return this._undoStack; | ||
66 | }, | ||
67 | set:function(value){ | ||
68 | this._undoStack = value; | ||
69 | } | ||
70 | }, | ||
71 | |||
72 | _redoStack: { value: [], enumerable: false }, | ||
73 | |||
74 | redoStack: { | ||
75 | get: function() { | ||
76 | return this._redoStack; | ||
77 | }, | ||
78 | set:function(value){ | ||
79 | this._redoStack = value; | ||
80 | } | ||
81 | }, | ||
82 | |||
62 | 83 | ||
63 | // GETTERS / SETTERS | 84 | // GETTERS / SETTERS |
64 | 85 | ||
@@ -681,6 +702,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
681 | } | 702 | } |
682 | 703 | ||
683 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; | 704 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; |
705 | |||
706 | //persist a clone of history per document | ||
707 | this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); | ||
708 | this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); | ||
709 | this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start | ||
684 | } | 710 | } |
685 | }, | 711 | }, |
686 | 712 | ||
@@ -704,6 +730,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
704 | this.application.ninja.stage.handleScroll(); | 730 | this.application.ninja.stage.handleScroll(); |
705 | 731 | ||
706 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; | 732 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; |
733 | |||
734 | this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); | ||
735 | this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); | ||
707 | } | 736 | } |
708 | } | 737 | } |
709 | //////////////////////////////////////////////////////////////////// | 738 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/models/color-model.js b/js/models/color-model.js index 2c86422f..d3618c3e 100755 --- a/js/models/color-model.js +++ b/js/models/color-model.js | |||
@@ -265,7 +265,7 @@ exports.ColorModel = Montage.create(Component, { | |||
265 | //////////////////////////////////////////////////////// | 265 | //////////////////////////////////////////////////////// |
266 | case 'rgb': | 266 | case 'rgb': |
267 | //Checking for match of previous (RGB) | 267 | //Checking for match of previous (RGB) |
268 | if (color.r !== this.rgb.r && color.g !== this.rgb.g && color.b !== this.rgb.b) { | 268 | if (color && color.r !== this.rgb.r && color.g !== this.rgb.g && color.b !== this.rgb.b) { |
269 | //Setting value and breaking out of function | 269 | //Setting value and breaking out of function |
270 | this.rgb = color; | 270 | this.rgb = color; |
271 | return; | 271 | return; |
@@ -279,7 +279,7 @@ exports.ColorModel = Montage.create(Component, { | |||
279 | //////////////////////////////////////////////////////// | 279 | //////////////////////////////////////////////////////// |
280 | case 'hsv': | 280 | case 'hsv': |
281 | //Checking for match of previous (HSV) | 281 | //Checking for match of previous (HSV) |
282 | if (color.h !== this.hsv.h && color.s !== this.hsv.s && color.v !== this.hsv.v) { | 282 | if (color && color.h !== this.hsv.h && color.s !== this.hsv.s && color.v !== this.hsv.v) { |
283 | //Setting value and breaking out of function | 283 | //Setting value and breaking out of function |
284 | this.hsv = color; | 284 | this.hsv = color; |
285 | return; | 285 | return; |
@@ -293,7 +293,7 @@ exports.ColorModel = Montage.create(Component, { | |||
293 | //////////////////////////////////////////////////////// | 293 | //////////////////////////////////////////////////////// |
294 | case 'hsl': | 294 | case 'hsl': |
295 | //Checking for match of previous (HSV) | 295 | //Checking for match of previous (HSV) |
296 | if (color.h !== this.hsl.h && color.s !== this.hsl.s && color.l !== this.hsl.l) { | 296 | if (color && color.h !== this.hsl.h && color.s !== this.hsl.s && color.l !== this.hsl.l) { |
297 | //Setting value and breaking out of function | 297 | //Setting value and breaking out of function |
298 | this.hsl = color; | 298 | this.hsl = color; |
299 | return; | 299 | return; |
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 6efeef8a..ab9503ec 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js | |||
@@ -98,6 +98,9 @@ exports.Ninja = Montage.create(Component, { | |||
98 | if(this._appLoaded && this._preload) { | 98 | if(this._appLoaded && this._preload) { |
99 | // App is now deserialized and files are preloaded | 99 | // App is now deserialized and files are preloaded |
100 | this.appModel.materials = MaterialsLibrary.materials; | 100 | this.appModel.materials = MaterialsLibrary.materials; |
101 | |||
102 | this.currentDocument = null; | ||
103 | |||
101 | } | 104 | } |
102 | } | 105 | } |
103 | }, | 106 | }, |
diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index 8fa33a75..fa4c56f2 100755 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js | |||
@@ -268,12 +268,12 @@ exports.Content = Montage.create(Component, { | |||
268 | } | 268 | } |
269 | else | 269 | else |
270 | { | 270 | { |
271 | if (currentValue.color.a !== undefined) | 271 | if (currentValue.color && (currentValue.color.a !== undefined)) |
272 | { | 272 | { |
273 | this.application.ninja.colorController.colorModel.alpha = | 273 | this.application.ninja.colorController.colorModel.alpha = |
274 | {value: currentValue.color.a, wasSetByCode: true, type: 'change'}; | 274 | {value: currentValue.color.a, wasSetByCode: true, type: 'change'}; |
275 | } | 275 | } |
276 | if(currentValue.color.mode) | 276 | if(currentValue.color && currentValue.color.mode) |
277 | { | 277 | { |
278 | this.application.ninja.colorController.colorModel[currentValue.color.mode] = currentValue.color; | 278 | this.application.ninja.colorController.colorModel[currentValue.color.mode] = currentValue.color; |
279 | } | 279 | } |