- void TextSelectionPopup::CreateOrderedListOfPopupOptions()
- {
- mOrderListOfButtons.clear();
- mOrderListOfButtons.reserve( 8u );
-
- // Create button for each possible option using Option priority
- mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::CUT, mCutOptionPriority, OPTION_CUT, POPUP_CUT_STRING , mCutIconImage, 0 != ( mEnabledButtons & Toolkit::TextSelectionPopup::CUT) ) );
- mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::COPY, mCopyOptionPriority, OPTION_COPY, POPUP_COPY_STRING, mCopyIconImage, 0 != ( mEnabledButtons & Toolkit::TextSelectionPopup::COPY) ) );
- mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::PASTE, mPasteOptionPriority, OPTION_PASTE, POPUP_PASTE_STRING, mPasteIconImage, 0 != ( mEnabledButtons & Toolkit::TextSelectionPopup::PASTE) ) );
- mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::SELECT, mSelectOptionPriority, OPTION_SELECT_WORD, POPUP_SELECT_STRING, mSelectIconImage, 0 != ( mEnabledButtons & Toolkit::TextSelectionPopup::SELECT) ) );
- mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::SELECT_ALL, mSelectAllOptionPriority, OPTION_SELECT_ALL, POPUP_SELECT_ALL_STRING, mSelectAllIconImage, 0 != ( mEnabledButtons & Toolkit::TextSelectionPopup::SELECT_ALL) ) );
- mOrderListOfButtons.push_back( ButtonRequirement( Toolkit::TextSelectionPopup::CLIPBOARD, mClipboardOptionPriority, OPTION_CLIPBOARD, POPUP_CLIPBOARD_STRING, mClipboardIconImage, 0 != ( mEnabledButtons & Toolkit::TextSelectionPopup::CLIPBOARD) ) );
-
- // Sort the buttons according their priorities.
- std::sort( mOrderListOfButtons.begin(), mOrderListOfButtons.end(), TextSelectionPopup::ButtonPriorityCompare() );
- }
-
- void TextSelectionPopup::AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption )
- {
- // 1. Create a option.
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextSelectionPopup::AddOption\n" );
-
- Toolkit::PushButton option = Toolkit::PushButton::New();
- option.SetProperty( Dali::Actor::Property::NAME, button.name );
- option.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-
- switch( button.id )
- {
- case Toolkit::TextSelectionPopup::CUT:
- {
- option.ClickedSignal().Connect( this, &TextSelectionPopup::OnCutButtonPressed );
- break;
- }
- case Toolkit::TextSelectionPopup::COPY:
- {
- option.ClickedSignal().Connect( this, &TextSelectionPopup::OnCopyButtonPressed );
- break;
- }
- case Toolkit::TextSelectionPopup::PASTE:
- {
- option.ClickedSignal().Connect( this, &TextSelectionPopup::OnPasteButtonPressed );
- break;
- }
- case Toolkit::TextSelectionPopup::SELECT:
- {
- option.ClickedSignal().Connect( this, &TextSelectionPopup::OnSelectButtonPressed );
- break;
- }
- case Toolkit::TextSelectionPopup::SELECT_ALL:
- {
- option.ClickedSignal().Connect( this, &TextSelectionPopup::OnSelectAllButtonPressed );
- break;
- }
- case Toolkit::TextSelectionPopup::CLIPBOARD:
- {
- option.ClickedSignal().Connect( this, &TextSelectionPopup::OnClipboardButtonPressed );
- break;
- }
- case Toolkit::TextSelectionPopup::NONE:
- {
- // Nothing to do:
- break;
- }
- }
-
- // 2. Set the options contents.
- if( showCaption )
- {
- // PushButton layout properties.
- option.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 24.0f, 24.0f, 14.0f, 14.0f ) );
-
- // Label properties.
- Property::Map buttonLabelProperties;
- buttonLabelProperties.Insert( Toolkit::TextVisual::Property::TEXT, button.caption );
- option.SetProperty( Toolkit::Button::Property::LABEL, buttonLabelProperties );
- }
- if( showIcons )
- {
- option.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
- option.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
-
- // TODO: This is temporarily disabled until the text-selection-popup image API is changed to strings.
- //option.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, button.icon );
- //option.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, button.icon );
- }
-
- // 3. Set the normal option image (blank / Transparent).
- option.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, "" );
-
- // 4. Set the pressed option image.
- Property::Value selectedBackgroundValue( mPressedImage );
- if( mPressedImage.empty() )
- {
- // The image can be blank, the color can be used in that case.
- selectedBackgroundValue = Property::Value{ { Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR },
- { Toolkit::ColorVisual::Property::MIX_COLOR, mPressedColor } };
- }
- option.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, selectedBackgroundValue );
- option.SetProperty( Toolkit::Control::Property::STYLE_NAME, TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME );
-
- // 5 Add option to tool bar
- mToolbar.AddOption( option );
-
- // 6. Add the divider
- if( showDivider )
- {
- const Size size( mOptionDividerSize.width, 0.0f ); // Height FILL_TO_PARENT
-
- Toolkit::Control divider = Toolkit::Control::New();
-#ifdef DECORATOR_DEBUG
- divider.SetProperty( Dali::Actor::Property::NAME,"Text's popup divider");
-#endif
- divider.SetSize( size );
- divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
- divider.SetBackgroundColor( mDividerColor );
- mToolbar.AddDivider( divider );
- }
- }
-
- std::size_t TextSelectionPopup::GetNumberOfEnabledOptions()
- {
- std::size_t numberOfOptions = 0u;
- for( std::vector<ButtonRequirement>::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it )
- {
- const ButtonRequirement& button( *it );
- if( button.enabled )
- {
- ++numberOfOptions;
- }
- }
-
- return numberOfOptions;
- }
-
- void TextSelectionPopup::AddPopupOptionsToToolbar( bool showIcons, bool showCaptions )
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextSelectionPopup::AddPopupOptionsToToolbar\n" );
-
- CreateOrderedListOfPopupOptions();
-
- mButtonsChanged = false;
- UnparentAndReset( mToolbar);
-
- if( !mToolbar )
- {
- Actor self = Self();
- mToolbar = Toolkit::TextSelectionToolbar::New();
- if ( mPopupMaxSize != Vector2::ZERO ) // If PopupMaxSize property set then apply to Toolbar. Toolbar currently is not retriving this from json
- {
- mToolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, mPopupMaxSize );
- }
- mToolbar.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );