From bb52eae847ee00d2caf94bc5e94111c7663b91ea Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Fri, 30 May 2014 14:44:46 +0100 Subject: [PATCH] TextInput uses style properties for PopUp and Highlight [problem] Popup button order, colour of background, colour of pressed buttons and highlight predefined in internal code [solution] Dali Properties now represent the above settings so can be defined in a JSON file or via the Public API. Change-Id: Ia33d63d95cfdcbfb095a31c1cf514368f2683814 --- .../controls/text-input/text-input-impl.cpp | 258 ++++++++++++---- .../internal/controls/text-input/text-input-impl.h | 49 +++ .../controls/text-input/text-input-popup-impl.cpp | 337 +++++++++++++++++---- .../controls/text-input/text-input-popup-impl.h | 118 +++++++- .../public-api/controls/text-input/text-input.h | 18 +- 5 files changed, 664 insertions(+), 116 deletions(-) diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp index 7b85230..5decd2f 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp +++ b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp @@ -27,9 +27,6 @@ #include #include #include -#include - -#define GET_LOCALE_TEXT(string) dgettext("sys_string", string) using namespace std; using namespace Dali; @@ -56,22 +53,8 @@ const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-sel const char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" ); const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" ); -const char* DEFAULT_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" ); -const char* DEFAULT_ICON_COPY( DALI_IMAGE_DIR "copy_paste_icon_copy.png" ); -const char* DEFAULT_ICON_CUT( DALI_IMAGE_DIR "copy_paste_icon_cut.png" ); -const char* DEFAULT_ICON_PASTE( DALI_IMAGE_DIR "copy_paste_icon_paste.png" ); -const char* DEFAULT_ICON_SELECT( DALI_IMAGE_DIR "copy_paste_icon_select.png" ); -const char* DEFAULT_ICON_SELECT_ALL( DALI_IMAGE_DIR "copy_paste_icon_select_all.png" ); - const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f ); -const std::string OPTION_SELECT_WORD("select_word"); ///< "Select Word" popup option. -const std::string OPTION_SELECT_ALL("select_all"); ///< "Select All" popup option. -const std::string OPTION_CUT("cut"); ///< "Cut" popup option. -const std::string OPTION_COPY("copy"); ///< "Copy" popup option. -const std::string OPTION_PASTE("paste"); ///< "Paste" popup option. -const std::string OPTION_CLIPBOARD("clipboard"); ///< "Clipboard" popup option. - const std::size_t CURSOR_BLINK_INTERVAL = 500; ///< Cursor blink interval const float CHARACTER_THRESHOLD( 2.5f ); ///< the threshold of a line. const float DISPLAYED_HIGHLIGHT_Z_OFFSET( 0.0f ); ///< 1. Highlight rendered (z-offset). @@ -95,6 +78,16 @@ const float SCROLL_THRESHOLD = 10.f; const float SCROLL_SPEED = 15.f; /** + * Selection state enumeration (FSM) + */ +enum SelectionState +{ + SelectionNone, ///< Currently not encountered selected section. + SelectionStarted, ///< Encountered selected section + SelectionFinished ///< Finished selected section +}; + +/** * Whether the given style is the default style or not. * @param[in] style The given style. * @return \e true if the given style is the default. Otherwise it returns \e false. @@ -124,16 +117,6 @@ bool IsTextDefaultStyle( const Toolkit::MarkupProcessor::StyledTextArray& textAr return true; } -/** - * Selection state enumeration (FSM) - */ -enum SelectionState -{ - SelectionNone, ///< Currently not encountered selected section. - SelectionStarted, ///< Encountered selected section - SelectionFinished ///< Finished selected section -}; - std::size_t FindVisibleCharacterLeft( std::size_t cursorPosition, const Toolkit::TextView::CharacterLayoutInfoContainer& characterLayoutInfoTable ) { for( Toolkit::TextView::CharacterLayoutInfoContainer::const_reverse_iterator it = characterLayoutInfoTable.rbegin() + characterLayoutInfoTable.size() - cursorPosition, endIt = characterLayoutInfoTable.rend(); @@ -213,6 +196,17 @@ namespace Dali namespace Toolkit { +// Properties +const Property::Index TextInput::HIGHLIGHT_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX; +const Property::Index TextInput::CUT_AND_PASTE_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+1; +const Property::Index TextInput::CUT_AND_PASTE_PRESSED_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+2; + +const Property::Index TextInput::CUT_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+3; +const Property::Index TextInput::COPY_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+4; +const Property::Index TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+5; +const Property::Index TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+6; +const Property::Index TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+7; +const Property::Index TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+8; namespace Internal { @@ -236,6 +230,17 @@ SignalConnectorType signalConnector6( typeRegistration, Toolkit::TextInput::SIGN } +PropertyRegistration property1( typeRegistration, "highlight-color", Toolkit::TextInput::HIGHLIGHT_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property2( typeRegistration, "cut-and-paste-bg-color", Toolkit::TextInput::CUT_AND_PASTE_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property3( typeRegistration, "cut-and-paste-pressed-color", Toolkit::TextInput::CUT_AND_PASTE_PRESSED_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property4( typeRegistration, "cut-button-position-priority", Toolkit::TextInput::CUT_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property5( typeRegistration, "copy-button-position-priority", Toolkit::TextInput::COPY_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property6( typeRegistration, "paste-button-position-priority", Toolkit::TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property7( typeRegistration, "select-button-position-priority", Toolkit::TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property8( typeRegistration, "select-all-button-position-priority", Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property9( typeRegistration, "clipboard-button-position-priority", Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); + + // [TextInput::HighlightInfo] ///////////////////////////////////////////////// void TextInput::HighlightInfo::AddQuad( float x1, float y1, float x2, float y2 ) @@ -296,6 +301,7 @@ TextInput::TextInput() mTouchStartTime( 0 ), mTextLayoutInfo(), mCurrentCopySelecton(), + mPopUpPanel(), mScrollTimer(), mScrollDisplacement(), mCurrentHandlePosition(), @@ -305,6 +311,7 @@ TextInput::TextInput() mSelectionHandleFlipMargin( 0.0f, 0.0f, 0.0f, 0.0f ), mBoundingRectangleWorldCoordinates( 0.0f, 0.0f, 0.0f, 0.0f ), mClipboard(), + mMaterialColor( LIGHTBLUE ), mOverrideAutomaticAlignment( false ), mCursorRTLEnabled( false ), mClosestCursorPositionEOL ( false ), @@ -520,6 +527,24 @@ std::size_t TextInput::GetNumberOfCharacters() const return mStyledText.size(); } +// Styling +void TextInput::SetMaterialDiffuseColor( const Vector4& color ) +{ + mMaterialColor = color; + if ( mCustomMaterial ) + { + mCustomMaterial.SetDiffuseColor( mMaterialColor ); + mMeshData.SetMaterial( mCustomMaterial ); + } +} + +const Vector4& TextInput::GetMaterialDiffuseColor() const +{ + return mMaterialColor; +} + +// Signals + Toolkit::TextInput::InputSignalV2& TextInput::InputStartedSignal() { return mInputStartedSignalV2; @@ -1578,7 +1603,7 @@ bool TextInput::OnPopupButtonPressed( Toolkit::Button button ) const std::string& name = button.GetName(); - if(name == OPTION_SELECT_WORD) + if(name == TextInputPopup::OPTION_SELECT_WORD) { std::size_t start = 0; std::size_t end = 0; @@ -1586,7 +1611,7 @@ bool TextInput::OnPopupButtonPressed( Toolkit::Button button ) SelectText( start, end ); } - else if(name == OPTION_SELECT_ALL) + else if(name == TextInputPopup::OPTION_SELECT_ALL) { SetCursorVisibility(false); StopCursorBlinkTimer(); @@ -1596,7 +1621,7 @@ bool TextInput::OnPopupButtonPressed( Toolkit::Button button ) SelectText( start, end ); } - else if(name == OPTION_CUT) + else if(name == TextInputPopup::OPTION_CUT) { bool ret = CopySelectedTextToClipboard(); @@ -1611,7 +1636,7 @@ bool TextInput::OnPopupButtonPressed( Toolkit::Button button ) HidePopup(); } - else if(name == OPTION_COPY) + else if(name == TextInputPopup::OPTION_COPY) { CopySelectedTextToClipboard(); @@ -1622,7 +1647,7 @@ bool TextInput::OnPopupButtonPressed( Toolkit::Button button ) HidePopup(); } - else if(name == OPTION_PASTE) + else if(name == TextInputPopup::OPTION_PASTE) { const Text retrievedString( mClipboard.GetItem( 0 ) ); // currently can only get first item in clip board, index 0; @@ -1635,7 +1660,7 @@ bool TextInput::OnPopupButtonPressed( Toolkit::Button button ) HidePopup(); } - else if(name == OPTION_CLIPBOARD) + else if(name == TextInputPopup::OPTION_CLIPBOARD) { // In the case of clipboard being shown we do not want to show updated pop-up after hide animation completes // Hence pass the false parameter for signalFinished. @@ -3667,6 +3692,11 @@ void TextInput::ClearPopup() mPopUpPanel.Clear(); } +void TextInput::AddPopupOptions() +{ + mPopUpPanel.AddPopupOptions(); +} + void TextInput::AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption) { mPopUpPanel.AddOption(name, caption, icon, finalOption); @@ -3753,29 +3783,29 @@ void TextInput::ShowPopup(bool animate) void TextInput::ShowPopupCutCopyPaste() { ClearPopup(); + + mPopUpPanel.CreateOrderedListOfOptions(); // todo Move this so only run when order has changed // Check the selected text is whole text or not. if( IsTextSelected() && ( mStyledText.size() != GetSelectedText().size() ) ) { - Image selectAllIcon = Image::New( DEFAULT_ICON_SELECT_ALL ); - AddPopupOption( OPTION_SELECT_ALL, GET_LOCALE_TEXT("IDS_COM_BODY_SELECT_ALL"), selectAllIcon ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsSelectAll, true ); } if ( !mStyledText.empty() ) { - Image cutIcon = Image::New( DEFAULT_ICON_CUT ); - Image copyIcon = Image::New( DEFAULT_ICON_COPY ); - AddPopupOption( OPTION_CUT, GET_LOCALE_TEXT("IDS_COM_BODY_CUT"), cutIcon ); - AddPopupOption( OPTION_COPY, GET_LOCALE_TEXT("IDS_COM_BODY_COPY"), copyIcon, true ); + + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsCopy, true ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsCut, true ); } - if(mClipboard.NumberOfItems()) + if( mClipboard.NumberOfItems() ) { - Image pasteIcon = Image::New( DEFAULT_ICON_PASTE ); - Image clipboardIcon = Image::New( DEFAULT_ICON_CLIPBOARD ); - AddPopupOption( OPTION_PASTE, GET_LOCALE_TEXT("IDS_COM_BODY_PASTE"), pasteIcon ); - AddPopupOption( OPTION_CLIPBOARD, GET_LOCALE_TEXT("IDS_COM_BODY_CLIPBOARD"), clipboardIcon, true ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsPaste, true ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsClipboard, true ); } + AddPopupOptions(); + mPopUpPanel.Hide(false); ShowPopup(); } @@ -3783,24 +3813,23 @@ void TextInput::ShowPopupCutCopyPaste() void TextInput::SetUpPopUpSelection() { ClearPopup(); - + mPopUpPanel.CreateOrderedListOfOptions(); // todo Move this so only run when order has changed // If no text exists then don't offer to select if ( !mStyledText.empty() ) { - Image selectIcon = Image::New( DEFAULT_ICON_SELECT ); - Image selectAllIcon = Image::New( DEFAULT_ICON_SELECT_ALL ); - AddPopupOption( OPTION_SELECT_WORD, GET_LOCALE_TEXT("IDS_COM_SK_SELECT"), selectIcon ); - AddPopupOption( OPTION_SELECT_ALL, GET_LOCALE_TEXT("IDS_COM_BODY_SELECT_ALL"), selectAllIcon ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsSelectAll, true ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsSelect, true ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsCut, true ); } // if clipboard has valid contents then offer paste option if( mClipboard.NumberOfItems() ) { - Image pasteIcon = Image::New( DEFAULT_ICON_PASTE ); - Image clipboardIcon = Image::New( DEFAULT_ICON_CLIPBOARD ); - AddPopupOption( OPTION_PASTE, GET_LOCALE_TEXT("IDS_COM_BODY_PASTE"), pasteIcon, true ); - AddPopupOption( OPTION_CLIPBOARD, GET_LOCALE_TEXT("IDS_COM_BODY_CLIPBOARD"), clipboardIcon, true ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsPaste, true ); + mPopUpPanel.TogglePopUpButtonOnOff( TextInputPopup::ButtonsClipboard, true ); } + AddPopupOptions(); + mPopUpPanel.Hide(false); } @@ -4671,7 +4700,7 @@ void TextInput::CreateHighlight() mMeshData.SetHasNormals( true ); mCustomMaterial = Material::New("CustomMaterial"); - mCustomMaterial.SetDiffuseColor( LIGHTBLUE ); + mCustomMaterial.SetDiffuseColor( mMaterialColor ); mMeshData.SetMaterial( mCustomMaterial ); @@ -5108,6 +5137,127 @@ void TextInput::GetTextLayoutInfo() } } +void TextInput::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ) +{ + Toolkit::TextInput textInput = Toolkit::TextInput::DownCast( Dali::BaseHandle( object ) ); + + if ( textInput ) + { + TextInput& textInputImpl( GetImpl( textInput ) ); + + switch ( propertyIndex ) + { + case Toolkit::TextInput::HIGHLIGHT_COLOR_PROPERTY: + { + textInputImpl.SetMaterialDiffuseColor( value.Get< Vector4 >() ); + break; + } + case Toolkit::TextInput::CUT_AND_PASTE_COLOR_PROPERTY: + { + textInputImpl.mPopUpPanel.SetCutPastePopUpColor( value.Get< Vector4 >() ); + break; + } + case Toolkit::TextInput::CUT_AND_PASTE_PRESSED_COLOR_PROPERTY: + { + textInputImpl.mPopUpPanel.SetCutPastePopUpPressedColor( value.Get< Vector4 >() ); + break; + } + case Toolkit::TextInput::CUT_BUTTON_POSITION_PRIORITY_PROPERTY: + { + textInputImpl.mPopUpPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsCut, value.Get() ); + break; + } + case Toolkit::TextInput::COPY_BUTTON_POSITION_PRIORITY_PROPERTY: + { + textInputImpl.mPopUpPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsCopy, value.Get() ); + break; + } + case Toolkit::TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY: + { + textInputImpl.mPopUpPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsPaste, value.Get() ); + break; + } + case Toolkit::TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY: + { + textInputImpl.mPopUpPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsSelect, value.Get() ); + break; + } + case Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY: + { + textInputImpl.mPopUpPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsSelectAll, value.Get() ); + break; + } + case Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY: + { + textInputImpl.mPopUpPanel.SetButtonPriorityPosition( TextInputPopup::ButtonsClipboard, value.Get() ); + break; + } + } + } +} + +Property::Value TextInput::GetProperty( BaseObject* object, Property::Index propertyIndex ) +{ + Property::Value value; + + Toolkit::TextInput textInput = Toolkit::TextInput::DownCast( Dali::BaseHandle( object ) ); + + if ( textInput ) + { + TextInput& textInputImpl( GetImpl( textInput ) ); + + switch ( propertyIndex ) + { + case Toolkit::TextInput::HIGHLIGHT_COLOR_PROPERTY: + { + value = textInputImpl.GetMaterialDiffuseColor(); + break; + } + case Toolkit::TextInput::CUT_AND_PASTE_COLOR_PROPERTY: + { + value = textInputImpl.mPopUpPanel.GetCutPastePopUpColor(); + break; + } + case Toolkit::TextInput::CUT_AND_PASTE_PRESSED_COLOR_PROPERTY: + { + value = textInputImpl.mPopUpPanel.GetCutPastePopUpPressedColor(); + break; + } + case Toolkit::TextInput::CUT_BUTTON_POSITION_PRIORITY_PROPERTY: + { + value = textInputImpl.mPopUpPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsCut ); + break; + } + case Toolkit::TextInput::COPY_BUTTON_POSITION_PRIORITY_PROPERTY: + { + value = textInputImpl.mPopUpPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsCopy ); + break; + } + case Toolkit::TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY: + { + value = textInputImpl.mPopUpPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsPaste ); + break; + } + case Toolkit::TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY: + { + value = textInputImpl.mPopUpPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsSelect ); + break; + } + case Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY: + { + value = textInputImpl.mPopUpPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsSelectAll ); + break; + } + case Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY: + { + value = textInputImpl.mPopUpPanel.GetButtonPriorityPosition( TextInputPopup::ButtonsClipboard ); + break; + } + } + } + return value; +} + void TextInput::EmitStyleChangedSignal() { // emit signal if input style changes. diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.h b/base/dali-toolkit/internal/controls/text-input/text-input-impl.h index 75d2d03..b9f3233 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.h +++ b/base/dali-toolkit/internal/controls/text-input/text-input-impl.h @@ -47,6 +47,13 @@ class TextInput : public Control { public: + // Properties + enum + { + TEXTINPUT_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, + TEXTINPUT_PROPERTY_END_INDEX = TEXTINPUT_PROPERTY_START_INDEX + 512 ///< Reserving property indices + }; + /** * Create a new TextInput * @return instrusive ptr to a TextInput @@ -378,6 +385,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: /** @@ -1032,6 +1055,11 @@ public: // Public to allow internal testing. void ClearPopup(); /** + * Adds Popup options which have been enabled. + */ + void AddPopupOptions(); + + /** * Adds a popup option. * @note Creates popup frame if not already created. * @param[in] name The unique name for this option. @@ -1316,6 +1344,24 @@ public: // Public to allow internal testing. */ void GetTextLayoutInfo(); + // 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. */ @@ -1419,6 +1465,9 @@ private: Clipboard mClipboard; ///< Handle to clipboard + // Styling + Vector4 mMaterialColor; // Color of the highlight + 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) bool mClosestCursorPositionEOL:1; ///< closest cursor position is end of line. diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.cpp index 85d2a60..ca1c16a 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.cpp +++ b/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.cpp @@ -16,15 +16,25 @@ */ #include + #include +#include + +#include using namespace std; using namespace Dali; +#define GET_LOCALE_TEXT(string) dgettext("sys_string", string) + namespace { -// Popup: Background -const char* DEFAULT_PANEL_BACKGROUND = DALI_IMAGE_DIR "cutCopyPastePopup_bg.png"; +// Default Colors + +const Vector4 DEFAULT_POPUP_BACKGROUND( Vector4( 0.24f, 0.41f, 0.88f, 1.0f ) ); +const Vector4 DEFAULT_POPUP_BUTTON_PRESSED( Vector4( 0.18f, 0.56f, 1.0f, 1.0f ) ); +const Vector4 DEFAULT_BORDER_COLOR( Vector4( 0.2f, 0.2f, 0.2f, 1.0f ) ); +const Vector3 POPUP_BORDER( Vector3(1.0f, 1.0f, 0.0f) ); // Popup: Divider const char* DEFAULT_PANEL_BUTTON_DIVIDER = DALI_IMAGE_DIR "copypanelLine.png"; @@ -34,18 +44,6 @@ const char* DEFAULT_PANEL_BUTTON_DIVIDER = DALI_IMAGE_DIR "copypanelLine.png"; * the left image can be rounded on the left and straight on the right, the right image can be straight on the left and rounded on the right. */ -// Popup: Left Pressed Highlight -const char* DEFAULT_BUTTON_HIGHLIGHT_LEFT( DALI_IMAGE_DIR "00_popup_button_pressed.png" ); -const Vector4 DEFAULT_BUTTON_HIGHLIGHT_LEFT_BORDER( 6.0f, 9.0f, 6.0f, 9.0f ); - -// Popup: Center Pressed Highlight -const char* DEFAULT_BUTTON_HIGHLIGHT_CENTER( DALI_IMAGE_DIR "00_popup_button_pressed.png" ); -const Vector4 DEFAULT_BUTTON_HIGHLIGHT_CENTER_BORDER( 6.0f, 9.0f, 6.0f, 9.0f ); - -// Popup: Right Pressed Highlight -const char* DEFAULT_BUTTON_HIGHLIGHT_RIGHT( DALI_IMAGE_DIR "00_popup_button_pressed.png" ); -const Vector4 DEFAULT_BUTTON_HIGHLIGHT_RIGHT_BORDER( 6.0f, 9.0f, 6.0f, 9.0f ); - // Popup: Tails const char* DEFAULT_POPUP_TAIL_BOTTOM( DALI_IMAGE_DIR "00_popup_bubble_tail_bottom.png" ); @@ -54,19 +52,17 @@ const char* DEFAULT_POPUP_TAIL_BOTTOM( DALI_IMAGE_DIR "00_popup_bubble_tail_bott // height of the indicator actor from Dali-Toolkit. const Vector2 DEFAULT_POPUP_INDICATOR_OFFSET(0.0f, 60.0f); -const Vector4 BACKGROUND_IMAGE_BORDER( 22.0f, 20.0f, 29.0f, 27.0f ); -const Vector2 BACKGROUND_IMAGE_SIZE( 50.0f, 54.0f ); -const Vector3 POPUP_TEXT_OFFSET( 12.0f, 10.0f, 0.0f ); +const Vector3 POPUP_TEXT_OFFSET( 0.0f, 0.0f, 0.0f ); const Vector3 POPUP_TEXT_ENLARGE( 12.0f, 28.0f, 0.0f ); const Vector3 POPUP_MINIMUM_SIZE( 128.0f, 124.0f, 0.0f ); const Vector3 BUTTON_TEXT_ENLARGE( 32.0f, 0.0f, 0.0f ); const Vector3 BUTTON_TEXT_MINIMUM_SIZE( 128.0f, 126.0f, 0.0f ); -const Vector3 BUTTON_TEXT_MAXIMUM_SIZE( 196.0f, 126.0f, 0.0f ); +const Vector3 BUTTON_TEXT_MAXIMUM_SIZE( 190.0f, 126.0f, 0.0f ); const Vector3 TEXT_LABEL_MAX_SIZE( 160.0f, 30.0f, 0.0f ); const float DIVIDER_WIDTH(2.0f); ///< Width of each button divider -const float DIVIDER_MARGIN(10.0f); ///< Top/Bottom Margin between divider and edge of popup. +const float DIVIDER_MARGIN(0.0f); ///< Top/Bottom Margin between divider and edge of popup. const float DEFAULT_UI_FONT_SIZE(7.0f); ///< Standard font size for Text-Input's UI @@ -77,6 +73,13 @@ const Vector2 DEFAULT_ICON_SIZE( 45.0f, 45.0f ); ///< const float TEXT_POSITION_OFFSET( -19.0f ); ///< Default offset for text label const float ICON_POSITION_OFFSET( 19.0f ); ///< Default offset for icon +const char* DEFAULT_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" ); +const char* DEFAULT_ICON_COPY( DALI_IMAGE_DIR "copy_paste_icon_copy.png" ); +const char* DEFAULT_ICON_CUT( DALI_IMAGE_DIR "copy_paste_icon_cut.png" ); +const char* DEFAULT_ICON_PASTE( DALI_IMAGE_DIR "copy_paste_icon_paste.png" ); +const char* DEFAULT_ICON_SELECT( DALI_IMAGE_DIR "copy_paste_icon_select.png" ); +const char* DEFAULT_ICON_SELECT_ALL( DALI_IMAGE_DIR "copy_paste_icon_select_all.png" ); + // TODO: This should be based on the content for example: // 1. For selection: should be above top of highlighted selection, or below bottom of highlighted selection + end handle. // 2. For cursor: should be above top of cursor, or below bottom of cursor + grab handle. @@ -183,9 +186,26 @@ const char* const TextInputPopup::SIGNAL_PRESSED = "pressed"; const char* const TextInputPopup::SIGNAL_HIDE_FINISHED = "hide-finished"; const char* const TextInputPopup::SIGNAL_SHOW_FINISHED = "show-finished"; +const char* const TextInputPopup::OPTION_SELECT_WORD = "select_word"; // "Select Word" popup option. +const char* const TextInputPopup::OPTION_SELECT_ALL("select_all"); // "Select All" popup option. +const char* const TextInputPopup::OPTION_CUT("cut"); // "Cut" popup option. +const char* const TextInputPopup::OPTION_COPY("copy"); // "Copy" popup option. +const char* const TextInputPopup::OPTION_PASTE("paste"); // "Paste" popup option. +const char* const TextInputPopup::OPTION_CLIPBOARD("clipboard"); // "Clipboard" popup option. + TextInputPopup::TextInputPopup() : mState(StateHidden), mRootActor(Layer::New()), + mContentSize( Vector3::ZERO ), + mCutPasteButtonsColor( DEFAULT_POPUP_BACKGROUND ), + mCutPasteButtonsPressedColor( DEFAULT_POPUP_BUTTON_PRESSED ), + mBorderColor( DEFAULT_BORDER_COLOR ), + mSelectOptionPriority(1), + mSelectAllOptionPriority(2), + mCutOptionPriority(3), + mCopyOptionPriority(4), + mPasteOptionPriority(5), + mClipboardOptionPriority(6), mPressedSignal(), mHideFinishedSignal(), mShowFinishedSignal() @@ -277,15 +297,7 @@ void TextInputPopup::CreatePopUpBackground() // Create background-panel if not already created (required if we have at least one option) if ( !mBackground ) { - Image backgroundImage = Image::New( DEFAULT_PANEL_BACKGROUND ); - - mBackground = ImageActor::New( backgroundImage ); - // Expand background from bottom-center of root actor. - mBackground.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); - mBackground.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); - mBackground.SetStyle( ImageActor::STYLE_NINE_PATCH ); - - mBackground.SetNinePatchBorder( Vector4(13.0f, 13.0f, 13.0f, 13.0f) ); + mBackground = Toolkit::CreateSolidColorActor( GetCutPastePopUpColor(), true, mBorderColor ); Self().Add( mBackground ); mContentSize = POPUP_TEXT_OFFSET; @@ -313,7 +325,7 @@ void TextInputPopup::CreateDivider() ImageActor divider = ImageActor::New( dividerImage ); divider.SetParentOrigin( ParentOrigin::TOP_LEFT ); divider.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - divider.SetPosition( Vector3( mContentSize.width, POPUP_TEXT_OFFSET.y + 5.0f, 0.0f ) ); + divider.SetPosition( Vector3( mContentSize.width, POPUP_TEXT_OFFSET.y, 0.0f ) ); // Keep track of all the dividers. As their height's need to be updated to the max. of all // buttons currently added. mDividerContainer.push_back(divider); @@ -323,37 +335,112 @@ void TextInputPopup::CreateDivider() } } -ImageActor TextInputPopup::CreatePressedBackground( const Vector3 requiredSize, const bool finalFlag ) +ImageActor TextInputPopup::CreatePressedBackground( const Vector3 requiredSize ) { std::string pressedImageFilename; Vector4 pressedImageBorder; Vector2 pressedImageSize; - if(mButtonContainer.size() == 0) // LEFT - { - pressedImageFilename = DEFAULT_BUTTON_HIGHLIGHT_LEFT; - pressedImageBorder = DEFAULT_BUTTON_HIGHLIGHT_LEFT_BORDER; - } - else if(!finalFlag) // CENTER - { - pressedImageFilename = DEFAULT_BUTTON_HIGHLIGHT_CENTER; - pressedImageBorder = DEFAULT_BUTTON_HIGHLIGHT_CENTER_BORDER; - } - else // RIGHT + ImageActor pressedButtonBg = Toolkit::CreateSolidColorActor( GetCutPastePopUpPressedColor() ); + + pressedButtonBg.SetSize ( requiredSize ); + pressedButtonBg.SetParentOrigin( ParentOrigin::CENTER ); + pressedButtonBg.SetAnchorPoint( AnchorPoint::CENTER ); + + return pressedButtonBg; +} + +TextInputPopup::ButtonRequirement TextInputPopup::CreateRequiredButton( TextInputPopup::Buttons buttonId, std::size_t orderOfPriority, + const std::string& name, const std::string& caption, Image iconImage, bool enabled ) +{ + TextInputPopup::ButtonRequirement currentButton; + + currentButton.buttonId = buttonId; + currentButton.orderOfPriority = orderOfPriority; + currentButton.name = name; + currentButton.caption = caption; + currentButton.iconImage = iconImage; + currentButton.enabled = enabled; + + return currentButton; +} + +void TextInputPopup::CreateOrderedListOfOptions() +{ + mOrderListOfButtons.clear(); + + for ( std::size_t index= 0; index < ButtonsEnumEnd; index++ ) { - pressedImageFilename = DEFAULT_BUTTON_HIGHLIGHT_RIGHT; - pressedImageBorder = DEFAULT_BUTTON_HIGHLIGHT_RIGHT_BORDER; - } + TextInputPopup::ButtonRequirement currentButton; - Image pressedImage = Image::New( pressedImageFilename ); - ImageActor pressedImageBg = ImageActor::New( pressedImage ); - pressedImageBg.SetStyle( ImageActor::STYLE_NINE_PATCH ); - pressedImageBg.SetNinePatchBorder( pressedImageBorder ); - pressedImageBg.SetSize ( requiredSize ); - pressedImageBg.SetParentOrigin( ParentOrigin::CENTER ); - pressedImageBg.SetAnchorPoint( AnchorPoint::CENTER ); + // Create button for each possible option using Option priority + switch ( index ) + { + case ButtonsCut: + { + Image cutIcon = Image::New( DEFAULT_ICON_CUT ); + currentButton = CreateRequiredButton( ButtonsCut, mCutOptionPriority, OPTION_CUT, GET_LOCALE_TEXT("IDS_COM_BODY_CUT"), cutIcon, false ); + break; + } + case ButtonsCopy: + { + Image copyIcon = Image::New( DEFAULT_ICON_COPY ); + currentButton = CreateRequiredButton( ButtonsCopy, mCopyOptionPriority, OPTION_COPY, GET_LOCALE_TEXT("IDS_COM_BODY_COPY"), copyIcon, false ); + break; + } + case ButtonsPaste: + { + Image pasteIcon = Image::New( DEFAULT_ICON_PASTE ); + currentButton = CreateRequiredButton( ButtonsPaste, mPasteOptionPriority, OPTION_PASTE, GET_LOCALE_TEXT("IDS_COM_BODY_PASTE"), pasteIcon, false ); + break; + } + case ButtonsSelect: + { + Image selectIcon = Image::New( DEFAULT_ICON_SELECT ); + currentButton = CreateRequiredButton( ButtonsSelect, mSelectOptionPriority, OPTION_SELECT_WORD, GET_LOCALE_TEXT("IDS_COM_SK_SELECT"), selectIcon, false ); + break; + } + case ButtonsSelectAll: + { + Image selectAllIcon = Image::New( DEFAULT_ICON_SELECT_ALL ); + currentButton = CreateRequiredButton( ButtonsSelectAll, mSelectAllOptionPriority, OPTION_SELECT_ALL, GET_LOCALE_TEXT("IDS_COM_BODY_SELECT_ALL"), selectAllIcon, false ); + break; + } + case ButtonsClipboard: + { + Image clipboardIcon = Image::New( DEFAULT_ICON_CLIPBOARD ); + currentButton = CreateRequiredButton( ButtonsClipboard, mClipboardOptionPriority, OPTION_CLIPBOARD, GET_LOCALE_TEXT("IDS_COM_BODY_CLIPBOARD"), clipboardIcon, false ); + break; + } + case ButtonsEnumEnd: + { + DALI_ASSERT_DEBUG( "ButtonsEnumEnd used but an invalid choice"); + currentButton.orderOfPriority = 0; + break; + } + } - return pressedImageBg; + bool match = false; + + // Insert button in list of buttons in order of priority setting. + for( std::vector::iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt && !match ); ++it ) + { + const ButtonRequirement& button( *it ); + if ( currentButton.orderOfPriority < button.orderOfPriority ) + { + if ( currentButton.orderOfPriority != 0 ) // If order priority 0 then do not add button as not required. + { + mOrderListOfButtons.insert( it, currentButton ); + } + match = true; + } + } + + if ( !match) + { + mOrderListOfButtons.push_back( currentButton ); + } + } } void TextInputPopup::AddOption(const std::string& name, const std::string& caption, const Image iconImage, bool finalOption) @@ -393,7 +480,7 @@ void TextInputPopup::AddOption(const std::string& name, const std::string& capti button.SetParentOrigin( ParentOrigin::TOP_LEFT ); button.SetAnchorPoint( AnchorPoint::TOP_LEFT ); button.SetSize( buttonSize ); - button.SetPosition( Vector3( mContentSize.width, POPUP_TEXT_OFFSET.y, 0.0f ) ); + button.SetPosition( Vector3( mContentSize.width, POPUP_BORDER.y, 0.0f ) ); // 2. Add icon ImageActor icon = CreateOptionIcon( iconImage ); @@ -401,7 +488,7 @@ void TextInputPopup::AddOption(const std::string& name, const std::string& capti iconTextContainer.Add( icon ); // 3. Add highlight - Pressed state in Pushbutton needs a new image which means creating the text and icon again but including a highlight this time. - ImageActor pressedImageBg = CreatePressedBackground( buttonSize, finalOption ); + ImageActor pressedImageBg = CreatePressedBackground( buttonSize ); Actor iconPressedTextContainer = Actor::New(); iconPressedTextContainer.SetDrawMode( DrawMode::OVERLAY ); @@ -425,7 +512,7 @@ void TextInputPopup::AddOption(const std::string& name, const std::string& capti // Update content size (represents size of all content i.e. from top-left of first button, to bottom-right of last button) mContentSize.width += buttonSize.width; - mContentSize.height = std::max(mContentSize.height, buttonSize.height); + mContentSize.height = std::max(mContentSize.height + ( POPUP_BORDER.y ), buttonSize.height); mButtonContainer.push_back(button); // resize all dividers based on the height content (i.e. max of all button heights) @@ -435,7 +522,7 @@ void TextInputPopup::AddOption(const std::string& name, const std::string& capti i->SetSize( DIVIDER_WIDTH, dividerHeight ); } - Vector3 popupSize( Max(mContentSize + POPUP_TEXT_ENLARGE, POPUP_MINIMUM_SIZE) ); + Vector3 popupSize( Max(mContentSize, POPUP_MINIMUM_SIZE) ); mBackground.SetSize( popupSize ); // Make Root Actor reflect the size of its content @@ -519,6 +606,144 @@ Actor TextInputPopup::GetRootActor() const return mRootActor; } +// Styling + +void TextInputPopup::SetCutPastePopUpColor( const Vector4& color ) +{ + mCutPasteButtonsColor = color; +} + +const Vector4& TextInputPopup::GetCutPastePopUpColor() const +{ + return mCutPasteButtonsColor; +} + +void TextInputPopup::SetCutPastePopUpPressedColor( const Vector4& color ) +{ + mCutPasteButtonsPressedColor = color; +} + +const Vector4& TextInputPopup::GetCutPastePopUpPressedColor() const +{ + return mCutPasteButtonsPressedColor; +} + +void TextInputPopup::TogglePopUpButtonOnOff( TextInputPopup::Buttons requiredButton, bool enable ) +{ + bool match ( false ); + for( std::vector::iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt && !match ); ++it ) + { + ButtonRequirement& button( *it ); + if ( requiredButton == button.buttonId ) + { + button.enabled = enable; + match = true; + } + } +} + +void TextInputPopup::SetButtonPriorityPosition( TextInputPopup::Buttons button, unsigned int priority ) +{ + switch ( button ) + { + case ButtonsCut: + { + mCutOptionPriority = priority; + break; + } + case ButtonsCopy: + { + mCopyOptionPriority = priority; + break; + } + case ButtonsPaste: + { + mPasteOptionPriority = priority; + break; + } + case ButtonsSelect: + { + mSelectOptionPriority = priority; + break; + } + case ButtonsSelectAll: + { + mSelectAllOptionPriority = priority; + break; + } + case ButtonsClipboard: + { + mClipboardOptionPriority = priority; + break; + } + case ButtonsEnumEnd: + { + DALI_ASSERT_DEBUG( "ButtonsEnumEnd used but an invalid choice"); + break; + } + } + CreateOrderedListOfOptions(); // Update list of options as priority changed. +} + +unsigned int TextInputPopup::GetButtonPriorityPosition( TextInputPopup::Buttons button ) const +{ + unsigned int priority = 0; + + switch ( button ) + { + case ButtonsCut: + { + priority = mCutOptionPriority; + break; + } + case ButtonsCopy: + { + priority = mCopyOptionPriority; + break; + } + case ButtonsPaste: + { + priority = mPasteOptionPriority; + break; + } + case ButtonsSelect: + { + priority = mSelectOptionPriority; + break; + } + case ButtonsSelectAll: + { + priority = mSelectAllOptionPriority; + break; + } + case ButtonsClipboard: + { + priority = mClipboardOptionPriority; + break; + } + case ButtonsEnumEnd: + { + DALI_ASSERT_DEBUG( "ButtonsEnumEnd used but an invalid choice"); + break; + } + } + + return priority; +} + +void TextInputPopup::AddPopupOptions() +{ + for( std::vector::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it ) + { + const ButtonRequirement& button( *it ); + if ( button.enabled ) + { + AddOption( button.name, button.caption, button.iconImage, false ); + } + } +} + + bool TextInputPopup::OnButtonPressed( Toolkit::Button button ) { mPressedSignal.Emit( button ); diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.h b/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.h index afc6412..81186df 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.h +++ b/base/dali-toolkit/internal/controls/text-input/text-input-popup-impl.h @@ -47,6 +47,34 @@ public: StateShown }; + enum Buttons + { + ButtonsCut, + ButtonsCopy, + ButtonsPaste, + ButtonsSelect, + ButtonsSelectAll, + ButtonsClipboard, + ButtonsEnumEnd + }; + + struct ButtonRequirement + { + TextInputPopup::Buttons buttonId; + std::size_t orderOfPriority; + std::string name; + std::string caption; + Image iconImage; + bool enabled; + }; + + static const char* const OPTION_SELECT_WORD; + static const char* const OPTION_SELECT_ALL; + static const char* const OPTION_CUT; + static const char* const OPTION_COPY; + static const char* const OPTION_PASTE; + static const char* const OPTION_CLIPBOARD; + // Signal names static const char* const SIGNAL_PRESSED; static const char* const SIGNAL_HIDE_FINISHED; @@ -123,10 +151,14 @@ public: /** * Create a background to be used when button pressed * @param[in] requiredSize size Image actor should be - * @param[in] finalFlag flag to be set if option is the final one. * @return Returns an Image Actor to be used a pressed background */ - ImageActor CreatePressedBackground( const Vector3 requiredSize, const bool finalFlag ); + ImageActor CreatePressedBackground( const Vector3 requiredSize ); + + /** + * Creates a ordered vector of button options + */ + void CreateOrderedListOfOptions(); /** * Adds a popup option. @@ -171,10 +203,72 @@ public: */ Actor GetRootActor() const; + /** + * Set the Cut and Paste buttons color when in normal state + * @param[in] color color to use + */ + void SetCutPastePopUpColor( const Vector4& color ); + + /** + * Get the set color of the Copy and Paste PopUp buttons + * @return color + */ + const Vector4& GetCutPastePopUpColor() const; + + /** + * Set the Cut and Paste button color when pressed. + * @param[in] color color to use + */ + void SetCutPastePopUpPressedColor( const Vector4& color ); + + /** + * Get the Cut and Paste pressed button color. + * @return color + */ + const Vector4& GetCutPastePopUpPressedColor() const; + + /** + * Toggle if a popup button should be enabled (shown) or not + * @param[in] requiredButton Button Id to enable or disable + * @param[in] enable toggle to enable (true) or disable (false) + */ + void TogglePopUpButtonOnOff( TextInputPopup::Buttons requiredButton, bool enable ); + + /** + * Set the Button Priority Position + * @param[in] button Button id for priority to be set on + * @param[in] priority Priority level, 1 is highest so will appear first. 0 priority will not show the button. + */ + void SetButtonPriorityPosition( TextInputPopup::Buttons button, unsigned int priority ); + + /** + * Get the Button Priority Position + * @param[in] button Button id to get priority of + * @return the button priority, 1 is highest, 0 is not shown. + */ + unsigned int GetButtonPriorityPosition( TextInputPopup::Buttons button ) const; + + /** + * Adds Popup options which have been enabled. + */ + void AddPopupOptions(); + private: /** - * Adds popup to the stage (ideally on a separate top-most layer and as an overlay) + * Creates a Button with the required parameters. + * @param[in] buttonId enum representing the button + * @param[in] orderOfPriority Position in toolbar button should be position, 1 is first from left to right. + * @param[in] name Given name for Button actor + * @param[in] caption Text to display in button + * @param[in] iconImage Icon to display in button + * @param[in] enabled Toggle if button should be used or not, this is decided by the current state/conditions. + */ + TextInputPopup::ButtonRequirement CreateRequiredButton( TextInputPopup::Buttons buttonId, std::size_t orderOfPriority, + const std::string& name, const std::string& caption, Image iconImage, bool enabled ); + + /** + * Adds Popup to the stage (ideally on a separate top-most layer and as an overlay) */ void AddToStage(); @@ -184,12 +278,12 @@ private: void ApplyConfinementConstraint(); /** - * Removes popup from the stage. + * Removes Popup from the stage. */ void RemoveFromStage(); /** - * Called when a button is pressed in the popup + * Called when a button is pressed in the Popup * @param[in] button The button pressed. */ bool OnButtonPressed( Toolkit::Button button ); @@ -220,6 +314,20 @@ private: ActorContainer mDividerContainer; ///< List of dividers added to popup. Animation mAnimation; ///< Popup Hide/Show animation. + std::vector mOrderListOfButtons; // List of buttons in the order to be displayed and a flag to indicate if needed. + + Vector4 mCutPasteButtonsColor; // Color of the cut and paste popup + Vector4 mCutPasteButtonsPressedColor; // Color of the cut and paste buttons when pressed. + Vector4 mBorderColor; // Color of the border around the Cut and Paste Popup + + // Priority of Options/Buttons in the Cut and Paste pop-up, higher priority buttons are displayed first, left to right. + std::size_t mSelectOptionPriority; // Position of Select Button + std::size_t mSelectAllOptionPriority; // Position of Select All button + std::size_t mCutOptionPriority; // Position of Cut button + std::size_t mCopyOptionPriority; // Position of Copy button + std::size_t mPasteOptionPriority; // Position of Paste button + std::size_t mClipboardOptionPriority; // Position of Clipboard button + PressedSignalV2 mPressedSignal; ///< Signal emitted when a button within the popup is pressed. HideFinishedSignalV2 mHideFinishedSignal; ///< Signal emitted when popup is completely hidden ShowFinishedSignalV2 mShowFinishedSignal; ///< Signal emitted when popup is completely shown diff --git a/capi/dali-toolkit/public-api/controls/text-input/text-input.h b/capi/dali-toolkit/public-api/controls/text-input/text-input.h index 7764e05..df140b3 100644 --- a/capi/dali-toolkit/public-api/controls/text-input/text-input.h +++ b/capi/dali-toolkit/public-api/controls/text-input/text-input.h @@ -47,13 +47,29 @@ class TextInput : public Control public: - //Signal Names + /// @name Properties + /** @{ */ + static const Property::Index HIGHLIGHT_COLOR_PROPERTY; // Property, name "highlight-color", type VECTOR4 + static const Property::Index CUT_AND_PASTE_COLOR_PROPERTY; // Property, name "cut-and-paste-bg-color", type VECTOR4 + static const Property::Index CUT_AND_PASTE_PRESSED_COLOR_PROPERTY; // Property, name "cut-and-paste-pressed-color", type VECTOR4 + + static const Property::Index CUT_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "cut-button-position-priority", type unsigned int + static const Property::Index COPY_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "copy-button-position-priority", type unsigned int + static const Property::Index PASTE_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "paste-button-position-priority", type unsigned int + static const Property::Index SELECT_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "select-button-position-priority", type unsigned int + static const Property::Index SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "select-all-button-position-priority", type unsigned int + static const Property::Index CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY; // Property, name "clipboard-button-position-priority", type unsigned int + /** @} */ + + /// @name Signals + /** @{ */ static const char* const SIGNAL_START_INPUT; ///< name "start-input" static const char* const SIGNAL_END_INPUT; ///< name "end-input" static const char* const SIGNAL_STYLE_CHANGED; ///< name "style-changed" static const char* const SIGNAL_MAX_INPUT_CHARACTERS_REACHED; ///< name "max-input-characters-reached" static const char* const SIGNAL_TOOLBAR_DISPLAYED; ///< name "toolbar-displayed" static const char* const SIGNAL_TEXT_EXCEED_BOUNDARIES; ///< name "text-exceed-boundaries" + /** @} */ public: -- 2.7.4