fix "uncover" slide transitions with presenter console
It turns out it is really not a good idea to render _anything_ on the first run of performIn/performOut in classes derived from SlideChangeBase. That is because the functions are called separetely for every view, so, if there is more than one view, like when the presenter console is active, it will be done only for the first of them. This commit introduces another function, prepareForRun, that can be used reliably for that purpose. Change-Id: I2c690fb145ccc05a680d4c2991c73900336e6f42
This commit is contained in:
@@ -199,6 +199,10 @@ void SlideChangeBase::start( const AnimatableShapeSharedPtr& rShape,
|
|||||||
|
|
||||||
prefetch(rShape,rLayer); // no-op, if already done
|
prefetch(rShape,rLayer); // no-op, if already done
|
||||||
|
|
||||||
|
// get the subclasses a chance to do any specific initialization before run
|
||||||
|
for ( ViewsVecT::const_iterator aCurr( beginViews() ), aEnd( endViews() ); aCurr != aEnd; ++aCurr )
|
||||||
|
prepareForRun( *aCurr, aCurr->mpView->getCanvas() );
|
||||||
|
|
||||||
// start accompanying sound effect, if any
|
// start accompanying sound effect, if any
|
||||||
if( mpSoundPlayer )
|
if( mpSoundPlayer )
|
||||||
{
|
{
|
||||||
@@ -356,6 +360,12 @@ bool SlideChangeBase::operator()( double nValue )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SlideChangeBase::prepareForRun(
|
||||||
|
const ViewEntry& /* rViewEntry */,
|
||||||
|
const boost::shared_ptr<cppcanvas::Canvas>& /* rDestinationCanvas */ )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void SlideChangeBase::performIn(
|
void SlideChangeBase::performIn(
|
||||||
const cppcanvas::CustomSpriteSharedPtr& /*rSprite*/,
|
const cppcanvas::CustomSpriteSharedPtr& /*rSprite*/,
|
||||||
const ViewEntry& /*rViewEntry*/,
|
const ViewEntry& /*rViewEntry*/,
|
||||||
|
@@ -126,6 +126,18 @@ protected:
|
|||||||
void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap,
|
void renderBitmap( SlideBitmapSharedPtr const& pSlideBitmap,
|
||||||
boost::shared_ptr<cppcanvas::Canvas> const& pCanvas );
|
boost::shared_ptr<cppcanvas::Canvas> const& pCanvas );
|
||||||
|
|
||||||
|
/** Called on derived classes to perform actions before first run.
|
||||||
|
|
||||||
|
This typically involves rendering of the initial slide content.
|
||||||
|
|
||||||
|
@param rViewEntry the view entry
|
||||||
|
|
||||||
|
@param rDestinationCanvas the canvas to render on
|
||||||
|
*/
|
||||||
|
virtual void prepareForRun(
|
||||||
|
const ViewEntry& rViewEntry,
|
||||||
|
const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
|
||||||
|
|
||||||
/** Called on derived classes to implement actual slide change.
|
/** Called on derived classes to implement actual slide change.
|
||||||
|
|
||||||
This method is called with the sprite of the slide coming 'in'
|
This method is called with the sprite of the slide coming 'in'
|
||||||
|
@@ -393,10 +393,13 @@ public:
|
|||||||
rViewContainer,
|
rViewContainer,
|
||||||
rScreenUpdater,
|
rScreenUpdater,
|
||||||
rEventMultiplexer ),
|
rEventMultiplexer ),
|
||||||
maFadeColor( rFadeColor ),
|
maFadeColor( rFadeColor )
|
||||||
mbFirstTurn( true )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
virtual void prepareForRun(
|
||||||
|
const ViewEntry& rViewEntry,
|
||||||
|
const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
|
||||||
|
|
||||||
virtual void performIn(
|
virtual void performIn(
|
||||||
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
||||||
const ViewEntry& rViewEntry,
|
const ViewEntry& rViewEntry,
|
||||||
@@ -411,9 +414,19 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const boost::optional< RGBColor > maFadeColor;
|
const boost::optional< RGBColor > maFadeColor;
|
||||||
bool mbFirstTurn;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void FadingSlideChange::prepareForRun(
|
||||||
|
const ViewEntry& rViewEntry,
|
||||||
|
const cppcanvas::CanvasSharedPtr& rDestinationCanvas )
|
||||||
|
{
|
||||||
|
// clear page to given fade color. 'Leaving' slide is
|
||||||
|
// painted atop of that, but slowly fading out.
|
||||||
|
fillPage( rDestinationCanvas,
|
||||||
|
::basegfx::B2DSize( getEnteringSlideSizePixel( rViewEntry.mpView ) ),
|
||||||
|
*maFadeColor );
|
||||||
|
}
|
||||||
|
|
||||||
void FadingSlideChange::performIn(
|
void FadingSlideChange::performIn(
|
||||||
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
||||||
const ViewEntry& /*rViewEntry*/,
|
const ViewEntry& /*rViewEntry*/,
|
||||||
@@ -434,7 +447,7 @@ void FadingSlideChange::performIn(
|
|||||||
|
|
||||||
void FadingSlideChange::performOut(
|
void FadingSlideChange::performOut(
|
||||||
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
||||||
const ViewEntry& rViewEntry,
|
const ViewEntry& /* rViewEntry */,
|
||||||
const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
|
const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
|
||||||
double t )
|
double t )
|
||||||
{
|
{
|
||||||
@@ -448,17 +461,6 @@ void FadingSlideChange::performOut(
|
|||||||
// only needed for color fades
|
// only needed for color fades
|
||||||
if( maFadeColor )
|
if( maFadeColor )
|
||||||
{
|
{
|
||||||
if( mbFirstTurn )
|
|
||||||
{
|
|
||||||
mbFirstTurn = false;
|
|
||||||
|
|
||||||
// clear page to given fade color. 'Leaving' slide is
|
|
||||||
// painted atop of that, but slowly fading out.
|
|
||||||
fillPage( rDestinationCanvas,
|
|
||||||
::basegfx::B2DSize( getEnteringSlideSizePixel( rViewEntry.mpView ) ),
|
|
||||||
*maFadeColor );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Until half of the active time, fade out old
|
// Until half of the active time, fade out old
|
||||||
// slide. After half of the active time, old slide
|
// slide. After half of the active time, old slide
|
||||||
// will be invisible.
|
// will be invisible.
|
||||||
@@ -486,10 +488,13 @@ public:
|
|||||||
rViewContainer,
|
rViewContainer,
|
||||||
rScreenUpdater,
|
rScreenUpdater,
|
||||||
rEventMultiplexer ),
|
rEventMultiplexer ),
|
||||||
maFadeColor( rFadeColor ),
|
maFadeColor( rFadeColor )
|
||||||
mbFirstTurn( true )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
virtual void prepareForRun(
|
||||||
|
const ViewEntry& rViewEntry,
|
||||||
|
const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
|
||||||
|
|
||||||
virtual void performIn(
|
virtual void performIn(
|
||||||
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
||||||
const ViewEntry& rViewEntry,
|
const ViewEntry& rViewEntry,
|
||||||
@@ -504,9 +509,19 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RGBColor maFadeColor;
|
RGBColor maFadeColor;
|
||||||
bool mbFirstTurn;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CutSlideChange::prepareForRun(
|
||||||
|
const ViewEntry& rViewEntry,
|
||||||
|
const cppcanvas::CanvasSharedPtr& rDestinationCanvas )
|
||||||
|
{
|
||||||
|
// clear page to given fade color. 'Leaving' slide is
|
||||||
|
// painted atop of that
|
||||||
|
fillPage( rDestinationCanvas,
|
||||||
|
::basegfx::B2DSize( getEnteringSlideSizePixel( rViewEntry.mpView ) ),
|
||||||
|
maFadeColor );
|
||||||
|
}
|
||||||
|
|
||||||
void CutSlideChange::performIn(
|
void CutSlideChange::performIn(
|
||||||
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
||||||
const ViewEntry& /*rViewEntry*/,
|
const ViewEntry& /*rViewEntry*/,
|
||||||
@@ -523,7 +538,7 @@ void CutSlideChange::performIn(
|
|||||||
|
|
||||||
void CutSlideChange::performOut(
|
void CutSlideChange::performOut(
|
||||||
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
||||||
const ViewEntry& rViewEntry,
|
const ViewEntry& /* rViewEntry */,
|
||||||
const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
|
const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
|
||||||
double t )
|
double t )
|
||||||
{
|
{
|
||||||
@@ -534,17 +549,6 @@ void CutSlideChange::performOut(
|
|||||||
rDestinationCanvas,
|
rDestinationCanvas,
|
||||||
"FadingSlideChange::performOut(): Invalid dest canvas" );
|
"FadingSlideChange::performOut(): Invalid dest canvas" );
|
||||||
|
|
||||||
if( mbFirstTurn )
|
|
||||||
{
|
|
||||||
mbFirstTurn = false;
|
|
||||||
|
|
||||||
// clear page to given fade color. 'Leaving' slide is
|
|
||||||
// painted atop of that
|
|
||||||
fillPage( rDestinationCanvas,
|
|
||||||
::basegfx::B2DSize( getEnteringSlideSizePixel( rViewEntry.mpView ) ),
|
|
||||||
maFadeColor );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Until 1/3rd of the active time, display old slide.
|
// Until 1/3rd of the active time, display old slide.
|
||||||
rSprite->setAlpha( t > 1/3.0 ? 0.0 : 1.0 );
|
rSprite->setAlpha( t > 1/3.0 ? 0.0 : 1.0 );
|
||||||
}
|
}
|
||||||
@@ -557,8 +561,6 @@ class MovingSlideChange : public SlideChangeBase
|
|||||||
/// Direction vector for entering slide,
|
/// Direction vector for entering slide,
|
||||||
const ::basegfx::B2DVector maEnteringDirection;
|
const ::basegfx::B2DVector maEnteringDirection;
|
||||||
|
|
||||||
bool mbFirstPerformCall;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Create a new SlideChanger, for the given entering slide
|
/** Create a new SlideChanger, for the given entering slide
|
||||||
bitmaps, which performes a moving slide change effect
|
bitmaps, which performes a moving slide change effect
|
||||||
@@ -600,10 +602,13 @@ public:
|
|||||||
// TODO(F1): calc correct length of direction
|
// TODO(F1): calc correct length of direction
|
||||||
// vector. Directions not strictly horizontal or vertical
|
// vector. Directions not strictly horizontal or vertical
|
||||||
// must travel a longer distance.
|
// must travel a longer distance.
|
||||||
maEnteringDirection( rEnteringDirection ),
|
maEnteringDirection( rEnteringDirection )
|
||||||
mbFirstPerformCall( true )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
virtual void prepareForRun(
|
||||||
|
const ViewEntry& rViewEntry,
|
||||||
|
const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
|
||||||
|
|
||||||
virtual void performIn(
|
virtual void performIn(
|
||||||
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
||||||
const ViewEntry& rViewEntry,
|
const ViewEntry& rViewEntry,
|
||||||
@@ -617,6 +622,16 @@ public:
|
|||||||
double t );
|
double t );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void MovingSlideChange::prepareForRun(
|
||||||
|
const ViewEntry& rViewEntry,
|
||||||
|
const cppcanvas::CanvasSharedPtr& rDestinationCanvas )
|
||||||
|
{
|
||||||
|
if ( maLeavingDirection.equalZero() )
|
||||||
|
renderBitmap( getLeavingBitmap( rViewEntry ), rDestinationCanvas );
|
||||||
|
else if ( maEnteringDirection.equalZero() )
|
||||||
|
renderBitmap( getEnteringBitmap( rViewEntry ), rDestinationCanvas );
|
||||||
|
}
|
||||||
|
|
||||||
void MovingSlideChange::performIn(
|
void MovingSlideChange::performIn(
|
||||||
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
|
||||||
const ViewEntry& rViewEntry,
|
const ViewEntry& rViewEntry,
|
||||||
@@ -632,12 +647,6 @@ void MovingSlideChange::performIn(
|
|||||||
rDestinationCanvas,
|
rDestinationCanvas,
|
||||||
"MovingSlideChange::performIn(): Invalid dest canvas" );
|
"MovingSlideChange::performIn(): Invalid dest canvas" );
|
||||||
|
|
||||||
if (mbFirstPerformCall && maLeavingDirection.equalZero())
|
|
||||||
{
|
|
||||||
mbFirstPerformCall = false;
|
|
||||||
renderBitmap( getLeavingBitmap(rViewEntry), rDestinationCanvas );
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(F1): This does not account for non-translational
|
// TODO(F1): This does not account for non-translational
|
||||||
// transformations! If the canvas is rotated, we still
|
// transformations! If the canvas is rotated, we still
|
||||||
// move the sprite unrotated (which might or might not
|
// move the sprite unrotated (which might or might not
|
||||||
@@ -670,12 +679,6 @@ void MovingSlideChange::performOut(
|
|||||||
rDestinationCanvas,
|
rDestinationCanvas,
|
||||||
"MovingSlideChange::performOut(): Invalid dest canvas" );
|
"MovingSlideChange::performOut(): Invalid dest canvas" );
|
||||||
|
|
||||||
if (mbFirstPerformCall && maEnteringDirection.equalZero())
|
|
||||||
{
|
|
||||||
mbFirstPerformCall = false;
|
|
||||||
renderBitmap( getEnteringBitmap(rViewEntry), rDestinationCanvas );
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(F1): This does not account for non-translational
|
// TODO(F1): This does not account for non-translational
|
||||||
// transformations! If the canvas is rotated, we still
|
// transformations! If the canvas is rotated, we still
|
||||||
// move the sprite unrotated (which might or might not
|
// move the sprite unrotated (which might or might not
|
||||||
|
Reference in New Issue
Block a user