• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PICKER_TEXT_PICKER_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PICKER_TEXT_PICKER_PATTERN_H
18 
19 #include <optional>
20 
21 #include "core/components/theme/app_theme.h"
22 #include "core/components/picker/picker_theme.h"
23 #include "core/components/dialog/dialog_theme.h"
24 #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h"
25 #include "core/components_ng/pattern/picker/picker_type_define.h"
26 #include "core/components_ng/pattern/text_picker/textpicker_row_accessibility_property.h"
27 #include "core/components_ng/pattern/text_picker/textpicker_event_hub.h"
28 #include "core/components_ng/pattern/text_picker/textpicker_layout_property.h"
29 #include "core/components_ng/pattern/text_picker/textpicker_paint_method.h"
30 #include "core/components_ng/pattern/text_picker/toss_animation_controller.h"
31 #include "core/common/resource/resource_object.h"
32 
33 #ifdef SUPPORT_DIGITAL_CROWN
34 #include "core/event/crown_event.h"
35 #endif
36 namespace OHOS::Ace::NG {
37 class InspectorFilter;
38 using EventCallback = std::function<void(bool)>;
39 using ColumnChangeCallback = std::function<void(const RefPtr<FrameNode>&, bool, uint32_t, bool)>;
40 
41 namespace {
42 const Dimension TEXT_FOCUS_PAINT_WIDTH = 2.0_vp;
43 }
44 class TextPickerPattern : public LinearLayoutPattern {
45     DECLARE_ACE_TYPE(TextPickerPattern, LinearLayoutPattern);
46 
47 public:
TextPickerPattern()48     TextPickerPattern() : LinearLayoutPattern(false) {};
49 
50     ~TextPickerPattern() override = default;
51 
52     void BeforeCreateLayoutWrapper() override;
53 
IsAtomicNode()54     bool IsAtomicNode() const override
55     {
56         return true;
57     }
58 
OnColorModeChange(uint32_t colorMode)59     void OnColorModeChange(uint32_t colorMode) override
60     {
61         LinearLayoutPattern::OnColorModeChange(colorMode);
62         auto host = GetHost();
63         CHECK_NULL_VOID(host);
64         host->MarkModifyDone();
65     }
66 
CreateEventHub()67     RefPtr<EventHub> CreateEventHub() override
68     {
69         return MakeRefPtr<TextPickerEventHub>();
70     }
71 
CreateLayoutProperty()72     RefPtr<LayoutProperty> CreateLayoutProperty() override
73     {
74         return MakeRefPtr<TextPickerLayoutProperty>();
75     }
76 
CreateAccessibilityProperty()77     RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override
78     {
79         return MakeRefPtr<TextPickerRowAccessibilityProperty>();
80     }
81 
CreateNodePaintMethod()82     RefPtr<NodePaintMethod> CreateNodePaintMethod() override
83     {
84         auto textPickerPaintMethod = MakeRefPtr<TextPickerPaintMethod>(WeakClaim(this));
85         textPickerPaintMethod->SetDefaultPickerItemHeight(CalculateHeight());
86         textPickerPaintMethod->SetEnabled(enabled_);
87         return textPickerPaintMethod;
88     }
89 
CreateLayoutAlgorithm()90     RefPtr<LayoutAlgorithm> CreateLayoutAlgorithm() override
91     {
92         return MakeRefPtr<LinearLayoutAlgorithm>();
93     }
94 
95     void SetEventCallback(EventCallback&& value);
96 
97     void FireChangeEvent(bool refresh);
98 
99     void SetScrollStopEventCallback(EventCallback&& value);
100 
101     void FireScrollStopEvent(bool refresh);
102 
103     void SetEnterSelectedAreaEventCallback(EventCallback&& value);
104 
105     void FireEnterSelectedAreaEvent(bool refresh);
106 
107     void OnColumnsBuilding();
108 
109     void FlushOptions();
110 
111     void SetDefaultPickerItemHeight();
112 
113     std::map<uint32_t, RefPtr<FrameNode>> GetColumnNodes() const;
114 
115     RefPtr<FrameNode> GetColumnNode();
116 
117     uint32_t GetShowOptionCount() const;
118 
SetSelected(uint32_t value)119     void SetSelected(uint32_t value)
120     {
121         selectedIndex_ = value;
122     }
123 
GetSelected()124     uint32_t GetSelected() const
125     {
126         return selectedIndex_;
127     }
128 
SetRange(const std::vector<NG::RangeContent> & value)129     void SetRange(const std::vector<NG::RangeContent>& value)
130     {
131         if (value.empty()) {
132             return;
133         }
134         range_ = value;
135     }
136 
GetRange()137     std::vector<NG::RangeContent> GetRange() const
138     {
139         return range_;
140     }
141 
SetColumnWidths(const std::vector<Dimension> & widths)142     void SetColumnWidths(const std::vector<Dimension>& widths)
143     {
144         columnWidths_.clear();
145         for (size_t i = 0; i < widths.size(); i++) {
146             columnWidths_.emplace_back(widths[i]);
147         }
148     }
149 
GetColumnWidths()150     std::vector<Dimension> GetColumnWidths() const
151     {
152         return columnWidths_;
153     }
154 
GetMultiOptions()155     std::vector<NG::TextCascadePickerOptions> GetMultiOptions() const
156     {
157         return cascadeOriginptions_;
158     }
159 
SetColumnsKind(uint32_t columnKind)160     void SetColumnsKind(uint32_t columnKind)
161     {
162         columnsKind_ = columnKind;
163     }
164 
ClearOption()165     void ClearOption()
166     {
167         options_.clear();
168     }
169 
AppendOption(const NG::RangeContent & value)170     void AppendOption(const NG::RangeContent& value)
171     {
172         options_.emplace_back(value);
173     }
174 
GetOptionCount()175     uint32_t GetOptionCount() const
176     {
177         return options_.size();
178     }
179 
180     std::string GetSelectedObject(bool isColumnChange, int32_t status = 0, bool isEnterSelectedAreaEvent = false) const;
181 
GetOption(uint32_t index)182     std::string GetOption(uint32_t index) const
183     {
184         if (index >= GetOptionCount()) {
185             return "";
186         }
187         return options_[index].text_;
188     }
189 
SetBackgroundColor(const Color & color)190     void SetBackgroundColor(const Color& color)
191     {
192         if (backgroundColor_ == color) {
193             return;
194         }
195         auto host = GetHost();
196         CHECK_NULL_VOID(host);
197         backgroundColor_ = color;
198         host->MarkDirtyNode(PROPERTY_UPDATE_RENDER);
199     }
200 
GetBackgroundColor()201     Color GetBackgroundColor()
202     {
203         return backgroundColor_;
204     }
205 
GetFocusPattern()206     FocusPattern GetFocusPattern() const override
207     {
208         auto pipeline = PipelineBase::GetCurrentContext();
209         CHECK_NULL_RETURN(pipeline, FocusPattern());
210         auto pickerTheme = pipeline->GetTheme<PickerTheme>();
211         CHECK_NULL_RETURN(pickerTheme, FocusPattern());
212         auto focusColor = pickerTheme->GetFocusColor();
213 
214         FocusPaintParam focusPaintParams;
215         focusPaintParams.SetPaintColor(focusColor);
216 
217         return { FocusType::NODE, true, FocusStyleType::CUSTOM_REGION, focusPaintParams };
218     }
219 
220     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override;
221 
SetCascadeOptions(const std::vector<NG::TextCascadePickerOptions> & options,const std::vector<NG::TextCascadePickerOptions> & cascadeOptions)222     void SetCascadeOptions(const std::vector<NG::TextCascadePickerOptions>& options,
223         const std::vector<NG::TextCascadePickerOptions>& cascadeOptions)
224     {
225         cascadeOptions_.clear();
226         cascadeOriginptions_.clear();
227         for (auto& option : cascadeOptions) {
228             cascadeOptions_.emplace_back(std::move(option));
229         }
230         for (auto& option : options) {
231             cascadeOriginptions_.emplace_back(std::move(option));
232         }
233     }
234 
GetCascadeOptionCount()235     uint32_t GetCascadeOptionCount() const
236     {
237         return cascadeOptions_.size();
238     }
239 
GetOptionCount(const RefPtr<FrameNode> & frmeNode)240     uint32_t GetOptionCount(const RefPtr<FrameNode>& frmeNode)
241     {
242         uint32_t count = 0;
243         auto it = optionsWithNode_.find(frmeNode);
244         if (it != optionsWithNode_.end()) {
245             count = it->second.size();
246         }
247         return count;
248     }
249 
SetIsCascade(bool isCascade)250     void SetIsCascade(bool isCascade)
251     {
252         isCascade_ = isCascade;
253     }
254 
GetIsCascade()255     bool GetIsCascade() const
256     {
257         return isCascade_;
258     }
259 
SetConfirmNode(WeakPtr<FrameNode> buttonConfirmNode)260     void SetConfirmNode(WeakPtr<FrameNode> buttonConfirmNode)
261     {
262         weakButtonConfirm_ = buttonConfirmNode;
263     }
264 
SetCancelNode(WeakPtr<FrameNode> buttonCancelNode)265     void SetCancelNode(WeakPtr<FrameNode> buttonCancelNode)
266     {
267         weakButtonCancel_ = buttonCancelNode;
268     }
269 
SetForwardNode(WeakPtr<FrameNode> buttonForwardNode)270     void SetForwardNode(WeakPtr<FrameNode> buttonForwardNode)
271     {
272         weakButtonForward_ = buttonForwardNode;
273     }
274 
SetBackwardNode(WeakPtr<FrameNode> buttonBackwardNode)275     void SetBackwardNode(WeakPtr<FrameNode> buttonBackwardNode)
276     {
277         weakButtonBackward_ = buttonBackwardNode;
278     }
279 
280     void OnLanguageConfigurationUpdate() override;
281     void OnFontConfigurationUpdate() override;
282     void OnFontScaleConfigurationUpdate() override;
283 
SetValues(const std::vector<std::string> & values)284     void SetValues(const std::vector<std::string>& values)
285     {
286         values_.clear();
287         for (auto& value : values) {
288             values_.emplace_back(value);
289         }
290     }
291 
GetValues()292     const std::vector<std::string>& GetValues()
293     {
294         return values_;
295     }
296 
GetSelecteds()297     const std::vector<uint32_t>& GetSelecteds()
298     {
299         return selecteds_;
300     }
301 
SetHasSelectAttr(bool value)302     void SetHasSelectAttr(bool value)
303     {
304         isHasSelectAttr_ = value;
305     }
306 
GetHasSelectAttr()307     bool GetHasSelectAttr()
308     {
309         return isHasSelectAttr_;
310     }
311 
SetResizePickerItemHeight(double resizePickerItemHeight)312     void SetResizePickerItemHeight(double resizePickerItemHeight)
313     {
314         resizePickerItemHeight_ = resizePickerItemHeight;
315     }
316 
GetResizePickerItemHeight()317     double GetResizePickerItemHeight() const
318     {
319         return resizePickerItemHeight_;
320     }
321 
SetResizeFlag(bool resizeFlag)322     void SetResizeFlag(bool resizeFlag)
323     {
324         resizeFlag_ = resizeFlag;
325     }
326 
GetResizeFlag()327     bool GetResizeFlag() const
328     {
329         return resizeFlag_;
330     }
331 
SetIsShowInDialog(bool isShowInDialog)332     void SetIsShowInDialog(bool isShowInDialog)
333     {
334         isShowInDialog_ = isShowInDialog;
335     }
336 
GetIsShowInDialog()337     bool GetIsShowInDialog() const
338     {
339         return isShowInDialog_;
340     }
341 
GetDefaultPickerItemHeight()342     double GetDefaultPickerItemHeight() const
343     {
344         return defaultPickerItemHeight_;
345     }
346 
347     void SetSelecteds(const std::vector<uint32_t>& values);
348 
349     void HandleColumnChange(const RefPtr<FrameNode>& tag, bool isAdd, uint32_t index, bool needNotify);
350 
351     void SetChangeCallback(ColumnChangeCallback&& value);
352 
353     void ProcessCascadeOptions(const std::vector<NG::TextCascadePickerOptions>& options,
354         std::vector<NG::TextCascadePickerOptions>& reOptions, uint32_t index);
355 
356     size_t ProcessCascadeOptionDepth(const NG::TextCascadePickerOptions& option);
357 
358     void OnColorConfigurationUpdate() override;
359 
360     bool OnThemeScopeUpdate(int32_t themeScopeId) override;
361 
362     void OnDirectionConfigurationUpdate() override;
363 
SetContentRowNode(RefPtr<FrameNode> & contentRowNode)364     void SetContentRowNode(RefPtr<FrameNode>& contentRowNode)
365     {
366         contentRowNode_ = contentRowNode;
367     }
368 
SetPickerTag(bool isPicker)369     void SetPickerTag(bool isPicker)
370     {
371         isPicker_ = isPicker;
372     }
373 
374     void CheckAndUpdateColumnSize(SizeF& size, RefPtr<FrameNode>& frameNode, bool isNeedAdaptForAging = false);
375     bool NeedAdaptForAging();
376 
SetDivider(const ItemDivider & divider)377     void SetDivider(const ItemDivider& divider)
378     {
379         divider_ = divider;
380     }
381 
GetDivider()382     ItemDivider GetDivider()
383     {
384         return divider_;
385     }
386 
SetCustomDividerFlag(bool customDividerFlag)387     void SetCustomDividerFlag(bool customDividerFlag)
388     {
389         customDividerFlag_ = customDividerFlag;
390     }
391 
GetCustomDividerFlag()392     bool GetCustomDividerFlag()
393     {
394         return customDividerFlag_;
395     }
SetGradientHeight(const Dimension & value)396     void SetGradientHeight(const Dimension& value)
397     {
398         value_ = value;
399     }
400 
GetGradientHeight()401     Dimension GetGradientHeight()
402     {
403         return value_;
404     }
405 
406     void SetCanLoop(bool isLoop);
407     void SetDigitalCrownSensitivity(int32_t crownSensitivity);
408 
GetCanLoop()409     bool GetCanLoop()
410     {
411         return canloop_;
412     }
413 
HasUserDefinedDisappearFontFamily(bool isUserDefined)414     void HasUserDefinedDisappearFontFamily(bool isUserDefined)
415     {
416         hasUserDefinedDisappearFontFamily_ = isUserDefined;
417     }
418 
GetHasUserDefinedDisappearFontFamily()419     bool GetHasUserDefinedDisappearFontFamily()
420     {
421         return hasUserDefinedDisappearFontFamily_;
422     }
423 
HasUserDefinedNormalFontFamily(bool isUserDefined)424     void HasUserDefinedNormalFontFamily(bool isUserDefined)
425     {
426         hasUserDefinedNormalFontFamily_ = isUserDefined;
427     }
428 
GetHasUserDefinedNormalFontFamily()429     bool GetHasUserDefinedNormalFontFamily()
430     {
431         return hasUserDefinedNormalFontFamily_;
432     }
433 
HasUserDefinedSelectedFontFamily(bool isUserDefined)434     void HasUserDefinedSelectedFontFamily(bool isUserDefined)
435     {
436         hasUserDefinedSelectedFontFamily_ = isUserDefined;
437     }
438 
GetHasUserDefinedSelectedFontFamily()439     bool GetHasUserDefinedSelectedFontFamily()
440     {
441         return hasUserDefinedSelectedFontFamily_;
442     }
443 
SetRangeType(int32_t rangeType)444     void SetRangeType(int32_t rangeType)
445     {
446         rangeType_ = rangeType;
447     }
448 
GetRangeType()449     int32_t GetRangeType()
450     {
451         return rangeType_;
452     }
453 
updateFontConfigurationEvent(const std::function<void ()> & closeDialogEvent)454     void updateFontConfigurationEvent(const std::function<void()>& closeDialogEvent)
455     {
456         closeDialogEvent_ = closeDialogEvent;
457     }
458 
GetTextProperties()459     const PickerTextProperties& GetTextProperties() const
460     {
461         return textProperties_;
462     }
463 
SetTextProperties(const PickerTextProperties & properties)464     void SetTextProperties(const PickerTextProperties& properties)
465     {
466         textProperties_ = properties;
467         if (properties.disappearTextStyle_.fontSize.has_value() && properties.disappearTextStyle_.fontSize->IsValid()) {
468             isUserSetGradientFont_ = true;
469             gradientHeight_ = properties.disappearTextStyle_.fontSize.value();
470         }
471 
472         if (properties.normalTextStyle_.fontSize.has_value() && properties.normalTextStyle_.fontSize->IsValid()) {
473             isUserSetGradientFont_ = true;
474             gradientHeight_ = std::max(properties.normalTextStyle_.fontSize.value(), gradientHeight_);
475         }
476 
477         if (properties.selectedTextStyle_.fontSize.has_value() && properties.selectedTextStyle_.fontSize->IsValid()) {
478             isUserSetDividerSpacingFont_ = true;
479             dividerSpacing_ = properties.selectedTextStyle_.fontSize.value();
480         }
481     }
482 
GetIsUserSetDividerSpacingFont()483     bool GetIsUserSetDividerSpacingFont()
484     {
485         return isUserSetDividerSpacingFont_;
486     }
487 
GetIsUserSetGradientFont()488     bool GetIsUserSetGradientFont()
489     {
490         return isUserSetGradientFont_;
491     }
492 
GetDividerSpacing()493     Dimension GetDividerSpacing()
494     {
495         return dividerSpacing_;
496     }
497 
GetTextGradientHeight()498     Dimension GetTextGradientHeight()
499     {
500         return gradientHeight_;
501     }
502 
SetPaintDividerSpacing(float & value)503     void SetPaintDividerSpacing(float& value)
504     {
505         paintDividerSpacing_ = value;
506     }
507 
GetPaintDividerSpacing()508     float GetPaintDividerSpacing()
509     {
510         return paintDividerSpacing_;
511     }
512 
SetUserDefinedOpacity(double opacity)513     void SetUserDefinedOpacity(double opacity)
514     {
515         curOpacity_ = opacity;
516     }
517 
518     void SetDisableTextStyleAnimation(bool isDisableTextStyleAnimation);
519 
GetDisableTextStyleAnimation()520     bool GetDisableTextStyleAnimation() const
521     {
522         return isDisableTextStyleAnimation_;
523     }
524 
SetIsEnableHaptic(bool isEnableHapticFeedback)525     void SetIsEnableHaptic(bool isEnableHapticFeedback)
526     {
527         if (isEnableHaptic_ != isEnableHapticFeedback) {
528             isHapticChanged_ = true;
529         }
530         isEnableHaptic_ = isEnableHapticFeedback;
531     }
532 
GetIsEnableHaptic()533     bool GetIsEnableHaptic() const
534     {
535         return isEnableHaptic_;
536     }
537 
538     void ColumnPatternInitHapticController();
539     void UpdateUserSetSelectColor();
540     std::string GetTextPickerRange() const;
SetSingleRange(bool isSingleRange)541     inline void SetSingleRange(bool isSingleRange)
542     {
543         isSingleRange_ = isSingleRange;
544     }
545 
546     void UpdateDisappearTextStyle(const PickerTextStyle& textStyle);
547     void UpdateNormalTextStyle(const PickerTextStyle& textStyle);
548     void UpdateSelectedTextStyle(const PickerTextStyle& textStyle);
549     void UpdateDefaultTextStyle(const PickerTextStyle& textStyle);
550 
UpdateMeasureOnColorModeChange()551     void UpdateMeasureOnColorModeChange()
552     {
553         auto host = GetHost();
554         CHECK_NULL_VOID(host);
555         auto pipelineContext = host->GetContext();
556         CHECK_NULL_VOID(pipelineContext);
557 
558         if (pipelineContext->IsSystmColorChange() && host->GetRerenderable()) {
559             host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF);
560         }
561     }
562 
563     void ParseCascadeRangeOptions(std::vector<NG::TextCascadePickerOptions>& options);
564     void GetAndUpdateRealSelectedArr(const std::vector<NG::TextCascadePickerOptions>& rangeOptions,
565         const std::vector<RefPtr<ResourceObject>>& valueArrResObj);
566 
567 private:
568     void OnModifyDone() override;
569     void InitCrownAndKeyEvent();
570     void SetCallBack();
571     void SetLayoutDirection(TextDirection textDirection);
572     void OnAttachToFrameNode() override;
573     bool OnDirtyLayoutWrapperSwap(const RefPtr<LayoutWrapper>& dirty, const DirtySwapConfig& config) override;
574 
575     void InitOnKeyEvent(const RefPtr<FocusHub>& focusHub);
576     bool OnKeyEvent(const KeyEvent& event);
577     bool HandleDirectionKey(KeyCode code);
578     void InitFocusEvent();
579     void InitSelectorProps();
580     void HandleFocusEvent();
581     void HandleBlurEvent();
582     void AddIsFocusActiveUpdateEvent();
583     void RemoveIsFocusActiveUpdateEvent();
584     void GetInnerFocusButtonPaintRect(RoundRect& paintRect, float focusButtonXOffset);
585     void CalcLeftTotalColumnWidth(const RefPtr<FrameNode>& host, float& leftTotalColumnWidth, float childSize);
586     void UpdateFocusButtonState();
587     void SetHaveFocus(bool haveFocus);
588     void UpdateColumnButtonStyles(const RefPtr<FrameNode>& columnNode, bool haveFocus, bool needMarkDirty);
589     const RefPtr<FrameNode> GetFocusButtonNode() const;
590     double CalculateHeight();
591     float GetColumnWidthSumForFirstIndexColumns(int32_t index);
592 
593     void ClearFocus();
594     void SetDefaultFocus();
595     bool IsCircle();
596 #ifdef SUPPORT_DIGITAL_CROWN
597     void InitOnCrownEvent(const RefPtr<FocusHub>& focusHub);
598     bool OnCrownEvent(const CrownEvent& event);
599 #endif
600     void InitDisabled();
601     void GetInnerFocusPaintRect(RoundRect& paintRect);
602     void PaintFocusState();
603     void SetButtonIdeaSize();
604     void CalculateButtonMetrics(RefPtr<UINode> child, RefPtr<PickerTheme> pickerTheme);
605     std::string GetRangeStr() const;
606     std::string GetOptionsMultiStr() const;
607     std::string GetOptionsMultiStrInternal() const;
608     std::string GetColumnWidthsStr() const;
609     std::string GetOptionsCascadeStr(
610         const std::vector<NG::TextCascadePickerOptions>& options) const;
611     bool ChangeCurrentOptionValue(NG::TextCascadePickerOptions& option,
612         uint32_t value, uint32_t curColumn, uint32_t replaceColumn);
613     void OnColumnsBuildingUnCascade();
614     void OnColumnsBuildingCascade();
615     std::string GetSelectedObjectMulti(const std::vector<std::string>& values,
616         const std::vector<uint32_t>& indexs, int32_t status) const;
617     void SupplementOption(const std::vector<NG::TextCascadePickerOptions>& reOptions,
618         std::vector<NG::RangeContent>& rangeContents, uint32_t patterIndex);
619     void ProcessCascadeOptionsValues(const std::vector<std::string>& rangeResultValue, uint32_t index);
620     void SetFocusCornerRadius(RoundRect& paintRect, const BorderRadiusProperty& radius);
621     void UpdateButtonMargin(
622         const RefPtr<FrameNode>& buttonNode, const RefPtr<DialogTheme>& dialogTheme, const bool isConfirmOrNextNode);
623     void CheckFocusID(int32_t childSize);
624     bool ParseDirectionKey(RefPtr<TextPickerColumnPattern>& textPickerColumnPattern, KeyCode& code,
625         uint32_t totalOptionCount, int32_t childSize);
626     RectF CalculatePaintRect(int32_t currentFocusIndex, float centerX, float centerY, float paintRectWidth,
627         float paintRectHeight, float columnWidth);
628     void AdjustFocusBoxOffset(float& centerX, float& centerY);
629     float CalculateColumnSize(int32_t index, float childCount, const SizeF& pickerContentSize);
630     int32_t CalculateIndex(RefPtr<FrameNode>& frameNode);
631     void UpdateDialogAgingButton(const RefPtr<FrameNode>& buttonNode, bool isNext);
632     Dimension ConvertFontScaleValue(const Dimension& fontSizeValue);
633 
634     void UpdateTextStyleCommon(
635         const PickerTextStyle& textStyle,
636         const TextStyle& defaultTextStyle,
637         std::function<void(const Color&)> updateTextColorFunc,
638         std::function<void(const Dimension&)> updateFontSizeFunc,
639         std::function<void(const std::vector<std::string>&)> updateFontFamilyFunc,
640         std::function<void(const Dimension&)> updateMinFontSizeFunc,
641         std::function<void(const Dimension&)> updateMaxFontSizeFunc);
642 
643     void ParseRangeResult(NG::TextCascadePickerOptions& option);
644     void GetRealSelectedIndex(const std::vector<NG::TextCascadePickerOptions>& rangeOptions,
645         const std::vector<std::string>& valueArr, uint32_t depth, std::vector<uint32_t>& selectedArray);
646     bool enabled_ = true;
647     int32_t focusKeyID_ = 0;
648     double defaultPickerItemHeight_ = 0.0;
649     double resizePickerItemHeight_ = 0.0;
650     bool focusEventInitialized_ = false;
651     bool haveFocus_ = false;
652     bool useButtonFocusArea_ = false;
653     Dimension selectorItemRadius_ = 8.0_vp;
654     std::function<void(bool)> isFocusActiveUpdateEvent_;
655     uint32_t selectedIndex_ = 0;
656     std::vector<NG::RangeContent> range_;
657     std::vector<NG::RangeContent> options_;
658     uint32_t columnsKind_ = 0;
659     std::vector<NG::TextCascadePickerOptions> cascadeOptions_;
660     std::map<WeakPtr<FrameNode>, std::vector<NG::RangeContent>> optionsWithNode_;
661     std::vector<NG::TextCascadePickerOptions> cascadeOriginptions_;
662     bool isCascade_ = false;
663     bool isHasSelectAttr_ = false;
664     WeakPtr<FrameNode> weakButtonConfirm_;
665     WeakPtr<FrameNode> weakButtonCancel_;
666     WeakPtr<FrameNode> weakButtonForward_;
667     WeakPtr<FrameNode> weakButtonBackward_;
668     std::vector<std::string> values_;
669     std::vector<uint32_t> selecteds_;
670     Color backgroundColor_ = Color::WHITE;
671     bool resizeFlag_ = false;
672     bool isShowInDialog_ = false;
673     bool canloop_ = true;
674 
675     bool hasUserDefinedDisappearFontFamily_ = false;
676     bool hasUserDefinedNormalFontFamily_ = false;
677     bool hasUserDefinedSelectedFontFamily_ = false;
678 
679     double curOpacity_ = 1.0;
680 
681     ACE_DISALLOW_COPY_AND_MOVE(TextPickerPattern);
682 
683     WeakPtr<NG::FrameNode> contentRowNode_;
684     bool isPicker_ = true;
685     bool isFiredSelectsChange_ = false;
686     std::optional<std::string> firedSelectsStr_;
687 
688     ItemDivider divider_;
689     bool customDividerFlag_ = false;
690     Dimension value_;
691     int32_t rangeType_ = 0;
692     std::function<void()> closeDialogEvent_;
693     bool isUserSetDividerSpacingFont_ = false;
694     bool isUserSetGradientFont_ = false;
695     Dimension gradientHeight_;
696     Dimension dividerSpacing_;
697     float paintDividerSpacing_ = 1.0f;
698     bool isNeedUpdateSelectedIndex_ = true;
699     PickerTextProperties textProperties_;
700     std::vector<Dimension> columnWidths_;
701 
702     bool isDisableTextStyleAnimation_ = false;
703     bool isEnableHaptic_ = true;
704     bool isHapticChanged_ = false;
705     int32_t selectedColumnId_ = INVALID_SELECTED_COLUMN_INDEX;
706     bool isSingleRange_ = true;
707 };
708 } // namespace OHOS::Ace::NG
709 
710 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_PICKER_TEXT_PICKER_PATTERN_H
711