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-impl.cpp;h=ec74f6734f5bd21e872a996eb571b515a471a9aa;hp=4ce45eb22ec738ecae14ead81282298ff4716ce2;hb=c3cac93143d2055fcc4fe6531cbdb1afbd25cfb7;hpb=27c3ff64b7236bb404bd931259674094390d63a1 diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 4ce45eb..ec74f67 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -151,8 +151,6 @@ bool Controller::Impl::ProcessInputEvents() return false; } - mEventData->mDecoratorUpdated = false; - if( mEventData->mDecorator ) { for( std::vector::iterator iter = mEventData->mEventQueue.begin(); @@ -161,16 +159,6 @@ bool Controller::Impl::ProcessInputEvents() { switch( iter->type ) { - case Event::KEYBOARD_FOCUS_GAIN_EVENT: - { - OnKeyboardFocus( true ); - break; - } - case Event::KEYBOARD_FOCUS_LOST_EVENT: - { - OnKeyboardFocus( false ); - break; - } case Event::CURSOR_KEY_EVENT: { OnCursorKeyEvent( *iter ); @@ -243,7 +231,10 @@ bool Controller::Impl::ProcessInputEvents() mEventData->mEventQueue.clear(); DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::ProcessInputEvents\n" ); - return mEventData->mDecoratorUpdated; + + bool decoratorUpdated = mEventData->mDecoratorUpdated; + mEventData->mDecoratorUpdated = false; + return decoratorUpdated; } void Controller::Impl::UpdateModel( OperationsMask operationsRequired ) @@ -406,24 +397,6 @@ void Controller::Impl::GetDefaultFonts( Vector& fonts, Length numberOfC } } -void Controller::Impl::OnKeyboardFocus( bool hasFocus ) -{ - if( NULL == mEventData ) - { - // Nothing to do if there is no text input. - return; - } - - if( !hasFocus ) - { - ChangeState( EventData::INACTIVE ); - } - else - { - ChangeState( EventData::EDITING ); - } -} - void Controller::Impl::OnCursorKeyEvent( const Event& event ) { if( NULL == mEventData ) @@ -1068,40 +1041,97 @@ void Controller::Impl::UpdateCursorPosition() return; } - CursorInfo cursorInfo; - GetCursorPosition( mEventData->mPrimaryCursorPosition, - cursorInfo ); + if( IsShowingPlaceholderText() ) + { + // Do not want to use the place-holder text to set the cursor position. - const Vector2 offset = mEventData->mScrollPosition + mAlignmentOffset; - const Vector2 cursorPosition = cursorInfo.primaryPosition + offset; + // Use the line's height of the font's family set to set the cursor's size. + // If there is no font's family set, use the default font. + // Use the current alignment to place the cursor at the beginning, center or end of the box. - // Sets the cursor position. - mEventData->mDecorator->SetPosition( PRIMARY_CURSOR, - cursorPosition.x, - cursorPosition.y, - cursorInfo.primaryCursorHeight, - cursorInfo.lineHeight ); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Primary cursor position: %f,%f\n", cursorPosition.x, cursorPosition.y ); + float lineHeight = 0.f; - // Sets the grab handle position. - mEventData->mDecorator->SetPosition( GRAB_HANDLE, - cursorPosition.x, - cursorPosition.y, - cursorInfo.lineHeight ); + FontId defaultFontId = 0u; + if( NULL == mFontDefaults ) + { + defaultFontId = mFontClient.GetFontId( EMPTY_STRING, + EMPTY_STRING ); + } + else + { + defaultFontId = mFontDefaults->GetFontId( mFontClient ); + } - if( cursorInfo.isSecondaryCursor ) - { - mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_BOTH ); - mEventData->mDecorator->SetPosition( SECONDARY_CURSOR, - cursorInfo.secondaryPosition.x + offset.x, - cursorInfo.secondaryPosition.y + offset.y, - cursorInfo.secondaryCursorHeight, - cursorInfo.lineHeight ); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + offset.x, cursorInfo.secondaryPosition.y + offset.y ); + Text::FontMetrics fontMetrics; + mFontClient.GetFontMetrics( defaultFontId, fontMetrics ); + + lineHeight = fontMetrics.ascender - fontMetrics.descender; + + + Vector2 cursorPosition; + + switch( mLayoutEngine.GetHorizontalAlignment() ) + { + case LayoutEngine::HORIZONTAL_ALIGN_BEGIN: + { + cursorPosition.x = 1.f; + break; + } + case LayoutEngine::HORIZONTAL_ALIGN_CENTER: + { + cursorPosition.x = floor( 0.5f * mControlSize.width ); + break; + } + case LayoutEngine::HORIZONTAL_ALIGN_END: + { + cursorPosition.x = mControlSize.width; + break; + } + } + + mEventData->mDecorator->SetPosition( PRIMARY_CURSOR, + cursorPosition.x, + cursorPosition.y, + lineHeight, + lineHeight ); } else { - mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY ); + CursorInfo cursorInfo; + GetCursorPosition( mEventData->mPrimaryCursorPosition, + cursorInfo ); + + const Vector2 offset = mEventData->mScrollPosition + mAlignmentOffset; + const Vector2 cursorPosition = cursorInfo.primaryPosition + offset; + + // Sets the cursor position. + mEventData->mDecorator->SetPosition( PRIMARY_CURSOR, + cursorPosition.x, + cursorPosition.y, + cursorInfo.primaryCursorHeight, + cursorInfo.lineHeight ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Primary cursor position: %f,%f\n", cursorPosition.x, cursorPosition.y ); + + // Sets the grab handle position. + mEventData->mDecorator->SetPosition( GRAB_HANDLE, + cursorPosition.x, + cursorPosition.y, + cursorInfo.lineHeight ); + + if( cursorInfo.isSecondaryCursor ) + { + mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_BOTH ); + mEventData->mDecorator->SetPosition( SECONDARY_CURSOR, + cursorInfo.secondaryPosition.x + offset.x, + cursorInfo.secondaryPosition.y + offset.y, + cursorInfo.secondaryCursorHeight, + cursorInfo.lineHeight ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Secondary cursor position: %f,%f\n", cursorInfo.secondaryPosition.x + offset.x, cursorInfo.secondaryPosition.y + offset.y ); + } + else + { + mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_PRIMARY ); + } } DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--Controller::UpdateCursorPosition\n" ); }