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 ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMPONENT_H 17 #define ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMPONENT_H 18 19 #include <cassert> 20 #include <string> 21 22 #include "component.h" 23 24 namespace ArkUICapiTest { 25 class ImageAnimatorComponent : public Component { 26 public: ImageAnimatorComponent()27 explicit ImageAnimatorComponent() : Component(ARKUI_NODE_IMAGE_ANIMATOR) {} ImageAnimatorComponent(ArkUI_NodeHandle handle)28 explicit ImageAnimatorComponent(ArkUI_NodeHandle handle) : Component(handle) {} 29 void SetState(int32_t state); 30 void SetIteration(int32_t iteration); 31 void SetImage(std::vector<ArkUI_ImageAnimatorFrameInfo*>& vector); 32 void SetFixedSize(int32_t fixedSize); 33 void SetReverse(int32_t reverse); 34 void SetFillMode(int32_t mode); 35 void SetDuration(int32_t duration); 36 void RegisterOnStart(const std::function<void(ArkUI_NodeEvent *event)> &onStart); 37 void RegisterOnCancel(const std::function<void(ArkUI_NodeEvent *event)> &onCancel); 38 void RegisterOnPause(const std::function<void(ArkUI_NodeEvent *event)> &onPause); 39 void RegisterOnRepeat(const std::function<void(ArkUI_NodeEvent *event)> &onRepeat); 40 void RegisterOnFinish(const std::function<void(ArkUI_NodeEvent *event)> &onFinish); 41 void OnNodeEvent(ArkUI_NodeEvent *event) override; 42 43 std::function<void(ArkUI_NodeEvent *event)> onStart_; 44 std::function<void(ArkUI_NodeEvent *event)> onCancel_; 45 std::function<void(ArkUI_NodeEvent *event)> onPause_; 46 std::function<void(ArkUI_NodeEvent *event)> onRepeat_; 47 std::function<void(ArkUI_NodeEvent *event)> onFinish_; 48 }; 49 } // namespace ArkUICapiTest 50 #endif // ARKUI_CAPI_DEMO_IMAGEANIMATOR_COMPONENT_H 51