X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=f24e69a153cd720131e451f457c5bfedf6fa275b;hp=41344acd46acd759084755f5c629bfdc5dd25619;hb=bcbdc0b7654fb74b6527ee371deb61257abcf7a9;hpb=0b168b2809db16cbcc82378fd4b031ba3fde3113 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 41344ac..f24e69a 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -41,6 +41,7 @@ const float MAX_FLOAT = std::numeric_limits::max(); const unsigned int POINTS_PER_INCH = 72; const std::string EMPTY_STRING(""); +const unsigned int ZERO = 0u; float ConvertToEven( float value ) { @@ -232,8 +233,10 @@ void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, boo mImpl->mFontDefaults = new FontDefaults(); } - mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily; + mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily; + DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s userDefined: %s\n", defaultFontFamily.c_str(), userDefined ? "true":"false" ); mImpl->mUserDefinedFontFamily = userDefined; + // Clear the font-specific data ClearFontData(); @@ -247,20 +250,40 @@ const std::string& Controller::GetDefaultFontFamily() const { if( mImpl->mFontDefaults ) { - return mImpl->mFontDefaults->mDefaultFontFamily; + return mImpl->mFontDefaults->mFontDescription.family; + } + + return EMPTY_STRING; +} + +void Controller::SetDefaultFontStyle( const std::string& style ) +{ + if( !mImpl->mFontDefaults ) + { + mImpl->mFontDefaults = new FontDefaults(); + } + + mImpl->mFontDefaults->mFontStyle = style; +} + +const std::string& Controller::GetDefaultFontStyle() const +{ + if( mImpl->mFontDefaults ) + { + return mImpl->mFontDefaults->mFontStyle; } return EMPTY_STRING; } -void Controller::SetDefaultFontStyle( const std::string& defaultFontStyle ) +void Controller::SetDefaultFontWidth( FontWidth width ) { if( !mImpl->mFontDefaults ) { mImpl->mFontDefaults = new FontDefaults(); } - mImpl->mFontDefaults->mDefaultFontStyle = defaultFontStyle; + mImpl->mFontDefaults->mFontDescription.width = width; // Clear the font-specific data ClearFontData(); @@ -271,14 +294,70 @@ void Controller::SetDefaultFontStyle( const std::string& defaultFontStyle ) mImpl->RequestRelayout(); } -const std::string& Controller::GetDefaultFontStyle() const +FontWidth Controller::GetDefaultFontWidth() const { if( mImpl->mFontDefaults ) { - return mImpl->mFontDefaults->mDefaultFontStyle; + return mImpl->mFontDefaults->mFontDescription.width; } - return EMPTY_STRING; + return TextAbstraction::FontWidth::NORMAL; +} + +void Controller::SetDefaultFontWeight( FontWeight weight ) +{ + if( !mImpl->mFontDefaults ) + { + mImpl->mFontDefaults = new FontDefaults(); + } + + mImpl->mFontDefaults->mFontDescription.weight = weight; + + // Clear the font-specific data + ClearFontData(); + + mImpl->mOperationsPending = ALL_OPERATIONS; + mImpl->mRecalculateNaturalSize = true; + + mImpl->RequestRelayout(); +} + +FontWeight Controller::GetDefaultFontWeight() const +{ + if( mImpl->mFontDefaults ) + { + return mImpl->mFontDefaults->mFontDescription.weight; + } + + return TextAbstraction::FontWeight::NORMAL; +} + +void Controller::SetDefaultFontSlant( FontSlant slant ) +{ + if( !mImpl->mFontDefaults ) + { + mImpl->mFontDefaults = new FontDefaults(); + } + + mImpl->mFontDefaults->mFontDescription.slant = slant; + + // Clear the font-specific data + ClearFontData(); + + mImpl->mOperationsPending = ALL_OPERATIONS; + mImpl->mRecalculateNaturalSize = true; + + mImpl->RequestRelayout(); +} + +FontSlant Controller::GetDefaultFontSlant() const +{ + if( mImpl->mFontDefaults ) + { + return mImpl->mFontDefaults->mFontDescription.slant; + } + + return TextAbstraction::FontSlant::NORMAL; } void Controller::SetDefaultPointSize( float pointSize ) @@ -327,7 +406,7 @@ void Controller::UpdateAfterFontChange( std::string& newDefaultFont ) 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->mFontDefaults->mFontDescription.family = newDefaultFont; mImpl->UpdateModel( ALL_OPERATIONS ); mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED ); mImpl->mRecalculateNaturalSize = true; @@ -670,11 +749,24 @@ bool Controller::Relayout( const Size& 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; } @@ -1621,6 +1713,13 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt { mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text mImpl->mOperationsPending = ALL_OPERATIONS; + + // This is to reset the virtual keyboard to Upper-case + if( 0u == mImpl->mLogicalModel->mText.Count() ) + { + NotifyImfManager(); + } + if( 0u != mImpl->mLogicalModel->mText.Count() || !mImpl->IsPlaceholderAvailable() ) { @@ -1784,6 +1883,12 @@ bool Controller::BackspaceKeyEvent() if( removed ) { + // This is to reset the virtual keyboard to Upper-case + if( 0u == mImpl->mLogicalModel->mText.Count() ) + { + NotifyImfManager(); + } + if( 0u != mImpl->mLogicalModel->mText.Count() || !mImpl->IsPlaceholderAvailable() ) { @@ -1799,6 +1904,22 @@ bool Controller::BackspaceKeyEvent() return removed; } +void Controller::NotifyImfManager() +{ + ImfManager imfManager = ImfManager::Get(); + + if( imfManager ) + { + // Notifying IMF of a cursor change triggers a surrounding text request so updating it now. + std::string text; + GetText( text ); + imfManager.SetSurroundingText( text ); + + imfManager.SetCursorPosition( GetLogicalCursorPosition() ); + imfManager.NotifyCursorPosition(); + } +} + void Controller::ShowPlaceholderText() { if( mImpl->IsPlaceholderAvailable() )