Ensure Text Controls do an up-call on-style-change & trigger a relayout 74/116874/4
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 23 Mar 2017 11:04:47 +0000 (11:04 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 23 Mar 2017 11:30:56 +0000 (11:30 +0000)
The up-call is required as per the control writing guidelines.
A relayout request is required so that the control's fonts and size can be recalculated.
A similar fix has already been pushed to the product branch.

Change-Id: Ib23baeef60d6fb6fb3e68105defba9a30b458b5f

automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp

index dc95a8e..20de8e8 100644 (file)
@@ -1,5 +1,5 @@
  /*
  /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -642,8 +642,11 @@ int UtcDaliStyleManagerStyleChangedSignalFontFamily(void)
   Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr);
   Stage::GetCurrent().Add( label );
 
   Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr);
   Stage::GetCurrent().Add( label );
 
-  Toolkit::TextLabel label2 = Toolkit::TextLabel::New(labelStr);
-  Stage::GetCurrent().Add( label2 );
+  Toolkit::TextField field = Toolkit::TextField::New();
+  Stage::GetCurrent().Add( field );
+
+  Toolkit::TextEditor editor = Toolkit::TextEditor::New();
+  Stage::GetCurrent().Add( editor );
 
   StyleChangedSignalChecker styleChangedSignalHandler;
   Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get();
 
   StyleChangedSignalChecker styleChangedSignalHandler;
   Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get();
@@ -666,6 +669,18 @@ int UtcDaliStyleManagerStyleChangedSignalFontFamily(void)
 
   DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION);
 
 
   DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION);
 
+  // Check that the field's font style has been altered
+  family = field.GetProperty(TextField::Property::FONT_FAMILY);
+  family.Get( familyStr );
+
+  DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION);
+
+  // Check that the editor's font style has been altered
+  family = editor.GetProperty(TextEditor::Property::FONT_FAMILY);
+  family.Get( familyStr );
+
+  DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION);
+
   END_TEST;
 }
 
   END_TEST;
 }
 
index fc86c7e..c08b897 100644 (file)
@@ -1098,20 +1098,25 @@ void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange:
       const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
       // Property system did not set the font so should update it.
       mController->UpdateAfterFontChange( newFont );
       const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
       // Property system did not set the font so should update it.
       mController->UpdateAfterFontChange( newFont );
+      RelayoutRequest();
       break;
     }
 
     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
     {
       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
       break;
     }
 
     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
     {
       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      RelayoutRequest();
       break;
     }
     case StyleChange::THEME_CHANGE:
     {
       break;
     }
     case StyleChange::THEME_CHANGE:
     {
-      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      // Nothing to do, let control base class handle this
       break;
     }
   }
       break;
     }
   }
+
+  // Up call to Control
+  Control::OnStyleChange( styleManager, change );
 }
 
 Vector3 TextEditor::GetNaturalSize()
 }
 
 Vector3 TextEditor::GetNaturalSize()
index bafa08e..2e300b1 100644 (file)
@@ -1209,20 +1209,25 @@ void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::
       const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
       // Property system did not set the font so should update it.
       mController->UpdateAfterFontChange( newFont );
       const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
       // Property system did not set the font so should update it.
       mController->UpdateAfterFontChange( newFont );
+      RelayoutRequest();
       break;
     }
 
     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
     {
       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
       break;
     }
 
     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
     {
       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      RelayoutRequest();
       break;
     }
     case StyleChange::THEME_CHANGE:
     {
       break;
     }
     case StyleChange::THEME_CHANGE:
     {
-      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      // Nothing to do, let control base class handle this
       break;
     }
   }
       break;
     }
   }
+
+  // Up call to Control
+  Control::OnStyleChange( styleManager, change );
 }
 
 Vector3 TextField::GetNaturalSize()
 }
 
 Vector3 TextField::GetNaturalSize()
index b6b5db0..3d161e0 100644 (file)
@@ -672,19 +672,24 @@ void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::
       const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
       DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE newFont(%s)\n", newFont.c_str() );
       mController->UpdateAfterFontChange( newFont );
       const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
       DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE newFont(%s)\n", newFont.c_str() );
       mController->UpdateAfterFontChange( newFont );
+      RelayoutRequest();
       break;
     }
     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
     {
       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
       break;
     }
     case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
     {
       GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      RelayoutRequest();
       break;
     }
     case StyleChange::THEME_CHANGE:
     {
       break;
     }
     case StyleChange::THEME_CHANGE:
     {
-      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      // Nothing to do, let control base class handle this
       break;
     }
   }
       break;
     }
   }
+
+  // Up call to Control
+  Control::OnStyleChange( styleManager, change );
 }
 
 Vector3 TextLabel::GetNaturalSize()
 }
 
 Vector3 TextLabel::GetNaturalSize()
index 19be9ba..c4ee219 100644 (file)
@@ -1500,8 +1500,8 @@ void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Ty
   if( styleManager && change == StyleChange::THEME_CHANGE )
   {
     GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
   if( styleManager && change == StyleChange::THEME_CHANGE )
   {
     GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+    RelayoutRequest();
   }
   }
-  RelayoutRequest();
 }
 
 void Control::OnPinch(const PinchGesture& pinch)
 }
 
 void Control::OnPinch(const PinchGesture& pinch)