X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-input%2Ftext-input-impl.h;h=8df0ac92694ca190d75ec5334f94135afb960667;hb=refs%2Ftags%2Fsubmit%2Ftizen%2F20150309.074330;hp=e3a760814961da68d31f500f146a3c0186774b8b;hpb=e2e777d22421d671e2bc7bf81148f7b89a44e807;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/text-input/text-input-impl.h b/dali-toolkit/internal/controls/text-input/text-input-impl.h index e3a7608..8df0ac9 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-impl.h +++ b/dali-toolkit/internal/controls/text-input/text-input-impl.h @@ -1,34 +1,39 @@ #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__ #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_H__ -// -// 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include // INTERNAL INCLUDES #include #include #include -#include #include #include -#include -#include -#include - namespace Dali { @@ -43,7 +48,7 @@ class TextView; typedef IntrusivePtr TextInputPtr; -class TextInput : public ControlImpl +class TextInput : public Control { public: @@ -113,32 +118,37 @@ public: /** * @copydoc Toolkit::TextInput::InputStartedSignal() */ - Toolkit::TextInput::InputSignalV2& InputStartedSignal(); + Toolkit::TextInput::InputSignalType& InputStartedSignal(); /** * @copydoc Toolkit::TextInput::InputFinishedSignal() */ - Toolkit::TextInput::InputSignalV2& InputFinishedSignal(); + Toolkit::TextInput::InputSignalType& InputFinishedSignal(); /** * @copydoc Toolkit::TextInput::CutAndPasteToolBarDisplayedSignal() */ - Toolkit::TextInput::InputSignalV2& CutAndPasteToolBarDisplayedSignal(); + Toolkit::TextInput::InputSignalType& CutAndPasteToolBarDisplayedSignal(); /** * @copydoc Toolkit::TextInput::StyleChangedSignal() */ - Toolkit::TextInput::StyleChangedSignalV2& StyleChangedSignal(); + Toolkit::TextInput::StyleChangedSignalType& StyleChangedSignal(); + + /** + * @copydoc Toolkit::TextInput::TextModifiedSignal() + */ + Toolkit::TextInput::TextModifiedSignalType& TextModifiedSignal(); /** * @copydoc Toolkit::TextInput::MaxInputCharactersReachedSignal() */ - Toolkit::TextInput::MaxInputCharactersReachedSignalV2& MaxInputCharactersReachedSignal(); + Toolkit::TextInput::MaxInputCharactersReachedSignalType& MaxInputCharactersReachedSignal(); /** * @copydoc Toolkit::TextInput::InputTextExceedBoundariesSignal() */ - Toolkit::TextInput::InputTextExceedBoundariesSignalV2& InputTextExceedBoundariesSignal(); + Toolkit::TextInput::InputTextExceedBoundariesSignalType& InputTextExceedBoundariesSignal(); /** * Connects a callback function with the object's signals. @@ -373,6 +383,22 @@ public: */ std::size_t GetNumberOfCharacters() const; + /** + * Styling + */ + + /** + * Set the diffuse color for the highlight + * @param[in] color color to use + */ + void SetMaterialDiffuseColor( const Vector4& color ); + + /** + * Get the diffuse color used by the highlight + * @return color + */ + const Vector4& GetMaterialDiffuseColor() const; + private: /** @@ -521,11 +547,11 @@ private: virtual void OnKeyInputFocusLost(); /** - * From ControlImpl; called whenever the control is added to the stage. + * From Control; called whenever the control is added to the stage. */ virtual void OnControlStageConnection(); -private: // From ControlImpl +private: // From Control /** * Creation of the layer that is used by top level active parts of the TextInput like handles @@ -533,19 +559,19 @@ private: // From ControlImpl void CreateActiveLayer(); /** - * @copydoc Toolkit::ControlImpl::OnInitialize() + * @copydoc Control::OnInitialize() */ virtual void OnInitialize(); /** - * @copydoc Toolkit::ControlImpl::OnControlSizeSet() + * @copydoc Control::OnControlSizeSet() */ virtual void OnControlSizeSet(const Vector3& targetSize); /** - * @copydoc Toolkit::ControlImpl::OnRelaidOut() + * @copydoc Control::OnRelayout() */ - virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container ); + virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container ); /** * Retrieves the text-input's natural size by calling TextView::GetNaturalSize(). @@ -588,7 +614,7 @@ private: * @param actor Handle of the selection or grab handle. * @param gesture Data structure with the parameters of the gesture. */ - void OnHandlePan(Actor actor, PanGesture gesture); + void OnHandlePan(Actor actor, const PanGesture& gesture); /** * Callback for touch down on Grab handle @@ -616,21 +642,21 @@ private: * @param[in] actor * @param[in] tap touch event */ - void OnTextTap(Dali::Actor actor, Dali::TapGesture tap); + void OnTextTap(Dali::Actor actor, const Dali::TapGesture& tap); /** * Callback for double tap on TextInput * @param[in] actor * @param[in] tap touch event */ - void OnDoubleTap(Dali::Actor actor, Dali::TapGesture tap); + void OnDoubleTap(Dali::Actor actor, const Dali::TapGesture& tap); /** * Callback for long press on TextInput * @param[in] actor * @param[in] longPress long press event */ - void OnLongPress(Dali::Actor actor, Dali::LongPressGesture longPress); + void OnLongPress(Dali::Actor actor, const Dali::LongPressGesture& longPress); /** * Callback for the ClipboardEventNotifier when text is selected in the clipboard window. @@ -675,6 +701,22 @@ private: bool OnKeyUpEvent(const KeyEvent& event); /** + * Chooses from all handle position and alternative handle positions where to set the position of the two selection handles. + * + * @param[in] cursorPositionOne The initial position of the first selection handle. + * @param[in] cursorPositionTwo The initial position of the second selection handle. + * @param[in] altPositionValidOne Whether there is an alternative position for the first selection handle. + * @param[in] altPositionValidTwo Whether there is an alternative position for the second selection handle. + * @param[in] altPositionOne The alternative position of the first selection handle. + * @param[in] altPositionTwo The alternative position of the second selection handle. + */ + void ChooseRtlSelectionHandlePosition( const Vector3& cursorPositionOne, + const Vector3& cursorPositionTwo, + bool altPositionValidOne, + bool altPositionValidTwo, + const Vector3& altPositionOne, + const Vector3& altPositionTwo ); + /** * Callback called when the text-view is scrolled. * * Updates the selection and grab handles, and the highlighted text. @@ -838,12 +880,11 @@ public: // Public to allow internal testing. std::size_t InsertAt( const Text& newText, const std::size_t insertionPosition, const std::size_t numberOfCharactersToReplace ); /** - * Creates a cursor from the supplied image - * @param[in] cursorImage the image to be used for the cursor. - * @param[in] border the nine patch border corresponding to the supplied image. - * @return the image actor to be used as the cursor. - */ - ImageActor CreateCursor( Image cursorImage, const Vector4& border ); + * Creates a cursor. + * @param[in] color the cursor color. + * @return the image actor to be used as the cursor. + */ + ImageActor CreateCursor( const Vector4 &color ); /** * Moves cursor to the right @@ -854,9 +895,8 @@ public: // Public to allow internal testing. /** * Draw a cursor / caret at position where new text should appear - * @param[in] nthChar the position along the text string in which new text should appear. */ - void DrawCursor(const std::size_t nthChar = 0); + void DrawCursor(); /** * Sets cursor visibility @@ -991,15 +1031,6 @@ public: // Public to allow internal testing. void SetSelectionHandlePosition(SelectionHandleId handleId); /** - * Gets the visual position of a logical position. - * @note This is preferred over directly accessing the Map, as it resolves visual - * positions outside of the character map range. - * @param[in] logicalPosition The logical position - * @return Visual position is returned. - */ - std::size_t GetVisualPosition(std::size_t logicalPosition) const; - - /** * Gets a table of the visual text positions which has a flag * for each Character. The flag is either true (character selected) * or false (character deselected) @@ -1017,6 +1048,11 @@ public: // Public to allow internal testing. HighlightInfo CalculateHighlightInfo(); /** + * This method was added to fix a PLM. it creates one quad per character so the mesh can show different selection boxes when a mix of right to left and left to right text is selected. + */ + HighlightInfo CalculateHighlightInfoRtl(); + + /** * Calculates new Mesh data so highlight moves with selection handles. */ void UpdateHighlight(); @@ -1027,21 +1063,16 @@ public: // Public to allow internal testing. void ClearPopup(); /** - * Adds a popup option. - * @note Creates popup frame if not already created. - * @param[in] name The unique name for this option. - * @param[in] caption The caption (label) for this option - * @param[in] icon the image icon to be displayed for this option - * @param[in] finalOption Flag to indicate that this is the final option. - * (set to true on the last option you add) + * Adds Popup options which have been enabled. */ - void AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption = false); + void AddPopupOptions(); /** * Sets popup position * @param[in] position The actual position for this popup. + * @param[in] alternativePosition Alternative popup position if no space in upper area. */ - void SetPopupPosition(const Vector3& position); + void SetPopupPosition(const Vector3& position, const Vector2& alternativePosition ); /** * Hides the popup @@ -1063,8 +1094,10 @@ public: // Public to allow internal testing. /** * Setup the selection popup and clipboard if relevant so the correct options are shown when ShowPopup is called. + * @param[in] showCutButton Flag to show or hide cut button, in some cases like whitespace we do not want to cut just select. + * default is true. */ - void SetUpPopUpSelection(); + void SetUpPopupSelection( bool showCutButton = true ); /** * Return the logical index containing the character position closest to the source. @@ -1131,6 +1164,15 @@ public: // Public to allow internal testing. std::size_t GetRowStartFromCharacterPosition(std::size_t logicalPosition) const; /** + * Retrieves the first character of a group of characters with the same direction. + * + * @param[in] logicalPosition Index to a character. + * + * @return Index to the character. + */ + std::size_t GetFirstCharacterWithSameDirection( std::size_t logicalPosition ) const; + + /** * Retrieve the dimensions of this row of text that the character resides on. * @param[in] characterPosition the position in the 'string' of characters. * @return The size of the rectangle representing this row @@ -1197,8 +1239,9 @@ public: // Public to allow internal testing. /** * Hide highlight shown between selection handles. + * @param[in] hidePopup flag to hide the popup too, default is to hide popup. */ - void RemoveHighlight(); + void RemoveHighlight( bool hidePopup = true ); /** * Highlights text that has been selected @@ -1312,11 +1355,52 @@ public: // Public to allow internal testing. void GetTextLayoutInfo(); /** + * Set the offset for positioning Popup from the TextInput + * @param[in] offset in the order, left, top, right, bottom + */ + void SetOffsetFromText( const Vector4& offset ); + + /** + * Get the offset of the Popup from the TextInput + * @return Vector4 with the offset in the order, left, top, right, bottom + */ + const Vector4& GetOffsetFromText() const; + + /** + * Show the Placeholder text with an already created StyleTextArray + * @param[in] stylePlaceHolderText Required placeholder text to be used + */ + void ShowPlaceholderText( const MarkupProcessor::StyledTextArray& stylePlaceHolderText ); + + // Properties + + /** + * Called when a property of an object of this type is set. + * @param[in] object The object whose property is set. + * @param[in] index The property index. + * @param[in] value The new property value. + */ + static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ); + + /** + * Called to retrieve a property of an object of this type. + * @param[in] object The object whose property is to be retrieved. + * @param[in] index The property index. + * @return The current value of the property. + */ + static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex ); + + /** * Emits the style changed signal. */ void EmitStyleChangedSignal(); /** + * Emit signal when text is modified. + */ + void EmitTextModified(); + + /** * Emits max input characters reached signal. */ void EmitMaxInputCharactersReachedSignal(); @@ -1396,7 +1480,7 @@ private: ///< the text size after layout and the scroll offset. MarkupProcessor::StyledTextArray mCurrentCopySelecton; ///< Array to store copied text. - TextInputPopup mPopUpPanel; ///< Panel to house cut and paste, select all buttons. + TextInputPopup mPopupPanel; ///< Panel to house cut and paste, select all buttons. Timer mScrollTimer; Vector2 mScrollDisplacement; @@ -1407,7 +1491,11 @@ private: Vector4 mSelectionHandleFlipMargin; Vector4 mBoundingRectangleWorldCoordinates; - Clipboard mClipboard; ///< Handle to clipboard + Clipboard mClipboard; ///< Handle to clipboard + + // Styling + Vector4 mMaterialColor; // Color of the highlight + Vector4 mPopupOffsetFromText; // Offset of Popup from the TextInput. bool mOverrideAutomaticAlignment:1; ///< Whether to override the alignment automatically set by the text content (e.g. european LTR or arabic RTL) bool mCursorRTLEnabled:1; ///< Enable state of Alternate RTL Cursor (need to keep track of this as it's not always enabled) @@ -1443,12 +1531,13 @@ private: bool mPlaceHolderSet:1; ///< Whether the place holder text is set. bool mMarkUpEnabled:1; ///< enable to scan for mark-up - Toolkit::TextInput::InputSignalV2 mInputStartedSignalV2; ///< Signal emitted when input starts - Toolkit::TextInput::InputSignalV2 mInputFinishedSignalV2; ///< Signal emitted when input ends - Toolkit::TextInput::StyleChangedSignalV2 mStyleChangedSignalV2; ///< Signal emitted when style changes. - Toolkit::TextInput::MaxInputCharactersReachedSignalV2 mMaxInputCharactersReachedSignalV2; ///< Signal emitted when max input characters is reached. - Toolkit::TextInput::InputSignalV2 mCutAndPasteToolBarDisplayedV2; ///< Signal emitted when toolbar displayed - Toolkit::TextInput::InputTextExceedBoundariesSignalV2 mInputTextExceedBoundariesSignalV2; ///< Signal emitted when input text exceeds the boundaries of the text-input. + Toolkit::TextInput::InputSignalType mInputStartedSignal; ///< Signal emitted when input starts + Toolkit::TextInput::InputSignalType mInputFinishedSignal; ///< Signal emitted when input ends + Toolkit::TextInput::StyleChangedSignalType mStyleChangedSignal; ///< Signal emitted when style changes. + Toolkit::TextInput::TextModifiedSignalType mTextModifiedSignal; ///< Signal emitted when text modified. + Toolkit::TextInput::MaxInputCharactersReachedSignalType mMaxInputCharactersReachedSignal; ///< Signal emitted when max input characters is reached. + Toolkit::TextInput::InputSignalType mCutAndPasteToolBarDisplayed; ///< Signal emitted when toolbar displayed + Toolkit::TextInput::InputTextExceedBoundariesSignalType mInputTextExceedBoundariesSignal; ///< Signal emitted when input text exceeds the boundaries of the text-input. }; } // namespace Internal