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_COMPONENTS_POSITIONED_RENDER_POSITIONED_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_POSITIONED_RENDER_POSITIONED_H 18 19 #include "core/animation/property_animatable.h" 20 #include "core/components/proxy/render_proxy.h" 21 22 namespace OHOS::Ace { 23 24 using UpdatePositionFunc = std::function<void(const std::function<void(const Dimension&, const Dimension&)>&)>; 25 26 class ACE_EXPORT RenderPositioned : public RenderProxy { 27 DECLARE_ACE_TYPE(RenderPositioned, RenderProxy); 28 29 public: 30 void Update(const RefPtr<Component>& component) override; 31 32 static RefPtr<RenderNode> Create(); 33 GetBottom()34 const Dimension& GetBottom() const override 35 { 36 return bottom_; 37 } 38 GetTop()39 const Dimension& GetTop() const override 40 { 41 return top_; 42 } 43 GetHeight()44 double GetHeight() const 45 { 46 return height_; 47 } 48 GetWidth()49 double GetWidth() const 50 { 51 return width_; 52 } 53 GetLeft()54 const Dimension& GetLeft() const override 55 { 56 return left_; 57 } 58 GetRight()59 const Dimension& GetRight() const override 60 { 61 return right_; 62 } 63 HasLeft()64 bool HasLeft() const override 65 { 66 return hasLeft_; 67 } 68 HasTop()69 bool HasTop() const override 70 { 71 return hasTop_; 72 } 73 HasRight()74 bool HasRight() const override 75 { 76 return hasRight_; 77 } 78 HasBottom()79 bool HasBottom() const override 80 { 81 return hasBottom_; 82 } 83 84 void SetLeft(const Dimension& left) override; // add for animation 85 86 void SetTop(const Dimension& top) override; // add for animation 87 88 void SetRight(const Dimension& right) override; // add for animation 89 90 void SetBottom(const Dimension& bottom) override; // add for animation 91 92 protected: 93 Dimension bottom_; 94 Dimension top_; 95 Dimension left_; 96 Dimension right_; 97 double height_ = 0.0; 98 double width_ = 0.0; 99 100 bool hasLeft_ = false; 101 bool hasTop_ = false; 102 bool hasRight_ = false; 103 bool hasBottom_ = false; 104 105 UpdatePositionFunc updatePositionFunc_; 106 }; 107 108 } // namespace OHOS::Ace 109 110 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_POSITIONED_RENDER_POSITIONED_H 111