Merge "Fixes some alignment issues." into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 28 Aug 2015 11:51:01 +0000 (04:51 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 28 Aug 2015 11:51:02 +0000 (04:51 -0700)
1  2 
dali-toolkit/internal/text/text-controller.cpp

@@@ -38,7 -38,6 +38,7 @@@ namespac
  #endif
  
  const float MAX_FLOAT = std::numeric_limits<float>::max();
 +const unsigned int POINTS_PER_INCH = 72;
  
  const std::string EMPTY_STRING("");
  
@@@ -74,8 -73,6 +74,8 @@@ void Controller::EnableTextInput( Decor
  
  void Controller::SetText( const std::string& text )
  {
 +  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText\n" );
 +
    // Remove the previously set text
    ResetText();
  
@@@ -225,7 -222,7 +225,7 @@@ int Controller::GetMaximumNumberOfChara
    return mImpl->mMaximumNumberOfCharacters;
  }
  
 -void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
 +void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined )
  {
    if( !mImpl->mFontDefaults )
    {
    }
  
    mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily;
 -
 +  mImpl->mUserDefinedFontFamily = userDefined;
    // Clear the font-specific data
    ClearFontData();
  
@@@ -290,15 -287,6 +290,15 @@@ void Controller::SetDefaultPointSize( f
  
    mImpl->mFontDefaults->mDefaultPointSize = pointSize;
  
 +  unsigned int horizontalDpi( 0u );
 +  unsigned int verticalDpi( 0u );
 +  mImpl->mFontClient.GetDpi( horizontalDpi, verticalDpi );
 +
 +  // Adjust the metrics if the fixed-size font should be down-scaled
 +  int maxEmojiSize( pointSize/POINTS_PER_INCH * verticalDpi );
 +  DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultPointSize %p setting MaxEmojiSize %d\n", this, maxEmojiSize );
 +  mImpl->mMetrics->SetMaxEmojiSize( maxEmojiSize );
 +
    // Clear the font-specific data
    ClearFontData();
  
@@@ -318,23 -306,6 +318,23 @@@ float Controller::GetDefaultPointSize(
    return 0.0f;
  }
  
 +void Controller::UpdateAfterFontChange( std::string& newDefaultFont )
 +{
 +  DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange");
 +
 +  ClearFontData();
 +
 +  if ( !mImpl->mUserDefinedFontFamily ) // If user defined font then should not update when system font changes
 +  {
 +    DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
 +    mImpl->mFontDefaults->mDefaultFontFamily=newDefaultFont;
 +    mImpl->UpdateModel( ALL_OPERATIONS );
 +    mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
 +    mImpl->mRecalculateNaturalSize = true;
 +    mImpl->RequestRelayout();
 +  }
 +}
 +
  void Controller::SetTextColor( const Vector4& textColor )
  {
    mImpl->mTextColor = textColor;
@@@ -670,11 -641,24 +670,24 @@@ bool Controller::Relayout( const Size& 
    // Do not re-do any operation until something changes.
    mImpl->mOperationsPending = NO_OPERATION;
  
+   // Keep the current offset and alignment as it will be used to update the decorator's positions.
+   Vector2 offset;
+   if( mImpl->mEventData )
+   {
+     offset = mImpl->mAlignmentOffset + mImpl->mEventData->mScrollPosition;
+   }
    // After doing the text layout, the alignment offset to place the actor in the desired position can be calculated.
    CalculateTextAlignment( size );
  
    if( mImpl->mEventData )
    {
+     // If there is a nex size, the scroll position needs to be clamped.
+     mImpl->ClampHorizontalScroll( layoutSize );
+     // Update the decorator's positions.
+     mImpl->mEventData->mDecorator->UpdatePositions( mImpl->mAlignmentOffset + mImpl->mEventData->mScrollPosition - offset );
      // Move the cursor, grab handle etc.
      updated = mImpl->ProcessInputEvents() || updated;
    }