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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_LAYERS_LAYER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_LAYERS_LAYER_H 18 19 #include <list> 20 21 #include "base/memory/ace_type.h" 22 23 namespace OHOS::Ace::Flutter { 24 25 class SceneBuilder; 26 27 class Layer : public AceType { 28 DECLARE_ACE_TYPE(Layer, AceType) 29 public: 30 Layer() = default; 31 ~Layer() override = default; 32 GetParent()33 WeakPtr<Layer> GetParent() 34 { 35 return parentLayer_; 36 } 37 SetParent(const RefPtr<Layer> & layer)38 void SetParent(const RefPtr<Layer>& layer) 39 { 40 parentLayer_ = layer; 41 } 42 43 virtual void AddToScene(SceneBuilder& builder, double x, double y) = 0; 44 45 void AddChildren(const RefPtr<Layer>& layer); RemoveChildren()46 void RemoveChildren() 47 { 48 children_.clear(); 49 } 50 GetChildren()51 const std::list<RefPtr<Layer>>& GetChildren() const 52 { 53 return children_; 54 } 55 Size()56 int32_t Size() 57 { 58 return children_.size(); 59 } 60 61 virtual void DumpTree(int32_t depth); 62 virtual void Dump() = 0; 63 64 protected: 65 WeakPtr<Layer> parentLayer_; 66 std::list<RefPtr<Layer>> children_; 67 }; 68 69 } // namespace OHOS::Ace::Flutter 70 71 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_LAYERS_LAYER_H 72