1 /* 2 * Copyright (c) 2021 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_WATCH_SLIDER_WATCH_SLIDER_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_WATCH_SLIDER_WATCH_SLIDER_COMPONENT_H 18 19 #include <string> 20 21 #include "core/components/common/properties/color.h" 22 #include "core/components/common/rotation/rotation_controller.h" 23 #include "core/event/ace_event_handler.h" 24 #include "core/pipeline/base/element.h" 25 #include "core/pipeline/base/render_component.h" 26 27 namespace OHOS::Ace { 28 29 class WatchSliderComponent : public RenderComponent { 30 DECLARE_ACE_TYPE(WatchSliderComponent, RenderComponent); 31 32 public: WatchSliderComponent()33 WatchSliderComponent() : rotationController_(AceType::MakeRefPtr<RotationController>()) {} 34 ~WatchSliderComponent() override = default; 35 36 RefPtr<Element> CreateElement() override; 37 RefPtr<RenderNode> CreateRenderNode() override; 38 GetMinValue()39 double GetMinValue() const 40 { 41 return min_; 42 } 43 SetMinValue(double min)44 void SetMinValue(double min) 45 { 46 min_ = min; 47 } 48 GetMaxValue()49 double GetMaxValue() const 50 { 51 return max_; 52 } 53 SetMaxValue(double min)54 void SetMaxValue(double min) 55 { 56 max_ = min; 57 } 58 GetStep()59 double GetStep() const 60 { 61 return step_; 62 } 63 SetStep(double step)64 void SetStep(double step) 65 { 66 step_ = step; 67 } 68 GetValue()69 double GetValue() const 70 { 71 return value_; 72 } 73 SetValue(double value)74 void SetValue(double value) 75 { 76 value_ = value; 77 } 78 GetOnMoveEndEventId()79 const EventMarker& GetOnMoveEndEventId() const 80 { 81 return onMoveEndEventId_; 82 } 83 SetOnMoveEndEventId(const EventMarker & methodId)84 void SetOnMoveEndEventId(const EventMarker& methodId) 85 { 86 onMoveEndEventId_ = methodId; 87 } 88 GetOnMovingEventId()89 const EventMarker& GetOnMovingEventId() const 90 { 91 return onMovingEventId_; 92 } 93 SetOnMovingEventId(const EventMarker & methodId)94 void SetOnMovingEventId(const EventMarker& methodId) 95 { 96 onMovingEventId_ = methodId; 97 } 98 GetMinIconUrl()99 const std::string& GetMinIconUrl() const 100 { 101 return minIconUrl_; 102 } 103 SetMinIconUrl(const std::string & url)104 void SetMinIconUrl(const std::string& url) 105 { 106 minIconUrl_ = url; 107 } 108 GetMaxIconUrl()109 const std::string& GetMaxIconUrl() const 110 { 111 return maxIconUrl_; 112 } 113 SetMaxIconUrl(const std::string & url)114 void SetMaxIconUrl(const std::string& url) 115 { 116 maxIconUrl_ = url; 117 } 118 GetBackgroundColor()119 const Color& GetBackgroundColor() const 120 { 121 return color_; 122 } 123 SetBackgroundColor(const Color & color)124 void SetBackgroundColor(const Color& color) 125 { 126 color_ = color; 127 } 128 GetSelectColor()129 const Color& GetSelectColor() const 130 { 131 return selectColor_; 132 } 133 SetSelectColor(const Color & color)134 void SetSelectColor(const Color& color) 135 { 136 selectColor_ = color; 137 } 138 GetContinuous()139 bool GetContinuous() const 140 { 141 return isContinuous_; 142 } 143 SetContinuous(bool flag)144 void SetContinuous(bool flag) 145 { 146 isContinuous_ = flag; 147 } 148 GetRotationController()149 const RefPtr<RotationController>& GetRotationController() const 150 { 151 return rotationController_; 152 } 153 SetDisable(bool disable)154 void SetDisable(bool disable) 155 { 156 isDisable_ = disable; 157 } 158 GetDisable()159 bool GetDisable() const 160 { 161 return isDisable_; 162 } 163 164 private: 165 double max_ = 100.0; 166 double min_ = 0.0; 167 double step_ = 1.0; 168 double value_ = 100.0; 169 bool isDisable_ = false; 170 std::string minIconUrl_; 171 std::string maxIconUrl_; 172 Color color_; 173 Color selectColor_; 174 EventMarker onMoveEndEventId_; 175 EventMarker onMovingEventId_; 176 bool isContinuous_ = true; 177 178 RefPtr<RotationController> rotationController_; 179 }; 180 181 } // namespace OHOS::Ace 182 183 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_WATCH_SLIDER_WATCH_SLIDER_COMPONENT_H 184