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=a529f37bb3b299b332912303c171cbd6f5b35b75;hp=d9d1e73e5938e875ceac564fd511ff0ec678c043;hb=efc7867951058f01bbbf9694a24726e1dfaf5c16;hpb=a881757839b7abb008873a68c67e17b3ba39669b 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 d9d1e73..a529f37 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 @@ -15,11 +15,17 @@ * */ +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include +#include #include // INTERNAL INCLUDES -#include - #include using namespace Dali; @@ -30,38 +36,39 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TEXT_INPUT_DECORATOR"); #endif - const Vector3 DEFAULT_SELECTION_HANDLE_SIZE( 51.0f, 79.0f, 0.0f ); - const float TOP_HANDLE_TOP_OFFSET(-1.5f); // Offset between top handle and cutCopyPaste pop-up - const float BOTTOM_HANDLE_BOTTOM_OFFSET(1.5f); // Offset between bottom handle and cutCopyPaste pop-up - const float UI_Z_OFFSET( 0.2f ); // Text Selection Handles/Cursor z-offset. - const Vector3 UI_OFFSET(0.0f, 0.0f, UI_Z_OFFSET); // Text Selection Handles/Cursor offset. - const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" ); - const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f ); - const std::size_t CURSOR_BLINK_INTERVAL = 500; // Cursor blink interval - const float CURSOR_THICKNESS(6.0f); - const Degree CURSOR_ANGLE_OFFSET(2.0f); // Offset from the angle - - const unsigned int SCROLL_TICK_INTERVAL = 50u; - const float SCROLL_THRESHOLD = 10.f; - const float SCROLL_SPEED = 15.f; - - /** - * Whether the given position plus the cursor size offset is inside the given boundary. - * - * @param[in] position The given position. - * @param[in] cursorSize The cursor size. - * @param[in] controlSize The given boundary. - * @param[in] threshold imaginary indent around boundary that will trigger the position to be outside of control. - * - * @return whether the given position is inside the given boundary. - */ - bool IsPositionWithinControl( const Vector3& position, const Size& cursorSize, const Vector3& controlSize, const Vector2 threshold = Vector2::ZERO ) - { - return ( position.x >= -Math::MACHINE_EPSILON_1000 + threshold.x ) && - ( position.x <= controlSize.width - threshold.x + Math::MACHINE_EPSILON_1000 ) && - ( position.y - cursorSize.height >= -Math::MACHINE_EPSILON_1000 + threshold.y ) && - ( position.y <= controlSize.height + Math::MACHINE_EPSILON_1000 - threshold.y); - } +const Vector3 DEFAULT_SELECTION_HANDLE_SIZE( 51.0f, 79.0f, 0.0f ); +const float TOP_HANDLE_TOP_OFFSET(-1.5f); // Offset between top handle and cutCopyPaste pop-up +const float BOTTOM_HANDLE_BOTTOM_OFFSET(1.5f); // Offset between bottom handle and cutCopyPaste pop-up +const float UI_Z_OFFSET( 0.2f ); // Text Selection Handles/Cursor z-offset. +const Vector3 UI_OFFSET(0.0f, 0.0f, UI_Z_OFFSET); // Text Selection Handles/Cursor offset. +const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" ); +const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f ); +const std::size_t CURSOR_BLINK_INTERVAL = 500; // Cursor blink interval +const float CURSOR_THICKNESS(6.0f); +const Degree CURSOR_ANGLE_OFFSET(2.0f); // Offset from the angle + +const unsigned int SCROLL_TICK_INTERVAL = 50u; +const float SCROLL_THRESHOLD = 10.f; +const float SCROLL_SPEED = 15.f; + +/** + * Whether the given position plus the cursor size offset is inside the given boundary. + * + * @param[in] position The given position. + * @param[in] cursorSize The cursor size. + * @param[in] controlSize The given boundary. + * @param[in] threshold imaginary indent around boundary that will trigger the position to be outside of control. + * + * @return whether the given position is inside the given boundary. + */ +bool IsPositionWithinControl( const Vector3& position, const Size& cursorSize, const Vector3& controlSize, const Vector2 threshold = Vector2::ZERO ) +{ + return ( position.x >= -Math::MACHINE_EPSILON_1000 + threshold.x ) && + ( position.x <= controlSize.width - threshold.x + Math::MACHINE_EPSILON_1000 ) && + ( position.y - cursorSize.height >= -Math::MACHINE_EPSILON_1000 + threshold.y ) && + ( position.y <= controlSize.height + Math::MACHINE_EPSILON_1000 - threshold.y); +} + } namespace Dali @@ -151,22 +158,19 @@ void Decorator::OnHandlePan(Actor actor, PanGesture gesture) // Revert back to non-pressed selection handle images if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleOne() ) { - mSelectionHandleOneActualPosition = MoveSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition, gesture.displacement ); + mSelectionHandleOneActualPosition = MoveSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition, gesture.displacement ); ShowPopupCutCopyPaste(); - ShowPopUp(); } else if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleTwo() ) { mSelectionHandleTwoActualPosition = MoveSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition, gesture.displacement ); ShowPopupCutCopyPaste(); - ShowPopUp(); } else if ( actor.GetParent() == mTextInputHandles.GetGrabHandle() ) { MoveGrabHandle( gesture.displacement ); SetCursorVisibility( true ); ShowPopupCutCopyPaste(); - ShowPopUp(); } } break; @@ -254,12 +258,6 @@ void Decorator::SetSelectionHandlesVisibility(bool visible ) mTextInputHandles.SetSelectionHandleTwoVisibility( visible ); } -bool Decorator::OnHandleReleased() -{ - ShowPopUp(); - return false; -} - void Decorator::PositionSelectionHandles( std::size_t start, std::size_t end ) { mSelectionHandleOnePosition = start; @@ -269,8 +267,6 @@ void Decorator::PositionSelectionHandles( std::size_t start, std::size_t end ) mSelectionHandleOneActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleOne(), mSelectionHandleOnePosition ); mSelectionHandleTwoActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleTwo(), mSelectionHandleTwoPosition ); - - mTextInputHandles.ReleasedSignal().Connect( this, &Decorator::OnHandleReleased ); } Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle, @@ -535,7 +531,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() ); @@ -701,7 +697,6 @@ void Decorator::CreateHighlight( Actor parent ) { mHighlightMeshActor = MeshActor::New( mTextHighlight.CreateHighLightMesh() ); mHighlightMeshActor.SetName( "HighlightMeshActor" ); - mHighlightMeshActor.SetInheritShaderEffect( false ); mHighlightMeshActor.SetAffectedByLighting(false); parent.Add( mHighlightMeshActor ); } @@ -838,7 +833,7 @@ Vector3 Decorator::PositionOfPopUpRelativeToSelectionHandles() // When text is selected, show popup above top handle (and text), or below bottom handle. // topHandle: referring to the top most point of the handle or the top line of selection. - if ( mSelectionHandleTwoActualPosition.y > mSelectionHandleOneActualPosition.y ) + if ( mSelectionHandleTwoActualPosition.y > mSelectionHandleOneActualPosition.y ) // Handle may switch positions so calculate which is top. { topHandle = mSelectionHandleOneActualPosition; rowSize= mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mSelectionHandleOnePosition, min, max );