aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/Layer.reel/Layer.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/Layer.reel/Layer.js')
-rw-r--r--js/panels/Timeline/Layer.reel/Layer.js56
1 files changed, 38 insertions, 18 deletions
diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js
index 9576d66f..4da1bfba 100644
--- a/js/panels/Timeline/Layer.reel/Layer.js
+++ b/js/panels/Timeline/Layer.reel/Layer.js
@@ -83,13 +83,14 @@ var Layer = exports.Layer = Montage.create(Component, {
83 return; 83 return;
84 } 84 }
85 if (newVal !== this._selectedStyleIndex) { 85 if (newVal !== this._selectedStyleIndex) {
86 console.log("Layer.selectedStyleIndex.set ", newVal);
87 this._selectedStyleIndex = newVal; 86 this._selectedStyleIndex = newVal;
88 this.layerData.selectedStyleIndex = newVal; 87 this.layerData.selectedStyleIndex = newVal;
89 this.needsDraw = true;
90 } 88 }
91 } 89 }
92 }, 90 },
91 _storedStyleIndex : {
92 value: false
93 },
93 94
94 /* Layer models: the name, ID, and selected and animation booleans for the layer */ 95 /* Layer models: the name, ID, and selected and animation booleans for the layer */
95 _layerName:{ 96 _layerName:{
@@ -277,6 +278,10 @@ var Layer = exports.Layer = Montage.create(Component, {
277 if (value === false) { 278 if (value === false) {
278 // If changing from true to false, we need to deselect any associated styles 279 // If changing from true to false, we need to deselect any associated styles
279 this.selectStyle(false); 280 this.selectStyle(false);
281 } else {
282 if (this._storedStyleIndex !== false) {
283 this.selectStyle(this._storedStyleIndex);
284 }
280 } 285 }
281 this._isSelected = value; 286 this._isSelected = value;
282 this.layerData.isSelected = value; 287 this.layerData.isSelected = value;
@@ -541,7 +546,7 @@ var Layer = exports.Layer = Montage.create(Component, {
541 } 546 }
542 // Enable or disable the delete style button as appropriate 547 // Enable or disable the delete style button as appropriate
543 if (this.isSelected) { 548 if (this.isSelected) {
544 if (this.selectedStyleIndex !== "false") { 549 if (this.selectedStyleIndex !== false) {
545 this.selectStyle(this.selectedStyleIndex); 550 this.selectStyle(this.selectedStyleIndex);
546 this.buttonDeleteStyle.classList.remove("disabled"); 551 this.buttonDeleteStyle.classList.remove("disabled");
547 } 552 }
@@ -630,6 +635,7 @@ var Layer = exports.Layer = Montage.create(Component, {
630 newStyle.ruleTweener = false; 635 newStyle.ruleTweener = false;
631 newStyle.isSelected = false; 636 newStyle.isSelected = false;
632 this.arrLayerStyles.push(newStyle); 637 this.arrLayerStyles.push(newStyle);
638 this.selectStyle(this.arrLayerStyles.length -1);
633 639
634 // Set up the event info and dispatch the event 640 // Set up the event info and dispatch the event
635 this.styleCounter += 1; 641 this.styleCounter += 1;
@@ -666,26 +672,37 @@ var Layer = exports.Layer = Montage.create(Component, {
666 }, 672 },
667 selectStyle : { 673 selectStyle : {
668 value: function(styleIndex) { 674 value: function(styleIndex) {
669 console.log("Layer.selectStyle ", styleIndex);
670
671 // Select a style based on its index. 675 // Select a style based on its index.
672 // use layerIndex = false to deselect all styles. 676 // use layerIndex = false to deselect all styles.
673 var i = 0, 677 var i = 0,
674 arrLayerStylesLength = this.arrLayerStyles.length; 678 arrLayerStylesLength = this.arrLayerStyles.length;
675 679
676 680 if (styleIndex === false) {
677 // First, update this.arrStyles[].isSelected 681 if (arrLayerStylesLength === 0) {
678 for (i = 0; i < arrLayerStylesLength; i++) { 682 // No styles selected, so do nothing.
679 if (i === styleIndex) { 683 return;
680 this.arrLayerStyles[i].isSelected = true; 684 }
681 } else { 685 for (i = 0; i < arrLayerStylesLength; i++) {
682 if (this.arrLayerStyles[i].isSelected === true) { 686 if (this.arrLayerStyles[i].isSelected === true) {
683 this.arrLayerStyles[i].isSelected = false; 687 this.arrLayerStyles[i].isSelected = false;
684 } 688 }
685 } 689 }
686 } 690 } else {
687 691 for (i = 0; i < arrLayerStylesLength; i++) {
688 692 if (i === styleIndex) {
693 this.arrLayerStyles[i].isSelected = true;
694 } else {
695 if (this.arrLayerStyles[i].isSelected === true) {
696 this.arrLayerStyles[i].isSelected = false;
697 }
698 }
699 }
700 this.selectedStyleIndex = styleIndex;
701 this._storedStyleIndex = styleIndex;
702 }
703
704
705
689 /* 706 /*
690 // Next, update this.styleRepetition.selectedIndexes. 707 // Next, update this.styleRepetition.selectedIndexes.
691 if (styleIndex !== false) { 708 if (styleIndex !== false) {
@@ -744,6 +761,9 @@ var Layer = exports.Layer = Montage.create(Component, {
744 }, 761 },
745 handleDeleteStyleClick: { 762 handleDeleteStyleClick: {
746 value: function(event) { 763 value: function(event) {
764 if (event.target.classList.contains("disabled")) {
765 return;
766 }
747 this.deleteStyle(); 767 this.deleteStyle();
748 } 768 }
749 }, 769 },