2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h>
22 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
23 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
24 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
27 #include <dali/public-api/images/nine-patch-image.h>
28 #include <dali/public-api/images/resource-image.h>
29 #include <dali/public-api/math/vector2.h>
30 #include <dali/public-api/math/vector4.h>
33 // todo Move this to adaptor??
34 #define GET_LOCALE_TEXT(string) dgettext("elementary", string)
47 const Dali::Vector4 DEFAULT_POPUP_BACKGROUND( Dali::Vector4( .20f, 0.29f, 0.44f, 1.0f ) );
48 const Dali::Vector4 DEFAULT_POPUP_BACKGROUND_PRESSED( Dali::Vector4( 0.07f, 0.10f, 0.17f, 1.0f ) );
49 const Dali::Vector4 DEFAULT_POPUP_LINE_COLOR( Dali::Vector4( 0.36f, 0.45f, 0.59f, 1.0f ) );
50 const Dali::Vector4 DEFAULT_OPTION_ICON( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
51 const Dali::Vector4 DEFAULT_OPTION_ICON_PRESSED( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
52 const Dali::Vector4 DEFAULT_OPTION_TEXT( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
53 const Dali::Vector4 DEFAULT_OPTION_TEXT_PRESSED( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
55 const std::string DEFAULT_POPUP_BACKGROUND_IMAGE( DALI_IMAGE_DIR "popup_bubble_bg.#.png" );
56 const std::string OPTION_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" );
57 const std::string OPTION_ICON_COPY( DALI_IMAGE_DIR "copy_paste_icon_copy.png" );
58 const std::string OPTION_ICON_CUT( DALI_IMAGE_DIR "copy_paste_icon_cut.png" );
59 const std::string OPTION_ICON_PASTE( DALI_IMAGE_DIR "copy_paste_icon_paste.png" );
60 const std::string OPTION_ICON_SELECT( DALI_IMAGE_DIR "copy_paste_icon_select.png" );
61 const std::string OPTION_ICON_SELECT_ALL( DALI_IMAGE_DIR "copy_paste_icon_select_all.png" );
63 const Dali::Vector2 DEFAULT_POPUP_MAX_SIZE( 470.0f, 120.0f ); ///< The maximum size of the popup.
65 const float OPTION_TEXT_LINE_HEIGHT( 32.0f ); ///< The line height of the text.
66 const Dali::Vector2 OPTION_ICON_SIZE( 0.f, 0.f ); ///< The size of the icon.
67 const float OPTION_GAP_ICON_TEXT( 6.f ); ///< The gap between the icon and the text
68 const float OPTION_MARGIN_WIDTH( 10.f ); ///< The margin between the right or lefts edge and the text or icon.
69 const float OPTION_MAX_WIDTH( DEFAULT_POPUP_MAX_SIZE.width / 6 ); ///< The maximum width of the option (currently set to the max)
70 const float OPTION_MIN_WIDTH( 86.0f ); ///< The minimum width of the option.
72 const float POPUP_DIVIDER_WIDTH( 1.f ); ///< The size of the divider.
74 const Dali::Vector2 POPUP_TAIL_SIZE( 20.0f, 16.0f ); ///< The size of the tail.
75 const float POPUP_TAIL_Y_OFFSET( 5.f ); ///< The y offset of the tail (when its position is on the bottom).
76 const float POPUP_TAIL_TOP_Y_OFFSET( 3.f ); ///< The y offset of the tail (when its position is on the top).
78 const float HIDE_POPUP_ANIMATION_DURATION( 0.2f ); ///< Duration of popup hide animation in seconds.
79 const float SHOW_POPUP_ANIMATION_DURATION( 0.2f ); ///< Duration of popup show animation in seconds.
81 const char* const OPTION_SELECT_WORD = "option-select_word"; // "Select Word" popup option.
82 const char* const OPTION_SELECT_ALL("option-select_all"); // "Select All" popup option.
83 const char* const OPTION_CUT("option-cut"); // "Cut" popup option.
84 const char* const OPTION_COPY("option-copy"); // "Copy" popup option.
85 const char* const OPTION_PASTE("option-paste"); // "Paste" popup option.
86 const char* const OPTION_CLIPBOARD("option-clipboard"); // "Clipboard" popup option.
90 //// Comparison function for ButtonRequirement Priority
91 //bool TextSelectionPopup::PriorityCompare( ButtonRequirement const& a, ButtonRequirement const& b )
93 // return a.priority < b.priority;
97 Dali::Toolkit::TextSelectionPopup TextSelectionPopup::New()
99 // Create the implementation, temporarily owned by this handle on stack
100 IntrusivePtr< TextSelectionPopup > impl = new TextSelectionPopup();
102 // Pass ownership to CustomActor handle
103 Dali::Toolkit::TextSelectionPopup handle( *impl );
105 // Second-phase init of the implementation
106 // This can only be done after the CustomActor connection has been made...
112 void TextSelectionPopup::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
114 Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast( Dali::BaseHandle( object ) );
118 TextSelectionPopup& impl( GetImpl( selectionPopup ) );
122 case Toolkit::TextSelectionPopup::Property::POPUP_MAX_SIZE:
124 impl.SetPopupMaxSize( value.Get< Vector2 >() );
127 case Toolkit::TextSelectionPopup::Property::POPUP_BACKGROUND_IMAGE:
129 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
130 impl.SetPopupImage( POPUP_BACKGROUND, image );
133 case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
135 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
136 impl.SetPopupImage( POPUP_CLIPBOARD_BUTTON, image );
139 case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
141 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
142 impl.SetPopupImage( POPUP_CUT_BUTTON_ICON, image );
145 case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
147 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
148 impl.SetPopupImage( POPUP_COPY_BUTTON_ICON, image );
151 case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
153 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
154 impl.SetPopupImage( POPUP_PASTE_BUTTON_ICON, image );
157 case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
159 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
160 impl.SetPopupImage( POPUP_SELECT_BUTTON_ICON, image );
163 case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
165 ResourceImage image = ResourceImage::New( value.Get< std::string >() );
166 impl.SetPopupImage( POPUP_SELECT_ALL_BUTTON_ICON, image );
170 } // TextSelectionPopup
173 Property::Value TextSelectionPopup::GetProperty( BaseObject* object, Property::Index index )
175 Property::Value value;
177 Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast( Dali::BaseHandle( object ) );
181 TextSelectionPopup& impl( GetImpl( selectionPopup ) );
185 case Toolkit::TextSelectionPopup::Property::POPUP_MAX_SIZE:
187 value = impl.GetPopupMaxSize();
190 case Toolkit::TextSelectionPopup::Property::POPUP_BACKGROUND_IMAGE:
192 ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_BACKGROUND ) );
195 value = image.GetUrl();
199 case Toolkit::TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE:
201 ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_CLIPBOARD_BUTTON ) );
204 value = image.GetUrl();
208 case Toolkit::TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE:
210 ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_CUT_BUTTON_ICON ) );
213 value = image.GetUrl();
217 case Toolkit::TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE:
219 ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_COPY_BUTTON_ICON ) );
222 value = image.GetUrl();
226 case Toolkit::TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE:
228 ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_PASTE_BUTTON_ICON ) );
231 value = image.GetUrl();
235 case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE:
237 ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_SELECT_BUTTON_ICON ) );
240 value = image.GetUrl();
244 case Toolkit::TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE:
246 ResourceImage image = ResourceImage::DownCast( impl.GetPopupImage( POPUP_SELECT_ALL_BUTTON_ICON ) );
249 value = image.GetUrl();
258 void TextSelectionPopup::OnInitialize()
263 void TextSelectionPopup::OnRelayout( const Vector2& size, RelayoutContainer& container )
268 void TextSelectionPopup::SetPopupMaxSize( const Size& maxSize )
273 const Dali::Vector2& TextSelectionPopup::GetPopupMaxSize() const
278 void TextSelectionPopup::SetPopupImage( PopupParts part, Dali::Image image )
282 case POPUP_BACKGROUND :
284 mBackgroundImage = image;
287 case POPUP_CLIPBOARD_BUTTON :
289 mClipboardIconImage = image;
292 case POPUP_CUT_BUTTON_ICON :
294 mCutIconImage = image;
297 case POPUP_COPY_BUTTON_ICON :
299 mCopyIconImage = image;
302 case POPUP_PASTE_BUTTON_ICON :
304 mPasteIconImage = image;
307 case POPUP_SELECT_BUTTON_ICON :
309 mSelectIconImage = image;
312 case POPUP_SELECT_ALL_BUTTON_ICON :
314 mSelectAllIconImage = image;
321 Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
325 case POPUP_BACKGROUND :
327 return mBackgroundImage;
330 case POPUP_CLIPBOARD_BUTTON :
332 return mClipboardIconImage;
335 case POPUP_CUT_BUTTON_ICON :
337 return mCutIconImage;
340 case POPUP_COPY_BUTTON_ICON :
342 return mCopyIconImage;
345 case POPUP_PASTE_BUTTON_ICON :
347 return mPasteIconImage;
350 case POPUP_SELECT_BUTTON_ICON :
352 return mSelectIconImage;
355 case POPUP_SELECT_ALL_BUTTON_ICON :
357 return mSelectAllIconImage;
362 DALI_ASSERT_DEBUG( "Unknown Popup Part" );
366 return Dali::Image();
369 void TextSelectionPopup::CreateOrderedListOfPopupOptions()
371 mOrderListOfButtons.clear();
373 // Create button for each possible option using Option priority
374 if ( !mCutIconImage )
376 mCutIconImage = ResourceImage::New( OPTION_ICON_CUT );
378 mOrderListOfButtons.push_back( ButtonRequirement( ButtonsCut, mCutOptionPriority, OPTION_CUT, GET_LOCALE_TEXT("IDS_COM_BODY_CUT"), mCutIconImage, true ) );
380 if ( !mCopyIconImage )
382 mCopyIconImage = ResourceImage::New( OPTION_ICON_COPY );
384 mOrderListOfButtons.push_back( ButtonRequirement( ButtonsCopy, mCopyOptionPriority, OPTION_COPY, GET_LOCALE_TEXT("IDS_COM_BODY_COPY"), mCopyIconImage, true ) );
386 if ( !mPasteIconImage )
388 mPasteIconImage = ResourceImage::New( OPTION_ICON_PASTE );
390 mOrderListOfButtons.push_back( ButtonRequirement( ButtonsPaste, mPasteOptionPriority, OPTION_PASTE, GET_LOCALE_TEXT("IDS_COM_BODY_PASTE"), mPasteIconImage, true ) );
392 if ( !mSelectIconImage )
393 mSelectIconImage = ResourceImage::New( OPTION_ICON_SELECT );
394 mOrderListOfButtons.push_back( ButtonRequirement( ButtonsSelect, mSelectOptionPriority, OPTION_SELECT_WORD, GET_LOCALE_TEXT("IDS_COM_SK_SELECT"), mSelectIconImage, true ) );
396 if ( !mSelectAllIconImage )
398 mSelectAllIconImage = ResourceImage::New( OPTION_ICON_SELECT_ALL );
400 mOrderListOfButtons.push_back( ButtonRequirement( ButtonsSelectAll, mSelectAllOptionPriority, OPTION_SELECT_ALL, GET_LOCALE_TEXT("IDS_COM_BODY_SELECT_ALL"), mSelectAllIconImage, true ) );
402 if ( !mClipboardIconImage )
404 mClipboardIconImage = ResourceImage::New( OPTION_ICON_CLIPBOARD );
406 mOrderListOfButtons.push_back( ButtonRequirement( ButtonsClipboard, mClipboardOptionPriority, OPTION_CLIPBOARD, GET_LOCALE_TEXT("IDS_COM_BODY_CLIPBOARD"), mClipboardIconImage, true ) );
408 // Sort the buttons according their priorities.
409 std::sort( mOrderListOfButtons.begin(), mOrderListOfButtons.end(), TextSelectionPopup::ButtonPriorityCompare() );
412 void TextSelectionPopup::CreateBackground()
414 if ( !mBackgroundImage )
416 mBackgroundImage = ResourceImage::New( DEFAULT_POPUP_BACKGROUND_IMAGE );
419 NinePatchImage backgroundImageNinePatch = NinePatchImage::DownCast( mBackgroundImage );
420 if( backgroundImageNinePatch )
422 const Size ninePatchImageSize = Size( static_cast<float>( mBackgroundImage.GetWidth() ), static_cast<float>( mBackgroundImage.GetHeight() ) );
423 Rect<int> childRect = backgroundImageNinePatch.GetChildRectangle();
425 // -1u because of the cropping.
426 mNinePatchMargins.x = childRect.x - 1u;
427 mNinePatchMargins.y = ninePatchImageSize.width - ( childRect.x + childRect.width ) - 1u;
428 mNinePatchMargins.z = childRect.y - 1u;
429 mNinePatchMargins.w = ninePatchImageSize.height - ( childRect.y + childRect.height ) - 1u;
432 SetBackgroundImage( mBackgroundImage );
433 SetBackgroundColor( mBackgroundColor );
436 void TextSelectionPopup::AddOption( Actor& parent, const std::string& name, const std::string& caption, const Image iconImage, bool finalOption, bool showIcons )
438 // 1. Create the backgrounds for the popup option both normal and pressed.
439 // Both containers will be added to a button.
440 Actor optionContainer = Actor::New();
441 optionContainer.SetDrawMode( DrawMode::OVERLAY );
442 //optionContainer.SetParentOrigin( ParentOrigin::CENTER );
443 optionContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
445 ImageActor optionPressedContainer = Toolkit::CreateSolidColorActor( mBackgroundPressedColor );
446 optionPressedContainer.SetDrawMode( DrawMode::OVERLAY );
447 //optionPressedContainer.SetParentOrigin( ParentOrigin::CENTER );
448 optionPressedContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
451 Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
452 captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
453 optionContainer.Add( captionTextLabel );
455 Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
456 pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
457 optionPressedContainer.Add( pressedCaptionTextLabel );
459 // Calculates the icon/text position.
460 float iconTextOffsetY = 0.0f;
464 // 3. Create the icons
465 ImageActor pressedIcon = ImageActor::New( iconImage );
466 ImageActor icon = ImageActor::New( iconImage );
468 optionContainer.Add( icon );
469 optionPressedContainer.Add( pressedIcon );
471 iconTextOffsetY = 0.5f * ( ( DEFAULT_POPUP_MAX_SIZE.height - mNinePatchMargins.z - mNinePatchMargins.w ) - ( OPTION_ICON_SIZE.height + OPTION_GAP_ICON_TEXT + OPTION_TEXT_LINE_HEIGHT ) );
473 icon.SetParentOrigin( ParentOrigin::TOP_CENTER );
474 icon.SetAnchorPoint( AnchorPoint::TOP_CENTER );
475 icon.SetY( iconTextOffsetY );
477 pressedIcon.SetParentOrigin( ParentOrigin::TOP_CENTER );
478 pressedIcon.SetAnchorPoint( AnchorPoint::TOP_CENTER );
479 pressedIcon.SetY( iconTextOffsetY );
481 // Layout icon + gap + text
482 captionTextLabel.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
483 pressedCaptionTextLabel.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
484 pressedCaptionTextLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
485 captionTextLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
486 pressedCaptionTextLabel.SetY( -iconTextOffsetY );
487 captionTextLabel.SetY( -iconTextOffsetY );
491 // Centre option text
492 captionTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
493 captionTextLabel.SetParentOrigin( ParentOrigin::CENTER );
494 pressedCaptionTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
495 pressedCaptionTextLabel.SetParentOrigin( ParentOrigin::CENTER );
498 // Calculate the size of the text.
499 Vector3 textSize = captionTextLabel.GetNaturalSize();
500 textSize.width = std::min( textSize.width, OPTION_MAX_WIDTH - 2.f * OPTION_MARGIN_WIDTH );
502 // Set the size to the text. Text will be ellipsized if exceeds the max width.
503 captionTextLabel.SetSize( textSize );
504 pressedCaptionTextLabel.SetSize( textSize );
506 // 4. Calculate the size of option.
508 // The width is the max size of the text or the icon plus the margins clamped between the option min and max size.
509 // The height is the whole popup height minus the ninepatch margins.
510 const Vector2 optionSize( std::min( OPTION_MAX_WIDTH, std::max( OPTION_MIN_WIDTH, std::max( textSize.width, OPTION_ICON_SIZE.width ) + 2.f * OPTION_MARGIN_WIDTH ) ),
511 DEFAULT_POPUP_MAX_SIZE.height - mNinePatchMargins.z - mNinePatchMargins.w );
513 optionContainer.SetSize( optionSize );
514 optionPressedContainer.SetSize( optionSize );
516 // 5. Create a option.
517 Toolkit::PushButton option = Toolkit::PushButton::New();
518 //option.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed ); FIXME
519 option.SetSize( optionSize );
520 option.SetAnchorPoint( AnchorPoint::TOP_LEFT );
521 option.SetX( mContentSize.width );
522 option.SetName( name );
523 option.SetAnimationTime( 0.0f );
524 //option.ClickedSignal().Connect( this, &TextInputPopup::OnButtonPressed );
526 parent.Add( option );
528 // 6. Set the normal option image.
529 option.SetButtonImage( optionContainer );
531 // 7. Set the pressed option image
532 option.SetSelectedImage( optionPressedContainer );
534 // 8. Update the content size.
535 mContentSize.width += optionSize.width;
536 mContentSize.height = std::max ( optionSize.height, mContentSize.height );
538 // 9. Add the divider
541 const Size size( POPUP_DIVIDER_WIDTH, mContentSize.height );
543 ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE );
544 divider.SetSize (size);
545 divider.SetParentOrigin( ParentOrigin::TOP_LEFT );
546 divider.SetAnchorPoint( AnchorPoint::TOP_LEFT );
547 divider.SetPosition( mContentSize.width - POPUP_DIVIDER_WIDTH, 0.0f );
548 parent.Add( divider );
552 void TextSelectionPopup::SetUpPopup( Size& size )
556 // Create Layer and Stencil.
557 mStencilLayer = Layer::New();
558 ImageActor stencil = CreateSolidColorActor( Color::RED );
559 stencil.SetDrawMode( DrawMode::STENCIL );
560 stencil.SetVisible( true );
561 Actor scrollview = Actor::New(); //todo make a scrollview
563 //todo Use Size negotiation
564 //self.SetSize( size ); // control matches stencil size
565 self.SetSize( mRequiredPopUpSize ); // control matches stencil size
566 mStencilLayer.SetSize( size ); // matches stencil size
567 stencil.SetSize( size );
568 scrollview.SetSize( size );
569 mButtons.SetSize( size );
571 mStencilLayer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
572 scrollview.SetAnchorPoint(AnchorPoint::TOP_LEFT);
573 mButtons.SetAnchorPoint( AnchorPoint::TOP_LEFT );
575 mStencilLayer.SetPosition( mNinePatchMargins.x, mNinePatchMargins.y );
577 self.Add( mStencilLayer );
578 mStencilLayer.Add( stencil );
579 mStencilLayer.Add( scrollview );
580 scrollview.Add( mButtons );
583 void TextSelectionPopup::AddPopupOptions( bool createTail, bool showIcons )
585 mShowIcons = showIcons;
587 mContentSize = Vector2::ZERO;
589 mButtons = Actor::New();
591 // Add the options into the buttons container.
593 // 1. Determine how many buttons are active and should be added to container.
594 std::size_t numberOfOptions = 0u;
595 for( std::vector<ButtonRequirement>::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it )
597 const ButtonRequirement& button( *it );
604 // 2. Iterate list of buttons and add active ones.
605 std::size_t optionsAdded = 0u;
606 for( std::vector<ButtonRequirement>::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); ( it != endIt ); ++it )
608 const ButtonRequirement& button( *it );
609 if ( button.enabled )
612 AddOption( mButtons, button.name, button.caption, button.icon, optionsAdded == numberOfOptions, mShowIcons );
616 // Calculate the size of the whole popup which may not be all visible.
617 mRequiredPopUpSize = Size( std::min( mMaxSize.width, mContentSize.width + mNinePatchMargins.x + mNinePatchMargins.y ), DEFAULT_POPUP_MAX_SIZE.height );
619 // Size of the contents within the popup
620 mVisiblePopUpSize = Size( mRequiredPopUpSize.width - mNinePatchMargins.x - mNinePatchMargins.y, mRequiredPopUpSize.height - mNinePatchMargins.z - mNinePatchMargins.w );
623 void TextSelectionPopup::CreatePopup()
625 if ( !mStencilLayer )
627 CreateOrderedListOfPopupOptions(); //todo Currently causes all options to be shown
629 AddPopupOptions( true, true );
630 SetUpPopup( mVisiblePopUpSize );
633 mStencilLayer.RaiseToTop();
636 TextSelectionPopup::TextSelectionPopup()
637 : Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ),
638 mMaxSize ( DEFAULT_POPUP_MAX_SIZE ),
639 mVisiblePopUpSize( DEFAULT_POPUP_MAX_SIZE ),
640 mRequiredPopUpSize( DEFAULT_POPUP_MAX_SIZE ),
641 mBackgroundColor( DEFAULT_POPUP_BACKGROUND ),
642 mBackgroundPressedColor( DEFAULT_POPUP_BACKGROUND_PRESSED ),
643 mLineColor( DEFAULT_POPUP_LINE_COLOR ),
644 mIconColor( DEFAULT_OPTION_ICON ),
645 mIconPressedColor( DEFAULT_OPTION_ICON_PRESSED ),
646 mTextColor( DEFAULT_OPTION_TEXT ),
647 mTextPressedColor( DEFAULT_OPTION_TEXT_PRESSED ),
648 mSelectOptionPriority( 1 ),
649 mSelectAllOptionPriority ( 2 ),
650 mCutOptionPriority ( 3 ),
651 mCopyOptionPriority ( 4 ),
652 mPasteOptionPriority ( 5 ),
653 mClipboardOptionPriority( 6 ),
658 TextSelectionPopup::~TextSelectionPopup()
663 } // namespace Internal
665 } // namespace Toolkit