Kaydet (Commit) 6f3ab481 authored tarafından Marco Cecchetti's avatar Marco Cecchetti

Now the skip effect feature is supported by the JavaScript presentation engine.

üst d7e5f9b3
...@@ -1433,7 +1433,7 @@ var NAVDBG = new DebugPrinter(); ...@@ -1433,7 +1433,7 @@ var NAVDBG = new DebugPrinter();
NAVDBG.off(); NAVDBG.off();
var ANIMDBG = new DebugPrinter(); var ANIMDBG = new DebugPrinter();
ANIMDBG.off(); ANIMDBG.on();
var aRegisterEventDebugPrinter = new DebugPrinter(); var aRegisterEventDebugPrinter = new DebugPrinter();
aRegisterEventDebugPrinter.off(); aRegisterEventDebugPrinter.off();
...@@ -2987,8 +2987,19 @@ function dispatchEffects(dir) ...@@ -2987,8 +2987,19 @@ function dispatchEffects(dir)
function skipEffects(dir) function skipEffects(dir)
{ {
// TODO to be implemented if( dir == 1 )
switchSlide(dir, true); {
var bRet = aSlideShow.skipEffect();
if( !bRet )
{
switchSlide( 1, false );
}
}
else
{
switchSlide( dir, false );
}
} }
function switchSlide( nOffset, bSkipTransition ) function switchSlide( nOffset, bSkipTransition )
...@@ -6149,6 +6160,7 @@ BaseContainerNode.prototype.init_children = function() ...@@ -6149,6 +6160,7 @@ BaseContainerNode.prototype.init_children = function()
BaseContainerNode.prototype.deactivate_st = function( eDestState ) BaseContainerNode.prototype.deactivate_st = function( eDestState )
{ {
this.nLeftIterations = 0;
if( eDestState == FROZEN_NODE ) if( eDestState == FROZEN_NODE )
{ {
// deactivate all children that are not FROZEN or ENDED: // deactivate all children that are not FROZEN or ENDED:
...@@ -6245,7 +6257,8 @@ BaseContainerNode.prototype.notifyDeactivatedChild = function( aChildNode ) ...@@ -6245,7 +6257,8 @@ BaseContainerNode.prototype.notifyDeactivatedChild = function( aChildNode )
BaseContainerNode.prototype.repeat = function() BaseContainerNode.prototype.repeat = function()
{ {
this.deactivate_st( ENDED_NODE ); // end all children that are not ENDED:
this.forEachChildNode( mem_fn( 'end' ), ~ENDED_NODE );
this.removeEffect(); this.removeEffect();
var bInitialized = this.init_children(); var bInitialized = this.init_children();
if( bInitialized ) if( bInitialized )
...@@ -6370,6 +6383,7 @@ function SequentialTimeContainer( aAnimElem, aParentNode, aNodeContext ) ...@@ -6370,6 +6383,7 @@ function SequentialTimeContainer( aAnimElem, aParentNode, aNodeContext )
SequentialTimeContainer.superclass.constructor.call( this, aAnimElem, aParentNode, aNodeContext ); SequentialTimeContainer.superclass.constructor.call( this, aAnimElem, aParentNode, aNodeContext );
this.sClassName = 'SequentialTimeContainer'; this.sClassName = 'SequentialTimeContainer';
this.aCurrentSkipEvent = null;
} }
extend( SequentialTimeContainer, BaseContainerNode ); extend( SequentialTimeContainer, BaseContainerNode );
...@@ -6422,7 +6436,16 @@ SequentialTimeContainer.prototype.notifyDeactivating = function( aNotifier ) ...@@ -6422,7 +6436,16 @@ SequentialTimeContainer.prototype.notifyDeactivating = function( aNotifier )
SequentialTimeContainer.prototype.skipEffect = function( aChildNode ) SequentialTimeContainer.prototype.skipEffect = function( aChildNode )
{ {
// not implemented if( this.isChildNode( aChildNode ) )
{
this.getContext().aTimerEventQueue.forceEmpty();
var aEvent = makeEvent( bind2( aChildNode.deactivate, aChildNode ) );
this.getContext().aTimerEventQueue.addEvent( aEvent );
}
else
{
log( 'SequentialTimeContainer.skipEffect: unknown child: ' + aChildNode.getId() );
}
}; };
SequentialTimeContainer.prototype.rewindEffect = function( aChildNode ) SequentialTimeContainer.prototype.rewindEffect = function( aChildNode )
...@@ -6437,15 +6460,24 @@ SequentialTimeContainer.prototype.resolveChild = function( aChildNode ) ...@@ -6437,15 +6460,24 @@ SequentialTimeContainer.prototype.resolveChild = function( aChildNode )
if( bResolved && this.isMainSequenceRootNode() ) if( bResolved && this.isMainSequenceRootNode() )
{ {
aChildNode.saveStateOfAnimatedElement(); aChildNode.saveStateOfAnimatedElement();
}
if( bResolved && this.isMainSequenceRootNode() ) if( this.aCurrentSkipEvent )
{ this.aCurrentSkipEvent.dispose();
// skip/rewind events handling
this.aCurrentSkipEvent = makeEvent( bind2( this.skipEffect, this, aChildNode ) );
this.aContext.aEventMultiplexer.registerSkipEffectEvent( this.aCurrentSkipEvent );
} }
return bResolved; return bResolved;
}; };
SequentialTimeContainer.prototype.dispose = function()
{
if( this.aCurrentSkipEvent )
this.aCurrentSkipEvent.dispose();
SequentialTimeContainer.superclass.dispose.call( this );
};
// ------------------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------------------ //
...@@ -8311,37 +8343,41 @@ function AnimatedElement( aElement ) ...@@ -8311,37 +8343,41 @@ function AnimatedElement( aElement )
log( 'AnimatedElement constructor: element is not valid' ); log( 'AnimatedElement constructor: element is not valid' );
} }
this.aBaseElement = aElement.cloneNode( true );
this.aActiveElement = aElement; this.aActiveElement = aElement;
this.initElement();
this.sElementId = this.aActiveElement.getAttribute( 'id' ); this.sElementId = this.aActiveElement.getAttribute( 'id' );
this.aBaseBBox = this.aActiveElement.getBBox(); this.aBaseBBox = this.aActiveElement.getBBox();
this.nBaseCenterX = this.aBaseBBox.x + this.aBaseBBox.width / 2; this.nBaseCenterX = this.aBaseBBox.x + this.aBaseBBox.width / 2;
this.nBaseCenterY = this.aBaseBBox.y + this.aBaseBBox.height / 2; this.nBaseCenterY = this.aBaseBBox.y + this.aBaseBBox.height / 2;
this.nCenterX = this.nBaseCenterX;
this.nCenterY = this.nBaseCenterY;
this.nScaleFactorX = 1.0;
this.nScaleFactorY = 1.0;
this.aClipPathElement = null; this.aClipPathElement = null;
this.aClipPathContent = null; this.aClipPathContent = null;
this.aPreviousElement = null; this.aPreviousElement = null;
this.aStateArray = new Array(); this.aStateArray = new Array();
this.nCurrentState = -1;
this.eAdditiveMode = ADDITIVE_MODE_REPLACE; this.eAdditiveMode = ADDITIVE_MODE_REPLACE;
this.bIsUpdated = true; this.bIsUpdated = true;
this.aTMatrix = document.documentElement.createSVGMatrix(); this.aTMatrix = document.documentElement.createSVGMatrix();
this.aCTM = document.documentElement.createSVGMatrix(); this.aCTM = document.documentElement.createSVGMatrix();
this.aICTM = document.documentElement.createSVGMatrix(); this.aICTM = document.documentElement.createSVGMatrix();
this.setCTM();
this.initElement();
//this.aElementArray[0] = this.aActiveElement.cloneNode( true ); //this.aElementArray[0] = this.aActiveElement.cloneNode( true );
} }
AnimatedElement.prototype.initElement = function() AnimatedElement.prototype.initElement = function()
{ {
this.nCenterX = this.nBaseCenterX;
this.nCenterY = this.nBaseCenterY;
this.nScaleFactorX = 1.0;
this.nScaleFactorY = 1.0;
this.setCTM();
this.nCurrentState = -1;
// add a transform attribute of type matrix // add a transform attribute of type matrix
this.aActiveElement.setAttribute( 'transform', makeMatrixString( 1, 0, 0, 1, 0, 0 ) ); this.aActiveElement.setAttribute( 'transform', makeMatrixString( 1, 0, 0, 1, 0, 0 ) );
}; };
...@@ -8440,14 +8476,16 @@ AnimatedElement.prototype.setToElement = function( aElement ) ...@@ -8440,14 +8476,16 @@ AnimatedElement.prototype.setToElement = function( aElement )
AnimatedElement.prototype.notifySlideStart = function() AnimatedElement.prototype.notifySlideStart = function()
{ {
this.nCurrentState = -1; var aClone = this.aBaseElement.cloneNode( true );
//this.setToFirst(); this.aActiveElement.parentNode.replaceChild( aClone, this.aActiveElement );
this.aActiveElement = aClone;
this.initElement();
this.DBG( '.notifySlideStart invoked' ); this.DBG( '.notifySlideStart invoked' );
}; };
AnimatedElement.prototype.notifyAnimationStart = function() AnimatedElement.prototype.notifyAnimationStart = function()
{ {
this.DBG( '.notifyAnimationStart invoked' ); this.DBG( '.notifyAnimationStart invoked' );
this.bIsUpdated = false; this.bIsUpdated = false;
}; };
...@@ -9561,7 +9599,7 @@ function EventMultiplexer( aTimerEventQueue ) ...@@ -9561,7 +9599,7 @@ function EventMultiplexer( aTimerEventQueue )
{ {
this.aTimerEventQueue = aTimerEventQueue; this.aTimerEventQueue = aTimerEventQueue;
this.aEventMap = new Object(); this.aEventMap = new Object();
this.aSkipEffectEvent = null;
} }
...@@ -9597,6 +9635,20 @@ EventMultiplexer.prototype.notifyEvent = function( eEventType, aNotifierId ) ...@@ -9597,6 +9635,20 @@ EventMultiplexer.prototype.notifyEvent = function( eEventType, aNotifierId )
} }
}; };
EventMultiplexer.prototype.registerSkipEffectEvent = function( aEvent )
{
this.aSkipEffectEvent = aEvent;
};
EventMultiplexer.prototype.notifySkipEffectEvent = function()
{
if( this.aSkipEffectEvent )
{
this.aTimerEventQueue.addEvent( this.aSkipEffectEvent );
this.aSkipEffectEvent = null;
}
};
EventMultiplexer.DEBUG = aEventMultiplexerDebugPrinter.isEnabled(); EventMultiplexer.DEBUG = aEventMultiplexerDebugPrinter.isEnabled();
EventMultiplexer.prototype.DBG = function( sMethodName, eEventType, aNotifierId, nTime ) EventMultiplexer.prototype.DBG = function( sMethodName, eEventType, aNotifierId, nTime )
...@@ -11162,7 +11214,10 @@ SlideShow.prototype.nextEffect = function() ...@@ -11162,7 +11214,10 @@ SlideShow.prototype.nextEffect = function()
return false; return false;
if( this.isRunning() ) if( this.isRunning() )
{
this.skipCurrentEffect();
return true; return true;
}
if( !this.aNextEffectEventArray ) if( !this.aNextEffectEventArray )
return false; return false;
...@@ -11179,6 +11234,29 @@ SlideShow.prototype.nextEffect = function() ...@@ -11179,6 +11234,29 @@ SlideShow.prototype.nextEffect = function()
return true; return true;
}; };
SlideShow.prototype.skipCurrentEffect = function()
{
this.aEventMultiplexer.notifySkipEffectEvent();
this.update();
};
SlideShow.prototype.skipEffect = function()
{
if( !this.aNextEffectEventArray )
return false;
this.notifyNextEffectStart();
if( this.nCurrentEffect >= this.aNextEffectEventArray.size() )
return false;
this.eDirection = FORWARD;
this.aNextEffectEventArray.at( this.nCurrentEffect ).fire();
this.aEventMultiplexer.notifySkipEffectEvent();
++this.nCurrentEffect;
this.update();
return true;
};
SlideShow.prototype.previousEffect = function() SlideShow.prototype.previousEffect = function()
{ {
if( this.nCurrentEffect <= 0 ) if( this.nCurrentEffect <= 0 )
...@@ -11461,11 +11539,22 @@ TimerEventQueue.prototype.addEvent = function( aEvent ) ...@@ -11461,11 +11539,22 @@ TimerEventQueue.prototype.addEvent = function( aEvent )
return true; return true;
}; };
TimerEventQueue.prototype.forceEmpty = function()
{
this.process_(true);
};
TimerEventQueue.prototype.process = function() TimerEventQueue.prototype.process = function()
{
this.process_(false);
};
TimerEventQueue.prototype.process_ = function( bFireAllEvents )
{ {
var nCurrentTime = this.aTimer.getElapsedTime(); var nCurrentTime = this.aTimer.getElapsedTime();
while( !this.isEmpty() && ( this.aEventSet.top().nActivationTime <= nCurrentTime ) ) while( !this.isEmpty() && ( bFireAllEvents || ( this.aEventSet.top().nActivationTime <= nCurrentTime ) ) )
{ {
var aEventEntry = this.aEventSet.top(); var aEventEntry = this.aEventSet.top();
this.aEventSet.pop(); this.aEventSet.pop();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment