using namespace Dali;
+using Dali::Toolkit::TextLabel;
+
// LOCAL STUFF
namespace
{
// The duration of the current image staying on screen when slideshow is on
const int VIEWINGTIME = 2000; // 2 seconds
+
+/**
+ * @brief Load an image, scaled-down to no more than the stage dimensions.
+ *
+ * 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 BOX_THEN_LINEAR to sample the image with
+ * maximum quality.
+ */
+ResourceImage LoadStageFillingImage( const char * const imagePath )
+{
+ Size stageSize = Stage::GetCurrent().GetSize();
+ return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
+}
+
} // namespace
class CubeTransitionApp : public ConnectionTracker
Toolkit::View mView;
Toolkit::ToolBar mToolBar;
Layer mContent;
+ Toolkit::TextLabel mTitleActor;
Actor mParent;
Vector2 mViewSize;
ImageActor mNextImage;
unsigned int mIndex;
bool mIsImageLoading;
- Constraint mImageConstraint;
PanGestureDetector mPanGestureDetector;
void CubeTransitionApp::OnInit( Application& application )
{
+ DemoHelper::RequestThemeChange();
+
Stage::GetCurrent().KeyEventSignal().Connect(this, &CubeTransitionApp::OnKeyEvent);
// Creates a default view with a default tool bar, the view is added to the stage.
mEffectChangeButton.ClickedSignal().Connect( this, &CubeTransitionApp::OnEffectButtonClicked );
mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
+ // Add title to the tool bar.
+ mTitleActor = DemoHelper::CreateToolBarLabel( APPLICATION_TITLE_WAVE );
+ mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
+
//Add an slideshow icon on the right of the title
mIconSlideshowStart = ResourceImage::New( SLIDE_SHOW_START_ICON );
mIconSlideshowStop = ResourceImage::New( SLIDE_SHOW_STOP_ICON );
mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick );
// show the first image
- mImageConstraint = Constraint::New<Vector3>( Actor::Property::Scale, LocalSource( Actor::Property::Size ), ParentSource( Actor::Property::Size ), ScaleToFitKeepAspectRatioConstraint() );
-
- mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) );
+ mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) );
mCurrentImage.SetPositionInheritanceMode( USE_PARENT_POSITION );
- mCurrentImage.ApplyConstraint( mImageConstraint );
+ mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
mParent.Add( mCurrentImage );
mCurrentEffect = mCubeWaveEffect;
void CubeTransitionApp::GoToNextImage()
{
- ResourceImage image = ResourceImage::New( IMAGES[ mIndex ] );
+ ResourceImage image = LoadStageFillingImage( IMAGES[ mIndex ] );
mNextImage = ImageActor::New( image );
+
mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION);
- mNextImage.ApplyConstraint( mImageConstraint );
+ mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
+ mNextImage.SetRelayoutEnabled( false );
mCurrentEffect.SetTargetImage(mNextImage);
if( image.GetLoadingState() == ResourceLoadingSucceeded )
{
if(mCurrentEffect == mCubeWaveEffect)
{
mCurrentEffect = mCubeCrossEffect;
+ mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_CROSS) );
mEffectChangeButton.SetBackgroundImage(mImageCross);
}
else if(mCurrentEffect == mCubeCrossEffect)
{
mCurrentEffect = mCubeFoldEffect;
+ mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_FOLD) );
mEffectChangeButton.SetBackgroundImage(mImageFold);
}
else
{
mCurrentEffect = mCubeWaveEffect;
+ mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_WAVE) );
mEffectChangeButton.SetBackgroundImage(mImageWave);
}
}
}
-// Entry point for Linux & SLP applications
+// Entry point for Linux & Tizen applications
int main( int argc, char **argv )
{
Application application = Application::New( &argc, &argv );