1 /* 2 * Copyright (c) 2024 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_LINEAR_INDICATOR_LINEAR_INDICATOR_PATTERN_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LINEAR_INDICATOR_LINEAR_INDICATOR_PATTERN_H 18 19 #include "core/components_ng/pattern/linear_indicator/linear_indicator_controller.h" 20 #include "core/components_ng/pattern/linear_indicator/linear_indicator_layout_property.h" 21 #include "core/components_ng/pattern/linear_indicator/linear_indicator_theme.h" 22 #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h" 23 #include "core/components_ng/pattern/pattern.h" 24 25 namespace OHOS::Ace::NG { 26 27 class LinearIndicatorPattern : public LinearLayoutPattern { 28 DECLARE_ACE_TYPE(LinearIndicatorPattern, LinearLayoutPattern); 29 30 public: 31 LinearIndicatorPattern(); 32 33 ~LinearIndicatorPattern() override; 34 GetController()35 const RefPtr<LinearIndicatorController>& GetController() const 36 { 37 return controller_; 38 } 39 IsAtomicNode()40 bool IsAtomicNode() const override 41 { 42 return true; 43 } 44 45 RefPtr<LayoutProperty> CreateLayoutProperty() override; 46 47 void DumpInfo() override; 48 void DumpInfo(std::unique_ptr<JsonValue>& json) override; DumpSimplifyInfo(std::shared_ptr<JsonValue> & json)49 void DumpSimplifyInfo(std::shared_ptr<JsonValue>& json) override {} 50 51 RefPtr<AccessibilityProperty> CreateAccessibilityProperty() override; 52 53 private: 54 void OnModifyDone() override; 55 void UpdateProgressNode(); 56 57 bool IsChangeLayoutPropertyAndUpdate(RefPtr<LinearIndicatorLayoutProperty> layoutProperty); 58 void UpdateProgressNodeAtIndex(std::size_t index); 59 void AddProgressNode(); 60 61 std::size_t GetProgressSize(); 62 RefPtr<FrameNode> GetProgressNode(int32_t index); 63 64 void RegisterVisibleChange(); 65 void VisibleChange(bool visible); 66 67 bool CalcProgressWidth(float& progressWidth); 68 69 OHOS::Ace::RefPtr<LinearIndicatorTheme> theme_; 70 71 Dimension strokeWidth_; 72 Dimension strokeRadius_; 73 Color trackBackgroundColor_; 74 Color trackColor_; 75 TextDirection direction_; 76 77 RefPtr<LinearIndicatorController> controller_; 78 bool hasVisibleChangeRegistered_; 79 bool isVisibleChangePause_; 80 81 ACE_DISALLOW_COPY_AND_MOVE(LinearIndicatorPattern); 82 }; 83 } // namespace OHOS::Ace::NG 84 85 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LINEAR_INDICATOR_LINEAR_INDICATOR_PATTERN_H 86