Revert to tizen branch.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / styling / style-manager-impl.cpp
index 1ee0e9e..4378e84 100644 (file)
@@ -23,6 +23,7 @@
 #include <sstream>
 #include <dali/public-api/adaptor-framework/singleton-service.h>
 #include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
@@ -35,6 +36,7 @@ namespace
 
 const char* LANDSCAPE_QUALIFIER = "landscape";
 const char* PORTRAIT_QUALIFIER  = "portrait";
+const char* FONT_SIZE_QUALIFIER = "font-size-";
 
 const char* DEFAULT_THEME = DALI_STYLE_DIR "tizen-default-theme.json";
 
@@ -72,7 +74,9 @@ BaseHandle Create()
 
   return handle;
 }
-TypeRegistration STYLE_MANAGER_TYPE( typeid(Dali::Toolkit::StyleManager), typeid(Dali::BaseHandle), Create, true /* Create instance at startup */ );
+
+DALI_TYPE_REGISTRATION_BEGIN_CREATE( Toolkit::StyleManager, Dali::BaseHandle, Create, true )
+DALI_TYPE_REGISTRATION_END()
 
 } // namespace
 
@@ -96,7 +100,8 @@ Toolkit::StyleManager StyleManager::Get()
 }
 
 StyleManager::StyleManager()
-  : mOrientationDegrees( 0 )  // Portrait
+: mOrientationDegrees( 0 ),  // Portrait
+  mDefaultFontSize( -1 )
 {
   // Add theme builder constants
   mThemeBuilderConstants[ PACKAGE_PATH_KEY ] = DEFAULT_PACKAGE_PATH;
@@ -107,6 +112,8 @@ StyleManager::StyleManager()
   if( styleMonitor )
   {
     styleMonitor.StyleChangeSignal().Connect( this, &StyleManager::StyleMonitorChange );
+
+    mDefaultFontSize = styleMonitor.GetDefaultFontSize();
   }
 }
 
@@ -241,9 +248,13 @@ void StyleManager::BuildQualifiedStyleName( const std::string& styleName, const
 
 void StyleManager::ApplyStyle( Toolkit::Builder builder, Toolkit::Control control )
 {
-  // Convert control name to lower case
-  std::string styleName = control.GetTypeName();
-  std::transform( styleName.begin(), styleName.end(), styleName.begin(), ::tolower );
+  std::string styleName = control.GetStyleName();
+  if( styleName.empty() )
+  {
+    // Convert control name to lower case
+    styleName = control.GetTypeName();
+    std::transform( styleName.begin(), styleName.end(), styleName.begin(), ::tolower );
+  }
 
   // Apply the style after choosing the correct actual style (e.g. landscape or portrait)
   StringList qualifiers;
@@ -263,6 +274,14 @@ void StyleManager::ApplyStyle( Toolkit::Builder builder, Toolkit::Control contro
     // Remove the last qualifier in an attempt to find a style that is valid
     qualifiers.pop_back();
   }
+
+  if( mDefaultFontSize >= 0 )
+  {
+    // Apply the style for logical font size
+    std::stringstream fontSizeQualifier;
+    fontSizeQualifier << styleName << "-" << FONT_SIZE_QUALIFIER << mDefaultFontSize;
+    builder.ApplyStyle( fontSizeQualifier.str(), control );
+  }
 }
 
 void StyleManager::ApplyThemeStyle( Toolkit::Control control )
@@ -377,6 +396,11 @@ void StyleManager::CacheBuilder( Toolkit::Builder builder, const std::string& ke
 
 void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange styleChange )
 {
+  if( styleChange.defaultFontSizeChange )
+  {
+    mDefaultFontSize = styleMonitor.GetDefaultFontSize();
+  }
+
   mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), styleChange );
 }