(StyleManager) Add style monitor signal into StyleManager
authorKingsley Stephens <k.stephens@partner.samsung.com>
Thu, 29 May 2014 14:27:41 +0000 (15:27 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 11 Jun 2014 07:57:05 +0000 (08:57 +0100)
[problem]      The StyleManager was missing the StyleMonitor signal
[solution]     Connect StyleManager to StyleMonitor style change signal

               patch 2: combine ThemeChangeSignal and StyleChangeSignal into one

Change-Id: I8141b0b71091b42b6c0a2db047272ded6d21b273

24 files changed:
automated-tests/TET/dali-test-suite/control/dummy-control.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp
base/dali-toolkit/internal/controls/buttons/button-impl.cpp
base/dali-toolkit/internal/controls/popup/popup-impl.cpp
base/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp
base/dali-toolkit/internal/controls/style-change-processor.cpp [deleted file]
base/dali-toolkit/internal/controls/style-change-processor.h [deleted file]
base/dali-toolkit/internal/controls/table-view/table-view-impl.cpp
base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp
base/dali-toolkit/internal/controls/text-view/text-view-impl.cpp
base/dali-toolkit/internal/controls/text-view/text-view-impl.h
base/dali-toolkit/internal/styling/style-manager-impl.cpp
base/dali-toolkit/internal/styling/style-manager-impl.h
base/dali-toolkit/public-api/controls/control-impl.cpp
base/dali-toolkit/public-api/controls/scrollable/scroll-component-impl.cpp
base/dali-toolkit/public-api/styling/style-manager.cpp
base/dali-toolkit/public-api/styling/style-manager.h
capi/dali-toolkit/public-api/controls/control-impl.h
optional/dali-toolkit/internal/controls/cluster/cluster-impl.cpp
optional/dali-toolkit/internal/controls/image-view/image-view-impl.cpp
optional/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp
optional/dali-toolkit/internal/controls/slider/slider-impl.cpp

index 18c10f9..0adee2d 100644 (file)
@@ -138,7 +138,8 @@ private:
   DummyControlImplOverride()
   : DummyControlImpl(),
     initializeCalled(false),
-    styleChangeCalled(false),
+    themeChangeCalled(false),
+    fontChangeCalled( false ),
     pinchCalled(false),
     panCalled(false),
     tapCalled(false),
@@ -162,7 +163,8 @@ private:
 private: // From ControlImpl
 
   virtual void OnInitialize() { initializeCalled = true; }
-  virtual void OnStyleChange(StyleChange change) { styleChangeCalled = true;}
+  virtual void OnThemeChange( StyleManager styleManager ) { themeChangeCalled = true }
+  virtual void OnFontChange( bool defaultFontChange, bool defaultFontSizeChange ) { fontChangeCalled = true;}
   virtual void OnPinch(PinchGesture pinch) { pinchCalled = true; }
   virtual void OnPan(PanGesture pan) { panCalled = true; }
   virtual void OnTap(TapGesture tap) { tapCalled = true; }
@@ -185,7 +187,8 @@ private: // From CustomActorImpl
 public:
 
   bool initializeCalled;
-  bool styleChangeCalled;
+  bool themeChangeCalled;
+  bool fontChangeCalled;
   bool pinchCalled;
   bool panCalled;
   bool tapCalled;
index 8640002..76893de 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "dummy-control.h"
 
+#include <dali-toolkit/public-api/styling/style-manager.h>
+
 namespace Dali
 {
 
@@ -65,7 +67,7 @@ DummyControl DummyControlImpl::New()
 }
 
 DummyControlImpl::DummyControlImpl()
-: Control(true)
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) )
 {
 }
 
@@ -85,7 +87,8 @@ DummyControl DummyControlImplOverride::New()
 DummyControlImplOverride::DummyControlImplOverride()
 : DummyControlImpl(),
   initializeCalled(false),
-  styleChangeCalled(false),
+  themeChangeCalled( false ),
+  fontChangeCalled( false ),
   pinchCalled(false),
   panCalled(false),
   tapCalled(false),
@@ -108,7 +111,8 @@ DummyControlImplOverride::~DummyControlImplOverride() { }
 
 
 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
-void DummyControlImplOverride::OnStyleChange(StyleChange change) { styleChangeCalled = true;}
+void DummyControlImplOverride::OnThemeChange(StyleManager change) { themeChangeCalled = true;}
+void DummyControlImplOverride::OnFontChange(bool defaultFontChange, bool defaultFontSizeChange) { fontChangeCalled = true; }
 void DummyControlImplOverride::OnPinch(PinchGesture pinch) { pinchCalled = true; }
 void DummyControlImplOverride::OnPan(PanGesture pan) { panCalled = true; }
 void DummyControlImplOverride::OnTap(TapGesture tap) { tapCalled = true; }
index 649ac0a..40dcf4f 100644 (file)
@@ -104,7 +104,8 @@ private:
 private: // From Internal::Control
 
   virtual void OnInitialize();
-  virtual void OnStyleChange(StyleChange change);
+  virtual void OnThemeChange( StyleManager styleManager );
+  virtual void OnFontChange(bool defaultFontChange, bool defaultFontSizeChange);
   virtual void OnPinch(PinchGesture pinch);
   virtual void OnPan(PanGesture pan);
   virtual void OnTap(TapGesture tap);
@@ -127,7 +128,8 @@ private: // From CustomActorImpl
 public:
 
   bool initializeCalled;
-  bool styleChangeCalled;
+  bool themeChangeCalled;
+  bool fontChangeCalled;
   bool pinchCalled;
   bool panCalled;
   bool tapCalled;
index f704531..1e40bcc 100644 (file)
@@ -652,13 +652,13 @@ int UtcDaliControlImplStyleChange(void)
   Actor actor = Actor::New();
   dummy.Add(actor);
 
-  DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, false, TEST_LOCATION );
+  DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, false, TEST_LOCATION );
   StyleChange styleChange;
   styleChange.defaultFontChange = true;
   Dali::StyleMonitor styleMonitor = application.GetAdaptor().GetToolkitStyleMonitor();
   styleMonitor.EmitStyleChangeSignal(styleChange);
 
-  DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, true, TEST_LOCATION );
+  DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, true, TEST_LOCATION );
 
   Stage::GetCurrent().Remove(dummy);
   END_TEST;
index 941ebcc..f3efbc3 100644 (file)
@@ -52,7 +52,7 @@ PropertyRegistration property1( typeRegistration, "dimmed", Toolkit::Button::PRO
 } // unnamed namespace
 
 Button::Button()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mState( ButtonUp ),
   mDimmed( false ),
   mPainter( NULL )
index 7f3b7c0..e453401 100755 (executable)
@@ -169,7 +169,7 @@ Dali::Toolkit::Popup Popup::New()
 }
 
 Popup::Popup(PopupStyle& style)
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mShowing(false),
   mState(Toolkit::Popup::POPUP_NONE), // Initially, the popup state should not be set, it's set in OnInitialize
   mAlterAddedChild(false),
index 6c4da93..ac8b7f1 100644 (file)
@@ -61,7 +61,7 @@ const Vector4     Scrollable::DEFAULT_OVERSHOOT_COLOUR(0.0f, 0.64f, 0.85f, 0.6f)
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 Scrollable::Scrollable()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mPropertyRelativePosition(Property::INVALID_INDEX),
   mPropertyPositionMin(Property::INVALID_INDEX),
   mPropertyPositionMax(Property::INVALID_INDEX),
diff --git a/base/dali-toolkit/internal/controls/style-change-processor.cpp b/base/dali-toolkit/internal/controls/style-change-processor.cpp
deleted file mode 100644 (file)
index 46f940e..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
-
-#include "style-change-processor.h"
-
-#include <boost/thread/tss.hpp>
-
-#include "dali-toolkit/public-api/controls/control.h"
-#include "dali-toolkit/public-api/controls/control-impl.h"
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-boost::thread_specific_ptr<StyleChangeProcessor> gThreadLocalStyleChangeProcessor;
-} // unnamed namespace
-
-StyleChangeProcessor::~StyleChangeProcessor()
-{
-}
-
-void StyleChangeProcessor::Register( Control* control )
-{
-  // Only create a style change processor if we have not created one in the local thread storage.
-  if (!gThreadLocalStyleChangeProcessor.get())
-  {
-    gThreadLocalStyleChangeProcessor.reset(new StyleChangeProcessor);
-  }
-
-  gThreadLocalStyleChangeProcessor->Reference();
-
-  std::vector<Control*>& controls( gThreadLocalStyleChangeProcessor->mControls );
-
-  // Store the Control raw pointer to allow traverse all off stage controls.
-  DALI_ASSERT_ALWAYS( ( std::find( controls.begin(), controls.end(), control ) == controls.end() ) && "StyleChangeProcessor::Register. The control has been registered twice." );
-
-  controls.push_back( control );
-}
-
-void StyleChangeProcessor::Unregister( Control* control )
-{
-  if (gThreadLocalStyleChangeProcessor.get())
-  {
-    std::vector<Control*>& controls( gThreadLocalStyleChangeProcessor->mControls );
-
-    // Removes the control from the vector as is not needed to notify it about style changes.
-    std::vector<Control*>::iterator it = std::find( controls.begin(), controls.end(), control );
-    std::vector<Control*>::iterator endIt = controls.end();
-    DALI_ASSERT_ALWAYS( ( it != endIt ) && "StyleChangeProcessor::UnRegister. The control has not been registered in the StyleChangeProcessor." );
-
-    *it = *(endIt - 1);
-    controls.erase( endIt - 1 );
-
-    gThreadLocalStyleChangeProcessor->Unreference();
-  }
-}
-
-void StyleChangeProcessor::Reference()
-{
-  ++mCount;
-}
-
-void StyleChangeProcessor::Unreference()
-{
-  if (--mCount == 0)
-  {
-    // If our count is 0, then we should reset the local storage which will call our destructor as well.
-    gThreadLocalStyleChangeProcessor.reset();
-  }
-}
-
-StyleChangeProcessor::StyleChangeProcessor()
-: mCount(0)
-{
-  if ( Adaptor::IsAvailable() )
-  {
-    StyleMonitor::Get().StyleChangeSignal().Connect(this, &StyleChangeProcessor::StyleChanged);
-  }
-}
-
-void StyleChangeProcessor::StyleChanged(Dali::StyleMonitor styleMonitor, StyleChange styleChange)
-{
-  // Traverse all registered controls.
-  std::vector<Control*>& controls( gThreadLocalStyleChangeProcessor->mControls );
-
-  for( std::vector<Control*>::iterator it = controls.begin(), endIt = controls.end(); it != endIt; ++it )
-  {
-    // Create a valid handle.
-    IntrusivePtr<Control> implementation( *it );
-
-    if (implementation)
-    {
-      implementation->OnStyleChange( styleChange );
-    }
-  }
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
diff --git a/base/dali-toolkit/internal/controls/style-change-processor.h b/base/dali-toolkit/internal/controls/style-change-processor.h
deleted file mode 100644 (file)
index 062bd5e..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_STYLE_CHANGE_PROCESSOR_H_
-#define __DALI_TOOLKIT_INTERNAL_STYLE_CHANGE_PROCESSOR_H_
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
-
-// INTERNAL INCLUDES
-#include <dali/dali.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-class Control;
-
-/**
- * This observes and processes when any style changes occur.  When they do occur, it traverses through
- * all registered controls and calls the StyleChanged method.
- *
- * This is created when a control first registers with it.  Subsequent registrations increase the
- * reference count.  When the last control unregisters, i.e. the reference count is 0, the instance
- * is also destroyed.
- */
-class StyleChangeProcessor : public ConnectionTracker
-{
-public:
-
-  /**
-   * Non virtual destructor.
-   * We should not derive from StyleChangeProcessor.
-   * Destructor is called when the last control unregisters.
-   */
-  ~StyleChangeProcessor();
-
-  /**
-   * Registers a control with the StyleChangeProcessor.
-   * @param[in] control The raw Control pointer.
-   */
-  static void Register( Control* control );
-
-  /**
-   * Unregisters a control from the StyleChangeProcessor.
-   * @param[in] control The raw Control pointer.
-   */
-  static void Unregister( Control* control );
-
-public:
-
-  /**
-   * Increment the processor's reference count.
-   */
-  void Reference();
-
-  /**
-   * Decrement the processor's reference count.
-   */
-  void Unreference();
-
-  /**
-   * Retrieve the processor's reference count.
-   * @return The reference count
-   */
-  unsigned int ReferenceCount() const;
-
-private:
-
-  /**
-   * Constructor.
-   * We should only create an instance upon first registration.
-   */
-  StyleChangeProcessor();
-
-  // Undefined
-  StyleChangeProcessor(const StyleChangeProcessor&);
-  StyleChangeProcessor& operator=(const StyleChangeProcessor&);
-
-private:
-
-  /**
-   * Callback for the StyleMonitor when the style changes on the platform.
-   * @param[in]  styleMonitor  The Style Monitor.
-   * @param[in]  styleChange   The style change information.
-   */
-  void StyleChanged(Dali::StyleMonitor styleMonitor, Dali::StyleChange styleChange);
-
-  /**
-   * Propagates the style change to all Controls in the actor hierarchy.
-   * This is done with a bottom-up approach, i.e. the leaf Control's StyleChange method gets
-   * called first followed by its parent and so on.
-   * @param[in]  actor   The actor whose children to process and send style change notification to.
-   * @param[in]  change  The style change.
-   */
-  static void PropagateStyleChange(Actor actor, Dali::StyleChange change);
-
-private:
-
-  unsigned int          mCount;        ///< The reference count
-  std::vector<Control*> mControls;     ///< Stores all registered controls.
-};
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_STYLE_CHANGE_PROCESSOR_H_
index fff8bc4..72d58af 100644 (file)
@@ -794,7 +794,7 @@ void TableView::OnControlChildRemove( Actor& child )
 }
 
 TableView::TableView( unsigned int initialRows, unsigned int initialColumns )
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mCellData( initialRows, initialColumns ),
   mLayoutingChild( false ),
   mConstraintDuration( DEFAULT_CONSTRAINT_DURATION )
index 3d79aad..ed8211d 100644 (file)
@@ -269,7 +269,7 @@ Dali::Toolkit::TextInput TextInput::New()
 }
 
 TextInput::TextInput()
-:Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
+:Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
  mState( StateEdit ),
  mStyledText(),
  mInputStyle(),
index 78c4980..728bee6 100644 (file)
@@ -1009,7 +1009,7 @@ TextView::RelayoutData& TextView::RelayoutData::operator=( const TextView::Relay
 }
 
 TextView::TextView()
-: Control( REQUIRES_THEME_CHANGE_SIGNALS ),
+: Control( REQUIRES_STYLE_CHANGE_SIGNALS  ),
   mCurrentStyledText(),
   mTextViewProcessorOperations(),
   mLayoutParameters( Toolkit::TextView::SplitByNewLineChar,
@@ -1149,7 +1149,7 @@ void TextView::OnInitialize()
 }
 
 
-void TextView::OnStyleChange( StyleChange change )
+void TextView::OnFontChange( bool defaultFontChange, bool defaultFontSizeChange )
 {
   mRelayoutData.mTextLayoutInfo.mEllipsizeLayoutInfo = TextViewProcessor::WordLayoutInfo();
   TextViewProcessor::CreateWordTextInfo( mLayoutParameters.mEllipsizeText,
index e4e7dd4..8c66ae2 100644 (file)
@@ -363,9 +363,9 @@ private: // From Control
   virtual void OnInitialize();
 
   /**
-   * @copydoc Toolkit::Control::OnStyleChange()
+   * @copydoc Toolkit::Control::OnFontChange( )
    */
-  virtual void OnStyleChange( StyleChange change );
+  virtual void OnFontChange( bool defaultFontChange, bool defaultFontSizeChange );
 
   /**
    * @copydoc Toolkit::Control::OnControlSizeSet()
index 56b97f8..46e9162 100644 (file)
@@ -110,6 +110,11 @@ StyleManager::StyleManager()
   mThemeBuilderConstants[ PACKAGE_PATH_KEY ] = DEFAULT_PACKAGE_PATH;
 
   RequestDefaultTheme();
+
+  if( Adaptor::IsAvailable() )
+  {
+    StyleMonitor::Get().StyleChangeSignal().Connect( this, &StyleManager::StyleMonitorChange );
+  }
 }
 
 StyleManager::~StyleManager()
@@ -330,17 +335,9 @@ bool StyleManager::LoadFile( const std::string& filename, std::string& stringOut
   return false;
 }
 
-Toolkit::StyleManager::ThemeChangeSignalType& StyleManager::ThemeChangeSignal()
+Toolkit::StyleManager::StyleChangeSignalType& StyleManager::StyleChangeSignal()
 {
-  return mThemeChangeSignal;
-}
-
-void StyleManager::EmitThemeChangeSignal()
-{
-  if( !mThemeChangeSignal.Empty() )
-  {
-    mThemeChangeSignal.Emit( Toolkit::StyleManager::Get() );
-  }
+  return mStyleChangeSignal;
 }
 
 void StyleManager::RequestThemeChange( const std::string& themeFile )
@@ -368,7 +365,9 @@ void StyleManager::SetTheme()
 
   mSetThemeConnection = false;
 
-  EmitThemeChangeSignal();
+  StyleChange change;
+  change.themeChange = true;
+  mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), change );
 }
 
 Toolkit::Builder StyleManager::FindCachedBuilder( const std::string& key )
@@ -387,6 +386,11 @@ void StyleManager::CacheBuilder( Toolkit::Builder builder, const std::string& ke
   mBuilderCache[ key ] = builder;
 }
 
+void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange styleChange )
+{
+  mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), styleChange );
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 2c15f89..2fae34a 100644 (file)
@@ -116,9 +116,9 @@ public:
   // SIGNALS
 
   /**
-   * @copydoc Toolkit::StyleManager::ThemeChangeSignal
+   * @copydoc Toolkit::StyleManager::StyleChangeSignal
    */
-  Toolkit::StyleManager::ThemeChangeSignalType& ThemeChangeSignal();
+  Toolkit::StyleManager::StyleChangeSignalType& StyleChangeSignal();
 
 protected:
 
@@ -193,11 +193,6 @@ private:
   void ApplyStyle( Toolkit::Builder builder, Toolkit::Control control );
 
   /**
-   * @brief Emit theme changed signal
-   */
-  void EmitThemeChangeSignal();
-
-  /**
    * @brief Callback for orientation changes
    *
    * @param[in] orientation The orientation object
@@ -220,6 +215,14 @@ private:
    */
   void CacheBuilder( Toolkit::Builder builder, const std::string& key );
 
+  /**
+   * Callback for when style monitor raises a signal
+   *
+   * @param[in] styleMonitor The style monitor object
+   * @param[in] styleChange The style change data
+   */
+  void StyleMonitorChange( StyleMonitor styleMonitor, StyleChange styleChange );
+
   // Undefined
   StyleManager(const StyleManager&);
 
@@ -245,7 +248,7 @@ private:
   bool mSetThemeConnection;           ///< Has the callback to set the theme been set
 
   // Signals
-  Toolkit::StyleManager::ThemeChangeSignalType       mThemeChangeSignal;         ///< Emitted when the theme changes
+  Toolkit::StyleManager::StyleChangeSignalType       mStyleChangeSignal;         ///< Emitted when the style( theme/font ) changes
 };
 
 } // namespace Internal
index d8d1e36..5ecacd7 100644 (file)
@@ -576,15 +576,12 @@ void Control::Initialize()
   // Calling deriving classes
   OnInitialize();
 
-  if( mImpl->mFlags & REQUIRES_THEME_CHANGE_SIGNALS )
+  if( mImpl->mFlags & REQUIRES_STYLE_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() );
+    // Register for style changes
+    styleManager.StyleChangeSignal().Connect( this, &ControlImpl::DoStyleChange );
   }
 
   mImpl->mInitialized = true;
@@ -743,6 +740,11 @@ Actor Control::GetBackgroundActor() const
   return Actor();
 }
 
+void Control::OnThemeChange( Toolkit::StyleManager styleManager )
+{
+  GetImpl( styleManager ).ApplyThemeStyle( GetOwner() );
+}
+
 void Control::OnPinch(PinchGesture pinch)
 {
   if (pinch.state == Gesture::Started)
@@ -906,6 +908,21 @@ void Control::DoActivatedAction(const PropertyValueContainer& attributes)
   OnActivated();
 }
 
+void Control::DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
+{
+  if( change.themeChange )
+  {
+    OnThemeChange( styleManager );
+  }
+  else if( change.defaultFontChange || change.defaultFontSizeChange )
+  {
+    // This OnStyleChange(StyleChange change ) is deprecated, use OnFontChange instead
+    OnStyleChange( change );
+
+    OnFontChange( change.defaultFontChange, change.defaultFontSizeChange );
+  }
+}
+
 Toolkit::Control::KeyEventSignalV2& Control::KeyEventSignal()
 {
   return mImpl->mKeyEventSignalV2;
@@ -1188,11 +1205,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
index 2b089f7..45bff67 100644 (file)
@@ -54,7 +54,7 @@ Toolkit::ScrollConnector ScrollComponentImpl::GetScrollConnector() const
 }
 
 ScrollComponentImpl::ScrollComponentImpl()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) )
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) )
 {
 }
 
index bdef3d1..633ada9 100644 (file)
@@ -83,9 +83,9 @@ StyleManager::StyleManager( Internal::StyleManager *impl )
 {
 }
 
-StyleManager::ThemeChangeSignalType& StyleManager::ThemeChangeSignal()
+StyleManager::StyleChangeSignalType& StyleManager::StyleChangeSignal()
 {
-  return GetImpl( *this ).ThemeChangeSignal();
+  return GetImpl( *this ).StyleChangeSignal();
 }
 
 void StyleManager::RequestThemeChange( const std::string& themeFile )
index 6b42f8d..b795b13 100644 (file)
@@ -63,7 +63,7 @@ class StyleManager : public BaseHandle
 public:
 
   // Signals
-  typedef SignalV2< void ( StyleManager ) > ThemeChangeSignalType;
+  typedef SignalV2< void ( StyleManager, StyleChange ) >  StyleChangeSignalType;
 
   /**
    * @brief Create a StyleManager handle; this can be initialised with StyleManager::Get()
@@ -162,14 +162,14 @@ public:
 public: // Signals
 
   /**
-   * @brief This signal is emitted whenever the theme is changed on device
+   * @brief This signal is emitted whenever the style (e.g. theme/font change) is changed on device
    * A callback of the following type may be connected:
    * @code
-   *   void YourCallbackName( StyleManager styleManager );
+   *   void YourCallbackName( StyleManager styleManager, StyleChange change );
    * @endcode
    * @return The signal to connect to.
    */
-  ThemeChangeSignalType& ThemeChangeSignal();
+  StyleChangeSignalType& StyleChangeSignal();
 
 public:
 
index 3ab3acf..840af0a 100644 (file)
@@ -299,11 +299,34 @@ private: // For derived classes to override
   virtual void OnInitialize() { }
 
   /**
-   * @brief Callback for when the theme changes.
+   * @brief This method should be overridden by deriving classes when
+   * they wish to be notified when the style manager changes the theme.
+   *
+   * @param[in] styleManager  The StyleManager object.
    */
   virtual void OnThemeChange( Toolkit::StyleManager styleManager );
 
   /**
+   * @brief This method should be overridden by deriving classes when
+   * they wish to be notified when the style changes the default font.
+   *
+   * @param[in] defaultFontChange  Information denoting whether the default font has changed.
+   * @param[in] defaultFontSizeChange Information denoting whether the default font size has changed.
+   */
+  virtual void OnFontChange( bool defaultFontChange, bool defaultFontSizeChange ){ }
+
+  /**
+   * @deprecated Use OnFontChange() instead.
+   * Before the using of StyleManager, the StyleChange only deals with font change.
+   *
+   * @brief This method should be overridden by deriving classes when
+   * they wish to be notified when the style changes.
+   *
+   * @param[in] change  Information denoting what has changed.
+   */
+  virtual void OnStyleChange( StyleChange change ) { }
+
+  /**
    * @brief Called whenever a pinch gesture is detected on this control.
    *
    * This can be overridden by deriving classes when pinch detection
@@ -518,14 +541,22 @@ private:
    */
   void DoActivatedAction(const PropertyValueContainer& attributes);
 
+  /**
+   * @brief This method is the callback for the StyleChangeSignal from StyleManager
+   *
+   * @param[in] styleManager The StyleManager Object
+   * @param[in] change  Information denoting what has changed.
+   */
+  void DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
+
 protected: // Construction
 
   // Flags for the constructor
   enum ControlBehaviour
   {
-    CONTROL_BEHAVIOUR_NONE        = 0x0,
-    REQUIRES_TOUCH_EVENTS         = 0x1,     ///< True if the OnTouchEvent() callback is required.
-    REQUIRES_THEME_CHANGE_SIGNALS = 0x2      ///< True if this control should listen to theme change signals
+    CONTROL_BEHAVIOUR_NONE         = 0x0,
+    REQUIRES_TOUCH_EVENTS          = 0x1,     ///< True if the OnTouchEvent() callback is required.
+    REQUIRES_STYLE_CHANGE_SIGNALS  = 0x2      ///< True if needs to monitor style change signals such as theme/font change
   };
 
   /**
index 4a5e45e..0ecc544 100644 (file)
@@ -80,7 +80,7 @@ Dali::Toolkit::Cluster Cluster::New(Toolkit::ClusterStyle& style)
 }
 
 Cluster::Cluster(Toolkit::ClusterStyle& style)
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mClusterStyle(style),
   mExpandedCount(0)
 {
index edd6f4a..f360f5e 100644 (file)
@@ -86,7 +86,7 @@ Dali::Toolkit::ImageView ImageView::New()
 }
 
 ImageView::ImageView()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) )
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) )
 {
 }
 
index 38a05a4..c534d4d 100644 (file)
@@ -474,7 +474,7 @@ Dali::Toolkit::MaskedImageView::MaskedImageViewSignal& MaskedImageView::MaskFini
 }
 
 MaskedImageView::MaskedImageView()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mEditMode( Dali::Toolkit::MaskedImageView::EDIT_DISABLED ),
   mSelfPropertySetting( false ),
   mSourceRotation( Dali::Toolkit::MaskedImageView::ROTATE_0 ),
index 8a3bbb2..87495b2 100755 (executable)
@@ -168,7 +168,7 @@ Dali::Toolkit::Slider Slider::New()
 }
 
 Slider::Slider()
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mState( NORMAL ),
   mDisableColor( 0.0f, 0.0f, 0.0f, 0.0f ),
   mPopupTextColor( 0.0f, 0.0f, 0.0f, 0.0f ),