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=3e90dd10342ea234e0b28a16f16c4a3cd980a07c;hp=1e034a3afe63c553f1cd7906b76d9b69a6af6e5d;hb=d5e3ed5f5b1c8fdba3ae97ead8729620f54b3836;hpb=30f6ca1e541089b19f2b349a8a12d8a5bcaf2f9e 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 1e034a3..3e90dd1 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,18 +1,19 @@ -// -// 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. + * + */ #include @@ -29,38 +30,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 @@ -150,22 +152,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; @@ -253,12 +252,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; @@ -268,8 +261,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, @@ -837,7 +828,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 );