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_TRANSITION_TRANSITION_COMPONENT_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TRANSITION_TRANSITION_COMPONENT_H
18 
19 #include "core/components/common/properties/tween_option.h"
20 #include "core/pipeline/base/composed_component.h"
21 
22 namespace OHOS::Ace {
23 
24 class TransitionComponent : public ComposedComponent {
25     DECLARE_ACE_TYPE(TransitionComponent, ComposedComponent);
26 
27 public:
TransitionComponent(const ComposeId & id,const std::string & name,const RefPtr<Component> & child)28     TransitionComponent(const ComposeId& id, const std::string& name, const RefPtr<Component>& child)
29         : ComposedComponent(id, name, child)
30     {}
TransitionComponent(const ComposeId & id,const std::string & name)31     TransitionComponent(const ComposeId& id, const std::string& name) : ComposedComponent(id, name) {}
32 
33     ~TransitionComponent() override = default;
34 
35     RefPtr<Element> CreateElement() override;
36 
MarkOptionChanged(bool change)37     void MarkOptionChanged(bool change)
38     {
39         optionChanged_ = change;
40     }
41 
IsOptionChanged()42     bool IsOptionChanged() const
43     {
44         return optionChanged_;
45     }
46 
SetTransitionOption(const TweenOption & transition)47     void SetTransitionOption(const TweenOption& transition)
48     {
49         MarkOptionChanged(true);
50         transitionOption_ = std::move(transition);
51     }
52 
GetTransitionOption()53     const TweenOption& GetTransitionOption() const
54     {
55         return transitionOption_;
56     }
57 
58     void SetTransitionOption(const TweenOption& in, const TweenOption& out);
59     const TweenOption& GetTransitionInOption() const;
60 
61     const TweenOption& GetTransitionOutOption() const;
62 
63     static ComposeId AllocTransitionComponentId();
64 
65     bool IsFirstFrameShow() const;
66     void SetIsFirstFrameShow(bool isFirstFrameShow);
67 
68 private:
69     TweenOption inOption_;  // In option
70     TweenOption outOption_; // Out option
71     TweenOption transitionOption_; // transition option
72     bool optionChanged_ = false;
73     bool isFirstFrameShow_ = true;
74 };
75 
76 } // namespace OHOS::Ace
77 
78 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TRANSITION_TRANSITION_COMPONENT_H
79