X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Ftext-input%2Ftext-input-decorator-impl.cpp;h=9f83898d7b07c1497730f52f38ff179ffc55468e;hp=d2ecb24ff969a09676ad846e7e9451c1e4d55d0f;hb=0697056b2ada1017c577c441c1c517ce8c08279f;hpb=00ef589046a32c53d20de1c61af7cc69524e51dc diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp index d2ecb24..9f83898 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp +++ b/base/dali-toolkit/internal/controls/text-input/text-input-decorator-impl.cpp @@ -1,24 +1,31 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include +#include #include // INTERNAL INCLUDES -#include - #include using namespace Dali; @@ -76,10 +83,17 @@ namespace Internal Decorator::Decorator( TextViewCharacterPositioning& textViewManager, TextInputTextStyle& textStyle ): mTextViewCharacterPositioning( textViewManager ), mTextStyle( textStyle ), + mSelectionHandleOnePosition(0), + mSelectionHandleTwoPosition(0), + mGrabHandlePosition(0), mCursorPosition( 0 ), mTextHighlight( textViewManager ), mCursorBlinkStatus( true ), mCursorVisibility( true ), + mCursorRTLEnabled( false ), + mIsGrabHandleInScrollArea( false ), + mIsCursorInScrollArea( false ), + mGrabHandleVisibility( false ), mGrabHandleEnabled( true ) { } @@ -115,7 +129,7 @@ Vector4 Decorator::GetBoundingBox() const /** * Selection Handles */ -void Decorator::OnHandlePan(Actor actor, PanGesture gesture) +void Decorator::OnHandlePan(Actor actor, const PanGesture& gesture) { Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne(); Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo(); @@ -231,17 +245,6 @@ Vector3 Decorator::PositionSelectionHandle( Actor selectionHandle, Vector3& actu selectionHandle.SetPosition( actualPosition += DEFAULT_HANDLE_OFFSET ); - if( mTextViewCharacterPositioning.IsScrollEnabled() ) - { - const Vector3 controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize(); - const Size cursorSize( GetCursorSizeAt( position ) ); - bool handleVisible = IsPositionWithinControl( actualPosition, Vector2(DEFAULT_HANDLE_OFFSET.width, DEFAULT_HANDLE_OFFSET.height), controlSize ); - - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::PositionSelectionHandle controlSize[%f,%f] cursorSize[%f,%f] actualPos[%f,%f] visible[%s] \n", - controlSize.x, controlSize.y, cursorSize.x, cursorSize.y, actualPosition.x, actualPosition.y, ( handleVisible )?"true":"false" ); - - selectionHandle.SetVisible( handleVisible ); - } return actualPosition; } @@ -269,7 +272,7 @@ Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle, { Vector3 actualHandlePosition; actualSelectionHandlePosition.x += displacement.x * selectionHandle.GetCurrentScale().x; - actualSelectionHandlePosition.y += displacement.y * selectionHandle.GetCurrentScale().y;; + actualSelectionHandlePosition.y += displacement.y * selectionHandle.GetCurrentScale().y; // Selection handles should jump to the nearest character std::size_t newHandlePosition = 0; @@ -282,47 +285,6 @@ Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle, bool handleVisible = true; - Vector2 min, max; - if( mTextViewCharacterPositioning.IsScrollEnabled() ) - { - const Vector3 controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize(); - const Size cursorSize( GetCursorSizeAt( newHandlePosition ) ); - - handleVisible = IsPositionWithinControl( actualHandlePosition, - cursorSize, - controlSize ); - - if( handleVisible ) - { - StopScrollTimer(); - mCurrentHandlePosition = actualHandlePosition; - mScrollDisplacement = Vector2::ZERO; - } - else - { - - if( ( actualHandlePosition.x < SCROLL_THRESHOLD ) && ( displacement.x <= 0.f ) ) - { - mScrollDisplacement.x = -SCROLL_SPEED; - } - else if( ( actualHandlePosition.x > controlSize.width - SCROLL_THRESHOLD ) && ( displacement.x >= 0.f ) ) - { - mScrollDisplacement.x = SCROLL_SPEED; - } - if( ( actualHandlePosition.y < SCROLL_THRESHOLD ) && ( displacement.y <= 0.f ) ) - { - mScrollDisplacement.y = -SCROLL_SPEED; - } - else if( ( actualHandlePosition.y > controlSize.height - SCROLL_THRESHOLD ) && ( displacement.y >= 0.f ) ) - { - mScrollDisplacement.y = SCROLL_SPEED; - } - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::MoveSelectionHandle Handle not visible scroll displacement [%f]\n", mScrollDisplacement.x); - - StartScrollTimer(); - } - } - if ( handleVisible && // Ensure the handle is visible. ( newHandlePosition != currentSelectionHandlePosition ) && // Ensure the handle has moved. ( newHandlePosition != mSelectionHandleTwoPosition ) && // Ensure new handle position not the same position as an existing handle. @@ -374,46 +336,7 @@ void Decorator::MoveGrabHandle( const Vector2& displacement /*, std::size_t curr bool handleVisible = true; - if( mTextViewCharacterPositioning.IsScrollEnabled() ) - { - const Vector3 controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize(); - const Size cursorSize( GetCursorSizeAt( newHandlePosition ) ); - // Scrolls the text if the handle is not in a visible position - handleVisible = IsPositionWithinControl( actualHandlePosition, - cursorSize, - controlSize ); - - DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::MoveGrabHandle handleVisible[%s]\n", ( handleVisible )?"true":"false"); - - if( handleVisible ) - { - StopScrollTimer(); - mCurrentHandlePosition = actualHandlePosition; - mScrollDisplacement = Vector2::ZERO; - } - else - { - if( ( actualHandlePosition.x < SCROLL_THRESHOLD ) && ( displacement.x <= 0.f ) ) - { - mScrollDisplacement.x = -SCROLL_SPEED; - } - else if( ( actualHandlePosition.x > controlSize.width - SCROLL_THRESHOLD ) && ( displacement.x >= 0.f ) ) - { - mScrollDisplacement.x = SCROLL_SPEED; - } - if( ( actualHandlePosition.y < SCROLL_THRESHOLD ) && ( displacement.y <= 0.f ) ) - { - mScrollDisplacement.y = -SCROLL_SPEED; - } - else if( ( actualHandlePosition.y > controlSize.height - SCROLL_THRESHOLD ) && ( displacement.y >= 0.f ) ) - { - mScrollDisplacement.y = SCROLL_SPEED; - } - StartScrollTimer(); - } - } - - if( ( newHandlePosition != mGrabHandlePosition ) && // Only redraw cursor and do updates if position changed + if( ( newHandlePosition != mGrabHandlePosition ) && // Only redraw cursor and do updates if position changed ( handleVisible ) )// and the new position is visible (if scroll is not enabled, it's always true). { mActualGrabHandlePosition = actualHandlePosition; @@ -433,8 +356,6 @@ void Decorator::MoveGrabHandle( const Vector2& displacement /*, std::size_t curr if ( !mTextViewCharacterPositioning.IsStyledTextEmpty() && ( cursorPosition > 0 ) ) { DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) ); - const TextStyle inputStyle = mTextViewCharacterPositioning.GetStyleAt( cursorPosition-1 ); - mTextStyle.SetInputStyle( inputStyle ); } } } @@ -506,16 +427,9 @@ void Decorator::DrawCursor(const std::size_t nthChar) // Get height of cursor and set its size Size size( CURSOR_THICKNESS, 0.0f ); - if ( !mTextViewCharacterPositioning.IsTextEmpty() ) - { - Vector2 min, max; // out parameters for GetRowRectFromCharacterPosition - size.height = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mTextViewCharacterPositioning.GetVisualPosition( cursorPosition ), min, max ).height; - } - else - { - // Measure Font so know how big text will be if no initial text to measure. - size.height = mTextViewCharacterPositioning.GetLineHeight( nthChar ); - } + + Vector2 min, max; // out parameters for GetRowRectFromCharacterPosition + size.height = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mTextViewCharacterPositioning.GetVisualPosition( cursorPosition ), min, max ).height; mCursor.SetSize(size); @@ -524,7 +438,7 @@ void Decorator::DrawCursor(const std::size_t nthChar) { DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) ); const TextStyle styleAtCursor = mTextViewCharacterPositioning.GetStyleAt( cursorPosition-1 ); - mCursor.SetRotation( styleAtCursor.GetItalics() ? Degree( styleAtCursor.GetItalicsAngle() - CURSOR_ANGLE_OFFSET ) : Degree( 0.f ), Vector3::ZAXIS ); + mCursor.SetRotation( styleAtCursor.IsItalicsEnabled() ? Degree( styleAtCursor.GetItalicsAngle() - CURSOR_ANGLE_OFFSET ) : Degree( 0.f ), Vector3::ZAXIS ); } DALI_ASSERT_DEBUG( cursorPosition <= mTextViewCharacterPositioning.GetNumberOfCharactersInText() ); @@ -537,28 +451,7 @@ void Decorator::DrawCursor(const std::size_t nthChar) SetAltCursorEnabled( altPositionValid ); - if(!altPositionValid) - { - mCursor.SetPosition( position + UI_OFFSET ); - } - else - { - size.height *= 0.5f; - mCursor.SetSize(size); - mCursor.SetPosition( position + UI_OFFSET - Vector3(0.0f, directionRTL ? 0.0f : size.height, 0.0f) ); - Vector2 min, max; // out parameters for GetRowRectFromCharacterPosition - Size rowSize = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mTextViewCharacterPositioning.GetVisualPosition( cursorPosition ), min, max ); - size.height = rowSize.height * 0.5f; - mCursorRTL.SetSize(size); - mCursorRTL.SetPosition( altPosition + UI_OFFSET - Vector3(0.0f, directionRTL ? size.height : 0.0f, 0.0f) ); - } - - if( mTextViewCharacterPositioning.IsScrollEnabled() ) - { - // Whether cursor and grab handle are inside the boundaries of the text-input when text scroll is enabled. - const Vector3& controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize(); - mIsCursorInScrollArea = mIsGrabHandleInScrollArea = IsPositionWithinControl( position, size, controlSize ); - } + mCursor.SetPosition( position + UI_OFFSET ); } } @@ -690,7 +583,6 @@ void Decorator::CreateHighlight( Actor parent ) { mHighlightMeshActor = MeshActor::New( mTextHighlight.CreateHighLightMesh() ); mHighlightMeshActor.SetName( "HighlightMeshActor" ); - mHighlightMeshActor.SetInheritShaderEffect( false ); mHighlightMeshActor.SetAffectedByLighting(false); parent.Add( mHighlightMeshActor ); } @@ -937,10 +829,6 @@ void Decorator::ShowPopupCutCopyPaste() void Decorator::HidePopUp( bool animate, bool signalFinished ) { - if ( ( mPopUpPanel.GetState() == TextInputPopupNew::StateShowing ) || ( mPopUpPanel.GetState() == TextInputPopupNew::StateShown ) ) - { - mPopUpPanel.Hide( animate ); - } } void Decorator::AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption) @@ -1108,12 +996,6 @@ bool Decorator::OnScrollTimerTick() scrollPosition += scrollDelta; mTextViewCharacterPositioning.SetScrollPosition( scrollPosition ); - // If scroll position goes too far TextView will trim it to fit. - if ( mTextViewCharacterPositioning.IsScrollPositionTrimmed() ) - { - StopScrollTimer(); - } - mActualGrabHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newGrabHandlePosition ).GetVectorXY(); } } @@ -1137,11 +1019,6 @@ bool Decorator::OnScrollTimerTick() scrollPosition += scrollDelta; mTextViewCharacterPositioning.SetScrollPosition( scrollPosition ); - if( mTextViewCharacterPositioning.IsScrollPositionTrimmed() ) - { - StopScrollTimer(); - } - mSelectionHandleOnePosition = newHandleOnePosition; mSelectionHandleOneActualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition ).GetVectorXY(); } @@ -1163,11 +1040,6 @@ bool Decorator::OnScrollTimerTick() scrollPosition += scrollDelta; mTextViewCharacterPositioning.SetScrollPosition( scrollPosition ); - if( mTextViewCharacterPositioning.IsScrollPositionTrimmed() ) - { - StopScrollTimer(); - } - mSelectionHandleTwoPosition = newHandleTwoPosition; mCurrentHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition ).GetVectorXY();