From 85dfdc9d46847d5fdd1b6fc6aaf35e93b09e9935 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Fri, 15 Jun 2012 00:28:24 -0700 Subject: F6 support for keyframes Signed-off-by: Jonathan Duran --- js/mediators/keyboard-mediator.js | 7 ++++ .../Timeline/TimelinePanel.reel/TimelinePanel.js | 10 ++++++ .../Timeline/TimelineTrack.reel/TimelineTrack.js | 41 +++++++++++++--------- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 4fd4bd4c..d1f8e221 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -50,6 +50,7 @@ var Keyboard = exports.Keyboard = { X:88, Y:89, Z:90, + F6:117, PLUS:187, MINUS:189 }; @@ -210,6 +211,12 @@ exports.KeyboardMediator = Montage.create(Component, { return; } + // F6 keyboard shortcut to add a keyframe to the timeline + if (evt.keyCode == Keyboard.F6) { + this.application.ninja.timeline.handleKeyframeShortcut(); + return; + } + // Check if cmd+a/ctrl+a for Select All if((evt.keyCode == Keyboard.A) && (evt.ctrlKey || evt.metaKey)) { NJevent("selectAll"); diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index b022bd8a..7f8d421d 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -905,6 +905,16 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } }, + handleKeyframeShortcut:{ + value:function(){ + //console.log(this.currentLayersSelected); + //console.log(this.trackRepetition); + var tempEv = {}; + tempEv.offsetX = this.playheadmarker.offsetLeft; + this.trackRepetition.childComponents[this.currentLayersSelected[0]].handleKeyboardShortcut(tempEv); + } + }, + updateTrackContainerWidth:{ value:function () { this.container_tracks.style.width = (this.end_hottext.value * 80) + "px"; diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index 6d557845..11c27ce3 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -649,25 +649,32 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { // This needs to move to a keyboard shortcut that is TBD var selectedIndex = this.application.ninja.timeline.getLayerIndexByID(this.trackID); if (ev.shiftKey) { - //if (this.application.ninja.timeline.arrLayers[selectedIndex].layerData.elementsList.length == 1) { - if (this.tweens.length < 1) { - this.insertTween(0); - this.addAnimationRuleToElement(ev); + if (this.tweens.length < 1) { + this.insertTween(0); + this.addAnimationRuleToElement(ev); + this.updateKeyframeRule(); + } else { + if (ev.target.className === "tracklane") { + this.handleNewTween(ev); + this.updateKeyframeRule(); + } else if (ev.target.className === "tween_span" && ev.target.parentElement.parentElement.className === "tracklane") { + this.handleNewTween(ev); this.updateKeyframeRule(); - } else { - //console.log(ev); - if (ev.target.className === "tracklane") { - this.handleNewTween(ev); - this.updateKeyframeRule(); - } else if (ev.target.className === "tween_span" && ev.target.parentElement.parentElement.className === "tracklane"){ - this.handleNewTween(ev); - this.updateKeyframeRule(); - } } - //} else { - // TEMP error check - //console.log("There must be exactly one element in an animated layer."); - //} + } + } + } + }, + + handleKeyboardShortcut:{ + value:function(ev){ + if (this.tweens.length < 1) { + this.insertTween(0); + this.addAnimationRuleToElement(ev); + this.updateKeyframeRule(); + } else { + this.handleNewTween(ev); + this.updateKeyframeRule(); } } }, -- cgit v1.2.3