1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "core/components/text_overlay/text_overlay_component.h"
17
18 #include "base/i18n/localization.h"
19 #include "base/json/json_util.h"
20 #include "core/components/box/box_component.h"
21 #include "core/components/button/button_component.h"
22 #include "core/components/clip/clip_component.h"
23 #include "core/components/common/properties/shadow_config.h"
24 #include "core/components/flex/flex_component.h"
25 #include "core/components/focus_collaboration/focus_collaboration_component.h"
26 #include "core/components/padding/padding_component.h"
27 #include "core/components/text/text_component.h"
28 #include "core/components/text_overlay/render_text_overlay.h"
29 #include "core/components/text_overlay/text_overlay_element.h"
30 #include "core/components/theme/theme_manager.h"
31 #include "core/event/ace_event_helper.h"
32 #include "core/event/back_end_event_manager.h"
33
34 namespace OHOS::Ace {
35 namespace {
36
37 constexpr char BUTTON_COPY_ALL[] = "textoverlay.select_all";
38 constexpr char BUTTON_CUT[] = "textoverlay.cut";
39 constexpr char BUTTON_COPY[] = "textoverlay.copy";
40 constexpr char BUTTON_PASTE[] = "textoverlay.paste";
41 constexpr char BUTTON_TRANSLATE[] = "textoverlay.translate";
42 constexpr char BUTTON_SHARE[] = "textoverlay.share";
43 constexpr char BUTTON_SEARCH[] = "textoverlay.search";
44 constexpr char OVERLAY_TRANSLATE[] = "translate";
45 constexpr char OVERLAY_SHARE[] = "share";
46 constexpr char OVERLAY_SEARCH[] = "search";
47
48 constexpr Dimension OVERLAY_MARGIN_BOTTOM = 8.0_vp;
49 constexpr Dimension TOOL_BAR_HEIGHT = 40.0_vp;
50
51 } // namespace
52
TextOverlayComponent(const RefPtr<ThemeManager> & themeManager,const RefPtr<AccessibilityManager> & accessibilityManager)53 TextOverlayComponent::TextOverlayComponent(
54 const RefPtr<ThemeManager>& themeManager, const RefPtr<AccessibilityManager>& accessibilityManager)
55 {
56 themeManager_ = themeManager;
57 accessibilityManager_ = accessibilityManager;
58 InitThemeStyle(themeManager);
59 }
60
CreateElement()61 RefPtr<Element> TextOverlayComponent::CreateElement()
62 {
63 return AceType::MakeRefPtr<TextOverlayElement>();
64 }
65
CreateRenderNode()66 RefPtr<RenderNode> TextOverlayComponent::CreateRenderNode()
67 {
68 return RenderTextOverlay::Create();
69 }
70
InitThemeStyle(const RefPtr<ThemeManager> & themeManager)71 void TextOverlayComponent::InitThemeStyle(const RefPtr<ThemeManager>& themeManager)
72 {
73 theme_ = themeManager->GetTheme<TextOverlayTheme>();
74 if (!theme_) {
75 return;
76 }
77 handleColor_ = theme_->GetHandleColor();
78 handleColorInner_ = theme_->GetHandleColorInner();
79 handleDiameter_ = theme_->GetHandleDiameter();
80 handleDiameterInner_ = theme_->GetHandleDiameterInner();
81 menuSpacingWithText_ = theme_->GetMenuSpacingWithText();
82 }
83
BuildChild(bool isSingleHandle,bool hasToolBar,bool hasMenu,bool hasIcon,bool hasAnimation)84 RefPtr<Component> TextOverlayComponent::BuildChild(
85 bool isSingleHandle, bool hasToolBar, bool hasMenu, bool hasIcon, bool hasAnimation)
86 {
87 // if type of input is password, don't show tool menu.
88 if (isPassword_) {
89 return nullptr;
90 }
91 if (!hasToolBar && !hasMenu && !hasIcon) {
92 return nullptr;
93 }
94 std::list<RefPtr<Component>> columnChildren;
95 auto column = AceType::MakeRefPtr<ColumnComponent>(FlexAlign::SPACE_AROUND, FlexAlign::FLEX_END, columnChildren);
96 if (GetTextDirection() == TextDirection::RTL) {
97 column->SetCrossAxisAlign(FlexAlign::FLEX_START);
98 }
99 column->SetMainAxisSize(MainAxisSize::MIN);
100
101 // Add toolbar.
102 column->AppendChild(BuildToolBar(isSingleHandle, hasToolBar, hasMenu, hasIcon, hasAnimation));
103 if (hasMenu) {
104 // Add menu.
105 column->AppendChild(BuildMenu());
106 } else {
107 menu_.Reset();
108 }
109
110 // Add focus collaboration to show focus animation.
111 auto focusCollaboration = AceType::MakeRefPtr<FocusCollaborationComponent>();
112 focusCollaboration->InsertChild(0, column);
113 return focusCollaboration;
114 }
115
BuildToolBar(bool isSingleHandle,bool hasToolBar,bool hasMenu,bool hasIcon,bool hasAnimation)116 RefPtr<Component> TextOverlayComponent::BuildToolBar(
117 bool isSingleHandle, bool hasToolBar, bool hasMenu, bool hasIcon, bool hasAnimation)
118 {
119 if (!hasToolBar && !hasMenu && !hasIcon) {
120 return nullptr;
121 }
122
123 std::list<RefPtr<Component>> operations;
124 auto row = AceType::MakeRefPtr<RowComponent>(FlexAlign::SPACE_AROUND, FlexAlign::FLEX_START, operations);
125 row->SetMainAxisSize(MainAxisSize::MIN);
126 row->SetStretchToParent(true);
127 if (hasToolBar) {
128 if (!isSingleHandle) {
129 if (onCut_) {
130 row->AppendChild(
131 BuildButton(Localization::GetInstance()->GetEntryLetters(BUTTON_CUT), cutButtonMarker_));
132 }
133 if (onCopy_) {
134 row->AppendChild(
135 BuildButton(Localization::GetInstance()->GetEntryLetters(BUTTON_COPY), copyButtonMarker_));
136 }
137 }
138 if (onPaste_) {
139 row->AppendChild(
140 BuildButton(Localization::GetInstance()->GetEntryLetters(BUTTON_PASTE), pasteButtonMarker_));
141 }
142 if (onCopyAll_) {
143 row->AppendChild(
144 BuildButton(Localization::GetInstance()->GetEntryLetters(BUTTON_COPY_ALL), copyAllButtonMarker_));
145 }
146 if (!translateButtonMarker_.IsEmpty()) {
147 const auto& translateButtonMarker = BackEndEventManager<void()>::GetInstance().GetAvailableMarker();
148 BackEndEventManager<void()>::GetInstance().BindBackendEvent(
149 translateButtonMarker, [weak = WeakClaim(this)]() {
150 auto overlay = weak.Upgrade();
151 if (overlay) {
152 overlay->OnToolBarButtonClick(overlay->translateButtonMarker_, OVERLAY_TRANSLATE);
153 }
154 });
155 row->AppendChild(
156 BuildButton(Localization::GetInstance()->GetEntryLetters(BUTTON_TRANSLATE), translateButtonMarker));
157 }
158 }
159 if (hasIcon && (!options_.empty() || !shareButtonMarker_.IsEmpty() || !searchButtonMarker_.IsEmpty())) {
160 hasMoreButton_ = true;
161 row->AppendChild(BuildMoreIconButton(hasMenu));
162 } else {
163 hasMoreButton_ = false;
164 }
165 auto firstButton = DynamicCast<ButtonComponent>(row->GetChildren().front());
166 if (firstButton) {
167 firstButton->SetAutoFocusState(true);
168 }
169 auto box = AceType::MakeRefPtr<BoxComponent>();
170 if (theme_) {
171 auto backDecoration = AceType::MakeRefPtr<Decoration>();
172 backDecoration->SetBackgroundColor(theme_->GetMenuBackgroundColor());
173 backDecoration->SetBorder(theme_->GetMenuBorder());
174 backDecoration->SetBorderRadius(Radius(theme_->GetMenuButtonHeight()));
175 box->SetBackDecoration(backDecoration);
176 box->SetPadding(theme_->GetMenuPadding());
177 }
178
179 if (hasAnimation) {
180 if (innerComposeId_.empty()) {
181 innerComposeId_ = TweenComponent::AllocTweenComponentId();
182 }
183 auto innerTween = AceType::MakeRefPtr<TweenComponent>(innerComposeId_, innerComposeId_, row);
184 innerTween->SetIsFirstFrameShow(true);
185 box->SetChild(innerTween);
186 } else {
187 box->SetChild(row);
188 }
189 box->SetTextDirection(GetTextDirection());
190 return BuildAnimation(box, hasAnimation);
191 }
192
BuildButton(const std::string & data,const EventMarker & onClick)193 RefPtr<ButtonComponent> TextOverlayComponent::BuildButton(const std::string& data, const EventMarker& onClick)
194 {
195 if (!theme_) {
196 return nullptr;
197 }
198 auto text = AceType::MakeRefPtr<TextComponent>(data);
199 text->SetTextStyle(theme_->GetMenuButtonTextStyle());
200 text->SetFocusColor(theme_->GetMenuButtonTextStyle().GetTextColor());
201
202 auto padding = AceType::MakeRefPtr<PaddingComponent>();
203 padding->SetPadding(theme_->GetMenuButtonPadding());
204 padding->SetChild(text);
205
206 std::list<RefPtr<Component>> children;
207 children.emplace_back(padding);
208 auto button = AceType::MakeRefPtr<ButtonComponent>(children);
209 button->SetIsInnerBorder(true);
210 button->SetClickedEventId(onClick);
211 button->SetHeight(theme_->GetMenuButtonHeight());
212 button->SetRectRadius(theme_->GetMenuButtonHeight() / 2.0);
213 button->SetBackgroundColor(theme_->GetMenuBackgroundColor());
214 button->SetHoverColor(theme_->GetButtonHoverColor());
215 button->SetClickedColor(theme_->GetButtonClickedColor());
216 button->SetFocusColor(theme_->GetMenuBackgroundColor());
217 return button;
218 }
219
BuildMoreIconButton(bool hasMenu)220 RefPtr<ButtonComponent> TextOverlayComponent::BuildMoreIconButton(bool hasMenu)
221 {
222 if (!theme_) {
223 return nullptr;
224 }
225
226 std::list<RefPtr<Component>> children;
227 auto button = AceType::MakeRefPtr<ButtonComponent>(children);
228 button->SetIsInnerBorder(true);
229 button->SetClickedEventId(moreButtonMarker_);
230 button->SetHeight(theme_->GetMenuButtonHeight());
231 button->SetWidth(theme_->GetMenuButtonHeight());
232 button->SetRectRadius(theme_->GetMenuButtonHeight() / 2.0);
233 button->SetBackgroundColor(Color::TRANSPARENT);
234 button->SetHoverColor(theme_->GetButtonHoverColor());
235 button->SetClickedColor(theme_->GetButtonClickedColor());
236 button->SetFocusColor(theme_->GetMenuBackgroundColor());
237 return button;
238 }
239
BuildAnimation(const RefPtr<Component> & child,bool hasAnimation)240 RefPtr<Component> TextOverlayComponent::BuildAnimation(const RefPtr<Component>& child, bool hasAnimation)
241 {
242 auto box = AceType::MakeRefPtr<BoxComponent>();
243 if (hasAnimation) {
244 auto clip = AceType::MakeRefPtr<ClipComponent>(child);
245 clip->SetTopLeftRadius(Radius(theme_->GetMenuButtonHeight()));
246 clip->SetTopRightRadius(Radius(theme_->GetMenuButtonHeight()));
247 clip->SetBottomLeftRadius(Radius(theme_->GetMenuButtonHeight()));
248 clip->SetBottomRightRadius(Radius(theme_->GetMenuButtonHeight()));
249 clip->SetHeight(TOOL_BAR_HEIGHT);
250 clip->SetClipWithShadow(true);
251
252 if (outerComposeId_.empty()) {
253 outerComposeId_ = TweenComponent::AllocTweenComponentId();
254 }
255 auto outerTween = AceType::MakeRefPtr<TweenComponent>(outerComposeId_, outerComposeId_, clip);
256 outerTween->SetIsFirstFrameShow(true);
257 box->SetChild(outerTween);
258 } else {
259 box->SetChild(child);
260 }
261
262 auto backDecoration = AceType::MakeRefPtr<Decoration>();
263 backDecoration->AddShadow(ShadowConfig::DefaultShadowM);
264 backDecoration->SetBackgroundColor(theme_->GetMenuBackgroundColor());
265 backDecoration->SetBorder(theme_->GetMenuBorder());
266 backDecoration->SetBorderRadius(Radius(theme_->GetMenuButtonHeight()));
267 box->SetBackDecoration(backDecoration);
268 return box;
269 }
270
BuildMenu()271 RefPtr<Component> TextOverlayComponent::BuildMenu()
272 {
273 if (!menu_) {
274 menu_ = AceType::MakeRefPtr<SelectPopupComponent>();
275 menu_->ClearAllOptions();
276
277 if (!shareButtonMarker_.IsEmpty()) {
278 auto optionComponent = BuildMenuOption("", InternalResource::ResourceId::SHARE_SVG,
279 Localization::GetInstance()->GetEntryLetters(BUTTON_SHARE), true);
280 const auto& shareButtonMarker = BackEndEventManager<void()>::GetInstance().GetAvailableMarker();
281 optionComponent->SetClickEvent(shareButtonMarker);
282 BackEndEventManager<void()>::GetInstance().BindBackendEvent(shareButtonMarker, [weak = WeakClaim(this)]() {
283 auto overlay = weak.Upgrade();
284 if (overlay) {
285 overlay->OnToolBarButtonClick(overlay->shareButtonMarker_, OVERLAY_SHARE);
286 }
287 });
288 menu_->AppendSelectOption(optionComponent);
289 }
290 if (!searchButtonMarker_.IsEmpty()) {
291 auto optionComponent = BuildMenuOption("", InternalResource::ResourceId::SEARCH_SVG,
292 Localization::GetInstance()->GetEntryLetters(BUTTON_SEARCH), true);
293 const auto& searchButtonMarker = BackEndEventManager<void()>::GetInstance().GetAvailableMarker();
294 optionComponent->SetClickEvent(searchButtonMarker);
295 BackEndEventManager<void()>::GetInstance().BindBackendEvent(searchButtonMarker, [weak = WeakClaim(this)]() {
296 auto overlay = weak.Upgrade();
297 if (overlay) {
298 overlay->OnToolBarButtonClick(overlay->searchButtonMarker_, OVERLAY_SEARCH);
299 }
300 });
301 menu_->AppendSelectOption(optionComponent);
302 }
303
304 int32_t index = 0;
305 for (const auto& option : options_) {
306 auto optionComponent =
307 BuildMenuOption(option.image, InternalResource::ResourceId::NO_ID, option.text, false);
308 EventMarker clickEvent = BackEndEventManager<void()>::GetInstance().GetAvailableMarker();
309 optionComponent->SetClickEvent(clickEvent);
310 BackEndEventManager<void()>::GetInstance().BindBackendEvent(clickEvent, [weak = WeakClaim(this), index]() {
311 auto overlay = weak.Upgrade();
312 overlay->OnOptionClick(index);
313 });
314 menu_->AppendSelectOption(optionComponent);
315 ++index;
316 }
317 menu_->SetIsFullScreen(false);
318 menu_->InitTheme(themeManager_);
319 menu_->Initialize(accessibilityManager_.Upgrade());
320 }
321
322 auto box = AceType::MakeRefPtr<BoxComponent>();
323 box->SetChild(menu_);
324 box->SetMargin(Edge(0.0_vp, OVERLAY_MARGIN_BOTTOM, 0.0_vp, 0.0_vp));
325 return box;
326 }
327
BuildMenuOption(const std::string & imageSrc,InternalResource::ResourceId resourceId,const std::string & text,bool useResource)328 RefPtr<OptionComponent> TextOverlayComponent::BuildMenuOption(
329 const std::string& imageSrc, InternalResource::ResourceId resourceId, const std::string& text, bool useResource)
330 {
331 auto optionComponent = AceType::MakeRefPtr<OptionComponent>();
332 RefPtr<ImageComponent> image;
333 if (useResource) {
334 image = AceType::MakeRefPtr<ImageComponent>(resourceId);
335 if (theme_) {
336 // fill color only effect svg image color
337 image->SetImageFill(theme_->GetMenuIconColor());
338 }
339 } else {
340 image = AceType::MakeRefPtr<ImageComponent>(imageSrc);
341 if (image) {
342 // fill color only effect svg image color
343 image->SetImageFill(imageFill_);
344 }
345 }
346 optionComponent->SetIcon(image);
347 auto textComponent = AceType::MakeRefPtr<TextComponent>(text);
348 optionComponent->SetText(textComponent);
349 optionComponent->SetValue(text);
350 optionComponent->InitTheme(themeManager_);
351 optionComponent->Initialize(accessibilityManager_.Upgrade());
352 return optionComponent;
353 }
354
OnOptionClick(int32_t index)355 void TextOverlayComponent::OnOptionClick(int32_t index)
356 {
357 const auto& event = AceAsyncEvent<void(const std::string&)>::Create(optionsClickMarker_, context_);
358 if (event) {
359 auto jsonResult = JsonUtil::Create(true);
360 jsonResult->Put("index", index);
361 jsonResult->Put("value", GetSelectedText().c_str());
362 event(std::string(R"("optionselect",)").append(jsonResult->ToString()));
363 }
364 if (popOverlay_) {
365 popOverlay_();
366 }
367 }
368
OnToolBarButtonClick(const EventMarker & marker,const std::string & eventName)369 void TextOverlayComponent::OnToolBarButtonClick(const EventMarker& marker, const std::string& eventName)
370 {
371 const auto& event = AceAsyncEvent<void(const std::string&)>::Create(marker, context_);
372 if (event) {
373 auto jsonResult = JsonUtil::Create(true);
374 jsonResult->Put("value", GetSelectedText().c_str());
375 if (eventName == OVERLAY_TRANSLATE) {
376 event(std::string(R"("translate",)").append(jsonResult->ToString()));
377 } else if (eventName == OVERLAY_SHARE) {
378 event(std::string(R"("share",)").append(jsonResult->ToString()));
379 } else if (eventName == OVERLAY_SEARCH) {
380 event(std::string(R"("search",)").append(jsonResult->ToString()));
381 }
382 }
383 if (popOverlay_) {
384 popOverlay_();
385 }
386 }
387
GetSelectedText() const388 std::string TextOverlayComponent::GetSelectedText() const
389 {
390 const auto& textField = weakTextField_.Upgrade();
391 if (textField) {
392 return textField->GetEditingValue().GetSelectedText();
393 }
394 return "";
395 }
396
HasMoreButton() const397 bool TextOverlayComponent::HasMoreButton() const
398 {
399 return hasMoreButton_;
400 }
401
SetIsPassword(bool isPassword)402 void TextOverlayComponent::SetIsPassword(bool isPassword)
403 {
404 isPassword_ = isPassword;
405 }
406
GetIsPassword() const407 bool TextOverlayComponent::GetIsPassword() const
408 {
409 return isPassword_;
410 }
411
SetIsSingleHandle(bool isSingleHandle)412 void TextOverlayComponent::SetIsSingleHandle(bool isSingleHandle)
413 {
414 isSingleHandle_ = isSingleHandle;
415 }
416
GetIsSingleHandle() const417 bool TextOverlayComponent::GetIsSingleHandle() const
418 {
419 return isSingleHandle_;
420 }
421
SetLineHeight(double lineHeight)422 void TextOverlayComponent::SetLineHeight(double lineHeight)
423 {
424 lineHeight_ = lineHeight;
425 }
426
GetLineHeight() const427 double TextOverlayComponent::GetLineHeight() const
428 {
429 return lineHeight_;
430 }
431
SetClipRect(const Rect & clipRect)432 void TextOverlayComponent::SetClipRect(const Rect& clipRect)
433 {
434 clipRect_ = clipRect;
435 }
436
GetClipRect() const437 const Rect& TextOverlayComponent::GetClipRect() const
438 {
439 return clipRect_;
440 }
441
SetHandleColor(const Color & handleColor)442 void TextOverlayComponent::SetHandleColor(const Color& handleColor)
443 {
444 handleColor_ = handleColor;
445 }
446
GetHandleColor() const447 const Color& TextOverlayComponent::GetHandleColor() const
448 {
449 return handleColor_;
450 }
451
SetHandleColorInner(const Color & handleColorInner)452 void TextOverlayComponent::SetHandleColorInner(const Color& handleColorInner)
453 {
454 handleColorInner_ = handleColorInner;
455 }
456
GetHandleColorInner() const457 const Color& TextOverlayComponent::GetHandleColorInner() const
458 {
459 return handleColorInner_;
460 }
461
SetHandleDiameter(const Dimension & handleDiameter)462 void TextOverlayComponent::SetHandleDiameter(const Dimension& handleDiameter)
463 {
464 handleDiameter_ = handleDiameter;
465 }
466
GetHandleDiameter() const467 const Dimension& TextOverlayComponent::GetHandleDiameter() const
468 {
469 return handleDiameter_;
470 }
471
SetHandleDiameterInner(const Dimension & handleDiameterInner)472 void TextOverlayComponent::SetHandleDiameterInner(const Dimension& handleDiameterInner)
473 {
474 handleDiameterInner_ = handleDiameterInner;
475 }
476
GetHandleDiameterInner() const477 const Dimension& TextOverlayComponent::GetHandleDiameterInner() const
478 {
479 return handleDiameterInner_;
480 }
481
SetMenuSpacingWithText(const Dimension & menuSpacingWithText)482 void TextOverlayComponent::SetMenuSpacingWithText(const Dimension& menuSpacingWithText)
483 {
484 menuSpacingWithText_ = menuSpacingWithText;
485 }
486
GetMenuSpacingWithText() const487 const Dimension& TextOverlayComponent::GetMenuSpacingWithText() const
488 {
489 return menuSpacingWithText_;
490 }
491
SetOnFocusChange(const std::function<void (bool,bool)> & onFocusChange)492 void TextOverlayComponent::SetOnFocusChange(const std::function<void(bool, bool)>& onFocusChange)
493 {
494 onFocusChange_ = onFocusChange;
495 }
496
GetOnFocusChange() const497 const std::function<void(bool, bool)>& TextOverlayComponent::GetOnFocusChange() const
498 {
499 return onFocusChange_;
500 }
501
SetOnCut(const CommonCallback & onCut)502 void TextOverlayComponent::SetOnCut(const CommonCallback& onCut)
503 {
504 onCut_ = onCut;
505 }
506
GetOnCut() const507 const CommonCallback& TextOverlayComponent::GetOnCut() const
508 {
509 return onCut_;
510 }
511
SetOnCopy(const CommonCallback & onCopy)512 void TextOverlayComponent::SetOnCopy(const CommonCallback& onCopy)
513 {
514 onCopy_ = onCopy;
515 }
516
GetOnCopy() const517 const CommonCallback& TextOverlayComponent::GetOnCopy() const
518 {
519 return onCopy_;
520 }
521
SetOnPaste(const CommonCallback & onPaste)522 void TextOverlayComponent::SetOnPaste(const CommonCallback& onPaste)
523 {
524 onPaste_ = onPaste;
525 }
526
GetOnPaste() const527 const CommonCallback& TextOverlayComponent::GetOnPaste() const
528 {
529 return onPaste_;
530 }
531
SetOnCopyAll(const CopyAllCallback & onCopyAll)532 void TextOverlayComponent::SetOnCopyAll(const CopyAllCallback& onCopyAll)
533 {
534 onCopyAll_ = onCopyAll;
535 }
536
GetOnCopyAll() const537 const CopyAllCallback& TextOverlayComponent::GetOnCopyAll() const
538 {
539 return onCopyAll_;
540 }
541
SetCutButtonMarker(const EventMarker & cutButtonMarker)542 void TextOverlayComponent::SetCutButtonMarker(const EventMarker& cutButtonMarker)
543 {
544 cutButtonMarker_ = cutButtonMarker;
545 }
546
GetCutButtonMarker() const547 const EventMarker& TextOverlayComponent::GetCutButtonMarker() const
548 {
549 return cutButtonMarker_;
550 }
551
SetCopyButtonMarker(const EventMarker & copyButtonMarker)552 void TextOverlayComponent::SetCopyButtonMarker(const EventMarker& copyButtonMarker)
553 {
554 copyButtonMarker_ = copyButtonMarker;
555 }
556
GetCopyButtonMarker() const557 const EventMarker& TextOverlayComponent::GetCopyButtonMarker() const
558 {
559 return copyButtonMarker_;
560 }
561
SetPasteButtonMarker(const EventMarker & pasteButtonMarker)562 void TextOverlayComponent::SetPasteButtonMarker(const EventMarker& pasteButtonMarker)
563 {
564 pasteButtonMarker_ = pasteButtonMarker;
565 }
566
GetPasteButtonMarker() const567 const EventMarker& TextOverlayComponent::GetPasteButtonMarker() const
568 {
569 return pasteButtonMarker_;
570 }
571
SetCopyAllButtonMarker(const EventMarker & copyAllButtonMarker)572 void TextOverlayComponent::SetCopyAllButtonMarker(const EventMarker& copyAllButtonMarker)
573 {
574 copyAllButtonMarker_ = copyAllButtonMarker;
575 }
576
GetCopyAllButtonMarker() const577 const EventMarker& TextOverlayComponent::GetCopyAllButtonMarker() const
578 {
579 return copyAllButtonMarker_;
580 }
581
SetMoreButtonMarker(const EventMarker & moreButtonMarker)582 void TextOverlayComponent::SetMoreButtonMarker(const EventMarker& moreButtonMarker)
583 {
584 moreButtonMarker_ = moreButtonMarker;
585 }
586
GetMoreButtonMarker() const587 const EventMarker& TextOverlayComponent::GetMoreButtonMarker() const
588 {
589 return moreButtonMarker_;
590 }
591
SetStartHandleOffset(const Offset & offset)592 void TextOverlayComponent::SetStartHandleOffset(const Offset& offset)
593 {
594 startHandleOffset_ = offset;
595 }
596
GetStartHandleOffset() const597 const Offset& TextOverlayComponent::GetStartHandleOffset() const
598 {
599 return startHandleOffset_;
600 }
601
SetEndHandleOffset(const Offset & offset)602 void TextOverlayComponent::SetEndHandleOffset(const Offset& offset)
603 {
604 endHandleOffset_ = offset;
605 }
606
GetEndHandleOffset() const607 const Offset& TextOverlayComponent::GetEndHandleOffset() const
608 {
609 return endHandleOffset_;
610 }
611
SetOnStartHandleMove(const StartHandleMoveCallback & onStartHandleMove)612 void TextOverlayComponent::SetOnStartHandleMove(const StartHandleMoveCallback& onStartHandleMove)
613 {
614 onStartHandleMove_ = onStartHandleMove;
615 }
616
GetOnStartHandleMove() const617 const StartHandleMoveCallback& TextOverlayComponent::GetOnStartHandleMove() const
618 {
619 return onStartHandleMove_;
620 }
621
SetOnEndHandleMove(const EndHandleMoveCallback & onEndHandleMove)622 void TextOverlayComponent::SetOnEndHandleMove(const EndHandleMoveCallback& onEndHandleMove)
623 {
624 onEndHandleMove_ = onEndHandleMove;
625 }
626
GetOnEndHandleMove() const627 const EndHandleMoveCallback& TextOverlayComponent::GetOnEndHandleMove() const
628 {
629 return onEndHandleMove_;
630 }
631
SetWeakTextField(const WeakPtr<RenderTextField> & weakTextField)632 void TextOverlayComponent::SetWeakTextField(const WeakPtr<RenderTextField>& weakTextField)
633 {
634 weakTextField_ = weakTextField;
635 }
636
GetWeakTextField() const637 const WeakPtr<RenderTextField>& TextOverlayComponent::GetWeakTextField() const
638 {
639 return weakTextField_;
640 }
641
SetRealTextDirection(TextDirection realTextDirection)642 void TextOverlayComponent::SetRealTextDirection(TextDirection realTextDirection)
643 {
644 realTextDirection_ = realTextDirection;
645 }
646
GetRealTextDirection() const647 TextDirection TextOverlayComponent::GetRealTextDirection() const
648 {
649 return realTextDirection_;
650 }
651
SetOptions(const std::vector<InputOption> & options)652 void TextOverlayComponent::SetOptions(const std::vector<InputOption>& options)
653 {
654 options_ = options;
655 }
656
GetOptions() const657 const std::vector<InputOption>& TextOverlayComponent::GetOptions() const
658 {
659 return options_;
660 }
661
SetImageFill(const std::optional<Color> & imageFill)662 void TextOverlayComponent::SetImageFill(const std::optional<Color>& imageFill)
663 {
664 imageFill_ = imageFill;
665 }
666
SetOptionsClickMarker(const EventMarker & onOptionsClick)667 void TextOverlayComponent::SetOptionsClickMarker(const EventMarker& onOptionsClick)
668 {
669 optionsClickMarker_ = onOptionsClick;
670 }
671
SetTranslateButtonMarker(const EventMarker & onTranslate)672 void TextOverlayComponent::SetTranslateButtonMarker(const EventMarker& onTranslate)
673 {
674 translateButtonMarker_ = onTranslate;
675 }
676
SetShareButtonMarker(const EventMarker & onShare)677 void TextOverlayComponent::SetShareButtonMarker(const EventMarker& onShare)
678 {
679 shareButtonMarker_ = onShare;
680 }
681
SetSearchButtonMarker(const EventMarker & onSearch)682 void TextOverlayComponent::SetSearchButtonMarker(const EventMarker& onSearch)
683 {
684 searchButtonMarker_ = onSearch;
685 }
686
SetPopOverlay(const CommonCallback & popOverlay)687 void TextOverlayComponent::SetPopOverlay(const CommonCallback& popOverlay)
688 {
689 popOverlay_ = popOverlay;
690 }
691
SetContext(const WeakPtr<PipelineContext> & context)692 void TextOverlayComponent::SetContext(const WeakPtr<PipelineContext>& context)
693 {
694 context_ = context;
695 }
696
GetMenu() const697 const RefPtr<SelectPopupComponent>& TextOverlayComponent::GetMenu() const
698 {
699 return menu_;
700 }
701
702 } // namespace OHOS::Ace
703