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_SLIDER_BLOCK_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SLIDER_BLOCK_COMPONENT_H 18 19 #include "base/geometry/dimension.h" 20 #include "core/components/common/properties/color.h" 21 #include "core/components/track/track_component.h" 22 #include "core/pipeline/base/component.h" 23 #include "core/pipeline/base/render_component.h" 24 25 namespace OHOS::Ace { 26 27 // The slider block in slider 28 class BlockComponent : public RenderComponent { 29 DECLARE_ACE_TYPE(BlockComponent, RenderComponent); 30 31 public: 32 BlockComponent() = default; 33 ~BlockComponent() override = default; 34 CreateElement()35 RefPtr<Element> CreateElement() override 36 { 37 // never use element to create element tree. 38 return nullptr; 39 } 40 GetBlockColor()41 const Color& GetBlockColor() const 42 { 43 return blockColor_; 44 } 45 SetBlockColor(const Color & color)46 void SetBlockColor(const Color& color) 47 { 48 blockColor_ = color; 49 } 50 GetBlockSize()51 const Dimension& GetBlockSize() const 52 { 53 return blockSize_; 54 } 55 GetHotRegionWidth()56 const Dimension& GetHotRegionWidth() const 57 { 58 return hotRegionWidth_; 59 } 60 GetHotRegionHeight()61 const Dimension& GetHotRegionHeight() const 62 { 63 return hotRegionHeight_; 64 } 65 SetBlockSize(const Dimension & size)66 void SetBlockSize(const Dimension& size) 67 { 68 blockSize_ = size; 69 } 70 SetHotRegionWidth(const Dimension & width)71 void SetHotRegionWidth(const Dimension& width) 72 { 73 hotRegionWidth_ = width; 74 } 75 SetHotRegionHeight(const Dimension & height)76 void SetHotRegionHeight(const Dimension& height) 77 { 78 hotRegionHeight_ = height; 79 } 80 GetHoverColor()81 const Color& GetHoverColor() const 82 { 83 return hoverColor_; 84 } 85 SetHoverColor(const Color & color)86 void SetHoverColor(const Color& color) 87 { 88 hoverColor_ = color; 89 } 90 91 private: 92 Color hoverColor_; 93 Color blockColor_; 94 Dimension blockSize_; 95 Dimension hotRegionWidth_; 96 Dimension hotRegionHeight_; 97 }; 98 99 class CircleBlock : public BlockComponent { 100 DECLARE_ACE_TYPE(CircleBlock, BlockComponent); 101 102 public: 103 CircleBlock() = default; 104 ~CircleBlock() override = default; 105 106 RefPtr<RenderNode> CreateRenderNode() override; 107 }; 108 109 } // namespace OHOS::Ace 110 111 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SLIDER_BLOCK_COMPONENT_H 112