X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-selection-popup-impl.h;h=9625435db98f09087f122b83b7b3eab4403807b6;hp=892c563269467908fd5a759ae7e830d07dfa1f50;hb=b1e8521ad77e7b4e62b59613b2edef64429130e9;hpb=7c5cd5665d3b4648fed0a8b0a67522cdb48885cf diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h index 892c563..9625435 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__ -#define __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__ +#ifndef DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H +#define DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H /* - * Copyright (c) 2015 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. @@ -18,14 +18,18 @@ * */ +// EXTERNAL INCLUDES +#include +#include +#include + // INTERNAL INCLUDES #include -#include +#include +#include +#include #include - -// EXTERNAL INCLUDES -#include -#include +#include namespace Dali { @@ -36,66 +40,44 @@ namespace Toolkit namespace Internal { -namespace +enum PopupCustomisations { -enum PopupParts -{ - POPUP_BACKGROUND, - POPUP_CLIPBOARD_BUTTON, - POPUP_CUT_BUTTON_ICON, - POPUP_COPY_BUTTON_ICON, - POPUP_PASTE_BUTTON_ICON, - POPUP_SELECT_BUTTON_ICON, - POPUP_SELECT_ALL_BUTTON_ICON, + POPUP_MAXIMUM_SIZE, + OPTION_MAXIMUM_SIZE, + OPTION_MINIMUM_SIZE, + OPTION_DIVIDER_SIZE }; -} // namespace - class TextSelectionPopup : public Control { public: - enum Buttons - { - ButtonsCut, - ButtonsCopy, - ButtonsPaste, - ButtonsSelect, - ButtonsSelectAll, - ButtonsClipboard, - ButtonsEnumEnd - }; - struct ButtonRequirement { ButtonRequirement() - : id( ButtonsEnumEnd ), + : id( Toolkit::TextSelectionPopup::NONE ), priority( 0u ), name(), caption(), - icon(), enabled( false ) {} - ButtonRequirement( Buttons buttonId, + ButtonRequirement( Toolkit::TextSelectionPopup::Buttons buttonId, std::size_t buttonPriority, const std::string& buttonName, const std::string& buttonCaption, - Dali::Image& buttonIcon, bool buttonEnabled ) : id( buttonId ), priority( buttonPriority ), name( buttonName ), caption( buttonCaption ), - icon( buttonIcon ), enabled( buttonEnabled ) {} - Buttons id; + Toolkit::TextSelectionPopup::Buttons id; std::size_t priority; std::string name; std::string caption; - Dali::Image icon; bool enabled; }; @@ -106,15 +88,12 @@ public: } }; -// static inline bool ButtonPriorityCompare( ButtonRequirement a, ButtonRequirement b ) -// { -// return a.priority < b.priority ? true : false; -// } - /** - * @copydoc Dali::Toollkit::TextSelectionPopup::New() + * @brief New constructor with provided buttons to enable. + * @param[in] callbackInterface The text popup callback interface which receives the button click callbacks. + * @return A handle to the TextSelectionPopup control. */ - static Toolkit::TextSelectionPopup New(); + static Toolkit::TextSelectionPopup New( TextSelectionPopupCallbackInterface* callbackInterface ); // Properties @@ -135,86 +114,143 @@ public: */ static Property::Value GetProperty( BaseObject* object, Property::Index index ); - void CreatePopup(); + /** + * @copydoc Toolkit::EnableButtons + */ + void EnableButtons( Toolkit::TextSelectionPopup::Buttons buttonsToEnable ); + + /** + * @copydoc Toolkit::TextSelectionPopup::RaiseAbove() + */ + void RaiseAbove( Layer target ); + + /** + * @copydoc Toolkit::TextSelectionPopup::ShowPopup() + */ + void ShowPopup(); - void DestroyPopup(); + /** + * @copydoc Toolkiut::TextSelectionPopup::HidePopup() + */ + void HidePopup(); private: // From Control /** * @copydoc Control::OnInitialize() */ - virtual void OnInitialize(); - -// /** -// * @copydoc Control::GetNaturalSize() -// */ -// virtual Vector3 GetNaturalSize(); -// -// /** -// * @copydoc Control::GetHeightForWidth() -// */ -// virtual float GetHeightForWidth( float width ); + virtual void OnInitialize(); + +private: // Implementation + + void HideAnimationFinished( Animation& animation ); /** - * @copydoc Control::OnInitialize() + * @brief When the cut button is pressed. + * @param[in] button the button pressed + * @return @e true to consume the event. */ - virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); -// -// /** -// * Received for single & double taps -// */ -// virtual void OnTap( const TapGesture& tap ); -// -// /** -// * @copydoc Text::ControlInterface::RequestTextRelayout() -// */ -// virtual void RequestTextRelayout(); + bool OnCutButtonPressed( Toolkit::Button button ); /** - * Set max size of Popup - * @param[in] maxSize Size (Vector2) + * @brief When the copy button is pressed. + * @param[in] button the button pressed + * @return @e true to consume the event. */ - void SetPopupMaxSize( const Size& maxSize ); + bool OnCopyButtonPressed( Toolkit::Button button ); /** - * Get Max size of Popup - * @return Vector2 the max size of the Popup + * @brief When the paste button is pressed. + * @param[in] button the button pressed + * @return @e true to consume the event. */ - const Dali::Vector2& GetPopupMaxSize() const; + bool OnPasteButtonPressed( Toolkit::Button button ); /** - * @brief Sets the image for the given part of the Popup. + * @brief When the select button is pressed. + * @param[in] button the button pressed + * @return @e true to consume the event. + */ + bool OnSelectButtonPressed( Toolkit::Button button ); + + /** + * @brief When the select all button is pressed. + * @param[in] button the button pressed + * @return @e true to consume the event. + */ + bool OnSelectAllButtonPressed( Toolkit::Button button ); + + /** + * @brief When the clipboard button is pressed. + * @param[in] button the button pressed + * @return @e true to consume the event. + */ + bool OnClipboardButtonPressed( Toolkit::Button button ); + + /** + * @brief Method to set the dimension or dimension constraint on certain aspects of the Popup. * - * @param[in] part The part of the pop from the Enum PopupParts + * @param[in] settingToCustomise The setting for the PopupCustomisations enum that can be customised + * @param[in] dimension The size to customise with + */ + void SetDimensionToCustomise( const PopupCustomisations& settingToCustomise, const Size& dimension ); + + /** + * @brief Method to get the dimension or dimension constraint on certain aspects of the Popup that was previously customised + * + * @param[in] setting The setting from the PopupCustomisations enum + */ + Size GetDimensionToCustomise( const PopupCustomisations& setting ) const; + + /** + * @brief Sets the image for the given button of the Popup. + * + * @param[in] button The button the image should be used for from the Buttons Enum. * @param[in] image The image to use. */ - void SetPopupImage( PopupParts part, Dali::Image image ); + void SetButtonImage( Toolkit::TextSelectionPopup::Buttons button, const std::string& image ); /** - * @brief Retrieves the image of the given part used by the popup + * @brief Retrieves the image of the given button used by the popup * - * @param[in] part The part of the popup - * @return The image used for that part. + * @param[in] button The button to get the image from + * @return The image used for that button. */ - Dali::Image GetPopupImage( PopupParts part ); + const std::string& GetButtonImage( Toolkit::TextSelectionPopup::Buttons button ) const; - void CreateOrderedListOfPopupOptions(); + /** + * @brief Sets the image for the pressed state of a popup option. + * + * @param[in] filename The image filename to use. + */ + void SetPressedImage( const std::string& filename); - void CreateBackground(); + /** + * @brief Gets the image used for the pressed state of a popup option. + * + * @return The image filename used. + */ + std::string GetPressedImage() const; - void AddOption( Dali::Toolkit::TableView& parent, const std::string& name, const std::string& caption, const Image iconImage, bool finalOption, bool showIcons, bool showCaption, std::size_t& indexInTable ); + void CreateOrderedListOfPopupOptions(); - void SetUpPopup(); + void AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption ); - void AddPopupOptions( bool createTail, bool showIcons, bool showCaptions ); + std::size_t GetNumberOfEnabledOptions() const; -private: // Implementation + void AddPopupOptionsToToolbar( bool showIcons, bool showCaptions ); + + /** + * Creates the background-border image + * + * @param[in] propertyMap The properties describing the background-border + */ + void CreateBackgroundBorder( Property::Map& propertyMap ); /** * Construct a new TextField. */ - TextSelectionPopup(); + TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface ); /** * A reference counted object may only be deleted by calling Unreference() @@ -229,41 +265,33 @@ private: private: // Data - Dali::Toolkit::TableView mTableOfButtons; // Actor which holds all the buttons, sensitivity can be set on buttons via this actor - Layer mStencilLayer; // Layer to enable clipping when buttons exceed popup - // Images to be used by the Popup - Image mBackgroundImage; - Image mCutIconImage; - Image mCopyIconImage; - Image mPasteIconImage; - Image mClipboardIconImage; - Image mSelectIconImage; - Image mSelectAllIconImage; + Dali::Toolkit::TextSelectionToolbar mToolbar; - ImageActor mBackground; // The background popup panel - ImageActor mTail; // The tail for the popup - ImageActor mTailEffect; //todo remove // the tail effect - ImageActor mTailLine; //todo remove // The border/outline around the tail + Dali::Toolkit::TableView mTableOfButtons; // Actor which holds all the buttons, sensitivity can be set on buttons via this actor - Size mMaxSize; // Max size of the Popup - Size mVisiblePopUpSize; // Visible Size of popup excluding content that needs scrolling. - Size mRequiredPopUpSize; // Total size of popup including any invisible margin + // Images paths to be used by the Popup buttons + std::string mCutIconImage; + std::string mCopyIconImage; + std::string mPasteIconImage; + std::string mClipboardIconImage; + std::string mSelectIconImage; + std::string mSelectAllIconImage; - Vector4 mNinePatchMargins; // Margins between the edge of the cropped image and the nine patch rect (left, right, top, bottom). - - Size mContentSize; // Size of Content (i.e. Buttons) - //Animation mAnimation; // Popup Hide/Show animation. + Size mPopupMaxSize; // Maximum size of the Popup + Size mOptionMaxSize; // Maximum size of an Option button + Size mOptionMinSize; // Minimum size of an Option button + Size mOptionDividerSize; // Size of divider line std::vector mOrderListOfButtons; // List of buttons in the order to be displayed and a flag to indicate if needed. - Vector4 mBackgroundColor; // Color of the background of the text input popup - Vector4 mBackgroundPressedColor; // Color of the option background. - Vector4 mLineColor; // Color of the line around the text input popup + Toolkit::TextSelectionPopup::Buttons mEnabledButtons; // stores enabled buttons + Toolkit::TextSelectionPopupCallbackInterface* mCallbackInterface; + + std::string mPressedImage; // Image used for the popup option when pressed. + Vector4 mPressedColor; // Color of the popup option when pressed. + Vector4 mDividerColor; // Color of the divider between buttons Vector4 mIconColor; // Color of the popup icon. - Vector4 mIconPressedColor; // Color of the popup icon when pressed. - Vector4 mTextColor; // Color of the popup text. - Vector4 mTextPressedColor; // Color of the popup text when pressed. // 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 @@ -272,9 +300,13 @@ private: // Data std::size_t mCopyOptionPriority; // Position of Copy button std::size_t mPasteOptionPriority; // Position of Paste button std::size_t mClipboardOptionPriority; // Position of Clipboard button + float mFadeInDuration; // Duration of the animation to fade in the Popup + float mFadeOutDuration; // Duration of the animation to fade out the Popup - bool mShowIcons; // Flag to show icons - bool mShowCaptions; // Flag to show text captions + bool mShowIcons:1; // Flag to show icons + bool mShowCaptions:1; // Flag to show text captions + bool mPopupShowing:1; // Flag to indicate Popup showing + bool mButtonsChanged:1; // Flag to indicate the Popup Buttons have changed }; @@ -304,4 +336,5 @@ inline const Toolkit::Internal::TextSelectionPopup& GetImpl( const Toolkit::Text } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__ +#endif // DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H +