• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_NG_PATTERN_MODEL_MODEL_LAYOUT_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_LAYOUT_PROPERTY_H
18 
19 #include "core/components_ng/base/frame_node.h"
20 #include "core/components_ng/layout/layout_property.h"
21 #include "core/components_ng/property/property.h"
22 #include "core/components_ng/pattern/model/model_property.h"
23 
24 namespace OHOS::Ace::NG {
25 class ModelPattern;
26 
27 class ACE_EXPORT ModelLayoutProperty : public LayoutProperty {
28     DECLARE_ACE_TYPE(ModelLayoutProperty, LayoutProperty);
29 
30 public:
31     ModelLayoutProperty() = default;
32 
33     ~ModelLayoutProperty() override = default;
34 
Clone()35     RefPtr<LayoutProperty> Clone() const override
36     {
37         auto value = MakeRefPtr<ModelLayoutProperty>();
38         value->LayoutProperty::UpdateLayoutProperty(DynamicCast<LayoutProperty>(this));
39         value->propModelSource_ = CloneModelSource();
40         value->propModelBackground_ = CloneModelBackground();
41         value->propModelCameraMove_ = CloneModelCameraMove();
42         value->propModelTransparent_ = CloneModelTransparent();
43         value->needsSceneSetup_ = CloneNeedsSceneSetup();
44 
45         return value;
46     }
47 
ResetFlagProperties()48     void ResetFlagProperties()
49     {
50         UpdateNeedsSceneSetup(false);
51     }
52 
Reset()53     void Reset() override
54     {
55         LayoutProperty::Reset();
56         ResetModelSource();
57         ResetModelBackground();
58         ResetModelCameraMove();
59         ResetModelTransparent();
60         ResetFlagProperties();
61     }
62 
OnModelSourceUpdate(const std::string & value)63     void OnModelSourceUpdate(const std::string& value)
64     {
65         UpdateNeedsSceneSetup(true);
66     }
67 
OnModelBackgroundUpdate(const std::string & value)68     void OnModelBackgroundUpdate(const std::string& value)
69     {
70         UpdateNeedsSceneSetup(true);
71     }
72 
73     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP_AND_USING_CALLBACK(ModelSource, std::string, PROPERTY_UPDATE_MEASURE);
74     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP_AND_USING_CALLBACK(ModelBackground, std::string, PROPERTY_UPDATE_MEASURE);
75     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ModelCameraMove, bool, PROPERTY_UPDATE_MEASURE);
76     ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(ModelTransparent, bool, PROPERTY_UPDATE_MEASURE);
77 
78     DEFINE_NEEDS_SETUP_FLAG_PROPERTY(Scene, false, PROPERTY_UPDATE_MEASURE);
79 
80 private:
81     ACE_DISALLOW_COPY_AND_MOVE(ModelLayoutProperty);
82 };
83 } // namespace OHOS::Ace::NG
84 
85 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MODEL_MODEL_LAYOUT_PROPERTY_H
86