2 * Copyright (c) 2021 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 #if defined(__GLIBC__)
25 #include <dali/integration-api/debug.h>
26 #include <dali/public-api/animation/animation.h>
27 #include <dali/public-api/math/vector2.h>
28 #include <dali/public-api/math/vector4.h>
29 #include <dali/public-api/object/property-map.h>
30 #include <dali/public-api/object/type-registry-helper.h>
35 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
36 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
37 #include <dali-toolkit/devel-api/controls/control-devel.h>
38 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
39 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
40 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
41 #include <dali-toolkit/internal/controls/text-controls/text-selection-popup-property-handler.h>
42 #include <dali-toolkit/internal/helpers/color-conversion.h>
43 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
44 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
45 #include <dali-toolkit/public-api/visuals/text-visual-properties.h>
46 #include <dali-toolkit/public-api/visuals/visual-properties.h>
56 #if defined(__GLIBC__)
57 #define GET_LOCALE_TEXT(string) dgettext("dali-toolkit", string)
60 const std::string TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME("TextSelectionPopupButton");
61 const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR(Dali::Vector4(0.24f, 0.72f, 0.8f, 1.0f));
63 #if defined(DEBUG_ENABLED)
64 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
67 #ifdef DGETTEXT_ENABLED
69 #define POPUP_CUT_STRING GET_LOCALE_TEXT("IDS_COM_BODY_CUT")
70 #define POPUP_COPY_STRING GET_LOCALE_TEXT("IDS_COM_BODY_COPY")
71 #define POPUP_PASTE_STRING GET_LOCALE_TEXT("IDS_COM_BODY_PASTE")
72 #define POPUP_SELECT_STRING GET_LOCALE_TEXT("IDS_COM_SK_SELECT")
73 #define POPUP_SELECT_ALL_STRING GET_LOCALE_TEXT("IDS_COM_BODY_SELECT_ALL")
74 #define POPUP_CLIPBOARD_STRING GET_LOCALE_TEXT("IDS_COM_BODY_CLIPBOARD")
78 #define POPUP_CUT_STRING "Cut"
79 #define POPUP_COPY_STRING "Copy"
80 #define POPUP_PASTE_STRING "Paste"
81 #define POPUP_SELECT_STRING "Select"
82 #define POPUP_SELECT_ALL_STRING "Select All"
83 #define POPUP_CLIPBOARD_STRING "Clipboard"
87 const char* const OPTION_SELECT_WORD = "option-select_word"; // "Select Word" popup option.
88 const char* const OPTION_SELECT_ALL("option-select_all"); // "Select All" popup option.
89 const char* const OPTION_CUT("optionCut"); // "Cut" popup option.
90 const char* const OPTION_COPY("optionCopy"); // "Copy" popup option.
91 const char* const OPTION_PASTE("optionPaste"); // "Paste" popup option.
92 const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup option.
94 const std::string IDS_LTR("IDS_LTR");
95 const std::string RTL_DIRECTION("RTL");
99 return Toolkit::TextSelectionPopup::New(NULL);
102 // Setup properties, signals and actions using the type-registry.
104 DALI_TYPE_REGISTRATION_BEGIN(Toolkit::TextSelectionPopup, Toolkit::Control, Create);
106 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupMaxSize", VECTOR2, POPUP_MAX_SIZE)
107 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupMinSize", VECTOR2, POPUP_MIN_SIZE)
108 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "optionMaxSize", VECTOR2, OPTION_MAX_SIZE)
109 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "optionMinSize", VECTOR2, OPTION_MIN_SIZE)
110 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "optionDividerSize", VECTOR2, OPTION_DIVIDER_SIZE)
111 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "optionDividerPadding", VECTOR4, OPTION_DIVIDER_PADDING)
112 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupClipboardButtonImage", STRING, POPUP_CLIPBOARD_BUTTON_ICON_IMAGE)
113 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupCutButtonImage", STRING, POPUP_CUT_BUTTON_ICON_IMAGE)
114 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupCopyButtonImage", STRING, POPUP_COPY_BUTTON_ICON_IMAGE)
115 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupPasteButtonImage", STRING, POPUP_PASTE_BUTTON_ICON_IMAGE)
116 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupSelectButtonImage", STRING, POPUP_SELECT_BUTTON_ICON_IMAGE)
117 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupSelectAllButtonImage", STRING, POPUP_SELECT_ALL_BUTTON_ICON_IMAGE)
118 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupDividerColor", VECTOR4, POPUP_DIVIDER_COLOR)
119 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupIconColor", VECTOR4, POPUP_ICON_COLOR)
120 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupPressedColor", VECTOR4, POPUP_PRESSED_COLOR)
121 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupPressedImage", STRING, POPUP_PRESSED_IMAGE)
122 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupFadeInDuration", FLOAT, POPUP_FADE_IN_DURATION)
123 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "popupFadeOutDuration", FLOAT, POPUP_FADE_OUT_DURATION)
124 DALI_PROPERTY_REGISTRATION(Toolkit, TextSelectionPopup, "backgroundBorder", MAP, BACKGROUND_BORDER)
126 DALI_TYPE_REGISTRATION_END()
130 Dali::Toolkit::TextSelectionPopup TextSelectionPopup::New(TextSelectionPopupCallbackInterface* callbackInterface)
132 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextSelectionPopup::New\n");
134 // Create the implementation, temporarily owned by this handle on stack
135 IntrusivePtr<TextSelectionPopup> impl = new TextSelectionPopup(callbackInterface);
137 // Pass ownership to CustomActor handle
138 Dali::Toolkit::TextSelectionPopup handle(*impl);
140 // Second-phase init of the implementation
141 // This can only be done after the CustomActor connection has been made...
147 void TextSelectionPopup::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
149 Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast(Dali::BaseHandle(object));
153 PropertyHandler::SetProperty(selectionPopup, index, value);
157 Property::Value TextSelectionPopup::GetProperty(BaseObject* object, Property::Index index)
159 Property::Value value;
161 Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast(Dali::BaseHandle(object));
165 value = PropertyHandler::GetProperty(selectionPopup, index);
170 void TextSelectionPopup::EnableButtons(Toolkit::TextSelectionPopup::Buttons buttonsToEnable)
172 mEnabledButtons = buttonsToEnable;
173 mButtonsChanged = true;
176 void TextSelectionPopup::RaiseAbove(Actor target)
180 mToolbar.RaiseAbove(target);
184 void TextSelectionPopup::ShowPopup()
186 if((!mPopupShowing || mButtonsChanged) &&
187 (Toolkit::TextSelectionPopup::NONE != mEnabledButtons))
190 AddPopupOptionsToToolbar(mShowIcons, mShowCaptions);
192 Animation animation = Animation::New(mFadeInDuration);
193 animation.AnimateTo(Property(self, Actor::Property::COLOR_ALPHA), 1.0f);
195 mPopupShowing = true;
199 void TextSelectionPopup::HidePopup()
203 mPopupShowing = false;
205 Animation animation = Animation::New(mFadeOutDuration);
206 animation.AnimateTo(Property(self, Actor::Property::COLOR_ALPHA), 0.0f);
207 animation.FinishedSignal().Connect(this, &TextSelectionPopup::HideAnimationFinished);
212 void TextSelectionPopup::OnInitialize()
214 DALI_LOG_INFO(gLogFilter, Debug::General, "TextSelectionPopup::OnInitialize\n");
216 self.SetResizePolicy(ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS);
217 self.SetProperty(Actor::Property::COLOR_ALPHA, 0.0f);
220 self.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true);
221 self.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::DIALOG);
224 DevelControl::ControlAccessible* TextSelectionPopup::CreateAccessibleObject()
226 return new TextSelectionPopupAccessible(Self());
229 Dali::Accessibility::States TextSelectionPopup::TextSelectionPopupAccessible::CalculateStates()
231 auto states = ControlAccessible::CalculateStates();
233 states[Dali::Accessibility::State::MODAL] = true;
238 void TextSelectionPopup::HideAnimationFinished(Animation& animation)
241 if(!mPopupShowing) // During the Hide/Fade animation there could be a call to Show the Popup again, mPopupShowing will be true in this case.
243 DALI_LOG_INFO(gLogFilter, Debug::General, "TextSelectionPopup::HideAnimationFinished\n");
244 UnparentAndReset(mToolbar);
248 bool TextSelectionPopup::OnCutButtonPressed(Toolkit::Button button)
250 if(mCallbackInterface)
252 mCallbackInterface->TextPopupButtonTouched(Toolkit::TextSelectionPopup::CUT);
258 bool TextSelectionPopup::OnCopyButtonPressed(Toolkit::Button button)
260 if(mCallbackInterface)
262 mCallbackInterface->TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::COPY);
268 bool TextSelectionPopup::OnPasteButtonPressed(Toolkit::Button button)
270 if(mCallbackInterface)
272 mCallbackInterface->TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::PASTE);
278 bool TextSelectionPopup::OnSelectButtonPressed(Toolkit::Button button)
280 if(mCallbackInterface)
282 mCallbackInterface->TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::SELECT);
288 bool TextSelectionPopup::OnSelectAllButtonPressed(Toolkit::Button button)
290 if(mCallbackInterface)
292 mCallbackInterface->TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::SELECT_ALL);
298 bool TextSelectionPopup::OnClipboardButtonPressed(Toolkit::Button button)
300 if(mCallbackInterface)
302 mCallbackInterface->TextPopupButtonTouched(Dali::Toolkit::TextSelectionPopup::CLIPBOARD);
308 void TextSelectionPopup::SetDimensionToCustomise(const PopupCustomisations& settingToCustomise, const Size& dimension)
310 switch(settingToCustomise)
312 case POPUP_MAXIMUM_SIZE:
314 mPopupMaxSize = dimension;
317 mToolbar.SetProperty(Toolkit::TextSelectionToolbar::Property::MAX_SIZE, dimension);
321 case OPTION_MAXIMUM_SIZE:
323 mOptionMaxSize = dimension;
324 // Option max size not currently currently supported
327 case OPTION_MINIMUM_SIZE:
329 mOptionMinSize = dimension;
330 // Option min size not currently currently supported
333 case OPTION_DIVIDER_SIZE:
335 mOptionDividerSize = dimension;
338 // Resize Dividers not currently supported
345 Size TextSelectionPopup::GetDimensionToCustomise(const PopupCustomisations& settingToCustomise) const
347 switch(settingToCustomise)
349 case POPUP_MAXIMUM_SIZE:
353 return mToolbar.GetProperty(Toolkit::TextSelectionToolbar::Property::MAX_SIZE).Get<Vector2>();
357 return mPopupMaxSize;
360 case OPTION_MAXIMUM_SIZE:
362 return mOptionMaxSize;
364 case OPTION_MINIMUM_SIZE:
366 return mOptionMinSize;
368 case OPTION_DIVIDER_SIZE:
370 return mOptionDividerSize;
377 void TextSelectionPopup::SetButtonImage(Toolkit::TextSelectionPopup::Buttons button, const std::string& image)
381 case Toolkit::TextSelectionPopup::CLIPBOARD:
383 mClipboardIconImage = image;
386 case Toolkit::TextSelectionPopup::CUT:
388 mCutIconImage = image;
391 case Toolkit::TextSelectionPopup::COPY:
393 mCopyIconImage = image;
396 case Toolkit::TextSelectionPopup::PASTE:
398 mPasteIconImage = image;
401 case Toolkit::TextSelectionPopup::SELECT:
403 mSelectIconImage = image;
406 case Toolkit::TextSelectionPopup::SELECT_ALL:
408 mSelectAllIconImage = image;
413 DALI_ASSERT_DEBUG("TextSelectionPopup SetPopupImage Unknown Button");
418 const std::string& TextSelectionPopup::GetButtonImage(Toolkit::TextSelectionPopup::Buttons button) const
422 case Toolkit::TextSelectionPopup::CLIPBOARD:
424 return mClipboardIconImage;
427 case Toolkit::TextSelectionPopup::CUT:
429 return mCutIconImage;
432 case Toolkit::TextSelectionPopup::COPY:
434 return mCopyIconImage;
437 case Toolkit::TextSelectionPopup::PASTE:
439 return mPasteIconImage;
442 case Toolkit::TextSelectionPopup::SELECT:
444 return mSelectIconImage;
447 case Toolkit::TextSelectionPopup::SELECT_ALL:
449 return mSelectAllIconImage;
452 case Toolkit::TextSelectionPopup::NONE:
458 DALI_ASSERT_DEBUG("TextSelectionPopup GetPopupImage Unknown Button");
459 static std::string empty;
463 void TextSelectionPopup::SetPressedImage(const std::string& filename)
465 mPressedImage = filename;
468 std::string TextSelectionPopup::GetPressedImage() const
470 return mPressedImage;
473 void TextSelectionPopup::SetOptionDividerPadding(const Padding& padding)
475 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextSelectionPopup::SetOptionDividerPadding padding(%f,%f,%f,%f)\n", padding.left, padding.right, padding.top, padding.bottom);
476 mOptionDividerPadding = Padding(padding.left, padding.right, padding.top, padding.bottom);
479 Padding TextSelectionPopup::GetOptionDividerPadding() const
481 return mOptionDividerPadding;
484 void TextSelectionPopup::CreateOrderedListOfPopupOptions()
486 mOrderListOfButtons.clear();
487 mOrderListOfButtons.reserve(8u);
489 // Create button for each possible option using Option priority
490 mOrderListOfButtons.push_back(ButtonRequirement(Toolkit::TextSelectionPopup::CUT, mCutOptionPriority, OPTION_CUT, POPUP_CUT_STRING, 0 != (mEnabledButtons & Toolkit::TextSelectionPopup::CUT)));
491 mOrderListOfButtons.push_back(ButtonRequirement(Toolkit::TextSelectionPopup::COPY, mCopyOptionPriority, OPTION_COPY, POPUP_COPY_STRING, 0 != (mEnabledButtons & Toolkit::TextSelectionPopup::COPY)));
492 mOrderListOfButtons.push_back(ButtonRequirement(Toolkit::TextSelectionPopup::PASTE, mPasteOptionPriority, OPTION_PASTE, POPUP_PASTE_STRING, 0 != (mEnabledButtons & Toolkit::TextSelectionPopup::PASTE)));
493 mOrderListOfButtons.push_back(ButtonRequirement(Toolkit::TextSelectionPopup::SELECT, mSelectOptionPriority, OPTION_SELECT_WORD, POPUP_SELECT_STRING, 0 != (mEnabledButtons & Toolkit::TextSelectionPopup::SELECT)));
494 mOrderListOfButtons.push_back(ButtonRequirement(Toolkit::TextSelectionPopup::SELECT_ALL, mSelectAllOptionPriority, OPTION_SELECT_ALL, POPUP_SELECT_ALL_STRING, 0 != (mEnabledButtons & Toolkit::TextSelectionPopup::SELECT_ALL)));
495 mOrderListOfButtons.push_back(ButtonRequirement(Toolkit::TextSelectionPopup::CLIPBOARD, mClipboardOptionPriority, OPTION_CLIPBOARD, POPUP_CLIPBOARD_STRING, 0 != (mEnabledButtons & Toolkit::TextSelectionPopup::CLIPBOARD)));
497 // Sort the buttons according their priorities.
498 std::sort(mOrderListOfButtons.begin(), mOrderListOfButtons.end(), TextSelectionPopup::ButtonPriorityCompare());
501 void TextSelectionPopup::AddOption(const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption)
503 // 1. Create a option.
504 DALI_LOG_INFO(gLogFilter, Debug::General, "TextSelectionPopup::AddOption\n");
506 Toolkit::PushButton option = Toolkit::PushButton::New();
507 option.SetProperty(Dali::Actor::Property::NAME, button.name);
508 option.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
512 case Toolkit::TextSelectionPopup::CUT:
514 option.ClickedSignal().Connect(this, &TextSelectionPopup::OnCutButtonPressed);
517 case Toolkit::TextSelectionPopup::COPY:
519 option.ClickedSignal().Connect(this, &TextSelectionPopup::OnCopyButtonPressed);
522 case Toolkit::TextSelectionPopup::PASTE:
524 option.ClickedSignal().Connect(this, &TextSelectionPopup::OnPasteButtonPressed);
527 case Toolkit::TextSelectionPopup::SELECT:
529 option.ClickedSignal().Connect(this, &TextSelectionPopup::OnSelectButtonPressed);
532 case Toolkit::TextSelectionPopup::SELECT_ALL:
534 option.ClickedSignal().Connect(this, &TextSelectionPopup::OnSelectAllButtonPressed);
537 case Toolkit::TextSelectionPopup::CLIPBOARD:
539 option.ClickedSignal().Connect(this, &TextSelectionPopup::OnClipboardButtonPressed);
542 case Toolkit::TextSelectionPopup::NONE:
549 // 2. Set the options contents.
552 // PushButton layout properties.
553 option.SetProperty(Toolkit::PushButton::Property::LABEL_PADDING, Vector4(24.0f, 24.0f, 14.0f, 14.0f));
556 Property::Map buttonLabelProperties;
557 buttonLabelProperties.Insert(Toolkit::TextVisual::Property::TEXT, button.caption);
558 option.SetProperty(Toolkit::Button::Property::LABEL, buttonLabelProperties);
562 option.SetProperty(Toolkit::PushButton::Property::ICON_PADDING, Vector4(10.0f, 10.0f, 10.0f, 10.0f));
563 option.SetProperty(Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BOTTOM");
565 // TODO: This is temporarily disabled until the text-selection-popup image API is changed to strings.
566 //option.SetProperty( Toolkit::Button::Property::SELECTED_VISUAL, button.icon );
567 //option.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, button.icon );
570 // 3. Set the normal option image (blank / Transparent).
571 option.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, "");
573 // 4. Set the pressed option image.
574 Property::Value selectedBackgroundValue(mPressedImage);
575 if(mPressedImage.empty())
577 // The image can be blank, the color can be used in that case.
578 selectedBackgroundValue = Property::Value{{Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR},
579 {Toolkit::ColorVisual::Property::MIX_COLOR, mPressedColor}};
581 option.SetProperty(Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, selectedBackgroundValue);
582 option.SetProperty(Toolkit::Control::Property::STYLE_NAME, TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME);
584 // 5 Add option to tool bar
585 mToolbar.AddOption(option);
587 // 6. Add the divider
590 const Size size(mOptionDividerSize.width, 0.0f); // Height FILL_TO_PARENT
591 const Padding padding(mOptionDividerPadding);
593 Toolkit::Control divider = Toolkit::Control::New();
594 #ifdef DECORATOR_DEBUG
595 divider.SetProperty(Dali::Actor::Property::NAME, "Text's popup divider");
597 divider.SetProperty(Actor::Property::SIZE, size);
598 divider.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT);
599 divider.SetProperty(Actor::Property::PADDING, padding);
600 divider.SetBackgroundColor(mDividerColor);
601 mToolbar.AddDivider(divider);
605 std::size_t TextSelectionPopup::GetNumberOfEnabledOptions() const
607 std::size_t numberOfOptions = 0u;
608 for(std::vector<ButtonRequirement>::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); (it != endIt); ++it)
610 const ButtonRequirement& button(*it);
617 return numberOfOptions;
620 void TextSelectionPopup::AddPopupOptionsToToolbar(bool showIcons, bool showCaptions)
622 DALI_LOG_INFO(gLogFilter, Debug::General, "TextSelectionPopup::AddPopupOptionsToToolbar\n");
624 CreateOrderedListOfPopupOptions();
626 mButtonsChanged = false;
627 UnparentAndReset(mToolbar);
632 mToolbar = Toolkit::TextSelectionToolbar::New();
633 if(mPopupMaxSize != Vector2::ZERO) // If PopupMaxSize property set then apply to Toolbar. Toolbar currently is not retriving this from json
635 mToolbar.SetProperty(Toolkit::TextSelectionToolbar::Property::MAX_SIZE, mPopupMaxSize);
637 mToolbar.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
638 #ifdef DECORATOR_DEBUG
639 mToolbar.SetProperty(Dali::Actor::Property::NAME, "TextSelectionToolbar");
644 // Whether to mirror the list of buttons (for right to left languages)
646 #if defined(__GLIBC__)
647 char* idsLtr = GET_LOCALE_TEXT(IDS_LTR.c_str());
650 mirror = (0 == strcmp(idsLtr, RTL_DIRECTION.c_str()));
654 std::reverse(mOrderListOfButtons.begin(), mOrderListOfButtons.end());
659 // Iterate list of buttons and add active ones to Toolbar
660 std::size_t numberOfOptionsRequired = GetNumberOfEnabledOptions();
661 std::size_t numberOfOptionsAdded = 0u;
662 for(std::vector<ButtonRequirement>::const_iterator it = mOrderListOfButtons.begin(), endIt = mOrderListOfButtons.end(); (it != endIt); ++it)
664 const ButtonRequirement& button(*it);
667 numberOfOptionsAdded++;
668 AddOption(button, (numberOfOptionsAdded < numberOfOptionsRequired), showIcons, showCaptions);
674 mToolbar.ScrollTo(Vector2(mPopupMaxSize.x, 0.f));
678 void TextSelectionPopup::CreateBackgroundBorder(Property::Map& propertyMap)
680 // Removes previous image if necessary
681 DevelControl::UnregisterVisual(*this, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER);
683 if(!propertyMap.Empty())
685 Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual(propertyMap);
689 DevelControl::RegisterVisual(*this, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER, visual, DepthIndex::CONTENT);
694 TextSelectionPopup::TextSelectionPopup(TextSelectionPopupCallbackInterface* callbackInterface)
695 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
700 mOptionDividerSize(),
701 mOptionDividerPadding(),
702 mEnabledButtons(Toolkit::TextSelectionPopup::NONE),
703 mCallbackInterface(callbackInterface),
704 mPressedColor(DEFAULT_OPTION_PRESSED_COLOR),
705 mDividerColor(Color::WHITE),
706 mIconColor(Color::WHITE),
707 mSelectOptionPriority(1),
708 mSelectAllOptionPriority(2),
709 mCutOptionPriority(4),
710 mCopyOptionPriority(3),
711 mPasteOptionPriority(5),
712 mClipboardOptionPriority(6),
713 mFadeInDuration(0.0f),
714 mFadeOutDuration(0.0f),
717 mPopupShowing(false),
718 mButtonsChanged(false)
722 TextSelectionPopup::~TextSelectionPopup()
726 } // namespace Internal
728 } // namespace Toolkit