[tizen_9.0] Use InheritedVisibilityChanged signal instead of window visibility 63/316563/1 accepted/tizen_unified_dev accepted/tizen/unified/20240909.154227 accepted/tizen/unified/20240927.171106 accepted/tizen/unified/dev/20240910.111609 accepted/tizen/unified/toolchain/20241004.101355 accepted/tizen/unified/x/20240910.014243 accepted/tizen/unified/x/asan/20241013.235707
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 23 Aug 2024 01:55:10 +0000 (10:55 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 23 Aug 2024 01:57:25 +0000 (10:57 +0900)
Let we use InheritedVisibilityChanged signal for check the widget's visibility.

It could pause widget if widget view's parent is invisible, not only for the window.

Change-Id: I81ef10ddcce389e5ba1ee266d697d90a07108ed3
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
widget_viewer_dali/internal/widget_view/widget_view_impl.cpp
widget_viewer_dali/internal/widget_view/widget_view_impl.h

index c993ef2540ddcf0a54fa17f9556b271235931849..c1258cba53106eab1906688979962d8b63c77bae 100644 (file)
@@ -235,7 +235,7 @@ WidgetView::WidgetView()
   mResizeRequired( false ),
   mPaused( false ),
   mPausedManually( false ),
-  mWindowVisible( true ),
+  mWidgetVisible( false ),
   mPreviewEnable( true ),
   mKeepWidgetSize(false),
   mIsReadyToRender(false)
@@ -263,7 +263,7 @@ WidgetView::WidgetView( const std::string& widgetId, const std::string& contentI
   mResizeRequired( false ),
   mPaused( false ),
   mPausedManually( false ),
-  mWindowVisible( true ),
+  mWidgetVisible( false ),
   mPreviewEnable( true ),
   mKeepWidgetSize(false),
   mIsReadyToRender(false)
@@ -403,6 +403,7 @@ void WidgetView::InitializeEvents()
   auto self = Self();
   self.TouchedSignal().Connect( this, &WidgetView::OnTouch );
   self.WheelEventSignal().Connect( this, &WidgetView::OnWheelEvent );
+  self.InheritedVisibilityChangedSignal().Connect( this, &WidgetView::OnInheritedVisibilityChanged );
 
   // Accessibility
   self.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::FILLER);
@@ -802,8 +803,7 @@ void WidgetView::SendWidgetEvent( int event )
     case WIDGET_INSTANCE_EVENT_RESUME:
     {
       // Call Resume/Pause for reloading
-      bool needPaused = IsOutOfScreen();
-      if( mWindowVisible && !needPaused)
+      if( mWidgetVisible && !IsOutOfScreen())
       {
         ResumeWidgetInternally();
       }
@@ -1143,53 +1143,42 @@ Dali::Toolkit::DevelControl::ControlAccessible* WidgetView::CreateAccessibleObje
 
 void WidgetView::OnSceneConnection( int depth )
 {
-  Control::OnSceneConnection( depth );
-  Window window = DevelWindow::Get( Self() );
-  if( window )
-  {
-    DevelWindow::VisibilityChangedSignal( window ).Connect( this, &WidgetView::OnWindowVisibilityChanged );
+  // Add Notification for check WidgetView is out-of-screen or not.
+  auto self = Self();
+  mPositionUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_POSITION, StepCondition( 1.0f, 1.0f ) );
+  mPositionUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
+  mSizeUpdateNotification = self.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ) );
+  mSizeUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
+  mScaleUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) );
+  mScaleUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
 
-    // Add Notification for check WidgetView is out-of-screen or not.
-    auto self = Self();
-    mPositionUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_POSITION, StepCondition( 1.0f, 1.0f ) );
-    mPositionUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
-    mSizeUpdateNotification = self.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ) );
-    mSizeUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
-    mScaleUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) );
-    mScaleUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
+  mPositionUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
+  mSizeUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
+  mScaleUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
 
-    mPositionUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
-    mSizeUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
-    mScaleUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
-  }
+  Control::OnSceneConnection( depth );
 }
 
 void WidgetView::OnSceneDisconnection()
 {
+  Self().RemovePropertyNotification( mPositionUpdateNotification );
+  Self().RemovePropertyNotification( mSizeUpdateNotification );
+  Self().RemovePropertyNotification( mScaleUpdateNotification );
   Control::OnSceneDisconnection();
-  Window window = DevelWindow::Get( Self() );
-  if( window )
-  {
-    DevelWindow::VisibilityChangedSignal( window ).Disconnect( this, &WidgetView::OnWindowVisibilityChanged );
-
-    Self().RemovePropertyNotification( mPositionUpdateNotification );
-    Self().RemovePropertyNotification( mSizeUpdateNotification );
-    Self().RemovePropertyNotification( mScaleUpdateNotification );
-  }
 }
 
-void WidgetView::OnWindowVisibilityChanged( Window window, bool visible )
+void WidgetView::OnInheritedVisibilityChanged( Actor actor, bool isVisible )
 {
-  mWindowVisible = visible;
-  bool needPaused = IsOutOfScreen();
+  mWidgetVisible = isVisible;
   if( mPausedManually )
   {
-    mPaused = ( needPaused || !mWindowVisible );
+    mPaused = ( !mWidgetVisible || IsOutOfScreen());
     DALI_LOG_RELEASE_INFO("Do not resume widget, because widget is paued manually [%p]\n", this);
     return;
   }
 
-  if( mWindowVisible && !needPaused)
+  const bool needPaused = IsOutOfScreen();
+  if( mWidgetVisible && !needPaused)
   {
     ResumeWidgetInternally();
   }
@@ -1197,7 +1186,7 @@ void WidgetView::OnWindowVisibilityChanged( Window window, bool visible )
   {
     PauseWidgetInternally();
   }
-  DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnWindowVisibilityChanged: visibility is changed (visible: %d) [%p]\n", visible, this );
+  DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInheritedVisibilityChanged: visibility is changed (visible: %d) [%p]\n", visible, this );
 }
 
 void WidgetView::OnUpdateArea( Dali::PropertyNotification& source )
index 3599566c6bebfaf0a4eb7e4f3c01da3d64f40101..393dad1e584a519e0c8cdfc3f1f706aa0a662936 100644 (file)
@@ -508,9 +508,9 @@ private:
   void ResizeWidget(int width, int height);
 
   /**
-   * @brief Callback when the visibility of the window is changed.
+   * @brief Callback when the inherited visibility of the widget is changed.
    */
-  void OnWindowVisibilityChanged( Window window, bool visible );
+  void OnInheritedVisibilityChanged( Actor actor, bool visible );
 
   /**
    * @brief Callback when the actor area is changed
@@ -585,7 +585,7 @@ private:
   bool mResizeRequired;                      ///< Check whether widget instance need to resize.
   bool mPaused;                              ///< Check whether widget is paused or not
   bool mPausedManually;                      ///< Check whether widget is paused or not by application
-  bool mWindowVisible;                       ///< Check whether window is visible or not
+  bool mWidgetVisible;                       ///< Check whether widget is really visible or not (on scene + visible + window visible)
   bool mPreviewEnable;                       ///< Check whether preview is enable or not
   bool mKeepWidgetSize;                      ///< Check whether widget instance keep it's size or not
   bool mIsReadyToRender;                     ///< Check whether widget is ready to render or not