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_INTERFACES_EXTENSION_CUSTOM_NODE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_EXTENSION_CUSTOM_NODE_H 18 19 #include "core/components_ng/base/extension_handler.h" 20 #include "core/interfaces/arkoala/arkoala_api.h" 21 22 namespace OHOS::Ace::NG { 23 24 class ExtensionCustomNode : public ExtensionHandler { 25 DECLARE_ACE_TYPE(ExtensionCustomNode, ExtensionHandler); 26 27 public: 28 ~ExtensionCustomNode() = default; 29 SetMeasureCallback(std::function<void (LayoutConstraintF & layoutConstraint)> measureCallback)30 void SetMeasureCallback(std::function<void(LayoutConstraintF& layoutConstraint)> measureCallback) 31 { 32 measureCallback_ = measureCallback; 33 } 34 SetLayoutCallback(std::function<void (OffsetF & position)> layoutCallback)35 void SetLayoutCallback(std::function<void(OffsetF& position)> layoutCallback) 36 { 37 layoutCallback_ = layoutCallback; 38 } 39 40 protected: 41 // FrameNode measure, layout, custom function. 42 // call InnerMeasure InnerLayout to process origin logic. 43 void OnMeasure(const ExtensionLayoutConstraint& layoutConstraint) override; 44 void OnLayout(int32_t width, int32_t height, int32_t positionX, int32_t positionY) override; 45 46 private: 47 std::function<void(LayoutConstraintF& layoutConstraint)> measureCallback_; 48 std::function<void(OffsetF& position)> layoutCallback_; 49 }; 50 51 } // namespace OHOS::Ace::NG 52 53 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_INTERFACES_EXTENSION_CUSTOM_NODE_H