TextField and TextLabel not to ApplyStyle if Font size or family already set 73/46073/2
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Thu, 13 Aug 2015 17:10:28 +0000 (18:10 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Fri, 14 Aug 2015 10:31:43 +0000 (03:31 -0700)
* If the Font Point size or Font family has been set then will not ApplyStyle after notifcation from StyleMonitor
* If StyleMonitor requests a ThemeChange then the new theme will be applied and over-ride set properties

- If the system font point size is changed this will not take effect until application restarted.
- Font Point Size or Font family can not be changed by system instantly

Change-Id: Ib3fd88c3def9f8af63aaca9556192043a2274e48
Signed-off-by: Agnelo Vaz <agnelo.vaz@samsung.com>
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp

index 5b6d950..d633e9b 100644 (file)
@@ -923,7 +923,38 @@ void TextField::OnInitialize()
 
 void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
 {
-  GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange\n");
+
+   switch ( change )
+   {
+     case StyleChange::DEFAULT_FONT_CHANGE:
+     {
+       DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE\n");
+       if ( mController->GetDefaultFontFamily() == "" )
+       {
+         // Property system did not set the font so should update it.
+         // todo instruct text-controller to update model
+       }
+       break;
+     }
+
+     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
+     {
+       DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() );
+
+       if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f
+       {
+         // Property system did not set the PointSize so should update it.
+         // todo instruct text-controller to update model
+       }
+       break;
+     }
+     case StyleChange::THEME_CHANGE:
+     {
+       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+       break;
+     }
+   }
 }
 
 Vector3 TextField::GetNaturalSize()
index 290c64f..81a5c97 100644 (file)
@@ -51,6 +51,10 @@ namespace
 namespace
 {
 
+#if defined(DEBUG_ENABLED)
+  Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
+#endif
+
 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
   { "BEGIN",  Toolkit::Text::LayoutEngine::HORIZONTAL_ALIGN_BEGIN  },
@@ -459,7 +463,39 @@ void TextLabel::OnInitialize()
 
 void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
 {
-  GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextLabel::OnStyleChange\n");
+
+  switch ( change )
+  {
+    case StyleChange::DEFAULT_FONT_CHANGE:
+    {
+      DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE\n");
+      if ( mController->GetDefaultFontFamily() == "" )
+      {
+        // Property system did not set the font so should update it.
+        // todo instruct text-controller to update model
+      }
+      break;
+    }
+
+    case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
+    {
+      DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnStyleChange StyleChange::DEFAULT_FONT_SIZE_CHANGE (%f)\n", mController->GetDefaultPointSize() );
+
+      if ( (mController->GetDefaultPointSize() <= 0.0f) ) // If DefaultPointSize not set by Property system it will be 0.0f
+      {
+        // Property system did not set the PointSize so should update it.
+        // todo instruct text-controller to update model
+      }
+      break;
+    }
+    case StyleChange::THEME_CHANGE:
+    {
+      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      break;
+    }
+  }
 }
 
 Vector3 TextLabel::GetNaturalSize()