From: Paul Wisbey
Date: Wed, 4 Mar 2015 18:53:01 +0000 (+0000)
Subject: Merge remote-tracking branch 'origin/tizen' into new_text
X-Git-Tag: new_text_0.1~5
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a61f04a9bf4241761bda7742918967f34de2891;p=platform%2Fcore%2Fuifw%2Fdali-demo.git
Merge remote-tracking branch 'origin/tizen' into new_text
Conflicts:
build/tizen/examples/CMakeLists.txt
demo/dali-demo.cpp
examples/buttons/buttons-example.cpp
examples/item-view/item-view-example.cpp
examples/text-view/text-view-example.cpp
Change-Id: I8816d065edca8e2a3fd37cdcedda4b02735f5007
---
8a61f04a9bf4241761bda7742918967f34de2891
diff --cc demo/dali-demo.cpp
index a13fcc4f,a2741e81..e703caca
--- a/demo/dali-demo.cpp
+++ b/demo/dali-demo.cpp
@@@ -16,7 -16,6 +16,7 @@@
*/
#include "dali-table-view.h"
- #include "examples/shared/dali-demo-strings.h"
++#include "shared/dali-demo-strings.h"
using namespace Dali;
@@@ -31,24 -25,25 +31,26 @@@ int main(int argc, char **argv
DaliTableView demo(app);
- demo.AddExample(Example("bubble-effect.example", "Bubbles"));
- demo.AddExample(Example("blocks.example", "Blocks"));
- demo.AddExample(Example("cluster.example", "Cluster control"));
- demo.AddExample(Example("cube-transition-effect.example", "Cube Transition"));
- demo.AddExample(Example("dissolve-effect.example", "Dissolve Transition"));
- demo.AddExample(Example("item-view.example", "Item View"));
- demo.AddExample(Example("magnifier.example", "Magnifier"));
- demo.AddExample(Example("motion-blur.example", "Motion Blur"));
- demo.AddExample(Example("motion-stretch.example", "Motion Stretch"));
- demo.AddExample(Example("page-turn-view.example", "Page Turn View"));
- demo.AddExample(Example("radial-menu.example", "Radial Menu"));
- demo.AddExample(Example("refraction-effect.example", "Refraction"));
- demo.AddExample(Example("scroll-view.example", "Scroll View"));
- demo.AddExample(Example("shadow-bone-lighting.example", "Lights and shadows"));
- demo.AddExample(Example("builder.example", "Script Based UI"));
- demo.AddExample(Example("image-scaling-irregular-grid.example", "Image Scaling Modes"));
- demo.AddExample(Example("text-view.example", "Text View"));
+ demo.AddExample(Example("bubble-effect.example", DALI_DEMO_STR_TITLE_BUBBLES));
+ demo.AddExample(Example("blocks.example", DALI_DEMO_STR_TITLE_BLOCKS));
+ demo.AddExample(Example("cluster.example", DALI_DEMO_STR_TITLE_CLUSTER));
+ demo.AddExample(Example("cube-transition-effect.example", DALI_DEMO_STR_TITLE_CUBE_TRANSITION));
+ demo.AddExample(Example("dissolve-effect.example", DALI_DEMO_STR_TITLE_DISSOLVE_TRANSITION));
+ demo.AddExample(Example("item-view.example", DALI_DEMO_STR_TITLE_ITEM_VIEW));
+ demo.AddExample(Example("magnifier.example", DALI_DEMO_STR_TITLE_MAGNIFIER));
+ demo.AddExample(Example("motion-blur.example", DALI_DEMO_STR_TITLE_MOTION_BLUR));
+ demo.AddExample(Example("motion-stretch.example", DALI_DEMO_STR_TITLE_MOTION_STRETCH));
+ demo.AddExample(Example("page-turn-view.example", DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW));
+ demo.AddExample(Example("radial-menu.example", DALI_DEMO_STR_TITLE_RADIAL_MENU));
+ demo.AddExample(Example("refraction-effect.example", DALI_DEMO_STR_TITLE_REFRACTION));
+ demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW));
+ demo.AddExample(Example("shadow-bone-lighting.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS));
+ demo.AddExample(Example("builder.example", DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI));
+ demo.AddExample(Example("image-scaling-irregular-grid.example", DALI_DEMO_STR_TITLE_IMAGE_SCALING));
+ demo.AddExample(Example("text-label.example", DALI_DEMO_STR_TITLE_TEXT_LABEL));
+ demo.AddExample(Example("text-label-multi-language.example", DALI_DEMO_STR_TITLE_TEXT_LABEL)/*TODO - new string*/);
+ demo.AddExample(Example("animated-shapes.example", "Animated Shapes"));
+ demo.AddExample(Example("path-animation.example", "Path Animation"));
app.MainLoop();
return 0;
diff --cc examples/cube-transition-effect/cube-transition-effect-example.cpp
index 00000000,00a84971..93e90798
mode 000000,100644..100644
--- a/examples/cube-transition-effect/cube-transition-effect-example.cpp
+++ b/examples/cube-transition-effect/cube-transition-effect-example.cpp
@@@ -1,0 -1,428 +1,411 @@@
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+ // EXTERNAL INCLUDES
+ #include
+
+ // INTERNAL INCLUDES
+ #include "shared/view.h"
+
+ #include
+ #include
+
+ using namespace Dali;
+
+ // LOCAL STUFF
+ namespace
+ {
+
+ const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
+ const char * const APPLICATION_TITLE_WAVE( "Cube Transition: Wave" );
+ const char * const APPLICATION_TITLE_CROSS( "Cube Transition: Cross" );
+ const char * const APPLICATION_TITLE_FOLD( "Cube Transition: Fold" );
+ const char * const EFFECT_WAVE_IMAGE( DALI_IMAGE_DIR "icon-effect-wave.png" );
+ const char * const EFFECT_CROSS_IMAGE( DALI_IMAGE_DIR "icon-effect-cross.png" );
+ const char * const EFFECT_FOLD_IMAGE( DALI_IMAGE_DIR "icon-effect-fold.png" );
+ const char * const SLIDE_SHOW_START_ICON( DALI_IMAGE_DIR "icon-play.png" );
+ const char * const SLIDE_SHOW_STOP_ICON( DALI_IMAGE_DIR "icon-stop.png" );
+
+ const char* IMAGES[] =
+ {
+ DALI_IMAGE_DIR "gallery-large-1.jpg",
+ DALI_IMAGE_DIR "gallery-large-2.jpg",
+ DALI_IMAGE_DIR "gallery-large-3.jpg",
+ DALI_IMAGE_DIR "gallery-large-4.jpg",
+ DALI_IMAGE_DIR "gallery-large-5.jpg",
+ DALI_IMAGE_DIR "gallery-large-6.jpg",
+ DALI_IMAGE_DIR "gallery-large-7.jpg",
+ DALI_IMAGE_DIR "gallery-large-8.jpg",
+ DALI_IMAGE_DIR "gallery-large-9.jpg",
+ DALI_IMAGE_DIR "gallery-large-10.jpg",
+ DALI_IMAGE_DIR "gallery-large-11.jpg",
+ DALI_IMAGE_DIR "gallery-large-12.jpg",
+ DALI_IMAGE_DIR "gallery-large-13.jpg",
+ DALI_IMAGE_DIR "gallery-large-14.jpg",
+ DALI_IMAGE_DIR "gallery-large-15.jpg",
+ DALI_IMAGE_DIR "gallery-large-16.jpg",
+ DALI_IMAGE_DIR "gallery-large-17.jpg",
+ DALI_IMAGE_DIR "gallery-large-18.jpg",
+ DALI_IMAGE_DIR "gallery-large-19.jpg",
+ DALI_IMAGE_DIR "gallery-large-20.jpg",
+ DALI_IMAGE_DIR "gallery-large-21.jpg",
+ };
+ const int NUM_IMAGES( sizeof(IMAGES) / sizeof(IMAGES[0]) );
+
+ // the number of cubes: NUM_COLUMNS*NUM_ROWS
+ // better choose the numbers that can divide viewAreaSize.x
+ const int NUM_COLUMNS_WAVE(16);
+ const int NUM_COLUMNS_CROSS(8);
+ const int NUM_COLUMNS_FOLD(8);
+ // better choose the numbers that can divide viewAreaSize.y
+ const int NUM_ROWS_WAVE(20);
+ const int NUM_ROWS_CROSS(10);
+ const int NUM_ROWS_FOLD(10);
+ //transition effect duration
+ const float ANIMATION_DURATION_WAVE(1.5f);
+ const float ANIMATION_DURATION_CROSS(1.f);
+ const float ANIMATION_DURATION_FOLD(1.f);
+ //transition effect displacement
+ const float CUBE_DISPLACEMENT_WAVE(70.f);
+ const float CUBE_DISPLACEMENT_CROSS(30.f);
+
+ // The duration of the current image staying on screen when slideshow is on
+ const int VIEWINGTIME = 2000; // 2 seconds
+ } // namespace
+
+ class CubeTransitionApp : public ConnectionTracker
+ {
+ public:
+
+ /**
+ * Constructor
+ * @param application class, stored as reference
+ */
+ CubeTransitionApp( Application& application );
+
+ ~CubeTransitionApp();
+
+ private:
+
+ /**
+ * This method gets called once the main loop of application is up and running
+ */
+ void OnInit( Application& application );
+ /**
+ * PanGesture callback. This method gets called when the pan gesture is detected.
+ * @param[in] actor The actor receiving the pan gesture.
+ * @param[in] gesture The detected pan gesture.
+ */
+ void OnPanGesture( Actor actor, const PanGesture& gesture );
+ /**
+ * Load the next image and start the transition;
+ */
+ void GoToNextImage();
+ /**
+ * Callback function of image resource loading succeed
+ * Start the transition
+ * @param[in] image The image content of the imageActor for transition
+ */
+ void OnImageLoaded(ResourceImage image);
+ /**
+ * Main key event handler
+ */
+ void OnKeyEvent(const KeyEvent& event);
+ /**
+ * Callback function of effect-switch button
+ * Change the effect when the effect button is clicked
+ * @param[in] button The handle of the clicked button
+ */
+ bool OnEffectButtonClicked( Toolkit::Button button );
+ /**
+ * Callback function of slideshow button
+ * Start or stop the automatical image display when the slideshow button is clicked
+ * @param[in] button The handle of the clicked button
+ */
+ bool OnSildeshowButtonClicked( Toolkit::Button button );
+ /**
+ * Callback function of cube transition completed signal
+ * @param[in] effect The cube effect used for the transition
+ * @param[in] imageActor The target imageActor of the completed transition
+ */
+ void OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, ImageActor imageActor);
+ /**
+ * Callback function of timer tick
+ * The timer is used to count the image display duration in slideshow,
+ */
+ bool OnTimerTick();
+
+ private:
+ Application& mApplication;
+ Toolkit::View mView;
+ Toolkit::ToolBar mToolBar;
+ Layer mContent;
- Toolkit::TextView mTitleActor;
+ Actor mParent;
+
+ Vector2 mViewSize;
+
+ ImageActor mCurrentImage;
+ ImageActor mNextImage;
+ unsigned int mIndex;
+ bool mIsImageLoading;
+ Constraint mImageConstraint;
+
+ PanGestureDetector mPanGestureDetector;
+
+ Toolkit::CubeTransitionEffect mCubeWaveEffect;
+ Toolkit::CubeTransitionEffect mCubeCrossEffect;
+ Toolkit::CubeTransitionEffect mCubeFoldEffect;
+ Toolkit::CubeTransitionEffect mCurrentEffect;
+
+ bool mSlideshow;
+ Timer mViewTimer;
+ Toolkit::PushButton mSlideshowButton;
+ Image mIconSlideshowStart;
+ Image mIconSlideshowStop;
+
+ Vector2 mPanPosition;
+ Vector2 mPanDisplacement;
+
+ Image mImageWave;
+ Image mImageCross;
+ Image mImageFold;
+ Toolkit::PushButton mEffectChangeButton;
+ };
+
+ CubeTransitionApp::CubeTransitionApp( Application& application )
+ : mApplication( application ),
+ mIndex( 0 ),
+ mIsImageLoading( false ),
+ mSlideshow( false )
+ {
+ mApplication.InitSignal().Connect( this, &CubeTransitionApp::OnInit );
+ }
+
+ CubeTransitionApp::~CubeTransitionApp()
+ {
+ //Nothing to do
+ }
+
+ void CubeTransitionApp::OnInit( Application& application )
+ {
+ Stage::GetCurrent().KeyEventSignal().Connect(this, &CubeTransitionApp::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.
+ mImageWave = ResourceImage::New( EFFECT_WAVE_IMAGE );
+ mImageCross = ResourceImage::New( EFFECT_CROSS_IMAGE );
+ mImageFold = ResourceImage::New( EFFECT_FOLD_IMAGE );
+ mEffectChangeButton = Toolkit::PushButton::New();
+ mEffectChangeButton.SetBackgroundImage(mImageWave);
+ 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 = Toolkit::TextView::New();
- 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 );
+ mSlideshowButton = Toolkit::PushButton::New();
+ mSlideshowButton.SetBackgroundImage( mIconSlideshowStart );
+ mSlideshowButton.ClickedSignal().Connect( this, &CubeTransitionApp::OnSildeshowButtonClicked );
+ mToolBar.AddControl( mSlideshowButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
+
+ // Set size to stage size to avoid seeing a black border on transition
+ mViewSize = Stage::GetCurrent().GetSize();
+
+ mParent = Actor::New();
+ mParent.SetSize( mViewSize );
+ mParent.SetPositionInheritanceMode( USE_PARENT_POSITION );
+ mContent.Add( mParent );
+
+ // use pan gesture to detect the cursor or finger movement
+ mPanGestureDetector = PanGestureDetector::New();
+ mPanGestureDetector.DetectedSignal().Connect( this, &CubeTransitionApp::OnPanGesture );
+ mPanGestureDetector.Attach( mParent );
+
+ //use small cubes
+ mCubeWaveEffect = Toolkit::CubeTransitionWaveEffect::New(NUM_ROWS_WAVE, NUM_COLUMNS_WAVE, mViewSize);
+ mCubeWaveEffect.SetTransitionDuration( ANIMATION_DURATION_WAVE );
+ mCubeWaveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_WAVE );
+ mCubeWaveEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
+ mParent.Add(mCubeWaveEffect.GetRoot());
+ // use big cubes
+ mCubeCrossEffect = Toolkit::CubeTransitionCrossEffect::New(NUM_ROWS_CROSS, NUM_COLUMNS_CROSS, mViewSize);
+ mCubeCrossEffect.SetTransitionDuration( ANIMATION_DURATION_CROSS);
+ mCubeCrossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_CROSS );
+ mCubeCrossEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
+ mParent.Add(mCubeCrossEffect.GetRoot());
+
+ mCubeFoldEffect = Toolkit::CubeTransitionFoldEffect::New(NUM_ROWS_FOLD, NUM_COLUMNS_FOLD, mViewSize);
+ mCubeFoldEffect.SetTransitionDuration( ANIMATION_DURATION_FOLD);
+ mCubeFoldEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
+ mParent.Add(mCubeFoldEffect.GetRoot());
+
+ mViewTimer = Timer::New( VIEWINGTIME );
+ mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick );
+
+ // show the first image
+ mImageConstraint = Constraint::New( Actor::Property::Scale, LocalSource( Actor::Property::Size ), ParentSource( Actor::Property::Size ), ScaleToFitKeepAspectRatioConstraint() );
+
+ mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) );
+ mCurrentImage.SetPositionInheritanceMode( USE_PARENT_POSITION );
+ mCurrentImage.ApplyConstraint( mImageConstraint );
+ mParent.Add( mCurrentImage );
+
+ mCurrentEffect = mCubeWaveEffect;
+ mCurrentEffect.SetCurrentImage( mCurrentImage );
-
- // Set Title text
- mTitleActor.SetText( APPLICATION_TITLE_WAVE );
- mTitleActor.SetSize( Font::New().MeasureText( APPLICATION_TITLE_WAVE ) );
- mTitleActor.SetStyleToCurrentText( DemoHelper::GetDefaultTextStyle() );
+ }
+
+ // signal handler, called when the pan gesture is detected
+ void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture )
+ {
+ // does not response when the transition has not finished
+ if( mIsImageLoading || mCubeWaveEffect.IsTransiting() || mCubeCrossEffect.IsTransiting() || mCubeFoldEffect.IsTransiting() || mSlideshow )
+ {
+ return;
+ }
+
+ if( gesture.state == Gesture::Continuing )
+ {
+ if( gesture.displacement.x < 0)
+ {
+ mIndex = (mIndex + 1)%NUM_IMAGES;
+ }
+ else
+ {
+ mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES;
+ }
+
+ mPanPosition = gesture.position;
+ mPanDisplacement = gesture.displacement;
+ GoToNextImage();
+ }
+ }
+
+ void CubeTransitionApp::GoToNextImage()
+ {
+ ResourceImage image = ResourceImage::New( IMAGES[ mIndex ] );
+ mNextImage = ImageActor::New( image );
+ mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION);
+ mNextImage.ApplyConstraint( mImageConstraint );
+ mCurrentEffect.SetTargetImage(mNextImage);
+ if( image.GetLoadingState() == ResourceLoadingSucceeded )
+ {
+ mIsImageLoading = false;
+ OnImageLoaded( image );
+ }
+ else
+ {
+ mIsImageLoading = true;
+ image.LoadingFinishedSignal().Connect( this, &CubeTransitionApp::OnImageLoaded );
+ }
+ }
+
+ void CubeTransitionApp::OnImageLoaded(ResourceImage image)
+ {
+ mIsImageLoading = false;
+ mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement );
+ mParent.Remove(mCurrentImage);
+ mParent.Add(mNextImage);
+ mCurrentImage = mNextImage;
+ }
+
+ bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button )
+ {
+ if(mCurrentEffect == mCubeWaveEffect)
+ {
+ mCurrentEffect = mCubeCrossEffect;
- mTitleActor.SetText( APPLICATION_TITLE_CROSS );
- mTitleActor.SetSize( Font::New().MeasureText( APPLICATION_TITLE_CROSS ) );
+ mEffectChangeButton.SetBackgroundImage(mImageCross);
+
+ }
+ else if(mCurrentEffect == mCubeCrossEffect)
+ {
+ mCurrentEffect = mCubeFoldEffect;
- mTitleActor.SetText( APPLICATION_TITLE_FOLD );
- mTitleActor.SetSize( Font::New().MeasureText( APPLICATION_TITLE_FOLD ) );
+ mEffectChangeButton.SetBackgroundImage(mImageFold);
+ }
+ else
+ {
+ mCurrentEffect = mCubeWaveEffect;
- mTitleActor.SetText( APPLICATION_TITLE_WAVE );
- mTitleActor.SetSize( Font::New().MeasureText( APPLICATION_TITLE_WAVE ) );
+ mEffectChangeButton.SetBackgroundImage(mImageWave);
+ }
- mTitleActor.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle());
+
+ // Set the current image to cube transition effect
+ // only need to set at beginning or change from another effect
+ mCurrentEffect.SetCurrentImage(mCurrentImage);
+ return true;
+ }
+
+ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button )
+ {
+ mSlideshow = !mSlideshow;
+ if( mSlideshow )
+ {
+ mPanGestureDetector.Detach( mParent );
+ mSlideshowButton.SetBackgroundImage( mIconSlideshowStop );
+ mPanPosition = Vector2( mViewSize.width, mViewSize.height*0.5f );
+ mPanDisplacement = Vector2( -10.f, 0.f );
+ mViewTimer.Start();
+ }
+ else
+ {
+ mPanGestureDetector.Attach( mParent );
+ mSlideshowButton.SetBackgroundImage( mIconSlideshowStart );
+ mViewTimer.Stop();
+ }
+ return true;
+ }
+
+ void CubeTransitionApp::OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, ImageActor imageActor)
+ {
+ if( mSlideshow )
+ {
+ mViewTimer.Start();
+ }
+ }
+
+ bool CubeTransitionApp::OnTimerTick()
+ {
+ if(mSlideshow)
+ {
+ mIndex = (mIndex + 1)%NUM_IMAGES;
+ GoToNextImage();
+ }
+
+ //return false to stop the timer
+ return false;
+ }
+
+ void CubeTransitionApp::OnKeyEvent(const KeyEvent& event)
+ {
+ if(event.state == KeyEvent::Down)
+ {
+ if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
+ {
+ mApplication.Quit();
+ }
+ }
+ }
+
+ // Entry point for Linux & SLP applications
+ int main( int argc, char **argv )
+ {
+ Application application = Application::New( &argc, &argv );
+ CubeTransitionApp test( application );
+ application.MainLoop();
+
+ return 0;
+ }
diff --cc examples/dissolve-effect/dissolve-effect-example.cpp
index 00000000,888a2547..8abfc674
mode 000000,100644..100644
--- a/examples/dissolve-effect/dissolve-effect-example.cpp
+++ b/examples/dissolve-effect/dissolve-effect-example.cpp
@@@ -1,0 -1,421 +1,414 @@@
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+ // EXTERNAL INCLUDES
+ #include
+
+ // INTERNAL INCLUDES
+ #include "shared/view.h"
+
+ #include
+ #include
+
+ using namespace Dali;
+
+ // LOCAL STUFF
+ namespace
+ {
+
+ const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
+ 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_MEDIUMP_IMAGE( DALI_IMAGE_DIR "icon-mediump.png" );
+ const char * const PLAY_ICON( DALI_IMAGE_DIR "icon-play.png" );
+ const char * const STOP_ICON( DALI_IMAGE_DIR "icon-stop.png" );
+
+ const char* IMAGES[] =
+ {
+ DALI_IMAGE_DIR "gallery-large-1.jpg",
+ DALI_IMAGE_DIR "gallery-large-2.jpg",
+ DALI_IMAGE_DIR "gallery-large-3.jpg",
+ DALI_IMAGE_DIR "gallery-large-4.jpg",
+ DALI_IMAGE_DIR "gallery-large-5.jpg",
+ DALI_IMAGE_DIR "gallery-large-6.jpg",
+ DALI_IMAGE_DIR "gallery-large-7.jpg",
+ DALI_IMAGE_DIR "gallery-large-8.jpg",
+ DALI_IMAGE_DIR "gallery-large-9.jpg",
+ DALI_IMAGE_DIR "gallery-large-10.jpg",
+ DALI_IMAGE_DIR "gallery-large-11.jpg",
+ DALI_IMAGE_DIR "gallery-large-12.jpg",
+ DALI_IMAGE_DIR "gallery-large-13.jpg",
+ DALI_IMAGE_DIR "gallery-large-14.jpg",
+ DALI_IMAGE_DIR "gallery-large-15.jpg",
+ DALI_IMAGE_DIR "gallery-large-16.jpg",
+ DALI_IMAGE_DIR "gallery-large-17.jpg",
+ DALI_IMAGE_DIR "gallery-large-18.jpg",
+ DALI_IMAGE_DIR "gallery-large-19.jpg",
+ DALI_IMAGE_DIR "gallery-large-20.jpg",
+ DALI_IMAGE_DIR "gallery-large-21.jpg",
+ };
+
+ const int NUM_IMAGES( sizeof(IMAGES) / sizeof(IMAGES[0]) );
+
+ // The duration of the current image staying on screen when slideshow is on
+ const int VIEWINGTIME = 2000; // 2 seconds
+
+ const float TRANSITION_DURATION = 2.5f; //2.5 second
+
+ const float INITIAL_DEPTH = -10.0f;
+ } // namespace
+
+ class DissolveEffectApp : public ConnectionTracker
+ {
+ public:
+
+ /**
+ * Constructor
+ * @param application class, stored as reference
+ */
+ DissolveEffectApp( Application& application );
+
+ ~DissolveEffectApp();
+
+ private:
+
+ /**
+ * This method gets called once the main loop of application is up and running
+ */
+ void OnInit( Application& application );
+ /**
+ * PanGesture callback. This method gets called when the pan gesture is detected.
+ * @param[in] actor The actor receiving the pan gesture.
+ * @param[in] gesture The detected pan gesture.
+ */
+ void OnPanGesture( Actor actor, const PanGesture& gesture );
+
+ /**
+ * Set up the animations for transition
+ * @param[in] position The point ( locates within rectange {(0,0),(0,1),(1,0),(1,1)} ) passing through the central line of the dissolve effect
+ * @param[in] displacement The direction of the central line of the dissolve effect
+ */
+ void StartTransition(Vector2 position, Vector2 displacement);
+ /**
+ * Callback function of effect-switch button
+ * Change the precision of the effect shader when the effect button is clicked
+ * @param[in] button The handle of the clicked button
+ */
+ bool OnEffectButtonClicked( Toolkit::Button button );
+ /**
+ * Callback function of slideshow button
+ * Start or stop the automatical image display when the slideshow button is clicked
+ * @param[in] button The handle of the clicked button
+ */
+ bool OnSildeshowButtonClicked( Toolkit::Button button );
+ /**
+ * Callback function of cube transition completed signal
+ * @param[in] effect The cube effect used for the transition
+ * @param[in] imageActor The target imageActor of the completed transition
+ */
+ void OnTransitionCompleted(Animation& source);
+ /**
+ * Callback function of timer tick
+ * The timer is used to count the image display duration after cube transition in slideshow,
+ */
+ bool OnTimerTick();
+
+ /**
+ * Main key event handler
+ */
+ void OnKeyEvent(const KeyEvent& event);
+
+ private:
+ Application& mApplication;
+ Toolkit::View mView;
+ Toolkit::ToolBar mToolBar;
+ Layer mContent;
- Toolkit::TextView mTitleActor;
+ Actor mParent;
+
+ ImageActor mCurrentImage;
+ ImageActor mNextImage;
+ unsigned int mIndex;
+ Constraint mSizeConstraint;
+
+ Toolkit::DissolveEffect mCurrentImageEffect;
+ Toolkit::DissolveEffect mNextImageEffect;
+ bool mUseHighPrecision;
+ Animation mAnimation;
+
+ PanGestureDetector mPanGestureDetector;
+ bool mIsTransiting;
+
+ bool mSlideshow;
+ Timer mViewTimer;
+ bool mTimerReady;
+ unsigned int mCentralLineIndex;
+
+ Image mIconPlay;
+ Image mIconStop;
+ Toolkit::PushButton mPlayStopButton;
+
+ Image mIconHighP;
+ Image mIconMediumP;
+ Toolkit::PushButton mEffectChangeButton;
+ };
+
+ DissolveEffectApp::DissolveEffectApp( Application& application )
+ : mApplication( application ),
+ mIndex( 0 ),
+ mUseHighPrecision(true),
+ mIsTransiting( false ),
+ mSlideshow( false ),
+ mTimerReady( false ),
+ mCentralLineIndex( 0 )
+ {
+ mApplication.InitSignal().Connect( this, &DissolveEffectApp::OnInit );
+ }
+
+ DissolveEffectApp::~DissolveEffectApp()
+ {
+ //Nothing to do
+ }
+
+ void DissolveEffectApp::OnInit( Application& application )
+ {
+ 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.ClickedSignal().Connect( this, &DissolveEffectApp::OnEffectButtonClicked );
+ mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
+
+ // Add title to the tool bar.
- mTitleActor = Toolkit::TextView::New();
- mTitleActor.SetText( APPLICATION_TITLE_HIGHP );
- mTitleActor.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle());
- mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
++ // TODO
+
+ // 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.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked );
+ mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
+
+ // use pan gesture to detect the cursor or finger movement
+ mPanGestureDetector = PanGestureDetector::New();
+ mPanGestureDetector.DetectedSignal().Connect( this, &DissolveEffectApp::OnPanGesture );
+
+ // create the dissolve effect object
+ mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision);
+ mNextImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision);
+
+ mViewTimer = Timer::New( VIEWINGTIME );
+ mViewTimer.TickSignal().Connect( this, &DissolveEffectApp::OnTimerTick );
+ mTimerReady = true;
+
+ // Set size to stage size to avoid seeing a black border on transition
+ mParent = Actor::New();
+ mParent.SetSize( Stage::GetCurrent().GetSize() );
+ mParent.SetPositionInheritanceMode( USE_PARENT_POSITION );
+ mContent.Add( mParent );
+
+ mSizeConstraint= Constraint::New( Actor::Property::Scale, LocalSource( Actor::Property::Size ), ParentSource( Actor::Property::Size ), ScaleToFitKeepAspectRatioConstraint() );
+
+ // show the first image
+ mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) );
+ mCurrentImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
+ mCurrentImage.ApplyConstraint( mSizeConstraint );
+ mParent.Add( mCurrentImage );
+
+ mPanGestureDetector.Attach( mCurrentImage );
+ }
+
+ // signal handler, called when the pan gesture is detected
+ void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture )
+ {
+ // does not response when the animation has not finished
+ if( mIsTransiting || mSlideshow )
+ {
+ return;
+ }
+
+ if( gesture.state == Gesture::Continuing )
+ {
+ if( gesture.displacement.x < 0)
+ {
+ mIndex = (mIndex + 1)%NUM_IMAGES;
+ }
+ else
+ {
+ mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES;
+ }
+
+ Image image = ResourceImage::New( IMAGES[ mIndex ] );
+ mNextImage = ImageActor::New( image );
+ mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
+ mNextImage.ApplyConstraint( mSizeConstraint );
+ mNextImage.SetZ(INITIAL_DEPTH);
+ mParent.Add( mNextImage );
+ Vector2 size = Vector2( mCurrentImage.GetCurrentSize() );
+ StartTransition( gesture.position / size, gesture.displacement * Vector2(1.0, size.x/size.y));
+ }
+ }
+
+ void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement)
+ {
+ mAnimation = Animation::New(TRANSITION_DURATION);
+
+ mCurrentImageEffect.SetCentralLine(position,displacement);
+ mCurrentImageEffect.SetDistortion(0.0f);
+ mCurrentImage.SetShaderEffect(mCurrentImageEffect);
+ mAnimation.AnimateTo( Property(mCurrentImageEffect, mCurrentImageEffect.GetDistortionPropertyName()), 1.0f, AlphaFunctions::Linear );
+
+ mNextImage.SetOpacity(0.0f);
+ mAnimation.OpacityTo( mNextImage, 1.0, AlphaFunctions::Linear );
+
+ if(mUseHighPrecision)
+ {
+ mNextImageEffect.SetCentralLine(position,-displacement);
+ mNextImageEffect.SetDistortion(1.0f);
+ mNextImage.SetShaderEffect(mNextImageEffect);
+ mAnimation.AnimateTo( Property(mNextImageEffect, mNextImageEffect.GetDistortionPropertyName()), 0.0f, AlphaFunctions::Linear );
+ }
+ else
+ {
+ mAnimation.MoveTo(mNextImage, Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Linear);
+ }
+
+ mAnimation.FinishedSignal().Connect( this, &DissolveEffectApp::OnTransitionCompleted );
+ mAnimation.Play();
+ mIsTransiting = true;
+ }
+
+ void DissolveEffectApp::OnKeyEvent(const KeyEvent& event)
+ {
+ if(event.state == KeyEvent::Down)
+ {
+ if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
+ {
+ mApplication.Quit();
+ }
+ }
+ }
+
+ bool DissolveEffectApp::OnEffectButtonClicked( Toolkit::Button button )
+ {
+ mUseHighPrecision = !mUseHighPrecision;
+ mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision);
+ if(mUseHighPrecision)
+ {
- mTitleActor.SetText( APPLICATION_TITLE_HIGHP );
+ mEffectChangeButton.SetBackgroundImage(mIconHighP);
+ }
+ else
+ {
- mTitleActor.SetText( APPLICATION_TITLE_MEDIUMP );
+ mEffectChangeButton.SetBackgroundImage(mIconMediumP);
+ }
- mTitleActor.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle());
+
+ return true;
+ }
+
+ bool DissolveEffectApp::OnSildeshowButtonClicked( Toolkit::Button button )
+ {
+ mSlideshow = !mSlideshow;
+ if( mSlideshow )
+ {
+ mPlayStopButton.SetBackgroundImage( mIconStop );
+ mPanGestureDetector.Detach( mParent );
+ mViewTimer.Start();
+ mTimerReady = false;
+ }
+ else
+ {
+ mPlayStopButton.SetBackgroundImage( mIconPlay );
+ mTimerReady = true;
+ mPanGestureDetector.Attach( mParent );
+ }
+ return true;
+ }
+
+ void DissolveEffectApp::OnTransitionCompleted( Animation& source )
+ {
+ mCurrentImage.RemoveShaderEffect();
+ mNextImage.RemoveShaderEffect();
+ mParent.Remove( mCurrentImage );
+ mPanGestureDetector.Detach( mCurrentImage );
+ mCurrentImage = mNextImage;
+ mPanGestureDetector.Attach( mCurrentImage );
+ mIsTransiting = false;
+
+ if( mSlideshow)
+ {
+ mViewTimer.Start();
+ mTimerReady = false;
+ }
+ }
+
+ bool DissolveEffectApp::OnTimerTick()
+ {
+ mTimerReady = true;
+ if(mSlideshow)
+ {
+ mIndex = (mIndex + 1)%NUM_IMAGES;
+ Image image = ResourceImage::New( IMAGES[ mIndex ] );
+ mNextImage = ImageActor::New( image );
+ mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
+ mNextImage.ApplyConstraint( mSizeConstraint );
+ mNextImage.SetZ(INITIAL_DEPTH);
+ mParent.Add( mNextImage );
+ switch( mCentralLineIndex%4 )
+ {
+ case 0:
+ {
+ StartTransition(Vector2(1.0f,0.5f), Vector2(-1.0f, 0.0f));
+ break;
+ }
+ case 1:
+ {
+ StartTransition(Vector2(0.5f,0.0f), Vector2(0.0f, 1.0f));
+ break;
+ }
+ case 2:
+ {
+ StartTransition(Vector2(0.0f,0.5f), Vector2(1.0f, 0.0f));
+ break;
+ }
+ default:
+ {
+ StartTransition(Vector2(0.5f,1.0f), Vector2(0.0f, -1.0f));
+ break;
+ }
+
+ }
+ mCentralLineIndex++;
+ }
+ return false; //return false to stop the timer
+ }
+
+ // Entry point for Linux & SLP applications
+ int main( int argc, char **argv )
+ {
+ Application application = Application::New( &argc, &argv );
+ DissolveEffectApp test( application );
+ application.MainLoop();
+
+ return 0;
+ }
diff --cc examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
index 00000000,437194cf..1d82b001
mode 000000,100644..100644
--- a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
+++ b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
@@@ -1,0 -1,597 +1,586 @@@
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+ /**
+ * @file image-scaling-irregular-grid-example.cpp
+ * @brief Demonstrates how to use image scaling modes when loading images.
+ *
+ * If an image is going to be drawn on-screen at a lower resolution than it is
+ * stored at on-disk, the scaling feature of the image loader can be used to
+ * reduce the image to save memory, improve performance, and potentially display
+ * a better small version of the image than if the default size were loaded.
+ *
+ * The functions CreateImage and CreateImageActor below show how to build an
+ * image using a scaling mode to have %Dali resize it during loading.
+ *
+ * This demo defaults to the ScaleToFill mode of ImageAttributes which makes
+ * sure that every pixel in the loaded image is filled with a source colour
+ * from the image's central region while losing the minimum number of pixels
+ * from its periphery.
+ * It is the best option for producing thumbnails of input images that have
+ * diverse aspect ratios.
+ *
+ * The other four scaling modes of dali can be cycled-through for the whole
+ * grid using the button in the top-right of the toolbar.
+ * A single image can be cycled by clicking the image directly.
+ *
+ * @see CreateImage CreateImageActor
+ */
+
+ // EXTERNAL INCLUDES
+ #include
+ #include