• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PATTERNS_SLIDER_SLIDER_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SLIDER_SLIDER_MODEL_H
18 
19 #include <functional>
20 #include <memory>
21 #include <mutex>
22 #include <optional>
23 
24 #include "base/geometry/axis.h"
25 #include "base/memory/ace_type.h"
26 #include "base/utils/macros.h"
27 #include "core/components/common/properties/clip_path.h"
28 #include "core/components/common/properties/color.h"
29 
30 namespace OHOS::Ace {
31 class ACE_EXPORT SliderModel {
32 public:
33     enum class SliderMode {
34         OUTSET,  // block on track, track is thin
35         INSET,   // block inside track, track is rough
36         CAPSULE, // capsule slider.
37     };
38 
39     enum class BlockStyleType {
40         DEFAULT,
41         IMAGE,
42         SHAPE,
43     };
44 
45     static SliderModel* GetInstance();
46     virtual ~SliderModel() = default;
47 
48     virtual void Create(float value, float step, float min, float max) = 0;
49     virtual void SetSliderMode(const SliderMode& value) = 0;
50     virtual void SetDirection(Axis value) = 0;
51     virtual void SetReverse(bool value) = 0;
52     virtual void SetBlockColor(const Color& value) = 0;
53     virtual void SetTrackBackgroundColor(const Color& value) = 0;
54     virtual void SetSelectColor(const Color& value) = 0;
55     virtual void SetMinLabel(float value) = 0;
56     virtual void SetMaxLabel(float value) = 0;
57     virtual void SetShowSteps(bool value) = 0;
58     virtual void SetShowTips(bool value, const std::optional<std::string>& content) = 0;
59     virtual void SetThickness(const Dimension& value) = 0;
60     virtual void SetBlockBorderColor(const Color& value) = 0;
61     virtual void SetBlockBorderWidth(const Dimension& value) = 0;
62     virtual void SetStepColor(const Color& value) = 0;
63     virtual void SetTrackBorderRadius(const Dimension& value) = 0;
64     virtual void SetBlockSize(const Dimension& width, const Dimension& height) = 0;
65     virtual void SetBlockType(BlockStyleType value) = 0;
66     virtual void SetBlockImage(const std::string& value) = 0;
67     virtual void SetBlockShape(const RefPtr<BasicShape>& value) = 0;
68     virtual void SetStepSize(const Dimension& value) = 0;
69     virtual void SetOnChange(std::function<void(float, int32_t)>&& eventOnChange) = 0;
70     virtual void SetOnChangeEvent(std::function<void(float)>&& onChangeEvent) = 0;
71 
72     virtual void ResetBlockBorderColor() = 0;
73     virtual void ResetBlockBorderWidth() = 0;
74     virtual void ResetStepColor() = 0;
75     virtual void ResetTrackBorderRadius() = 0;
76     virtual void ResetBlockSize() = 0;
77     virtual void ResetBlockType() = 0;
78     virtual void ResetBlockImage() = 0;
79     virtual void ResetBlockShape() = 0;
80     virtual void ResetStepSize() = 0;
81 
82 private:
83     static std::unique_ptr<SliderModel> instance_;
84     static std::mutex mutex_;
85 };
86 
87 } // namespace OHOS::Ace
88 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SLIDER_SLIDER_MODEL_H
89