From: Adeel Kazmi Date: Fri, 28 Aug 2015 11:51:01 +0000 (-0700) Subject: Merge "Fixes some alignment issues." into devel/master X-Git-Tag: dali_1.1.2~16 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=766fdcbec7da7e0bcdc4964c56211b195b257c16;hp=-c Merge "Fixes some alignment issues." into devel/master --- 766fdcbec7da7e0bcdc4964c56211b195b257c16 diff --combined dali-toolkit/internal/text/text-controller.cpp index 41344ac,ccc60fa..47afc96 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@@ -38,7 -38,6 +38,7 @@@ namespac #endif const float MAX_FLOAT = std::numeric_limits::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 ) { @@@ -233,7 -230,7 +233,7 @@@ } 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; }