1 /* 2 * Copyright (c) 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_NG_PATTERN_SCROLLABLE_PAINT_PROPERTY_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCROLLABLE_PAINT_PROPERTY_H 18 19 #include "core/animation/curve.h" 20 #include "core/animation/curves.h" 21 #include "core/components/common/layout/constants.h" 22 #include "core/components/common/properties/color.h" 23 #include "core/components_ng/pattern/scroll/inner/scroll_bar.h" 24 #include "core/components_ng/render/paint_property.h" 25 26 namespace OHOS::Ace::NG { 27 struct ScrollBarProperty { 28 ACE_DEFINE_PROPERTY_GROUP_ITEM(ScrollBarMode, NG::DisplayMode); 29 ACE_DEFINE_PROPERTY_GROUP_ITEM(ScrollBarWidth, Dimension); 30 ACE_DEFINE_PROPERTY_GROUP_ITEM(ScrollBarColor, Color); 31 }; 32 33 class ScrollablePaintProperty : public PaintProperty { 34 DECLARE_ACE_TYPE(ScrollablePaintProperty, PaintProperty) 35 36 public: 37 ScrollablePaintProperty() = default; 38 ~ScrollablePaintProperty() override = default; 39 Clone()40 RefPtr<PaintProperty> Clone() const override 41 { 42 auto paintProperty = MakeRefPtr<ScrollablePaintProperty>(); 43 paintProperty->UpdatePaintProperty(this); 44 paintProperty->propScrollBarProperty_ = CloneScrollBarProperty(); 45 return paintProperty; 46 } 47 Reset()48 void Reset() override 49 { 50 ResetScrollBarProperty(); 51 PaintProperty::Reset(); 52 } 53 54 void ToJsonValue(std::unique_ptr<JsonValue>& json) const override; 55 56 ACE_DEFINE_PROPERTY_GROUP(ScrollBarProperty, ScrollBarProperty); 57 ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ScrollBarProperty, ScrollBarMode, NG::DisplayMode, PROPERTY_UPDATE_RENDER); 58 ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ScrollBarProperty, ScrollBarWidth, Dimension, PROPERTY_UPDATE_RENDER); 59 ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(ScrollBarProperty, ScrollBarColor, Color, PROPERTY_UPDATE_RENDER); 60 61 private: 62 Color GetBarColor() const; 63 Dimension GetBarWidth() const; 64 std::string GetBarStateString() const; 65 }; 66 } // namespace OHOS::Ace::NG 67 68 #endif 69