1 /* 2 * Copyright (c) 2024 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_NG_SVG_BASE_LENGTH_SCALE_RULE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_SVG_BASE_LENGTH_SCALE_RULE_H 18 19 #include "base/geometry/rect.h" 20 21 namespace OHOS::Ace::NG { 22 23 enum class SvgLengthType { 24 HORIZONTAL = 0, 25 VERTICAL, 26 OTHER, 27 }; 28 29 enum class SvgLengthScaleUnit { 30 USER_SPACE_ON_USE = 0, 31 OBJECT_BOUNDING_BOX, 32 }; 33 34 class SvgLengthScaleRule { 35 public: SvgLengthScaleRule(Rect containerRect,Size viewPort,SvgLengthScaleUnit lengthScaleUnit)36 SvgLengthScaleRule(Rect containerRect, Size viewPort, SvgLengthScaleUnit lengthScaleUnit) 37 : containerRect_(containerRect), viewPort_(viewPort), lengthScaleUnit_(lengthScaleUnit) {} 38 SvgLengthScaleRule() = default; 39 ~SvgLengthScaleRule() = default; GetLengthScaleUnit()40 SvgLengthScaleUnit GetLengthScaleUnit() const 41 { 42 return lengthScaleUnit_; 43 } GetContainerRect()44 const Rect& GetContainerRect() const 45 { 46 return containerRect_; 47 } 48 GetViewPort()49 const Size& GetViewPort() const 50 { 51 return viewPort_; 52 } 53 54 bool operator==(const SvgLengthScaleRule& lengthRule) 55 { 56 return containerRect_ == lengthRule.GetContainerRect() && viewPort_ == lengthRule.GetViewPort() 57 && lengthScaleUnit_ == lengthRule.GetLengthScaleUnit(); 58 } 59 SetPathTransform(bool transform)60 void SetPathTransform(bool transform) 61 { 62 pathTransform_ = transform; 63 return ; 64 } GetPathTransform()65 bool GetPathTransform() const 66 { 67 return pathTransform_; 68 } 69 UseFillColor()70 bool UseFillColor() const 71 { 72 return useFillColor_; 73 } 74 SetUseFillColor(bool useFillColor)75 void SetUseFillColor(bool useFillColor) 76 { 77 useFillColor_ = useFillColor; 78 } 79 private: 80 Rect containerRect_; 81 Size viewPort_; 82 SvgLengthScaleUnit lengthScaleUnit_; 83 bool pathTransform_ = false; 84 bool useFillColor_ = true; 85 }; 86 } 87 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_SVG_BASE_LENGTH_SCALE_RULE_H