Outline effect has been fixed to be not front cropped.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.cpp
index 99e031a..7847fb9 100755 (executable)
@@ -27,6 +27,7 @@
 #include <dali/devel-api/text-abstraction/font-client.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/text-controls/placeholder-properties.h>
 #include <dali-toolkit/internal/text/bidirectional-support.h>
 #include <dali-toolkit/internal/text/character-set-conversion.h>
 #include <dali-toolkit/internal/text/layouts/layout-parameters.h>
@@ -47,14 +48,14 @@ const float MAX_FLOAT = std::numeric_limits<float>::max();
 
 const std::string EMPTY_STRING("");
 
-const char * const PLACEHOLDER_TEXT = "placeholderText";
-const char * const PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
-const char * const PLACEHOLDER_COLOR = "placeholderColor";
-const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily";
-const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle";
-const char * const PLACEHOLDER_POINT_SIZE = "placeholderPointSize";
-const char * const PLACEHOLDER_PIXEL_SIZE = "placeholderPixelSize";
-const char * const PLACEHOLDER_ELLIPSIS = "placeholderEllipsis";
+const char * const PLACEHOLDER_TEXT = "text";
+const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused";
+const char * const PLACEHOLDER_COLOR = "color";
+const char * const PLACEHOLDER_FONT_FAMILY = "fontFamily";
+const char * const PLACEHOLDER_FONT_STYLE = "fontStyle";
+const char * const PLACEHOLDER_POINT_SIZE = "pointSize";
+const char * const PLACEHOLDER_PIXEL_SIZE = "pixelSize";
+const char * const PLACEHOLDER_ELLIPSIS = "ellipsis";
 
 float ConvertToEven( float value )
 {
@@ -1112,6 +1113,21 @@ const Vector4& Controller::GetShadowColor() const
   return mImpl->mModel->mVisualModel->GetShadowColor();
 }
 
+void Controller::SetShadowBlurRadius( const float& shadowBlurRadius )
+{
+  if ( fabsf( GetShadowBlurRadius() - shadowBlurRadius ) > Math::MACHINE_EPSILON_1 )
+  {
+    mImpl->mModel->mVisualModel->SetShadowBlurRadius( shadowBlurRadius );
+
+    mImpl->RequestRelayout();
+  }
+}
+
+const float& Controller::GetShadowBlurRadius() const
+{
+  return mImpl->mModel->mVisualModel->GetShadowBlurRadius();
+}
+
 void Controller::SetUnderlineColor( const Vector4& color )
 {
   mImpl->mModel->mVisualModel->SetUnderlineColor( color );
@@ -1986,19 +2002,19 @@ void Controller::SetPlaceholderProperty( const Property::Map& map )
     Property::Key& key = keyValue.first;
     Property::Value& value = keyValue.second;
 
-    if( key == PLACEHOLDER_TEXT )
+    if( key == Toolkit::Text::PlaceHolder::Property::TEXT  || key == PLACEHOLDER_TEXT )
     {
       std::string text = "";
       value.Get( text );
       SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
     }
-    else if( key == PLACEHOLDER_TEXT_FOCUSED )
+    else if( key == Toolkit::Text::PlaceHolder::Property::TEXT_FOCUSED || key == PLACEHOLDER_TEXT_FOCUSED )
     {
       std::string text = "";
       value.Get( text );
       SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
     }
-    else if( key == PLACEHOLDER_COLOR )
+    else if( key == Toolkit::Text::PlaceHolder::Property::COLOR || key == PLACEHOLDER_COLOR )
     {
       Vector4 textColor;
       value.Get( textColor );
@@ -2007,17 +2023,17 @@ void Controller::SetPlaceholderProperty( const Property::Map& map )
         SetPlaceholderTextColor( textColor );
       }
     }
-    else if( key == PLACEHOLDER_FONT_FAMILY )
+    else if( key == Toolkit::Text::PlaceHolder::Property::FONT_FAMILY || key == PLACEHOLDER_FONT_FAMILY )
     {
       std::string fontFamily = "";
       value.Get( fontFamily );
       SetPlaceholderFontFamily( fontFamily );
     }
-    else if( key == PLACEHOLDER_FONT_STYLE )
+    else if( key == Toolkit::Text::PlaceHolder::Property::FONT_STYLE || key == PLACEHOLDER_FONT_STYLE )
     {
       SetFontStyleProperty( this, value, Text::FontStyle::PLACEHOLDER );
     }
-    else if( key == PLACEHOLDER_POINT_SIZE )
+    else if( key == Toolkit::Text::PlaceHolder::Property::POINT_SIZE || key == PLACEHOLDER_POINT_SIZE )
     {
       float pointSize;
       value.Get( pointSize );
@@ -2026,7 +2042,7 @@ void Controller::SetPlaceholderProperty( const Property::Map& map )
         SetPlaceholderTextFontSize( pointSize, Text::Controller::POINT_SIZE );
       }
     }
-    else if( key == PLACEHOLDER_PIXEL_SIZE )
+    else if( key == Toolkit::Text::PlaceHolder::Property::PIXEL_SIZE || key == PLACEHOLDER_PIXEL_SIZE )
     {
       float pixelSize;
       value.Get( pixelSize );
@@ -2035,7 +2051,7 @@ void Controller::SetPlaceholderProperty( const Property::Map& map )
         SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
       }
     }
-    else if( key == PLACEHOLDER_ELLIPSIS )
+    else if( key == Toolkit::Text::PlaceHolder::Property::ELLIPSIS || key == PLACEHOLDER_ELLIPSIS )
     {
       bool ellipsis;
       value.Get( ellipsis );
@@ -2050,33 +2066,33 @@ void Controller::GetPlaceholderProperty( Property::Map& map )
   {
     if( !mImpl->mEventData->mPlaceholderTextActive.empty() )
     {
-      map[ PLACEHOLDER_TEXT_FOCUSED ] = mImpl->mEventData->mPlaceholderTextActive;
+      map[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = mImpl->mEventData->mPlaceholderTextActive;
     }
     if( !mImpl->mEventData->mPlaceholderTextInactive.empty() )
     {
-      map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderTextInactive;
+      map[ Text::PlaceHolder::Property::TEXT ] = mImpl->mEventData->mPlaceholderTextInactive;
     }
 
-    map[ PLACEHOLDER_COLOR ] = mImpl->mEventData->mPlaceholderTextColor;
-    map[ PLACEHOLDER_FONT_FAMILY ] = GetPlaceholderFontFamily();
+    map[ Text::PlaceHolder::Property::COLOR ] = mImpl->mEventData->mPlaceholderTextColor;
+    map[ Text::PlaceHolder::Property::FONT_FAMILY ] = GetPlaceholderFontFamily();
 
     Property::Value fontStyleMapGet;
     GetFontStyleProperty( this, fontStyleMapGet, Text::FontStyle::PLACEHOLDER );
-    map[ PLACEHOLDER_FONT_STYLE ] = fontStyleMapGet;
+    map[ Text::PlaceHolder::Property::FONT_STYLE ] = fontStyleMapGet;
 
     // Choose font size : POINT_SIZE or PIXEL_SIZE
     if( !mImpl->mEventData->mIsPlaceholderPixelSize )
     {
-      map[ PLACEHOLDER_POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE );
+      map[ Text::PlaceHolder::Property::POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE );
     }
     else
     {
-      map[ PLACEHOLDER_PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE );
+      map[ Text::PlaceHolder::Property::PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE );
     }
 
     if( mImpl->mEventData->mPlaceholderEllipsisFlag )
     {
-      map[ PLACEHOLDER_ELLIPSIS ] = IsPlaceholderTextElideEnabled();
+      map[ Text::PlaceHolder::Property::ELLIPSIS ] = IsPlaceholderTextElideEnabled();
     }
   }
 }
@@ -2314,7 +2330,7 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent )
       // Do nothing.
       return false;
     }
-    else if( Dali::DALI_KEY_ESCAPE == keyCode || Dali::DALI_KEY_BACK == keyCode )
+    else if( Dali::DALI_KEY_ESCAPE == keyCode || Dali::DALI_KEY_BACK == keyCode  || Dali::DALI_KEY_SEARCH == keyCode )
     {
       // Do nothing
       return false;
@@ -3303,6 +3319,7 @@ bool Controller::DoRelayout( const Size& size,
     const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters;
     const Vector<Length>& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph;
     const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
+    float outlineWidth = mImpl->mModel->GetOutlineWidth();
 
     // Set the layout parameters.
     Layout::Parameters layoutParameters( size,
@@ -3317,7 +3334,8 @@ bool Controller::DoRelayout( const Size& size,
                                          glyphsPerCharacterBuffer,
                                          totalNumberOfGlyphs,
                                          mImpl->mModel->mHorizontalAlignment,
-                                         mImpl->mModel->mLineWrapMode );
+                                         mImpl->mModel->mLineWrapMode,
+                                         outlineWidth );
 
     // Resize the vector of positions to have the same size than the vector of glyphs.
     Vector<Vector2>& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions;