-#ifdef DECORATOR_DEBUG
- optionContainer.SetName("optionContainer");
- optionPressedContainer.SetName("optionPressedContainer");
-#endif
- // 2. Add text.
-
- if ( showCaption )
- {
- Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
- captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
- captionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-
- Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
- pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
- pressedCaptionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-
- Padding padding;
- padding.left = 24.0f;
- padding.right = 24.0f;
- padding.top = 14.0f;
- padding.bottom = 14.0f;
- captionTextLabel.SetPadding( padding );
- pressedCaptionTextLabel.SetPadding( padding );
-
- optionContainer.AddChild( captionTextLabel, Toolkit::TableView::CellPosition(( showIcons&showCaption)?1:0, 0 ) );
- optionPressedContainer.AddChild( pressedCaptionTextLabel, Toolkit::TableView::CellPosition(( showIcons&showCaption)?1:0, 0 ) );
- }
-
- // 3. Create the icons
- if ( showIcons )
- {
- ImageActor pressedIcon = ImageActor::New( iconImage );
- ImageActor icon = ImageActor::New( iconImage );
- icon.SetSortModifier( DECORATION_DEPTH_INDEX - 1 );
- pressedIcon.SetSortModifier( DECORATION_DEPTH_INDEX - 1 );
-
- icon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
- pressedIcon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
- icon.SetColor( mIconColor );
-
- if ( showCaption & showIcons )
- {
- optionContainer.SetFitHeight( 1 );
- optionContainer.SetFitWidth( 1 );
- optionPressedContainer.SetFitHeight( 1 );
- optionPressedContainer.SetFitWidth( 1 );
- }
-
- optionContainer.AddChild( icon, Toolkit::TableView::CellPosition( 0, 0 ) );
- optionPressedContainer.AddChild( pressedIcon, Toolkit::TableView::CellPosition( 0, 0 ) );
-
- icon.SetPadding( Padding( 10.0f, 10.0f, 10.0f, 10.0f ) );
- pressedIcon.SetPadding( Padding( 10.0f, 10.0f, 10.0f, 10.0f ) );
- }
-
- // 4. Create a option.
- Toolkit::PushButton option = Toolkit::PushButton::New();
- option.SetName( name );
- option.SetAnimationTime( 0.0f );
- option.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, 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;
- }
- }
-
- // 5. Set the normal option image.
- option.SetButtonImage( optionContainer );
-
- // 6. Set the pressed option image
- option.SetSelectedImage( optionPressedContainer );
-
- // 7 Add option to tool bar
- mToolbar.AddOption( option );
-
- // 8. Add the divider
- if( showDivider )
- {
- const Size size( mOptionDividerSize.width, 0.0f ); // Height FILL_TO_PARENT
-
- ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE );
- divider.SetSize( size );
- divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
- divider.SetColor( mLineColor );
- 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 )
- {
- // Iterate list of buttons and add active ones to Toolbar
- std::size_t numberOfOptionsRequired = GetNumberOfEnabledOptions();
- std::size_t numberOfOptionsAdded = 0u;
- for( std::vector<ButtonRequirement>::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it )
- {
- const ButtonRequirement& button( *it );
- if ( button.enabled )
- {
- numberOfOptionsAdded++;
- AddOption( button, ( numberOfOptionsAdded < numberOfOptionsRequired ) , showIcons, showCaptions );
- }
- }
- }
-
- void TextSelectionPopup::CreatePopup()
- {
- Actor self = Self();
- CreateOrderedListOfPopupOptions(); //todo Currently causes all options to be shown
- self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
- SetBackgroundImage( NinePatchImage::New( DEFAULT_POPUP_BACKGROUND_IMAGE ) );
-
- if ( !mToolbar )
- {
- mToolbar = Toolkit::TextSelectionToolbar::New();
- mToolbar.SetParentOrigin( ParentOrigin::CENTER );
- mToolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, mMaxSize );
- self.Add( mToolbar );
- AddPopupOptionsToToolbar( mShowIcons, mShowCaptions );
- }
- }
-
-TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface )
-: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),