#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/shader-effects/dissolve-effect.h>
using namespace Dali;
/**
* @brief Load an image, scaled-down to no more than the stage dimensions.
*
- * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at
+ * Uses image scaling mode SCALE_TO_FILL to resize the image at
* load time to cover the entire stage with pixels with no borders,
- * and filter mode ImageAttributes::BoxThenLinear to sample the image with
+ * and filter mode BOX_THEN_LINEAR to sample the image with
* maximum quality.
*/
ResourceImage LoadStageFillingImage( const char * const imagePath )
{
Size stageSize = Stage::GetCurrent().GetSize();
- ImageAttributes attributes;
- attributes.SetSize( stageSize.x, stageSize.y );
- attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
- attributes.SetScalingMode( ImageAttributes::ScaleToFill );
- return ResourceImage::New( imagePath, attributes );
+ return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
}
} // namespace
private:
Application& mApplication;
- Toolkit::View mView;
+ Toolkit::Control mView;
Toolkit::ToolBar mToolBar;
Layer mContent;
Toolkit::TextLabel mTitleActor;
ImageActor mNextImage;
unsigned int mIndex;
- Toolkit::DissolveEffect mCurrentImageEffect;
- Toolkit::DissolveEffect mNextImageEffect;
+ ShaderEffect mCurrentImageEffect;
+ ShaderEffect mNextImageEffect;
bool mUseHighPrecision;
Animation mAnimation;
void DissolveEffectApp::OnInit( Application& application )
{
- DemoHelper::RequestThemeChange();
-
Stage::GetCurrent().KeyEventSignal().Connect(this, &DissolveEffectApp::OnKeyEvent);
// Creates a default view with a default tool bar, the view is added to the stage.
mPanGestureDetector.DetectedSignal().Connect( this, &DissolveEffectApp::OnPanGesture );
// create the dissolve effect object
- mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision);
- mNextImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision);
+ mCurrentImageEffect = Toolkit::CreateDissolveEffect(mUseHighPrecision);
+ mNextImageEffect = Toolkit::CreateDissolveEffect(mUseHighPrecision);
mViewTimer = Timer::New( VIEWINGTIME );
mViewTimer.TickSignal().Connect( this, &DissolveEffectApp::OnTimerTick );
// show the first image
mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) );
- mCurrentImage.SetRelayoutEnabled( false );
mCurrentImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
- mCurrentImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- mCurrentImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
+ mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
mParent.Add( mCurrentImage );
mPanGestureDetector.Attach( mCurrentImage );
Image image = LoadStageFillingImage( IMAGES[ mIndex ] );
mNextImage = ImageActor::New( image );
- mNextImage.SetRelayoutEnabled( false );
mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
- mNextImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- mNextImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
+ mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
mNextImage.SetZ(INITIAL_DEPTH);
mParent.Add( mNextImage );
Vector2 size = Vector2( mCurrentImage.GetCurrentSize() );
{
mAnimation = Animation::New(TRANSITION_DURATION);
- mCurrentImageEffect.SetCentralLine(position,displacement);
- mCurrentImageEffect.SetDistortion(0.0f);
+ Dali::Toolkit::DissolveEffectSetCentralLine( mCurrentImageEffect, position, displacement );
+ mCurrentImageEffect.SetUniform("uPercentage", 0.0f);
mCurrentImage.SetShaderEffect(mCurrentImageEffect);
- mAnimation.AnimateTo( Property(mCurrentImageEffect, mCurrentImageEffect.GetDistortionPropertyName()), 1.0f, AlphaFunctions::Linear );
+ mAnimation.AnimateTo( Property(mCurrentImageEffect, "uPercentage"), 1.0f, AlphaFunction::LINEAR );
mNextImage.SetOpacity(0.0f);
- mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::Linear );
+ mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::LINEAR );
if(mUseHighPrecision)
{
- mNextImageEffect.SetCentralLine(position,-displacement);
- mNextImageEffect.SetDistortion(1.0f);
+ Dali::Toolkit::DissolveEffectSetCentralLine( mNextImageEffect, position, displacement );
+ mNextImageEffect.SetUniform("uPercentage", 1.0f);
mNextImage.SetShaderEffect(mNextImageEffect);
- mAnimation.AnimateTo( Property(mNextImageEffect, mNextImageEffect.GetDistortionPropertyName()), 0.0f, AlphaFunctions::Linear );
+ mAnimation.AnimateTo( Property(mNextImageEffect, "uPercentage"), 0.0f, AlphaFunction::LINEAR );
}
else
{
- mAnimation.AnimateTo( Property( mNextImage, Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), AlphaFunctions::Linear );
+ mAnimation.AnimateTo( Property( mNextImage, Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), AlphaFunction::LINEAR );
}
mAnimation.FinishedSignal().Connect( this, &DissolveEffectApp::OnTransitionCompleted );
bool DissolveEffectApp::OnEffectButtonClicked( Toolkit::Button button )
{
mUseHighPrecision = !mUseHighPrecision;
- mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision);
+ mCurrentImageEffect = Dali::Toolkit::CreateDissolveEffect(mUseHighPrecision);
if(mUseHighPrecision)
{
mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_HIGHP) );
}
else
{
+ mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_MEDIUMP) );
mEffectChangeButton.SetBackgroundImage(mIconMediumP);
}
Image image = LoadStageFillingImage( IMAGES[ mIndex ] );
mNextImage = ImageActor::New( image );
mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
- mNextImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- mNextImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
+ mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
mNextImage.SetZ(INITIAL_DEPTH);
mParent.Add( mNextImage );
switch( mCentralLineIndex%4 )
// Entry point for Linux & Tizen applications
int main( int argc, char **argv )
{
- Application application = Application::New( &argc, &argv );
+ Application application = Application::New( &argc, &argv, DALI_DEMO_THEME_PATH );
DissolveEffectApp test( application );
application.MainLoop();