#include <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/shader-effects/dissolve-effect.h>
using namespace Dali;
const char * const APPLICATION_TITLE_HIGHP( "Dissolve Effect(highp)" );
const char * const APPLICATION_TITLE_MEDIUMP( "Dissolve Effect(mediump)" );
const char * const EFFECT_HIGHP_IMAGE( DALI_IMAGE_DIR "icon-highp.png" );
+const char * const EFFECT_HIGHP_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-highp-selected.png" );
const char * const EFFECT_MEDIUMP_IMAGE( DALI_IMAGE_DIR "icon-mediump.png" );
+const char * const EFFECT_MEDIUMP_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-mediump-selected.png" );
const char * const PLAY_ICON( DALI_IMAGE_DIR "icon-play.png" );
+const char * const PLAY_ICON_SELECTED( DALI_IMAGE_DIR "icon-play-selected.png" );
const char * const STOP_ICON( DALI_IMAGE_DIR "icon-stop.png" );
+const char * const STOP_ICON_SELECTED( DALI_IMAGE_DIR "icon-stop-selected.png" );
const char* IMAGES[] =
{
/**
* @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;
bool mTimerReady;
unsigned int mCentralLineIndex;
- Image mIconPlay;
- Image mIconStop;
Toolkit::PushButton mPlayStopButton;
- Image mIconHighP;
- Image mIconMediumP;
Toolkit::PushButton mEffectChangeButton;
};
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.
mContent = DemoHelper::CreateView( application, mView,mToolBar, "", TOOLBAR_IMAGE, "" );
// Add an effect-changing button on the right of the tool bar.
- mIconHighP = ResourceImage::New( EFFECT_HIGHP_IMAGE );
- mIconMediumP = ResourceImage::New( EFFECT_MEDIUMP_IMAGE );
mEffectChangeButton = Toolkit::PushButton::New();
- mEffectChangeButton.SetBackgroundImage(mIconHighP);
+ mEffectChangeButton.SetUnselectedImage( EFFECT_HIGHP_IMAGE );
+ mEffectChangeButton.SetSelectedImage( EFFECT_HIGHP_IMAGE_SELECTED );
mEffectChangeButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnEffectButtonClicked );
mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
// Add an slide-show button on the right of the title
- mIconPlay = ResourceImage::New( PLAY_ICON );
- mIconStop = ResourceImage::New( STOP_ICON );
mPlayStopButton = Toolkit::PushButton::New();
- mPlayStopButton.SetBackgroundImage( mIconPlay );
+ mPlayStopButton.SetUnselectedImage( PLAY_ICON );
+ mPlayStopButton.SetSelectedImage( PLAY_ICON_SELECTED );
mPlayStopButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked );
mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
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 );
{
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) );
- mEffectChangeButton.SetBackgroundImage(mIconHighP);
+ mEffectChangeButton.SetUnselectedImage( EFFECT_HIGHP_IMAGE );
+ mEffectChangeButton.SetSelectedImage( EFFECT_HIGHP_IMAGE_SELECTED );
}
else
{
mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_MEDIUMP) );
- mEffectChangeButton.SetBackgroundImage(mIconMediumP);
+ mEffectChangeButton.SetUnselectedImage( EFFECT_MEDIUMP_IMAGE );
+ mEffectChangeButton.SetSelectedImage( EFFECT_MEDIUMP_IMAGE_SELECTED );
}
return true;
mSlideshow = !mSlideshow;
if( mSlideshow )
{
- mPlayStopButton.SetBackgroundImage( mIconStop );
+ mPlayStopButton.SetUnselectedImage( STOP_ICON );
+ mPlayStopButton.SetSelectedImage( STOP_ICON_SELECTED );
mPanGestureDetector.Detach( mParent );
mViewTimer.Start();
mTimerReady = false;
}
else
{
- mPlayStopButton.SetBackgroundImage( mIconPlay );
+ mPlayStopButton.SetUnselectedImage( PLAY_ICON );
+ mPlayStopButton.SetSelectedImage( PLAY_ICON_SELECTED );
mTimerReady = true;
mPanGestureDetector.Attach( mParent );
}
// 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();