Merge "support grabHandleColor property to TextField/TextEditor" into devel/master
authorBowon Ryu <bowon.ryu@samsung.com>
Wed, 24 Mar 2021 04:24:32 +0000 (04:24 +0000)
committerGerrit Code Review <gerrit@review>
Wed, 24 Mar 2021 04:24:32 +0000 (04:24 +0000)
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window-impl.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.h
automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.h
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp

index 4a5e76c..9909164 100755 (executable)
@@ -109,6 +109,26 @@ public:
 
   }
 
+  void RaiseAbove(Dali::VideoPlayer target)
+  {
+
+  }
+
+  void LowerBelow(Dali::VideoPlayer target)
+  {
+
+  }
+
+  void RaiseToTop()
+  {
+
+  }
+
+  void LowerToBottom()
+  {
+
+  }
+
 public:
 
   std::string mUrl;
@@ -325,5 +345,25 @@ void VideoPlayer::FinishSynchronization()
   Internal::Adaptor::GetImplementation( *this ).FinishSynchronization();
 }
 
+void VideoPlayer::RaiseAbove(Dali::VideoPlayer target)
+{
+  Internal::Adaptor::GetImplementation( *this ).RaiseAbove(target);
+}
+
+void VideoPlayer::LowerBelow(Dali::VideoPlayer target)
+{
+  Internal::Adaptor::GetImplementation( *this ).LowerBelow(target);
+}
+
+void VideoPlayer::RaiseToTop()
+{
+  Internal::Adaptor::GetImplementation( *this ).RaiseToTop();
+}
+
+void VideoPlayer::LowerToBottom()
+{
+  Internal::Adaptor::GetImplementation( *this ).LowerToBottom();
+}
+
 } // namespace Dali;
 
index 25e0a16..f443251 100644 (file)
@@ -44,6 +44,8 @@ public:
   virtual ~Window() = default;
   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent);
   FocusChangeSignalType mFocusChangeSignal;
+  ResizeSignalType      mResizeSignal;
+  int                   mRotationAngle;
   DevelWindow::VisibilityChangedSignalType mVisibilityChangedSignal;
 };
 
index 9e9ca35..9ab5021 100644 (file)
@@ -46,6 +46,8 @@ namespace Adaptor
 Window::Window( const PositionSize& positionSize )
 : SceneHolder( positionSize ),
   mFocusChangeSignal(),
+  mResizeSignal(),
+  mRotationAngle(90), // dummy angle for test coverage
   mVisibilityChangedSignal()
 {
 }
@@ -160,6 +162,11 @@ FocusChangeSignalType& Window::FocusChangeSignal()
   return GetImplementation( *this ).mFocusChangeSignal;
 }
 
+ResizeSignalType& Window::ResizeSignal()
+{
+  return GetImplementation( *this ).mResizeSignal;
+}
+
 Window::KeyEventSignalType& Window::KeyEventSignal()
 {
   return GetImplementation( *this ).KeyEventSignal();
@@ -195,6 +202,17 @@ Window DownCast( BaseHandle handle )
   return Dali::Window( windowImpl );
 }
 
+void SetPositionSize(Window window, PositionSize positionSize)
+{
+  Uint16Pair newSize(positionSize.width, positionSize.height);
+  GetImplementation( window ).mResizeSignal.Emit(window,newSize);
+}
+
+int GetPhysicalOrientation(Window window)
+{
+  return GetImplementation( window ).mRotationAngle;
+}
+
 void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
 {
   CallbackBase::Execute( *callback, frameId );
index 2291139..a696684 100644 (file)
@@ -47,12 +47,16 @@ class Window;
 
 class Window;
 typedef Signal< void (Window,bool) > FocusChangeSignalType;
+typedef Signal< void (Window,Uint16Pair) > ResizeSignalType;
 
 class Window : public BaseHandle
 {
 public:
+  using WindowSize     = Uint16Pair;
+
   using KeyEventSignalType = Signal< void (const KeyEvent&) >;
   using TouchEventSignalType = Signal< void (const TouchEvent&) >;
+  using ResizeSignalType      = Signal<void(Window, WindowSize)>;
 
   static Window New(PositionSize windowPosition, const std::string& name, bool isTransparent = false);
   static Window New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false);
@@ -76,6 +80,7 @@ public:
   FocusChangeSignalType& FocusChangeSignal();
   KeyEventSignalType& KeyEventSignal();
   TouchEventSignalType& TouchedSignal();
+  ResizeSignalType& ResizeSignal();
 
 public:
   explicit Window( Internal::Adaptor::Window* window );
@@ -93,6 +98,8 @@ typedef Signal< void ( Window, bool ) > VisibilityChangedSignalType;
 
 Dali::Window Get( Actor actor );
 Dali::Window DownCast(  BaseHandle handle );
+void SetPositionSize(Window window, PositionSize positionSize);
+int GetPhysicalOrientation(Window window);
 void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId );
 void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId );
 
index b0aa75e..9a77bba 100644 (file)
@@ -21,6 +21,7 @@
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
 #include <dali-toolkit/devel-api/controls/video-view/video-view-devel.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
 
 using namespace Dali;
@@ -559,6 +560,65 @@ int UtcDaliVideoViewNew2(void)
   END_TEST;
 }
 
+int UtcDaliVideoViewRaiseAboveLowerBelow(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewRaiseAboveLowerBelow");
+
+  VideoView view = VideoView::New( true );
+  DALI_TEST_CHECK( view );
+
+  application.GetScene().Add( view );
+  view.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  VideoView view2 = VideoView::New( "", false );
+  DALI_TEST_CHECK( view2 );
+
+  application.GetScene().Add( view2 );
+  view2.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  view.RaiseAbove(view2);
+  view.LowerBelow(view2);
+
+  END_TEST;
+}
+
+int UtcDaliVideoViewRaiseTopLowerBottom(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewRaiseTopLowerBottom");
+
+  VideoView view = VideoView::New( true );
+  DALI_TEST_CHECK( view );
+
+  application.GetScene().Add( view );
+  view.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  VideoView view2 = VideoView::New( "", false );
+  DALI_TEST_CHECK( view2 );
+
+  application.GetScene().Add( view2 );
+  view2.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  view.RaiseToTop();
+  view.LowerToBottom();
+
+  END_TEST;
+}
+
+
 int UtcDaliVideoViewPropertyDisplayMode(void)
 {
   ToolkitTestApplication application;
@@ -787,3 +847,27 @@ int UtcDaliVideoViewResizeWithSynchronization(void)
 
   END_TEST;
 }
+
+// For coverage.
+int UtcDaliVideoViewSynchronizationForWindowRotation(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewSynchronizationForWindowRotation");
+
+  Window window = Window::New(PositionSize(0,0,100,100) ,"", false);
+  DALI_TEST_CHECK( window );
+
+  VideoView view = VideoView::New( true );
+  DALI_TEST_CHECK( view );
+
+  window.Add( view );
+
+  view.Play();
+
+  DevelWindow::SetPositionSize(window,PositionSize(0,0,480, 240));
+
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
index 5608105..85b219e 100644 (file)
@@ -83,6 +83,8 @@ const char* const CUSTOM_FRAGMENT_SHADER("fragmentShader");
 const char* const DEFAULT_SAMPLER_TYPE_NAME("sampler2D");
 const char* const CUSTOM_SAMPLER_TYPE_NAME("samplerExternalOES");
 
+const char* const IS_VIDEO_VIEW_PROPERTY_NAME = "isVideoView";
+
 } // namespace
 
 VideoView::VideoView(Dali::VideoSyncMode syncMode)
@@ -91,7 +93,8 @@ VideoView::VideoView(Dali::VideoSyncMode syncMode)
   mFrameID(0),
   mIsPlay(false),
   mIsUnderlay(true),
-  mSyncMode(syncMode)
+  mSyncMode(syncMode),
+  mSiblingOrder(0)
 {
 }
 
@@ -111,12 +114,16 @@ Toolkit::VideoView VideoView::New(VideoSyncMode syncMode)
 
 void VideoView::OnInitialize()
 {
+  Actor self = Self();
   mVideoPlayer.FinishedSignal().Connect(this, &VideoView::EmitSignalFinish);
 
-  DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
+  DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
     return std::unique_ptr<Dali::Accessibility::Accessible>(
       new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::VIDEO));
   });
+
+  //update self property
+  self.RegisterProperty(IS_VIDEO_VIEW_PROPERTY_NAME, true, Property::READ_WRITE);
 }
 
 void VideoView::SetUrl(const std::string& url)
@@ -503,12 +510,15 @@ void VideoView::SetDepthIndex(int depthIndex)
 
 void VideoView::OnSceneConnection(int depth)
 {
-  Control::OnSceneConnection(depth);
-
+  Actor self = Self();
   if(mIsUnderlay)
   {
+    mSiblingOrder = self.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER);
+    DevelActor::ChildOrderChangedSignal(self.GetParent()).Connect(this, &VideoView::OnChildOrderChanged);
     SetWindowSurfaceTarget();
   }
+
+  Control::OnSceneConnection(depth);
 }
 
 void VideoView::OnSceneDisconnection()
@@ -526,6 +536,57 @@ void VideoView::OnSizeSet(const Vector3& targetSize)
   Control::OnSizeSet(targetSize);
 }
 
+void VideoView::OnChildOrderChanged(Actor actor)
+{
+  Actor self                = Self();
+  int   currentSiblingOrder = self.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER);
+  if(currentSiblingOrder != mSiblingOrder)
+  {
+    Actor parent = self.GetParent();
+    Actor child;
+    Actor upper;
+    Actor lower;
+
+    int numChildren = static_cast<int>(parent.GetChildCount());
+    for(int i = 0; i < numChildren; i++)
+    {
+      child = parent.GetChildAt(i);
+      if(!IsVideoView(child))
+      {
+        continue;
+      }
+
+      if(child == self)
+      {
+        continue;
+      }
+
+      if(i < currentSiblingOrder)
+      {
+        lower = child;
+      }
+      else if(i > currentSiblingOrder)
+      {
+        upper = child;
+        break;
+      }
+    }
+
+    if(lower)
+    {
+      Toolkit::VideoView lowerView = Toolkit::VideoView::DownCast(lower);
+      mVideoPlayer.RaiseAbove(GetImpl(lowerView).GetVideoPlayer());
+    }
+
+    if(upper)
+    {
+      Toolkit::VideoView upperView = Toolkit::VideoView::DownCast(upper);
+      mVideoPlayer.LowerBelow(GetImpl(upperView).GetVideoPlayer());
+    }
+    mSiblingOrder = currentSiblingOrder;
+  }
+}
+
 Vector3 VideoView::GetNaturalSize()
 {
   Vector3 size;
@@ -577,6 +638,9 @@ void VideoView::SetWindowSurfaceTarget()
     return;
   }
 
+  Dali::Window window = DevelWindow::Get(self);
+  window.ResizeSignal().Connect(this, &VideoView::OnWindowResized);
+
   int curPos = mVideoPlayer.GetPlayPosition();
 
   if(mIsPlay)
@@ -782,6 +846,17 @@ void VideoView::OnAnimationFinished(Animation& animation)
   SetFrameRenderCallback();
 }
 
+void VideoView::OnWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size)
+{
+  Dali::VideoPlayerPlugin::DisplayRotation videoAngle  = mVideoPlayer.GetDisplayRotation();
+  int                                      windowAngle = (DevelWindow::GetPhysicalOrientation(winHandle) / 90);
+
+  if(windowAngle != videoAngle)
+  {
+    mVideoPlayer.SetDisplayRotation(static_cast<Dali::VideoPlayerPlugin::DisplayRotation>(windowAngle));
+  }
+}
+
 void VideoView::PlayAnimation(Dali::Animation animation)
 {
   if(mIsUnderlay && mSyncMode == Dali::VideoSyncMode::ENABLED)
@@ -879,6 +954,28 @@ void VideoView::SetFrameRenderCallback()
                                         mFrameID);
 }
 
+bool VideoView::IsVideoView(Actor actor) const
+{
+  // Check whether the actor is a VideoView
+  bool isVideoView = false;
+
+  if(actor)
+  {
+    Property::Index propertyIsVideoView = actor.GetPropertyIndex(IS_VIDEO_VIEW_PROPERTY_NAME);
+    if(propertyIsVideoView != Property::INVALID_INDEX)
+    {
+      isVideoView = actor.GetProperty<bool>(propertyIsVideoView);
+    }
+  }
+
+  return isVideoView;
+}
+
+VideoPlayer VideoView::GetVideoPlayer()
+{
+  return mVideoPlayer;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 4d76176..d1605ce 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/devel-api/adaptor-framework/video-player.h>
 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
 #include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
+#include <dali/public-api/adaptor-framework/window.h>
 #include <dali/public-api/images/image-operations.h>
 #include <dali/public-api/object/property-conditions.h>
 #include <dali/public-api/object/property-map.h>
@@ -262,6 +263,21 @@ public:
    */
   void PlayAnimation(Dali::Animation animation);
 
+  /**
+   * @brief Checks whether the actor is set as a video view or not.
+   *
+   * @param[in] actor The actor to be checked
+   * @return True if actor is video view.
+   */
+  bool IsVideoView(Actor actor) const;
+
+  /**
+   * @brief Gets the Video Player.
+   *
+   * @return The return of video player.
+   */
+  VideoPlayer GetVideoPlayer();
+
 private: // From Control
   /**
    * @copydoc Toolkit::Control::OnInitialize()
@@ -365,6 +381,22 @@ private:
    */
   void OnAnimationFinished(Dali::Animation& animation);
 
+  /*
+   * @brief window's resize callback function
+   * This function is called when window is resized.
+   *
+   * @param[in] winHandle The resized window's handle.
+   * @param[in] size The window's new size.
+   */
+  void OnWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size);
+
+  /**
+   * @brief This signal is emitted when an actor's children change their sibling order
+   *
+   * @param[in] actor parent actor.
+   */
+  void OnChildOrderChanged(Actor actor);
+
 private:
   Dali::VideoPlayer     mVideoPlayer;
   Dali::ImageDimensions mVideoSize;
@@ -392,6 +424,7 @@ private:
   bool mIsUnderlay;
 
   Dali::VideoSyncMode mSyncMode;
+  int                 mSiblingOrder;
 };
 
 } // namespace Internal
index 4e95dfe..bb8571d 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/devel-api/adaptor-framework/image-loading.h>
 #include <dali/devel-api/rendering/renderer-devel.h>
 #include <dali/integration-api/debug.h>
+#include <dali/devel-api/common/stage.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
@@ -364,7 +365,7 @@ NPatchVisual::NPatchVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFa
 
 NPatchVisual::~NPatchVisual()
 {
-  if((mId != NPatchData::INVALID_NPATCH_DATA_ID) && (mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER))
+  if(Stage::IsInstalled() && (mId != NPatchData::INVALID_NPATCH_DATA_ID) && (mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER))
   {
     mLoader.Remove(mId, this);
     mId = NPatchData::INVALID_NPATCH_DATA_ID;