Framework for Font styles 08/36808/4
authorPaul Wisbey <p.wisbey@samsung.com>
Sun, 15 Mar 2015 11:04:02 +0000 (11:04 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Sun, 15 Mar 2015 13:51:42 +0000 (13:51 +0000)
Change-Id: Id7f56956bde776562246a65c442344addcc162ed

adaptors/common/style-monitor-impl.cpp
adaptors/common/style-monitor-impl.h
adaptors/public-api/adaptor-framework/style-monitor.cpp
adaptors/public-api/adaptor-framework/style-monitor.h
platform-abstractions/slp/slp-platform-abstraction.cpp
platform-abstractions/slp/slp-platform-abstraction.h

index db6757c..a7b87d0 100644 (file)
@@ -79,7 +79,8 @@ Dali::StyleMonitor StyleMonitor::Get()
 }
 
 StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction)
-: mPlatformAbstraction(platformAbstraction)
+: mPlatformAbstraction(platformAbstraction),
+  mDefaultFontSize(0u)
 {
 }
 
@@ -89,9 +90,13 @@ StyleMonitor::~StyleMonitor()
 
 void StyleMonitor::StyleChanged(StyleChange styleChange)
 {
-  if (styleChange.defaultFontChange || styleChange.defaultFontSizeChange)
+  if ( styleChange.defaultFontChange )
   {
-    //mPlatformAbstraction.UpdateDefaultsFromDevice();
+    mPlatformAbstraction.GetDefaultFontDescription( mDefaultFontFamily, mDefaultFontStyle );
+  }
+  if ( styleChange.defaultFontSizeChange )
+  {
+    mDefaultFontSize = mPlatformAbstraction.GetDefaultFontSize();
   }
 
   EmitStyleChangeSignal(styleChange);
@@ -99,14 +104,17 @@ void StyleMonitor::StyleChanged(StyleChange styleChange)
 
 std::string StyleMonitor::GetDefaultFontFamily() const
 {
-  //return mPlatformAbstraction.GetDefaultFontFamily();
-  return std::string();
+  return mDefaultFontFamily;
+}
+
+std::string StyleMonitor::GetDefaultFontStyle() const
+{
+  return mDefaultFontStyle;
 }
 
-float StyleMonitor::GetDefaultFontSize() const
+unsigned int StyleMonitor::GetDefaultFontSize() const
 {
-  //return mPlatformAbstraction.GetDefaultFontSize();
-  return float();
+  return mDefaultFontSize;
 }
 
 const std::string& StyleMonitor::GetTheme() const
index cd3adcd..b51f4ad 100644 (file)
@@ -73,9 +73,14 @@ public:
   std::string GetDefaultFontFamily() const;
 
   /**
+   * @copydoc Dali::StyleMonitor::GetDefaultFontStyle() const
+   */
+  std::string GetDefaultFontStyle() const;
+
+  /**
    * @copydoc Dali::StyleMonitor::GetDefaultFontSize() const
    */
-  float GetDefaultFontSize() const;
+  unsigned int GetDefaultFontSize() const;
 
   /**
    * @copydoc Dali::StyleMonitor::GetTheme() const
@@ -111,11 +116,14 @@ private:
 
 private:
 
-  Dali::StyleMonitor::StyleChangeSignalType      mStyleChangeSignal; ///< Emitted when the style changes
+  Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal; ///< Emitted when the style changes
 
-  Integration::PlatformAbstraction&            mPlatformAbstraction; ///< Reference to the PlatformAbstraction (for retrieving defaults)
-  std::string                                  mUserDefinedThemeFilePath;///< String containing the user defined theme file path
+  Integration::PlatformAbstraction& mPlatformAbstraction; ///< Reference to the PlatformAbstraction (for retrieving defaults)
 
+  std::string mDefaultFontFamily;        ///< The default font family
+  std::string mDefaultFontStyle;         ///< The default font style
+  std::string mUserDefinedThemeFilePath; ///< String containing the user defined theme file path
+  unsigned int mDefaultFontSize;         ///< The default accessibility font size e.g. 0 is smallest
 };
 
 } // namespace Adaptor
index ad79f6b..7993f3e 100644 (file)
@@ -52,7 +52,7 @@ std::string StyleMonitor::GetDefaultFontFamily() const
   return GetImplementation(*this).GetDefaultFontFamily();
 }
 
-float StyleMonitor::GetDefaultFontSize() const
+int StyleMonitor::GetDefaultFontSize() const
 {
   return GetImplementation(*this).GetDefaultFontSize();
 }
index d7f7efd..8b8fca3 100644 (file)
@@ -103,10 +103,19 @@ public: // Style Information
   std::string GetDefaultFontFamily() const;
 
   /**
-   * @brief Retrieves the default font size
+   * @brief Retrieves the default font style.
+   * @return The default font style.
+   */
+  std::string GetDefaultFontStyle() const;
+
+  /**
+   * @brief Retrieves the default font size.
+   *
+   * This is an accessibility size, which is mapped to a UI Control specific point-size in stylesheets.
+   * For example if zero the smallest size, this could potentially map to TextLabel point-size 8.
    * @return The default font size.
    */
-  float GetDefaultFontSize() const;
+  int GetDefaultFontSize() const;
 
   /**
    * @brief Retrieves the user defined Theme.
index d19d0f3..d98824e 100644 (file)
@@ -29,6 +29,7 @@
 #include "resource-loader/resource-loader.h"
 #include "dynamics/dynamics-factory.h"
 
+#include "slp-font-configuration-parser.h"
 #include "image-loaders/image-loader.h"
 
 namespace Dali
@@ -45,6 +46,7 @@ namespace SlpPlatform
 
 namespace
 {
+const std::string FONT_CONFIGURATION_FILE( FONT_CONFIGURATION_FILE_PATH ); ///< Default font configuration file
 const unsigned int NANOSECS_TO_MICROSECS( 1000 );                          ///< 1000 nanoseconds = 1 microsecond
 }
 
@@ -85,6 +87,22 @@ void SlpPlatformAbstraction::Resume()
   }
 }
 
+void SlpPlatformAbstraction::GetDefaultFontDescription( std::string& fontFamily, std::string& fontStyle ) const
+{
+  FontConfigurationParser::Parse(FONT_CONFIGURATION_FILE, fontFamily, fontStyle);
+}
+
+int SlpPlatformAbstraction::GetDefaultFontSize() const
+{
+  int fontSize( 0 );
+
+#ifndef DALI_PROFILE_UBUNTU
+  vconf_get_int( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &fontSize );
+#endif // DALI_PROFILE_UBUNTU
+
+  return fontSize;
+}
+
 void SlpPlatformAbstraction::GetClosestImageSize( const std::string& filename,
                                                   const ImageAttributes& attributes,
                                                   Vector2& closestSize )
index b27d9a7..a88f84d 100644 (file)
@@ -123,6 +123,16 @@ public: // PlatformAbstraction overrides
   virtual void JoinLoaderThreads();
 
   /**
+   * @copydoc PlatformAbstraction::GetDefaultFontDescription()
+   */
+  virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const;
+
+  /**
+   * @copydoc PlatformAbstraction::GetDefaultFontSize()
+   */
+  virtual int GetDefaultFontSize() const;
+
+  /**
    * @copydoc PlatformAbstraction::SetDpi()
    */
   virtual void SetDpi (unsigned int DpiHorizontal, unsigned int DpiVertical);