1 /*
2  * Copyright (c) 2021-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_V2_INSPECTOR_INSPECTOR_NODE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INSPECTOR_INSPECTOR_NODE_H
18 
19 #include <tuple>
20 
21 #include "base/geometry/dimension_offset.h"
22 #include "base/geometry/matrix4.h"
23 #include "base/json/json_util.h"
24 #include "core/components/box/mask.h"
25 #include "core/components/common/layout/grid_column_info.h"
26 #include "core/components/common/properties/clip_path.h"
27 
28 namespace OHOS::Ace::V2 {
29 
30 class InspectorNode;
31 
32 using DoubleJsonFunc = std::function<double(const InspectorNode&)>;
33 using StringJsonFunc = std::function<std::string(const InspectorNode&)>;
34 using BoolJsonFunc = std::function<bool(const InspectorNode&)>;
35 using IntJsonFunc = std::function<int32_t(const InspectorNode&)>;
36 using JsonValueJsonFunc = std::function<std::unique_ptr<JsonValue>(const InspectorNode&)>;
37 
38 struct RotateParam {
39     float x;
40     float y;
41     float z;
42     float angle;
43     Dimension centerX;
44     Dimension centerY;
45 };
46 
47 struct ScaleParam {
48     float x;
49     float y;
50     float z;
51     Dimension centerX;
52     Dimension centerY;
53 };
54 
55 class ACE_EXPORT InspectorNode : public virtual AceType {
56     DECLARE_ACE_TYPE(InspectorNode, AceType)
57 
58 public:
59     InspectorNode() = default;
60     ~InspectorNode() override = default;
61 
GetInspectorId()62     int32_t GetInspectorId() const
63     {
64         return inspectorId_;
65     }
66 
SetInspectorTag(const std::string & inspectorTag)67     void SetInspectorTag(const std::string& inspectorTag)
68     {
69         inspectorTag_ = inspectorTag;
70     }
71 
GetInspectorTag()72     const std::string& GetInspectorTag()
73     {
74         return inspectorTag_;
75     }
76 
SetDebugLine(const std::string & debugLine)77     void SetDebugLine(const std::string& debugLine)
78     {
79         debugLine_ = debugLine;
80     }
81 
GetDebugLine()82     std::string GetDebugLine()
83     {
84         return debugLine_;
85     }
86 
SetViewId(const std::string & viewId)87     void SetViewId(const std::string& viewId)
88     {
89         viewId_ = viewId;
90     }
91 
GetViewId()92     std::string GetViewId()
93     {
94         return viewId_;
95     }
96 
97     // dimension settings
98     virtual std::string GetWidth() const = 0;
99     virtual std::string GetHeight() const = 0;
100     virtual std::unique_ptr<JsonValue> GetSize() const = 0;
101     virtual std::string GetPadding() const = 0;
102     virtual Dimension GetMargin(OHOS::Ace::AnimatableType type) const = 0;
103     virtual std::string GetAllMargin() const = 0;
104     virtual std::string GetConstraintSize() const = 0;
105     virtual int32_t GetLayoutPriority() const = 0;
106     virtual int32_t GetLayoutWeight() const = 0;
107 
108     // position settings
109     virtual std::string GetAlign() const = 0;
110     virtual std::string GetDirectionStr() const = 0;
111     virtual TextDirection GetDirection() const = 0;
112     virtual std::unique_ptr<JsonValue> GetPosition() const = 0;
113     virtual std::unique_ptr<JsonValue> GetMarkAnchor() const = 0;
114     virtual std::unique_ptr<JsonValue> GetOffset() const = 0;
115     virtual std::string GetRect() = 0;
116     virtual Rect GetParentRect() const = 0;
117 
118     // layout constraint
119     virtual double GetAspectRatio() const = 0;
120     virtual int32_t GetDisplayPriority() const = 0;
121 
122     // flex layout
123     virtual std::string GetFlexBasis() const = 0;
124     virtual double GetFlexGrow() const = 0;
125     virtual double GetFlexShrink() const = 0;
126     virtual std::string GetAlignSelf() const = 0;
127 
128     // border settings
129     virtual Border GetBorder() const = 0;
130     virtual std::unique_ptr<JsonValue> GetUnifyBorder() const = 0;
131     virtual std::string GetBorderStyle() const = 0;
132     virtual std::string GetBorderWidth() const = 0;
133     virtual std::string GetBorderColor() const = 0;
134     virtual std::string GetBorderRadius() const = 0;
135 
136     // background settings
137     virtual RefPtr<Decoration> GetBackDecoration() const = 0;
138     virtual std::string GetBackgroundImage() const = 0;
139     virtual std::string GetBackgroundColor() const = 0;
140     virtual std::string GetBackgroundImageSize() const = 0;
141     virtual std::string GetBackgroundImagePosition() const = 0;
142 
143     // front decoration settings
144     virtual RefPtr<Decoration> GetFrontDecoration() const = 0;
145 
146     // opacity settings
147     virtual double GetOpacity() const = 0;
148 
149     // visibility settings
150     virtual std::string GetVisibility() const = 0;
151 
152     // enable settings
153     virtual bool GetEnabled() const = 0;
154 
155     // zindex settings
156     virtual int32_t GetZIndex() const = 0;
157 
158     // hit test behavior settings
159     virtual std::string GetHitTestBehaviorStr() const = 0;
160 
161     // graphical transformation
162     virtual DimensionOffset GetOriginPoint() const = 0;
163     virtual std::unique_ptr<JsonValue> GetRotate() const = 0;
164     virtual std::unique_ptr<JsonValue> GetScale() const = 0;
165     virtual std::unique_ptr<JsonValue> GetTransform() const = 0;
166     virtual std::unique_ptr<JsonValue> GetTranslate() const = 0;
167 
168     virtual double GetBlur() const = 0;
169     virtual double GetBackDropBlur() const = 0;
170     virtual std::unique_ptr<JsonValue> GetWindowBlur() const = 0;
171     virtual std::unique_ptr<JsonValue> GetShadow() const = 0;
172     virtual double GetBrightness() const = 0;
173     virtual double GetSaturate() const = 0;
174     virtual double GetContrast() const = 0;
175     virtual double GetInvert() const = 0;
176     virtual double GetSepia() const = 0;
177     virtual double GetGrayScale() const = 0;
178     virtual double GetHueRotate() const = 0;
179     virtual std::string GetColorBlend() const = 0;
180 
181     // shape clip
182     virtual std::string GetClip() const = 0;
183     virtual std::unique_ptr<JsonValue> GetMask() const = 0;
184 
185     // grid setting
186     virtual int32_t GetGridSpan() const = 0;
187     virtual int32_t GetGridOffset() const = 0;
188     virtual std::unique_ptr<JsonValue> GetUseSizeType() const = 0;
189     virtual RefPtr<GridColumnInfo> GetGridColumnInfo() const = 0;
190 
191     // useAlign setting
192     virtual std::unique_ptr<JsonValue> GetUseAlign() const = 0;
193     virtual std::unique_ptr<JsonValue> ToJsonObject() const = 0;
194 
195     virtual std::unique_ptr<JsonValue> GetOverlay() const = 0;
196 
197     virtual void UpdateEventTarget(BaseEventInfo& info) const = 0;
198 
199     virtual std::pair<Rect, Offset> GetCurrentRectAndOrigin() const = 0;
200     virtual std::pair<Rect, Offset> GetLastRectAndOrigin() = 0;
201     virtual void UpdateLastRectAndOrigin(const std::pair<Rect, Offset>& curRectOrigin) = 0;
202 
203     // color gradient
204     virtual std::unique_ptr<JsonValue> GetLinearGradient() const = 0;
205     virtual std::unique_ptr<JsonValue> GetSweepGradient() const = 0;
206     virtual std::unique_ptr<JsonValue> GetRadialGradient() const = 0;
207 
208     // bind popup
209     virtual std::string GetBindPopup() const = 0;
210 
211     // bind context menu
212     virtual std::string GetBindContextMenu() const = 0;
213 
214     // auto test
215     virtual bool GetClickable() const = 0;
216     virtual bool GetCheckable() const = 0;
217     virtual bool GetFocusable() const = 0;
218     virtual bool GetScrollable() const = 0;
219     virtual bool GetLongClickable() const = 0;
220     virtual bool GetTouchable() const = 0;
221     virtual bool IsSelected() const = 0;
222     virtual bool IsPassword() const = 0;
223     virtual bool IsChecked() const = 0;
224     virtual bool IsFocused() const = 0;
225 
226 protected:
227     int32_t inspectorId_ = 0;
228     int32_t inspectorParentId_ = -1;
229     std::string inspectorTag_;
230     std::string debugLine_;
231     std::string viewId_;
232 };
233 
234 } // namespace OHOS::Ace::V2
235 
236 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INSPECTOR_INSPECTOR_NODE_H
237