Revert "[SRUK] (StyleManager) Create a style manager"
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / control-impl.cpp
index 018e4f0..9347f6a 100644 (file)
 
 #include <dali/integration-api/debug.h>
 
+#include "dali-toolkit/internal/controls/style-change-processor.h"
 #include "dali-toolkit/internal/controls/relayout-controller.h"
 #include "dali-toolkit/internal/controls/relayout-helper.h"
 #include "dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h"
 #include "dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h"
 #include <dali-toolkit/public-api/controls/control.h>
 
-#include <dali-toolkit/public-api/styling/style-manager.h>
-#include <dali-toolkit/internal/styling/style-manager-impl.h>
-
 namespace Dali
 {
 
@@ -255,8 +253,7 @@ public:
     mIsKeyboardNavigationSupported(false),
     mIsKeyboardFocusGroup(false),
     mKeyEventSignalV2(),
-    mBackground( NULL ),
-    mFlags( Control::CONTROL_BEHAVIOUR_NONE )
+    mBackground( NULL )
   {
   }
 
@@ -531,8 +528,6 @@ public:
   // Background
   Background* mBackground;           ///< Only create the background if we use it
 
-  ControlBehaviour mFlags;           ///< Flags passed in from constructor
-
   // Properties - these need to be members of Internal::Control::Impl as they need to functions within this class.
   static PropertyRegistration PROPERTY_1;
   static PropertyRegistration PROPERTY_2;
@@ -554,7 +549,7 @@ PropertyRegistration Control::Impl::PROPERTY_7( CONTROL_TYPE, "key-input-focus",
 Toolkit::Control Control::New()
 {
   // Create the implementation, temporarily owned on stack
-  IntrusivePtr<Control> controlImpl = new Control( CONTROL_BEHAVIOUR_NONE );
+  IntrusivePtr<Control> controlImpl = new Control( false );
 
   // Pass ownership to handle
   Toolkit::Control handle( *controlImpl );
@@ -568,26 +563,22 @@ Toolkit::Control Control::New()
 
 Control::~Control()
 {
+  if( mImpl->mInitialized )
+  {
+    // Unregister only if control has been initialized.
+    Internal::StyleChangeProcessor::Unregister( this );
+  }
   delete mImpl;
 }
 
 void Control::Initialize()
 {
+  // Register with the style change processor so we are informed when the default style changes
+  Internal::StyleChangeProcessor::Register( this );
 
   // Calling deriving classes
   OnInitialize();
 
-  if( mImpl->mFlags & REQUIRES_THEME_CHANGE_SIGNALS )
-  {
-    Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
-
-    // Register for font/theme changes
-    styleManager.ThemeChangeSignal().Connect( this, &ControlImpl::OnThemeChange );
-
-    // Set theme
-    GetImpl( styleManager ).ApplyThemeStyle( GetOwner() );
-  }
-
   mImpl->mInitialized = true;
 }
 
@@ -1184,11 +1175,6 @@ void Control::NegotiateSize( Vector2 allocatedSize, ActorSizeContainer& containe
   Relayout( size, container );
 }
 
-void Control::OnThemeChange( Toolkit::StyleManager styleManager )
-{
-  GetImpl( styleManager ).ApplyThemeStyle( GetOwner() );
-}
-
 bool Control::EmitKeyEventSignal( const KeyEvent& event )
 {
   // Guard against destruction during signal emission
@@ -1232,13 +1218,6 @@ Control::Control( bool requiresTouchEvents )
 {
 }
 
-Control::Control( ControlBehaviour behaviourFlags )
-: CustomActorImpl( behaviourFlags & REQUIRES_TOUCH_EVENTS ),
-  mImpl(new Impl(*this))
-{
-  mImpl->mFlags = behaviourFlags;
-}
-
 } // namespace Internal
 
 } // namespace Toolkit