• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
77 #if defined(PREVIEW)
SetDebugLine(const std::string & debugLine)78     void SetDebugLine(const std::string& debugLine)
79     {
80         debugLine_ = debugLine;
81     }
82 
GetDebugLine()83     std::string GetDebugLine()
84     {
85         return debugLine_;
86     }
87 
SetViewId(const std::string & viewId)88     void SetViewId(const std::string& viewId)
89     {
90         viewId_ = viewId;
91     }
92 
GetViewId()93     std::string GetViewId()
94     {
95         return viewId_;
96     }
97 #endif
98 
99     // dimension settings
100     virtual std::string GetWidth() const = 0;
101     virtual std::string GetHeight() const = 0;
102     virtual std::unique_ptr<JsonValue> GetSize() const = 0;
103     virtual std::string GetPadding() const = 0;
104     virtual Dimension GetMargin(OHOS::Ace::AnimatableType type) const = 0;
105     virtual std::string GetAllMargin() const = 0;
106     virtual std::string GetConstraintSize() const = 0;
107     virtual int32_t GetLayoutPriority() const = 0;
108     virtual int32_t GetLayoutWeight() const = 0;
109 
110     // position settings
111     virtual std::string GetAlign() const = 0;
112     virtual std::string GetDirectionStr() const = 0;
113     virtual TextDirection GetDirection() const = 0;
114     virtual std::unique_ptr<JsonValue> GetPosition() const = 0;
115     virtual std::unique_ptr<JsonValue> GetMarkAnchor() const = 0;
116     virtual std::unique_ptr<JsonValue> GetOffset() const = 0;
117     virtual std::string GetRect() = 0;
118     virtual Rect GetParentRect() const = 0;
119 
120     // layout constraint
121     virtual double GetAspectRatio() const = 0;
122     virtual int32_t GetDisplayPriority() const = 0;
123 
124     // flex layout
125     virtual std::string GetFlexBasis() const = 0;
126     virtual double GetFlexGrow() const = 0;
127     virtual double GetFlexShrink() const = 0;
128     virtual std::string GetAlignSelf() const = 0;
129 
130     // border settings
131     virtual Border GetBorder() const = 0;
132     virtual std::unique_ptr<JsonValue> GetUnifyBorder() const = 0;
133     virtual std::string GetBorderStyle() const = 0;
134     virtual std::string GetBorderWidth() const = 0;
135     virtual std::string GetBorderColor() const = 0;
136     virtual std::string GetBorderRadius() const = 0;
137 
138     // background settings
139     virtual RefPtr<Decoration> GetBackDecoration() const = 0;
140     virtual std::string GetBackgroundImage() const = 0;
141     virtual std::string GetBackgroundColor() const = 0;
142     virtual std::string GetBackgroundImageSize() const = 0;
143     virtual std::string GetBackgroundImagePosition() const = 0;
144 
145     // front decoration settings
146     virtual RefPtr<Decoration> GetFrontDecoration() const = 0;
147 
148     // opacity settings
149     virtual double GetOpacity() const = 0;
150 
151     // visibility settings
152     virtual std::string GetVisibility() const = 0;
153 
154     // enable settings
155     virtual bool GetEnabled() const = 0;
156 
157     // zindex settings
158     virtual int32_t GetZIndex() const = 0;
159 
160     // hit test behavior settings
161     virtual std::string GetHitTestBehaviorStr() const = 0;
162 
163     // graphical transformation
164     virtual DimensionOffset GetOriginPoint() const = 0;
165     virtual std::unique_ptr<JsonValue> GetRotate() const = 0;
166     virtual std::unique_ptr<JsonValue> GetScale() const = 0;
167     virtual std::unique_ptr<JsonValue> GetTransform() const = 0;
168     virtual std::unique_ptr<JsonValue> GetTranslate() const = 0;
169 
170     virtual double GetBlur() const = 0;
171     virtual double GetBackDropBlur() const = 0;
172     virtual std::unique_ptr<JsonValue> GetWindowBlur() const = 0;
173     virtual std::unique_ptr<JsonValue> GetShadow() const = 0;
174     virtual double GetBrightness() const = 0;
175     virtual double GetSaturate() const = 0;
176     virtual double GetContrast() const = 0;
177     virtual double GetInvert() const = 0;
178     virtual double GetSepia() const = 0;
179     virtual double GetGrayScale() const = 0;
180     virtual double GetHueRotate() const = 0;
181     virtual std::string GetColorBlend() const = 0;
182 
183     // shape clip
184     virtual std::string GetClip() const = 0;
185     virtual std::unique_ptr<JsonValue> GetMask() const = 0;
186 
187     // grid setting
188     virtual int32_t GetGridSpan() const = 0;
189     virtual int32_t GetGridOffset() const = 0;
190     virtual std::unique_ptr<JsonValue> GetUseSizeType() const = 0;
191     virtual RefPtr<GridColumnInfo> GetGridColumnInfo() const = 0;
192 
193     // useAlign setting
194     virtual std::unique_ptr<JsonValue> GetUseAlign() const = 0;
195     virtual std::unique_ptr<JsonValue> ToJsonObject() const = 0;
196 
197     virtual std::unique_ptr<JsonValue> GetOverlay() const = 0;
198 
199     virtual void UpdateEventTarget(BaseEventInfo& info) const = 0;
200 
201     virtual std::pair<Rect, Offset> GetCurrentRectAndOrigin() const = 0;
202     virtual std::pair<Rect, Offset> GetLastRectAndOrigin() = 0;
203     virtual void UpdateLastRectAndOrigin(const std::pair<Rect, Offset>& curRectOrigin) = 0;
204 
205     // color gradient
206     virtual std::unique_ptr<JsonValue> GetLinearGradient() const = 0;
207     virtual std::unique_ptr<JsonValue> GetSweepGradient() const = 0;
208     virtual std::unique_ptr<JsonValue> GetRadialGradient() const = 0;
209 
210     // bind popup
211     virtual std::string GetBindPopup() const = 0;
212 
213     // bind context menu
214     virtual std::string GetBindContextMenu() const = 0;
215 
216     // auto test
217     virtual bool GetClickable() const = 0;
218     virtual bool GetCheckable() const = 0;
219     virtual bool GetFocusable() const = 0;
220     virtual bool GetScrollable() const = 0;
221     virtual bool GetLongClickable() const = 0;
222     virtual bool GetTouchable() const = 0;
223     virtual bool IsSelected() const = 0;
224     virtual bool IsPassword() const = 0;
225     virtual bool IsChecked() const = 0;
226     virtual bool IsFocused() const = 0;
227 
228 protected:
229     int32_t inspectorId_ = 0;
230     int32_t inspectorParentId_ = -1;
231     std::string inspectorTag_;
232 #if defined(PREVIEW)
233     std::string debugLine_;
234     std::string viewId_;
235 #endif
236 };
237 
238 } // namespace OHOS::Ace::V2
239 
240 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INSPECTOR_INSPECTOR_NODE_H
241