• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include "modifier_ng/geometry/rs_frame_modifier.h"
17 
18 namespace OHOS::Rosen::ModifierNG {
SetFrame(Vector4f frame)19 void RSFrameModifier::SetFrame(Vector4f frame)
20 {
21     Setter(RSPropertyType::FRAME, frame);
22 }
23 
SetFrameSize(Vector2f size)24 void RSFrameModifier::SetFrameSize(Vector2f size)
25 {
26     Vector4f oldFrame = GetFrame();
27     SetFrame({ oldFrame.x_, oldFrame.y_, size.x_, size.y_ });
28 }
29 
SetFrameWidth(float width)30 void RSFrameModifier::SetFrameWidth(float width)
31 {
32     Vector4f oldFrame = GetFrame();
33     SetFrame({ oldFrame.x_, oldFrame.y_, width, oldFrame.w_ });
34 }
35 
SetFrameHeight(float height)36 void RSFrameModifier::SetFrameHeight(float height)
37 {
38     Vector4f oldFrame = GetFrame();
39     SetFrame({ oldFrame.x_, oldFrame.y_, oldFrame.z_, height });
40 }
41 
SetFramePosition(Vector2f position)42 void RSFrameModifier::SetFramePosition(Vector2f position)
43 {
44     Vector4f oldFrame = GetFrame();
45     SetFrame({ position.x_, position.y_, oldFrame.z_, oldFrame.w_ });
46 }
47 
SetFramePositionX(float positionX)48 void RSFrameModifier::SetFramePositionX(float positionX)
49 {
50     Vector4f oldFrame = GetFrame();
51     SetFrame({ positionX, oldFrame.y_, oldFrame.z_, oldFrame.w_ });
52 }
53 
SetFramePositionY(float positionY)54 void RSFrameModifier::SetFramePositionY(float positionY)
55 {
56     Vector4f oldFrame = GetFrame();
57     SetFrame({ oldFrame.x_, positionY, oldFrame.z_, oldFrame.w_ });
58 }
59 
GetFrame() const60 Vector4f RSFrameModifier::GetFrame() const
61 {
62     return Getter(RSPropertyType::FRAME, Vector4f(0.0f, 0.0f, 0.0f, 0.0f));
63 }
64 
GetFrameSize() const65 Vector2f RSFrameModifier::GetFrameSize() const
66 {
67     Vector4f frame = GetFrame();
68     return { frame.z_, frame.w_ };
69 }
70 
GetFrameWidth() const71 float RSFrameModifier::GetFrameWidth() const
72 {
73     return GetFrame().z_;
74 }
75 
GetFrameHeight() const76 float RSFrameModifier::GetFrameHeight() const
77 {
78     return GetFrame().w_;
79 }
80 
GetFramePosition() const81 Vector2f RSFrameModifier::GetFramePosition() const
82 {
83     Vector4f frame = GetFrame();
84     return { frame.x_, frame.y_ };
85 }
86 
GetFramePositionX() const87 float RSFrameModifier::GetFramePositionX() const
88 {
89     return GetFrame().x_;
90 }
91 
GetFramePositionY() const92 float RSFrameModifier::GetFramePositionY() const
93 {
94     return GetFrame().y_;
95 }
96 } // namespace OHOS::Rosen::ModifierNG
97