• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_LAYERS_OFFSET_LAYER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_LAYERS_OFFSET_LAYER_H
18 
19 #include "base/geometry/offset.h"
20 #include "core/pipeline/layers/container_layer.h"
21 #include "core/pipeline/layers/scene_builder.h"
22 
23 namespace OHOS::Ace::Flutter {
24 
25 class OffsetLayer : public ContainerLayer {
26     DECLARE_ACE_TYPE(OffsetLayer, ContainerLayer)
27 public:
28     OffsetLayer() = default;
OffsetLayer(double x,double y)29     OffsetLayer(double x, double y) : x_(x), y_(y) {}
30     ~OffsetLayer() override = default;
31 
SetOffset(double x,double y)32     void SetOffset(double x, double y)
33     {
34         x_ = x;
35         y_ = y;
36     }
37 
SetStaticOffset(double x,double y)38     void SetStaticOffset(double x, double y)
39     {
40         staticX_ = x;
41         staticY_ = y;
42     }
43 
GetOffset()44     Offset GetOffset() const
45     {
46         return Offset(x_, y_);
47     }
48 
GetStaticOffset()49     Offset GetStaticOffset() const
50     {
51         return Offset(staticX_, staticY_);
52     }
53 
54     void AddToScene(SceneBuilder& builder, double x, double y) override;
55 
56     void Dump() override;
57 
58 protected:
59     double x_ = 0.0;
60     double y_ = 0.0;
61 
62     double staticX_ = 0.0;
63     double staticY_ = 0.0;
64 };
65 
66 } // namespace OHOS::Ace::Flutter
67 
68 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_LAYERS_OFFSET_LAYER_H
69