{
public:
+ enum Buttons
+ {
+ CUT = 1u << 0,
+ COPY = 1u << 1,
+ PASTE = 1u << 2,
+ SELECT = 1u << 3,
+ SELECT_ALL = 1u << 4,
+ CLIPBOARD = 1u << 5,
+ NONE = 1u << 6,
+ };
+
/**
* @brief The start and end property ranges for this control.
*/
{
enum
{
-
- POPUP_MAX_SIZE = PROPERTY_START_INDEX, ///< name "popup-max-size", The maximum size the Popup can be, type VECTOR2
- POPUP_MIN_SIZE, ///< name "popup-min-size", The minimum size the Popup can be, type VECTOR2
- OPTION_MAX_SIZE, ///< name "option-max-size", The maximum size an option can be, type VECTOR2
- OPTION_MIN_SIZE, ///< name "option-min-size", The minimum size an option can be, type VECTOR2
- OPTION_DIVIDER_SIZE, ///< name "option-divider-size", The size of the divider between options type VECTOR2
+ POPUP_MAX_SIZE = PROPERTY_START_INDEX, ///< name "popup-max-size", maximum size the Popup can be, type VECTOR2
+ POPUP_MIN_SIZE, ///< name "popup-min-size", minimum size the Popup can be, type VECTOR2
+ OPTION_MAX_SIZE, ///< name "option-max-size", maximum size an option can be, type VECTOR2
+ OPTION_MIN_SIZE, ///< name "option-min-size", minimum size an option can be, type VECTOR2
+ OPTION_DIVIDER_SIZE, ///< name "option-divider-size", size of the divider between options type VECTOR2
POPUP_CLIPBOARD_BUTTON_ICON_IMAGE, ///< name "popup-clipboard-button-image", The image to use as the popup clipboard icon, type STRING
POPUP_CUT_BUTTON_ICON_IMAGE, ///< name "popup-cut-button-image", The image to use as the popup cut icon, type STRING
POPUP_COPY_BUTTON_ICON_IMAGE, ///< name "popup-copy-button-image", The image to use as the popup copy icon, type STRING
static TextSelectionPopup New();
/**
+ * Create the TextSelectionPopup control with the given set of buttons.
+ * @param[in] enabledButtons The given set of buttons to enable
+ * @return A handle to the TextSelectionPopup control.
+ */
+ static TextSelectionPopup New( Buttons enabledButtons );
+
+ /**
* @brief Creates an empty handle.
*/
TextSelectionPopup();
#include <dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/buttons/push-button.h>
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
return handle;
}
+Dali::Toolkit::TextSelectionPopup TextSelectionPopup::New( Toolkit::TextSelectionPopup::Buttons buttonsToEnable )
+{
+ // Create the implementation, temporarily owned by this handle on stack
+ IntrusivePtr< TextSelectionPopup > impl = new TextSelectionPopup();
+
+ // Pass ownership to CustomActor handle
+ Dali::Toolkit::TextSelectionPopup handle( *impl );
+
+ impl->mEnabledButtons = buttonsToEnable;
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ impl->Initialize();
+
+ return handle;
+}
void TextSelectionPopup::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast( Dali::BaseHandle( object ) );
case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
{
ResourceImage image = ResourceImage::New( value.Get< std::string >() );
- impl.SetButtonImage( CLIPBOARD, image );
+ impl.SetButtonImage( Toolkit::TextSelectionPopup::CLIPBOARD, image );
break;
}
case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
{
ResourceImage image = ResourceImage::New( value.Get< std::string >() );
- impl.SetButtonImage( CUT, image );
+ impl.SetButtonImage( Toolkit::TextSelectionPopup::CUT, image );
break;
}
case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
{
ResourceImage image = ResourceImage::New( value.Get< std::string >() );
- impl.SetButtonImage( COPY, image );
+ impl.SetButtonImage( Toolkit::TextSelectionPopup::COPY, image );
break;
}
case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
{
ResourceImage image = ResourceImage::New( value.Get< std::string >() );
- impl.SetButtonImage( PASTE, image );
+ impl.SetButtonImage( Toolkit::TextSelectionPopup::PASTE, image );
break;
}
case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
{
ResourceImage image = ResourceImage::New( value.Get< std::string >() );
- impl.SetButtonImage( SELECT, image );
+ impl.SetButtonImage( Toolkit::TextSelectionPopup::SELECT, image );
break;
}
case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
{
ResourceImage image = ResourceImage::New( value.Get< std::string >() );
- impl.SetButtonImage( SELECT_ALL, image );
+ impl.SetButtonImage( Toolkit::TextSelectionPopup::SELECT_ALL, image );
break;
}
} // switch
}
case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
{
- ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( CLIPBOARD ) );
+ ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::CLIPBOARD ) );
if( image )
{
value = image.GetUrl();
}
case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
{
- ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( CUT ) );
+ ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::CUT ) );
if( image )
{
value = image.GetUrl();
}
case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
{
- ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( COPY ) );
+ ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::COPY ) );
if( image )
{
value = image.GetUrl();
}
case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
{
- ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( PASTE ) );
+ ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::PASTE ) );
if( image )
{
value = image.GetUrl();
}
case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
{
- ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( SELECT ) );
+ ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::SELECT ) );
if( image )
{
value = image.GetUrl();
}
case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
{
- ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( SELECT_ALL ) );
+ ResourceImage image = ResourceImage::DownCast( impl.GetButtonImage( Toolkit::TextSelectionPopup::SELECT_ALL ) );
if( image )
{
value = image.GetUrl();
CreatePopup();
}
+bool TextSelectionPopup::OnButtonPressed( Toolkit::Button button )
+{
+ return true;
+}
+
void TextSelectionPopup::SetDimensionToCustomise( const PopupCustomisations& settingToCustomise, const Size& dimension )
{
switch( settingToCustomise )
return Size::ZERO;
}
-void TextSelectionPopup::SetButtonImage( Buttons button, Dali::Image image )
+void TextSelectionPopup::SetButtonImage( Toolkit::TextSelectionPopup::Buttons button, Dali::Image image )
{
switch ( button )
{
break;
- case CLIPBOARD:
+ case Toolkit::TextSelectionPopup::CLIPBOARD:
{
mClipboardIconImage = image;
}
break;
- case CUT :
+ case Toolkit::TextSelectionPopup::CUT :
{
mCutIconImage = image;
}
break;
- case COPY :
+ case Toolkit::TextSelectionPopup::COPY :
{
mCopyIconImage = image;
}
break;
- case PASTE :
+ case Toolkit::TextSelectionPopup::PASTE :
{
mPasteIconImage = image;
}
break;
- case SELECT :
+ case Toolkit::TextSelectionPopup::SELECT :
{
mSelectIconImage = image;
}
break;
- case SELECT_ALL :
+ case Toolkit::TextSelectionPopup::SELECT_ALL :
{
mSelectAllIconImage = image;
}
} // switch
}
-Dali::Image TextSelectionPopup::GetButtonImage( Buttons button )
+Dali::Image TextSelectionPopup::GetButtonImage( Toolkit::TextSelectionPopup::Buttons button )
{
switch ( button )
{
- case CLIPBOARD :
+ case Toolkit::TextSelectionPopup::CLIPBOARD :
{
return mClipboardIconImage;
}
break;
- case CUT :
+ case Toolkit::TextSelectionPopup::CUT :
{
return mCutIconImage;
}
break;
- case COPY :
+ case Toolkit::TextSelectionPopup::COPY :
{
return mCopyIconImage;
}
break;
- case PASTE :
+ case Toolkit::TextSelectionPopup::PASTE :
{
return mPasteIconImage;
}
break;
- case SELECT :
+ case Toolkit::TextSelectionPopup::SELECT :
{
return mSelectIconImage;
}
break;
- case SELECT_ALL :
+ case Toolkit::TextSelectionPopup::SELECT_ALL :
{
return mSelectAllIconImage;
}
{
mCutIconImage = ResourceImage::New( OPTION_ICON_CUT );
}
- mOrderListOfButtons.push_back( ButtonRequirement( CUT, mCutOptionPriority, OPTION_CUT, POPUP_CUT_STRING , mCutIconImage, false ) );
+ mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::CUT, mCutOptionPriority, OPTION_CUT, POPUP_CUT_STRING , mCutIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::CUT) ) );
if ( !mCopyIconImage )
{
mCopyIconImage = ResourceImage::New( OPTION_ICON_COPY );
}
- mOrderListOfButtons.push_back( ButtonRequirement( COPY, mCopyOptionPriority, OPTION_COPY, POPUP_COPY_STRING, mCopyIconImage, false ) );
+ mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::COPY, mCopyOptionPriority, OPTION_COPY, POPUP_COPY_STRING, mCopyIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::COPY) ) );
if ( !mPasteIconImage )
{
mPasteIconImage = ResourceImage::New( OPTION_ICON_PASTE );
}
- mOrderListOfButtons.push_back( ButtonRequirement( PASTE, mPasteOptionPriority, OPTION_PASTE, POPUP_PASTE_STRING, mPasteIconImage, false ) );
+ mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::PASTE, mPasteOptionPriority, OPTION_PASTE, POPUP_PASTE_STRING, mPasteIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::PASTE) ) );
if ( !mSelectIconImage )
mSelectIconImage = ResourceImage::New( OPTION_ICON_SELECT );
- mOrderListOfButtons.push_back( ButtonRequirement( SELECT, mSelectOptionPriority, OPTION_SELECT_WORD, POPUP_SELECT_STRING, mSelectIconImage, true ) );
+ mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::SELECT, mSelectOptionPriority, OPTION_SELECT_WORD, POPUP_SELECT_STRING, mSelectIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::SELECT) ) );
if ( !mSelectAllIconImage )
{
mSelectAllIconImage = ResourceImage::New( OPTION_ICON_SELECT_ALL );
}
- mOrderListOfButtons.push_back( ButtonRequirement( SELECT_ALL, mSelectAllOptionPriority, OPTION_SELECT_ALL, POPUP_SELECT_ALL_STRING, mSelectAllIconImage, true ) );
+ mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::SELECT_ALL, mSelectAllOptionPriority, OPTION_SELECT_ALL, POPUP_SELECT_ALL_STRING, mSelectAllIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::SELECT_ALL) ) );
if ( !mClipboardIconImage )
{
mClipboardIconImage = ResourceImage::New( OPTION_ICON_CLIPBOARD );
}
- mOrderListOfButtons.push_back( ButtonRequirement( CLIPBOARD, mClipboardOptionPriority, OPTION_CLIPBOARD, POPUP_CLIPBOARD_STRING, mClipboardIconImage, false ) );
+ mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::CLIPBOARD, mClipboardOptionPriority, OPTION_CLIPBOARD, POPUP_CLIPBOARD_STRING, mClipboardIconImage, ( mEnabledButtons & Toolkit::TextSelectionPopup::CLIPBOARD) ) );
// Sort the buttons according their priorities.
std::sort( mOrderListOfButtons.begin(), mOrderListOfButtons.end(), TextSelectionPopup::ButtonPriorityCompare() );
option.SetName( name );
option.SetAnimationTime( 0.0f );
option.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
- //option.ClickedSignal().Connect( this, &TextInputPopup::OnButtonPressed );
+ option.ClickedSignal().Connect( this, &TextSelectionPopup::OnButtonPressed );
// 5. Set the normal option image.
option.SetButtonImage( optionContainer );
mMaxSize(),
mMinSize(),
mOptionDividerSize( Size( 2.0f, 0.0f) ),
+ mEnabledButtons( Toolkit::TextSelectionPopup::NONE ),
mLineColor( DEFAULT_POPUP_LINE_COLOR ),
mIconColor( DEFAULT_OPTION_ICON ),
mIconPressedColor( DEFAULT_OPTION_ICON_PRESSED ),
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/controls/buttons/push-button.h>
#include <dali-toolkit/public-api/controls/table-view/table-view.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h>
{
public:
- enum Buttons
- {
- CUT,
- COPY,
- PASTE,
- SELECT,
- SELECT_ALL,
- CLIPBOARD,
- ENUM_END
- };
-
struct ButtonRequirement
{
ButtonRequirement()
- : id( ENUM_END ),
+ : id( Toolkit::TextSelectionPopup::NONE ),
priority( 0u ),
name(),
caption(),
enabled( false )
{}
- ButtonRequirement( Buttons buttonId,
+ ButtonRequirement( Toolkit::TextSelectionPopup::Buttons buttonId,
std::size_t buttonPriority,
const std::string& buttonName,
const std::string& buttonCaption,
enabled( buttonEnabled )
{}
- Buttons id;
+ Toolkit::TextSelectionPopup::Buttons id;
std::size_t priority;
std::string name;
std::string caption;
*/
static Toolkit::TextSelectionPopup New();
+ /**
+ * @brief New constructor with provided buttons to enable.
+ * @param[in] buttonsToEnable bit mask of buttons to enable
+ * @return A handle to the TextSelectionPopup control.
+ */
+ static Toolkit::TextSelectionPopup New( Toolkit::TextSelectionPopup::Buttons buttonsToEnable );
+
// Properties
/**
private: // Implementation
/**
+ * @brief When a popup button is pressed
+ * @param[in] button the button pressed
+ * @return bool
+ */
+ bool OnButtonPressed( Toolkit::Button button );
+
+ /**
* @brief Method to set the dimension or dimension constraint on certain aspects of the Popup.
*
* @param[in] settingToCustomise The setting for the PopupCustomisations enum that can be customised
* @param[in] button The button the image should be used for from the Buttons Enum.
* @param[in] image The image to use.
*/
- void SetButtonImage( Buttons button, Dali::Image image );
+ void SetButtonImage( Toolkit::TextSelectionPopup::Buttons button, Dali::Image image );
/**
* @brief Retrieves the image of the given button used by the popup
* @param[in] button The button to get the image from
* @return The image used for that button.
*/
- Dali::Image GetButtonImage( Buttons button );
+ Dali::Image GetButtonImage( Toolkit::TextSelectionPopup::Buttons button );
void CreateOrderedListOfPopupOptions();
std::vector<ButtonRequirement> mOrderListOfButtons; // List of buttons in the order to be displayed and a flag to indicate if needed.
+ Toolkit::TextSelectionPopup::Buttons mEnabledButtons; // stores enabled buttons
+
Vector4 mLineColor; // Color of the line around the text input popup
Vector4 mIconColor; // Color of the popup icon.
Vector4 mIconPressedColor; // Color of the popup icon when pressed.
std::size_t mPasteOptionPriority; // Position of Paste button
std::size_t mClipboardOptionPriority; // Position of Clipboard button
- 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
};