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=5a8a6e0736ccbbf6037920fc27bafdfe949d5b9e;hp=9a46e8b1fbdb1dfe69bf8194d5cdc0549a906cc7;hb=60d99d04d7677a1b91d4f2fdd9e74bc5e1b5e7bf;hpb=23a14d2f980cba99eeb45f32d74b5b1ddab03453 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 9a46e8b..5a8a6e0 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -141,10 +141,12 @@ ControllerPtr Controller::New( ControlInterface* controlInterface ) } ControllerPtr Controller::New( ControlInterface* controlInterface, - EditableControlInterface* editableControlInterface ) + EditableControlInterface* editableControlInterface, + SelectableControlInterface* selectableControlInterface ) { return ControllerPtr( new Controller( controlInterface, - editableControlInterface ) ); + editableControlInterface, + selectableControlInterface ) ); } // public : Configure the text controller. @@ -835,6 +837,16 @@ void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily ) DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str()); mImpl->mFontDefaults->familyDefined = !defaultFontFamily.empty(); + if( mImpl->mEventData ) + { + // Update the cursor position if it's in editing mode + if( EventData::IsEditingState( mImpl->mEventData->mState ) ) + { + mImpl->mEventData->mDecoratorUpdated = true; + mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font family is updated. + } + } + // Clear the font-specific data ClearFontData(); @@ -888,6 +900,16 @@ void Controller::SetDefaultFontWeight( FontWeight weight ) mImpl->mFontDefaults->mFontDescription.weight = weight; mImpl->mFontDefaults->weightDefined = true; + if( mImpl->mEventData ) + { + // Update the cursor position if it's in editing mode + if( EventData::IsEditingState( mImpl->mEventData->mState ) ) + { + mImpl->mEventData->mDecoratorUpdated = true; + mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font weight is updated. + } + } + // Clear the font-specific data ClearFontData(); @@ -959,6 +981,16 @@ void Controller::SetDefaultFontWidth( FontWidth width ) mImpl->mFontDefaults->mFontDescription.width = width; mImpl->mFontDefaults->widthDefined = true; + if( mImpl->mEventData ) + { + // Update the cursor position if it's in editing mode + if( EventData::IsEditingState( mImpl->mEventData->mState ) ) + { + mImpl->mEventData->mDecoratorUpdated = true; + mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font width is updated. + } + } + // Clear the font-specific data ClearFontData(); @@ -1030,6 +1062,16 @@ void Controller::SetDefaultFontSlant( FontSlant slant ) mImpl->mFontDefaults->mFontDescription.slant = slant; mImpl->mFontDefaults->slantDefined = true; + if( mImpl->mEventData ) + { + // Update the cursor position if it's in editing mode + if( EventData::IsEditingState( mImpl->mEventData->mState ) ) + { + mImpl->mEventData->mDecoratorUpdated = true; + mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font slant is updated. + } + } + // Clear the font-specific data ClearFontData(); @@ -1119,6 +1161,16 @@ void Controller::SetDefaultFontSize( float fontSize, FontSizeType type ) } } + if( mImpl->mEventData ) + { + // Update the cursor position if it's in editing mode + if( EventData::IsEditingState( mImpl->mEventData->mState ) ) + { + mImpl->mEventData->mDecoratorUpdated = true; + mImpl->mEventData->mUpdateCursorPosition = true; // Cursor position should be updated when the font size is updated. + } + } + // Clear the font-specific data ClearFontData(); @@ -1462,6 +1514,22 @@ float Controller::GetDefaultLineSpacing() const return mImpl->mLayoutEngine.GetDefaultLineSpacing(); } +bool Controller::SetDefaultLineSize( float lineSize ) +{ + if( std::fabs( lineSize - mImpl->mLayoutEngine.GetDefaultLineSize() ) > Math::MACHINE_EPSILON_1000 ) + { + mImpl->mLayoutEngine.SetDefaultLineSize(lineSize); + mImpl->mRecalculateNaturalSize = true; + return true; + } + return false; +} + +float Controller::GetDefaultLineSize() const +{ + return mImpl->mLayoutEngine.GetDefaultLineSize(); +} + void Controller::SetInputColor( const Vector4& color ) { if( NULL != mImpl->mEventData ) @@ -2764,11 +2832,11 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) bool relayoutNeeded = false; if( ( NULL != mImpl->mEventData ) && - ( keyEvent.state == KeyEvent::Down ) ) + ( keyEvent.GetState() == KeyEvent::DOWN ) ) { - int keyCode = keyEvent.keyCode; - const std::string& keyString = keyEvent.keyPressed; - const std::string keyName = keyEvent.keyPressedName; + int keyCode = keyEvent.GetKeyCode(); + const std::string& keyString = keyEvent.GetKeyString(); + const std::string keyName = keyEvent.GetKeyName(); const bool isNullKey = ( 0 == keyCode ) && ( keyString.empty() ); @@ -3025,14 +3093,14 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y ) mImpl->ResetInputMethodContext(); } -void Controller::PanEvent( Gesture::State state, const Vector2& displacement ) +void Controller::PanEvent( GestureState state, const Vector2& displacement ) { DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" ); if( NULL != mImpl->mEventData ) { Event event( Event::PAN_EVENT ); - event.p1.mInt = state; + event.p1.mInt = static_cast( state ); event.p2.mFloat = displacement.x; event.p3.mFloat = displacement.y; mImpl->mEventData->mEventQueue.push_back( event ); @@ -3041,11 +3109,11 @@ void Controller::PanEvent( Gesture::State state, const Vector2& displacement ) } } -void Controller::LongPressEvent( Gesture::State state, float x, float y ) +void Controller::LongPressEvent( GestureState state, float x, float y ) { DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected LongPressEvent" ); - if( ( state == Gesture::Started ) && + if( ( state == GestureState::STARTED ) && ( NULL != mImpl->mEventData ) ) { // The 1st long-press on inactive text-field is treated as tap @@ -3064,7 +3132,7 @@ void Controller::LongPressEvent( Gesture::State state, float x, float y ) else if( !mImpl->IsShowingRealText() ) { Event event( Event::LONG_PRESS_EVENT ); - event.p1.mInt = state; + event.p1.mInt = static_cast( state ); event.p2.mFloat = x; event.p3.mFloat = y; mImpl->mEventData->mEventQueue.push_back( event ); @@ -3076,7 +3144,7 @@ void Controller::LongPressEvent( Gesture::State state, float x, float y ) mImpl->ResetInputMethodContext(); Event event( Event::LONG_PRESS_EVENT ); - event.p1.mInt = state; + event.p1.mInt = static_cast( state ); event.p2.mFloat = x; event.p3.mFloat = y; mImpl->mEventData->mEventQueue.push_back( event ); @@ -3119,6 +3187,24 @@ void Controller::SelectEvent( float x, float y, SelectionType selectType ) } } +void Controller::SetTextSelectionRange(const uint32_t *start, const uint32_t *end) +{ + if( mImpl->mEventData ) + { + mImpl->mEventData->mCheckScrollAmount = true; + mImpl->mEventData->mIsLeftHandleSelected = true; + mImpl->mEventData->mIsRightHandleSelected = true; + mImpl->SetTextSelectionRange(start, end); + mImpl->RequestRelayout(); + KeyboardFocusGainEvent(); + } +} + +Uint32Pair Controller::GetTextSelectionRange() const +{ + return mImpl->GetTextSelectionRange(); +} + InputMethodContext::CallbackData Controller::OnInputMethodContextEvent( InputMethodContext& inputMethodContext, const InputMethodContext::EventData& inputMethodContextEvent ) { // Whether the text needs to be relaid-out. @@ -3767,6 +3853,7 @@ bool Controller::RemoveText( int cursorOffset, if( ( currentText.Count() - numberOfCharacters == 0 ) && ( cursorIndex == 0 ) ) { mImpl->ClearPreEditFlag(); + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = 0; } // Updates the text style runs by removing characters. Runs with no characters are removed. @@ -4083,7 +4170,7 @@ void Controller::ProcessModifyEvents() mImpl->mEventData->mRightSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition; } - // Discard temporary text + // DISCARD temporary text events.Clear(); } @@ -4373,19 +4460,21 @@ Actor Controller::CreateBackgroundActor() Controller::Controller() : mImpl( NULL ) { - mImpl = new Controller::Impl( NULL, NULL ); + mImpl = new Controller::Impl( nullptr, nullptr, nullptr ); } Controller::Controller( ControlInterface* controlInterface ) { - mImpl = new Controller::Impl( controlInterface, NULL ); + mImpl = new Controller::Impl( controlInterface, NULL, NULL ); } Controller::Controller( ControlInterface* controlInterface, - EditableControlInterface* editableControlInterface ) + EditableControlInterface* editableControlInterface, + SelectableControlInterface* selectableControlInterface ) { mImpl = new Controller::Impl( controlInterface, - editableControlInterface ); + editableControlInterface, + selectableControlInterface ); } // The copy constructor and operator are left unimplemented.