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