Merge "Button should not propagate handled touch events" into devel/master
authorDavid Steele <david.steele@samsung.com>
Wed, 10 Jan 2018 13:07:33 +0000 (13:07 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Wed, 10 Jan 2018 13:07:33 +0000 (13:07 +0000)
automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h [new file with mode: 0644]
dali-toolkit/devel-api/visuals/image-visual-actions-devel.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp
dali-toolkit/internal/visuals/animated-image/animated-image-visual.h

index 2804868..0e06386 100644 (file)
@@ -24,6 +24,7 @@
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
 #include "dummy-control.h"
 
 using namespace Dali;
@@ -648,4 +649,78 @@ int UtcDaliAnimatedImageVisualLoopCount(void)
   }
 
   END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualPlayback(void)
+{
+  ToolkitTestApplication application;
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+  TraceCallStack& textureTrace = gl.GetTextureTrace();
+
+  tet_infoline( "UtcDaliAnimatedImageVisualPlayback" );
+
+  {
+    // request AnimatedImageVisual with a property map
+    // Test with forever (-1) loop count
+    VisualFactory factory = VisualFactory::Get();
+    Visual::Base animatedImageVisual = factory.CreateVisual(
+      Property::Map()
+      .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
+      .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
+      .Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
+      .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
+      .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
+      .Add( DevelImageVisual::Property::LOOP_COUNT, -1 ));
+
+    DummyControl dummyControl = DummyControl::New(true);
+    Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, animatedImageVisual );
+    dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+    textureTrace.Enable(true);
+    Stage::GetCurrent().Add( dummyControl );
+    application.SendNotification();
+    application.Render(16);
+
+    tet_infoline( "Test that a timer has been created" );
+    DALI_TEST_EQUALS( Test::GetTimerCount(), 1, TEST_LOCATION );
+
+    Test::EmitGlobalTimerSignal();
+    application.SendNotification();
+    application.Render(16);
+    DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
+
+    Property::Map attributes;
+    tet_infoline( "Test Pause action. Timer should stop after Pause action" );
+    DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PAUSE, attributes );
+    Test::EmitGlobalTimerSignal();
+    application.SendNotification();
+    application.Render(16);
+    DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
+
+    tet_infoline( "Test Play action. Timer should Restart after Play action" );
+    DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
+    Test::EmitGlobalTimerSignal();
+    application.SendNotification();
+    application.Render(16);
+    DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
+
+    tet_infoline( "Test Stop action. Timer should stop after Stop action" );
+    DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::STOP, attributes );
+    Test::EmitGlobalTimerSignal();
+    application.SendNotification();
+    application.Render(16);
+    DALI_TEST_EQUALS( Test::AreTimersRunning(), false, TEST_LOCATION );
+
+    tet_infoline( "Test Play action. Timer should Restart after Play action" );
+    DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes );
+    Test::EmitGlobalTimerSignal();
+    application.SendNotification();
+    application.Render(16);
+    DALI_TEST_EQUALS( Test::AreTimersRunning(), true, TEST_LOCATION );
+
+    dummyControl.Unparent();
+  }
+
+  END_TEST;
 }
\ No newline at end of file
index 812668b..03b3b6e 100644 (file)
@@ -92,6 +92,7 @@ devel_api_visual_factory_header_files = \
 
 devel_api_visuals_header_files = \
   $(devel_api_src_dir)/visuals/animated-gradient-visual-properties-devel.h \
+  $(devel_api_src_dir)/visuals/animated-image-visual-actions-devel.h \
   $(devel_api_src_dir)/visuals/color-visual-properties-devel.h \
   $(devel_api_src_dir)/visuals/image-visual-properties-devel.h \
   $(devel_api_src_dir)/visuals/image-visual-actions-devel.h \
diff --git a/dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h b/dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h
new file mode 100644 (file)
index 0000000..b654a69
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef DALI_TOOLKIT_DEVEL_API_VISUALS_ANIMATED_IMAGE_VISUAL_ACTIONS_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_VISUALS_ANIMATED_IMAGE_VISUAL_ACTIONS_DEVEL_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelAnimatedImageVisual
+{
+
+/**
+ * @brief Actions that the animated image visual can perform.  These actions are called through the Visual::Base::DoAction API.
+ */
+namespace Action
+{
+/**
+ * @brief The available actions for this visual
+ */
+enum Type
+{
+  PLAY,        ///< Play the animated GIF. This is also Default playback mode.
+  PAUSE,       ///< Pause the animated GIF.
+  STOP         ///< Stop the animated GIF.
+};
+
+} // namespace Action
+
+} // namespace DevelAnimatedImageVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_DEVEL_API_VISUALS_ANIMATED_IMAGE_VISUAL_ACTIONS_DEVEL_H
index f76e772..78a1451 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_DEVEL_API_VISUALS_IMAGE_VISUAL_ACTIONS_DEVEL_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -37,7 +37,7 @@ namespace Action
  */
 enum Type
 {
-  RELOAD = 0,  ///< Force reloading of the image, all visuals using this image will get the latest one.
+  RELOAD = 0  ///< Force reloading of the image, all visuals using this image will get the latest one.
 };
 
 } // namespace Actions
index c618006..6580790 100755 (executable)
@@ -1877,6 +1877,7 @@ Vector3 Controller::GetNaturalSize()
 
     // Clear the update info. This info will be set the next time the text is updated.
     mImpl->mTextUpdateInfo.Clear();
+    mImpl->mTextUpdateInfo.mClearAll = true;
 
     // Restore the actual control's size.
     mImpl->mModel->mVisualModel->mControlSize = actualControlSize;
index d37863e..d9c4cd4 100755 (executable)
@@ -179,6 +179,7 @@ AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache )
   mImageSize(),
   mWrapModeU( WrapMode::DEFAULT ),
   mWrapModeV( WrapMode::DEFAULT ),
+  mActionStatus( DevelAnimatedImageVisual::Action::PLAY ),
   mStartFirstFrame(false)
 {}
 
@@ -242,6 +243,38 @@ void AnimatedImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) cons
   // Do nothing
 }
 
+void AnimatedImageVisual::OnDoAction( const Dali::Property::Index actionId, const Dali::Property::Value& attributes )
+{
+  // Check if action is valid for this visual type and perform action if possible
+
+  switch ( actionId )
+  {
+    case DevelAnimatedImageVisual::Action::PAUSE:
+    {
+      // Pause will be executed on next timer tick
+      mActionStatus = DevelAnimatedImageVisual::Action::PAUSE;
+      break;
+    }
+    case DevelAnimatedImageVisual::Action::PLAY:
+    {
+      if( IsOnStage() && mActionStatus != DevelAnimatedImageVisual::Action::PLAY )
+      {
+        mFrameDelayTimer.Start();
+      }
+      mActionStatus = DevelAnimatedImageVisual::Action::PLAY;
+      break;
+    }
+    case DevelAnimatedImageVisual::Action::STOP:
+    {
+      // STOP reset functionality will actually be done in a future change
+      // Stop will be executed on next timer tick
+      mCurrentFrameIndex = 0;
+      mActionStatus = DevelAnimatedImageVisual::Action::STOP;
+      break;
+    }
+  }
+}
+
 void AnimatedImageVisual::DoSetProperties( const Property::Map& propertyMap )
 {
   // url[s] already passed in from constructor
@@ -561,6 +594,10 @@ void AnimatedImageVisual::FrameReady( TextureSet textureSet )
 
 bool AnimatedImageVisual::DisplayNextFrame()
 {
+  if( mActionStatus == DevelAnimatedImageVisual::Action::STOP || mActionStatus == DevelAnimatedImageVisual::Action::PAUSE )
+  {
+    return false;
+  }
   if( mFrameCount > 1 )
   {
     // Wrap the frame index
@@ -593,12 +630,14 @@ bool AnimatedImageVisual::DisplayNextFrame()
   }
 
   TextureSet textureSet;
-  if (mImageCache)
-    textureSet = mImageCache->NextFrame();
-  if( textureSet )
+  if( mImageCache )
   {
-    SetImageSize( textureSet );
-    mImpl->mRenderer.SetTextures( textureSet );
+    textureSet = mImageCache->NextFrame();
+    if( textureSet )
+    {
+      SetImageSize( textureSet );
+      mImpl->mRenderer.SetTextures( textureSet );
+    }
   }
 
   // Keep timer ticking
index e92c5ef..0db9154 100644 (file)
@@ -30,6 +30,7 @@
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-url.h>
 #include <dali-toolkit/internal/visuals/animated-image/image-cache.h>
+#include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
 
 namespace Dali
 {
@@ -130,6 +131,11 @@ public:  // from Visual
    */
   virtual void DoCreateInstancePropertyMap( Property::Map& map ) const;
 
+  /**
+   * @copydoc Visual::Base::OnDoAction
+   */
+  virtual void OnDoAction( const Dali::Property::Index actionName, const Dali::Property::Value& attributes ) override;
+
 protected:
 
   /**
@@ -252,6 +258,7 @@ private:
 
   Dali::WrapMode::Type mWrapModeU:3;
   Dali::WrapMode::Type mWrapModeV:3;
+  DevelAnimatedImageVisual::Action::Type mActionStatus:2;
   bool mStartFirstFrame:1;
 };