Merge "Stop doing unparent and reset in text decorator." into devel/master
authorPaul Wisbey <p.wisbey@samsung.com>
Mon, 6 Jul 2015 15:45:47 +0000 (08:45 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Mon, 6 Jul 2015 15:45:47 +0000 (08:45 -0700)
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/public-api/controls/control-impl.cpp

index f743c25..dd6ea63 100644 (file)
@@ -441,6 +441,25 @@ void Controller::Impl::GetDefaultFonts( Vector<FontRun>& fonts, Length numberOfC
   }
 }
 
+float Controller::Impl::GetDefaultFontLineHeight()
+{
+  FontId defaultFontId = 0u;
+  if( NULL == mFontDefaults )
+  {
+    defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
+                                           EMPTY_STRING );
+  }
+  else
+  {
+    defaultFontId = mFontDefaults->GetFontId( mFontClient );
+  }
+
+  Text::FontMetrics fontMetrics;
+  mFontClient.GetFontMetrics( defaultFontId, fontMetrics );
+
+  return( fontMetrics.ascender - fontMetrics.descender );
+}
+
 void Controller::Impl::OnCursorKeyEvent( const Event& event )
 {
   if( NULL == mEventData )
@@ -1338,23 +1357,8 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
 
   if( isFirstPosition && isLastPosition )
   {
-    // There is zero characters. Get the default font.
-
-    FontId defaultFontId = 0u;
-    if( NULL == mFontDefaults )
-    {
-      defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
-                                             EMPTY_STRING );
-    }
-    else
-    {
-      defaultFontId = mFontDefaults->GetFontId( mFontClient );
-    }
-
-    Text::FontMetrics fontMetrics;
-    mFontClient.GetFontMetrics( defaultFontId, fontMetrics );
-
-    cursorInfo.lineHeight = fontMetrics.ascender - fontMetrics.descender;
+    // There is zero characters. Get the default font's line height.
+    cursorInfo.lineHeight = GetDefaultFontLineHeight();
     cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
 
     cursorInfo.primaryPosition.x = 1.f;
index 434a1e0..426cc60 100644 (file)
@@ -330,6 +330,11 @@ struct Controller::Impl
    */
   void GetDefaultFonts( Dali::Vector<FontRun>& fonts, Length numberOfCharacters );
 
+  /**
+   * @brief Retrieve the line height of the default font.
+   */
+  float GetDefaultFontLineHeight();
+
   void OnCursorKeyEvent( const Event& event );
 
   void OnTapEvent( const Event& event );
index 3b9c725..68555b7 100644 (file)
@@ -1016,7 +1016,12 @@ void Controller::CalculateTextAlignment( const Size& size )
   // Get the direction of the first character.
   const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
 
-  const Size& actualSize = mImpl->mVisualModel->GetActualSize();
+  Size actualSize = mImpl->mVisualModel->GetActualSize();
+  if( fabsf( actualSize.height ) < Math::MACHINE_EPSILON_1000 )
+  {
+    // Get the line height of the default font.
+    actualSize.height = mImpl->GetDefaultFontLineHeight();
+  }
 
   // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
   LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
index 2274995..c0c71ea 100644 (file)
@@ -548,9 +548,12 @@ void Control::SetStyleName( const std::string& styleName )
   {
     mImpl->mStyleName = styleName;
 
-    // Apply new style
+    // Apply new style, if stylemanager is available
     Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
-    GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+    if( styleManager )
+    {
+      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+    }
   }
 }
 
@@ -865,12 +868,15 @@ void Control::Initialize()
   if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
   {
     Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+    // if stylemanager is available
+    if( styleManager )
+    {
+      // Register for style changes
+      styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
 
-    // Register for style changes
-    styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
-
-    // Apply the current style
-    GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+      // Apply the current style
+      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+    }
   }
 
   if( mImpl->mFlags & REQUIRES_KEYBOARD_NAVIGATION_SUPPORT )