1 /* 2 * Copyright (c) 2024-2025 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_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_FRAME_NODE_H 17 #define FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_FRAME_NODE_H 18 19 #include <functional> 20 #include <list> 21 #include <memory> 22 #include <optional> 23 #include <string> 24 25 #include "ui/base/ace_type.h" 26 #include "ui/base/geometry/ng/offset_t.h" 27 #include "ui/base/geometry/ng/size_t.h" 28 #include "ui/base/macros.h" 29 #include "ui/base/referenced.h" 30 #include "ui/properties/dirty_flag.h" 31 #include "ui/properties/gradient_property.h" 32 #include "ui/properties/ng/calc_length.h" 33 #include "ui/resource/resource_configuration.h" 34 #include "ui/view/ai_caller_helper.h" 35 #include "ui/view/layout/layout_info.h" 36 37 typedef struct _ArkUINode* ArkUINodeHandle; 38 39 namespace OHOS::Rosen { 40 class Filter; 41 } // namespace OHOS::Rosen 42 43 namespace OHOS::Ace::NG { 44 class LayoutProperty; 45 template<class T> 46 struct LayoutConstraintT; 47 48 template<class T> 49 struct PaddingPropertyT; 50 } // namespace OHOS::Ace::NG 51 52 namespace OHOS::Ace::Kit { 53 54 class Pattern; 55 class UIContext; 56 class Property; 57 using NodeHandle = void*; 58 59 class ACE_FORCE_EXPORT FrameNode : public AceType { 60 DECLARE_ACE_TYPE(FrameNode, AceType); 61 62 public: 63 FrameNode() = default; 64 virtual ~FrameNode() = default; 65 66 static RefPtr<FrameNode> GetFrameNode(ArkUINodeHandle node); 67 68 virtual void InitializePatternAndContext() = 0; 69 virtual void Reset() = 0; 70 71 virtual void Measure(const Kit::LayoutConstraintInfo& parentContraint) = 0; 72 virtual void Layout() = 0; 73 74 virtual RefPtr<NG::LayoutProperty> GetLayoutProperty() = 0; 75 virtual RefPtr<Pattern> GetPattern() = 0; 76 virtual RefPtr<Property> GetProperty() = 0; 77 virtual NodeHandle GetHandle() = 0; 78 79 virtual void AddChild(const RefPtr<FrameNode>& child) = 0; 80 virtual std::list<RefPtr<FrameNode>> GetChildren() = 0; 81 virtual void MarkDirtyNode(NG::PropertyChangeFlag flag = NG::PROPERTY_UPDATE_NORMAL) = 0; 82 virtual void RemoveChild(const RefPtr<FrameNode>& child) = 0; 83 84 virtual std::string GetTag() const = 0; 85 virtual int32_t GetId() const = 0; 86 87 virtual void MeasureChildren() = 0; 88 virtual void LayoutChildren() = 0; 89 virtual void SetOnNodeDestroyCallback(const std::function<void(RefPtr<FrameNode>)>& destroyCallback) = 0; 90 virtual void SetConfigurationUpdateCallback( 91 const std::function<void(const ConfigurationChange& configurationChange)>&& callback) = 0; 92 virtual void AddExtraCustomProperty(const std::string& key, void* extraData) = 0; 93 virtual void* GetExtraCustomProperty(const std::string& key) const = 0; 94 virtual void SetClipEdge(bool isClip) = 0; 95 virtual void SetPadding(const NG::PaddingPropertyT<NG::CalcLength>& value) = 0; 96 virtual void SetSafeAreaPadding(const NG::CalcLength& value) = 0; 97 virtual void ResetSafeAreaPadding() = 0; 98 virtual void SetLinearGradient(const NG::Gradient& gradient) = 0; 99 virtual void SetLinearGradientBlur(const NG::LinearGradientBlurPara& blurPara) = 0; 100 virtual void SetCompositingFilter(const OHOS::Rosen::Filter* compositingFilter) = 0; 101 virtual void ResetCompositingFilter() = 0; 102 virtual bool NeedAvoidContainerModal() = 0; 103 virtual NG::OffsetF GetParentGlobalOffsetDuringLayout() = 0; 104 virtual int32_t GetContainerModalTitleHeight() = 0; 105 virtual NG::OffsetF GetContainerModalButtonsOffset() = 0; 106 virtual NG::SizeF GetContainerModalButtonsSize() = 0; 107 108 virtual RefPtr<UIContext> GetUIContext() const = 0; 109 virtual void SetMeasureCallback(const std::function<void(RefPtr<FrameNode>)>& callback) = 0; 110 virtual int32_t GetMeasureWidth() = 0; 111 virtual int32_t GetMeasureHeight() = 0; 112 virtual NodeHandle GetParentHandle() = 0; 113 virtual void SetAICallerHelper(const std::shared_ptr<AICallerHelper>& aiCallerHelper) = 0; 114 }; 115 } // namespace OHOS::Ace::Kit 116 117 #endif // FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_FRAME_NODE_H 118