X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-impl.h;h=db02721278224b883a60748d38d6f4a35e31f019;hb=af1b5886e64600f578dc10edc257aad5f0574196;hp=5dd231a0b967946cfda6d0ed2276cbebedfc4a90;hpb=d1f61f0ceb1ea35714742033ac3fe033392c862b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 5dd231a..db02721 100755 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_TEXT_CONTROLLER_IMPL_H /* - * Copyright (c) 2017 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. @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES #include @@ -42,10 +43,15 @@ namespace Text const float DEFAULT_TEXTFIT_MIN = 10.f; const float DEFAULT_TEXTFIT_MAX = 100.f; const float DEFAULT_TEXTFIT_STEP = 1.f; +const float DEFAULT_FONT_SIZE_SCALE = 1.f; //Forward declarations struct CursorInfo; struct FontDefaults; +struct ControllerImplEventHandler; +struct SelectionHandleController; + +class SelectableControlInterface; struct Event { @@ -60,7 +66,8 @@ struct Event LEFT_SELECTION_HANDLE_EVENT, RIGHT_SELECTION_HANDLE_EVENT, SELECT, - SELECT_ALL + SELECT_ALL, + SELECT_NONE, }; union Param @@ -103,7 +110,7 @@ struct EventData EventData( DecoratorPtr decorator, InputMethodContext& inputMethodContext ); - ~EventData(); + ~EventData() = default; static bool IsEditingState( State stateToCheck ) { @@ -168,6 +175,7 @@ struct EventData bool mPlaceholderEllipsisFlag : 1; ///< True if the text controller sets the placeholder ellipsis. bool mShiftSelectionFlag : 1; ///< True if the text selection using Shift key is enabled. bool mUpdateAlignment : 1; ///< True if the whole text needs to be full aligned.. + bool mEditingEnabled : 1; ///< True if the editing is enabled, false otherwise. }; struct ModifyEvent @@ -200,11 +208,11 @@ struct FontDefaults fontClient.GetDefaultPlatformFontDescription( mFontDescription ); } - FontId GetFontId( TextAbstraction::FontClient& fontClient ) + FontId GetFontId( TextAbstraction::FontClient& fontClient, float fontPointSize ) { if( !mFontId ) { - const PointSize26Dot6 pointSize = static_cast( mDefaultPointSize * 64.f ); + const PointSize26Dot6 pointSize = static_cast( fontPointSize * 64.f ); mFontId = fontClient.GetFontId( mFontDescription, pointSize ); } @@ -306,9 +314,11 @@ struct OutlineDefaults struct Controller::Impl { Impl( ControlInterface* controlInterface, - EditableControlInterface* editableControlInterface ) + EditableControlInterface* editableControlInterface, + SelectableControlInterface* selectableControlInterface ) : mControlInterface( controlInterface ), mEditableControlInterface( editableControlInterface ), + mSelectableControlInterface( selectableControlInterface ), mModel(), mFontDefaults( NULL ), mUnderlineDefaults( NULL ), @@ -341,7 +351,8 @@ struct Controller::Impl mTextFitMinSize( DEFAULT_TEXTFIT_MIN ), mTextFitMaxSize( DEFAULT_TEXTFIT_MAX ), mTextFitStepSize( DEFAULT_TEXTFIT_STEP ), - mTextFitEnabled( false ) + mTextFitEnabled( false ), + mFontSizeScale( DEFAULT_FONT_SIZE_SCALE ) { mModel = Model::New(); @@ -604,19 +615,35 @@ struct Controller::Impl */ float GetDefaultFontLineHeight(); - void OnCursorKeyEvent( const Event& event ); - - void OnTapEvent( const Event& event ); + /** + * @copydoc Text::Controller::GetPrimaryCursorPosition() + */ + CharacterIndex GetPrimaryCursorPosition() const; - void OnPanEvent( const Event& event ); + /** + * @copydoc Text::Controller::SetPrimaryCursorPosition() + */ + bool SetPrimaryCursorPosition( CharacterIndex index ); - void OnLongPressEvent( const Event& event ); + /** + * @copydoc Text::SelectableControlInterface::SetTextSelectionRange() + */ + void SetTextSelectionRange(const uint32_t *pStart, const uint32_t *pEndf); - void OnHandleEvent( const Event& event ); + /** + * @copydoc Text::SelectableControlInterface::GetTextSelectionRange() + */ + Uint32Pair GetTextSelectionRange() const; - void OnSelectEvent( const Event& event ); + /** + * @copydoc Text::EditableControlInterface::IsEditable() + */ + bool IsEditable() const; - void OnSelectAllEvent(); + /** + * @copydoc Text::EditableControlInterface::SetEditable() + */ + void SetEditable( bool editable ); /** * @brief Retrieves the selected text. It removes the text if the @p deleteAfterRetrieval parameter is @e true. @@ -626,13 +653,17 @@ struct Controller::Impl */ void RetrieveSelection( std::string& selectedText, bool deleteAfterRetrieval ); + void SetSelection( int start, int end ); + + std::pair< int, int > GetSelectionIndexes() const; + void ShowClipboard(); void HideClipboard(); void SetClipboardHideEnable(bool enable); - bool CopyStringToClipboard( std::string& source ); + bool CopyStringToClipboard( const std::string& source ); void SendSelectionToClipboard( bool deleteAfterSending ); @@ -724,6 +755,18 @@ struct Controller::Impl */ void ScrollTextToMatchCursor( const CursorInfo& cursorInfo ); + /** + * @brief Scrolls the text to make primary cursor visible. + */ + void ScrollTextToMatchCursor( ); + + /** + * @brief Create an actor that renders the text background color + * + * @return the created actor or an empty handle if no background color needs to be rendered. + */ + Actor CreateBackgroundActor(); + public: /** @@ -746,6 +789,7 @@ public: ControlInterface* mControlInterface; ///< Reference to the text controller. EditableControlInterface* mEditableControlInterface; ///< Reference to the editable text controller. + SelectableControlInterface* mSelectableControlInterface; ///< Reference to the selectable text controller. ModelPtr mModel; ///< Pointer to the text's model. FontDefaults* mFontDefaults; ///< Avoid allocating this when the user does not specify a font. UnderlineDefaults* mUnderlineDefaults; ///< Avoid allocating this when the user does not specify underline parameters. @@ -780,10 +824,17 @@ public: bool mShouldClearFocusOnEscape:1; ///< Whether text control should clear key input focus LayoutDirection::Type mLayoutDirection; ///< Current system language direction + Shader mShaderBackground; ///< The shader for text background. + float mTextFitMinSize; ///< Minimum Font Size for text fit. Default 10 float mTextFitMaxSize; ///< Maximum Font Size for text fit. Default 100 float mTextFitStepSize; ///< Step Size for font intervalse. Default 1 bool mTextFitEnabled : 1; ///< Whether the text's fit is enabled. + float mFontSizeScale; ///< Scale value for Font Size. Default 1.0 + +private: + friend ControllerImplEventHandler; + friend SelectionHandleController; }; } // namespace Text