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