Dali-Text: Keyboard Shortcuts
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-font-style.cpp
index 6a57337..927f277 100644 (file)
@@ -45,10 +45,6 @@ const std::string TYPE_KEY( "type" );
 
 const std::string SYSTEM_TOKEN( "system" );
 
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_CONTROLS");
-#endif
-
 } // namespace
 
 void SetFontFamilyProperty( ControllerPtr controller, const Property::Value& value )
@@ -114,10 +110,13 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu
       const std::string& fontStyleProperties = value.Get<std::string>();
 
       ParsePropertyString( fontStyleProperties, map );
+      controller->FontStyleSetByString( true );
+
     }
     else
     {
       map = value.Get<Property::Map>();
+      controller->FontStyleSetByString( false );
     }
 
     if( !map.Empty() )
@@ -213,6 +212,28 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu
           }
           break;
         }
+        case FontStyle::PLACEHOLDER:
+        {
+          // Sets the placeholder text font's style values.
+          if( !weightDefined ||
+              ( weightDefined && ( controller->GetPlaceholderTextFontWeight() != weight ) ) )
+          {
+            controller->SetPlaceholderTextFontWeight( weight );
+          }
+
+          if( !widthDefined ||
+              ( widthDefined && ( controller->GetPlaceholderTextFontWidth() != width ) ) )
+          {
+            controller->SetPlaceholderTextFontWidth( width );
+          }
+
+          if( !slantDefined ||
+              ( slantDefined && ( controller->GetPlaceholderTextFontSlant() != slant ) ) )
+          {
+            controller->SetPlaceholderTextFontSlant( slant );
+          }
+          break;
+        }
       } // switch
     } // map not empty
     else
@@ -233,6 +254,13 @@ void SetFontStyleProperty( ControllerPtr controller, const Property::Value& valu
           controller->SetInputFontSlant( TextAbstraction::FontSlant::NONE );
           break;
         }
+        case FontStyle::PLACEHOLDER:
+        {
+          controller->SetPlaceholderTextFontWeight( TextAbstraction::FontWeight::NONE );
+          controller->SetPlaceholderTextFontWidth( TextAbstraction::FontWidth::NONE );
+          controller->SetPlaceholderTextFontSlant( TextAbstraction::FontSlant::NONE );
+          break;
+        }
       } // switch
     } // map.Empty()
   } // controller
@@ -242,7 +270,7 @@ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, Fon
 {
   if( controller )
   {
-    const bool isDefaultStyle = FontStyle::DEFAULT == type;
+    const bool isSetbyString = controller->IsFontStyleSetByString();
 
     bool weightDefined = false;
     bool widthDefined = false;
@@ -251,89 +279,168 @@ void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, Fon
     FontWidth width = TextAbstraction::FontWidth::NONE;
     FontSlant slant = TextAbstraction::FontSlant::NONE;
 
-    if( isDefaultStyle )
+    switch( type )
     {
-      weightDefined = controller->IsDefaultFontWeightDefined();
-      widthDefined = controller->IsDefaultFontWidthDefined();
-      slantDefined = controller->IsDefaultFontSlantDefined();
-
-      if( weightDefined )
+      case FontStyle::DEFAULT:
       {
-        weight = controller->GetDefaultFontWeight();
-      }
+        weightDefined = controller->IsDefaultFontWeightDefined();
+        widthDefined = controller->IsDefaultFontWidthDefined();
+        slantDefined = controller->IsDefaultFontSlantDefined();
 
-      if( widthDefined )
-      {
-        width = controller->GetDefaultFontWidth();
+        if( weightDefined )
+        {
+          weight = controller->GetDefaultFontWeight();
+        }
+
+        if( widthDefined )
+        {
+          width = controller->GetDefaultFontWidth();
+        }
+
+        if( slantDefined )
+        {
+          slant = controller->GetDefaultFontSlant();
+        }
+        break;
       }
+      case FontStyle::INPUT:
+      {
+        weightDefined = controller->IsInputFontWeightDefined();
+        widthDefined = controller->IsInputFontWidthDefined();
+        slantDefined = controller->IsInputFontSlantDefined();
 
-      if( slantDefined )
+        if( weightDefined )
+        {
+          weight = controller->GetInputFontWeight();
+        }
+
+        if( widthDefined )
+        {
+          width = controller->GetInputFontWidth();
+        }
+
+        if( slantDefined )
+        {
+          slant = controller->GetInputFontSlant();
+        }
+        break;
+      }
+      case FontStyle::PLACEHOLDER:
       {
-        slant = controller->GetDefaultFontSlant();
+        // The type is FontStyle::PLACEHOLDER
+        weightDefined = controller->IsPlaceholderTextFontWeightDefined();
+        widthDefined = controller->IsPlaceholderTextFontWidthDefined();
+        slantDefined = controller->IsPlaceholderTextFontSlantDefined();
+
+        if( weightDefined )
+        {
+          weight = controller->GetPlaceholderTextFontWeight();
+        }
+
+        if( widthDefined )
+        {
+          width = controller->GetPlaceholderTextFontWidth();
+        }
+
+        if( slantDefined )
+        {
+          slant = controller->GetPlaceholderTextFontSlant();
+        }
+        break;
       }
     }
-    else
+
+    if( !isSetbyString )
     {
-      weightDefined = controller->IsInputFontWeightDefined();
-      widthDefined = controller->IsInputFontWidthDefined();
-      slantDefined = controller->IsInputFontSlantDefined();
+      Property::Map map;
 
       if( weightDefined )
       {
-        weight = controller->GetInputFontWeight();
+        if( TextAbstraction::FontWeight::NONE != weight )
+        {
+          const std::string weightStr( GetEnumerationName( weight,
+                                                          FONT_WEIGHT_STRING_TABLE,
+                                                          FONT_WEIGHT_STRING_TABLE_COUNT ) );
+
+          map.Insert( WEIGHT_KEY, weightStr );
+        }
       }
 
       if( widthDefined )
       {
-        width = controller->GetInputFontWidth();
+        if( TextAbstraction::FontWidth::NONE != width )
+        {
+          const std::string widthStr( GetEnumerationName( width,
+                                                          FONT_WIDTH_STRING_TABLE,
+                                                          FONT_WIDTH_STRING_TABLE_COUNT ) );
+
+          map.Insert( WIDTH_KEY, widthStr );
+        }
       }
 
       if( slantDefined )
       {
-        slant = controller->GetInputFontSlant();
-      }
-    }
+        if( TextAbstraction::FontSlant::NONE != slant )
+        {
+          const std::string slantStr( GetEnumerationName( slant,
+                                                          FONT_SLANT_STRING_TABLE,
+                                                          FONT_SLANT_STRING_TABLE_COUNT ) );
 
-    Property::Map map;
+          map.Insert( SLANT_KEY, slantStr );
+        }
+      }
 
-    if( weightDefined )
+      value = map;
+    } // SetbyMAP
+    else
     {
-      if( TextAbstraction::FontWeight::NONE != weight )
+      std::string fontStyleProperties = "{";
+
+      if( weightDefined )
       {
-        const std::string weightStr( GetEnumerationName( weight,
-                                                         FONT_WEIGHT_STRING_TABLE,
-                                                         FONT_WEIGHT_STRING_TABLE_COUNT ) );
+        if( TextAbstraction::FontWeight::NONE != weight )
+        {
+          const std::string weightStr( GetEnumerationName( weight,
+                                                          FONT_WEIGHT_STRING_TABLE,
+                                                          FONT_WEIGHT_STRING_TABLE_COUNT ) );
 
-        map.Insert( WEIGHT_KEY, weightStr );
+          fontStyleProperties += "\"weight\":\"" + weightStr + "\",";
+        }
       }
-    }
 
-    if( widthDefined )
-    {
-      if( TextAbstraction::FontWidth::NONE != width )
+      if( widthDefined )
       {
-        const std::string widthStr( GetEnumerationName( width,
-                                                        FONT_WIDTH_STRING_TABLE,
-                                                        FONT_WIDTH_STRING_TABLE_COUNT ) );
-
-        map.Insert( WIDTH_KEY, widthStr );
+        if( TextAbstraction::FontWidth::NONE != width )
+        {
+          const std::string widthStr( GetEnumerationName( width,
+                                                          FONT_WIDTH_STRING_TABLE,
+                                                          FONT_WIDTH_STRING_TABLE_COUNT ) );
+          fontStyleProperties += "\"width\":\"" + widthStr + "\",";
+        }
       }
-    }
 
-    if( slantDefined )
-    {
-      if( TextAbstraction::FontSlant::NONE != slant )
+      if( slantDefined )
       {
-        const std::string slantStr( GetEnumerationName( slant,
-                                                        FONT_SLANT_STRING_TABLE,
-                                                        FONT_SLANT_STRING_TABLE_COUNT ) );
+        if( TextAbstraction::FontSlant::NONE != slant )
+        {
+          const std::string slantStr( GetEnumerationName( slant,
+                                                          FONT_SLANT_STRING_TABLE,
+                                                          FONT_SLANT_STRING_TABLE_COUNT ) );
+
+          fontStyleProperties += "\"slant\":\"" + slantStr + "\"";
+        }
+      }
 
-        map.Insert( SLANT_KEY, slantStr );
+      // If last character is comma, it will be removed.
+      if((*fontStyleProperties.rbegin()) == ',' )
+      {
+        fontStyleProperties = fontStyleProperties.substr( 0, fontStyleProperties.size()-1 );
       }
-    }
+      fontStyleProperties += "}";
 
-    value = map;
-  }
+      value = fontStyleProperties;
+    } // SetbyString
+  }// controller
 }
 
 FontWeight StringToWeight( const char* const weightStr )