1 /* 2 * Copyright (c) 2022-2023 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_PATTERN_TABS_TAB_BAR_PAINT_PROPERTY_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TABS_TAB_BAR_PAINT_PROPERTY_H 18 19 #include "base/geometry/ng/rect_t.h" 20 #include "core/components/common/layout/constants.h" 21 #include "core/components/common/properties/color.h" 22 #include "core/components/common/properties/decoration.h" 23 #include "core/components_ng/base/inspector_filter.h" 24 #include "core/components_ng/render/paint_property.h" 25 26 namespace OHOS::Ace::NG { 27 28 class TabBarPaintProperty : public PaintProperty { 29 DECLARE_ACE_TYPE(TabBarPaintProperty, PaintProperty) 30 31 public: 32 TabBarPaintProperty() = default; 33 ~TabBarPaintProperty() override = default; 34 Clone()35 RefPtr<PaintProperty> Clone() const override 36 { 37 auto paintProperty = MakeRefPtr<TabBarPaintProperty>(); 38 paintProperty->PaintProperty::UpdatePaintProperty(DynamicCast<PaintProperty>(this)); 39 paintProperty->propIndicator_ = CloneIndicator(); 40 paintProperty->propFadingEdge_ = CloneFadingEdge(); 41 paintProperty->propBarBackgroundColor_ = CloneBarBackgroundColor(); 42 paintProperty->propTabBarBlurStyle_ = CloneTabBarBlurStyle(); 43 return paintProperty; 44 } 45 Reset()46 void Reset() override 47 { 48 PaintProperty::Reset(); 49 ResetIndicator(); 50 ResetFadingEdge(); 51 ResetBarBackgroundColor(); 52 } 53 ToJsonValue(std::unique_ptr<JsonValue> & json,const InspectorFilter & filter)54 void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override 55 { 56 PaintProperty::ToJsonValue(json, filter); 57 /* no fixed attr below, just return */ 58 if (filter.IsFastFilter()) { 59 return; 60 } 61 if (HasIndicator()) { 62 json->PutExtAttr("indicator", GetIndicatorValue().ToString().c_str(), filter); 63 } 64 if (HasFadingEdge()) { 65 json->PutExtAttr("fadingEdge", GetFadingEdgeValue() ? "true" : "false", filter); 66 } 67 } 68 69 /* Need to render when indicator has animation */ 70 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(Indicator, RectF, PROPERTY_UPDATE_RENDER); 71 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(FadingEdge, bool, PROPERTY_UPDATE_RENDER); 72 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(BarBackgroundColor, Color, PROPERTY_UPDATE_RENDER); 73 ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TabBarBlurStyle, BlurStyle, PROPERTY_UPDATE_RENDER); 74 }; 75 76 } // namespace OHOS::Ace::NG 77 78 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TABS_TAB_BAR_PAINT_PROPERTY_H 79