• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 ROSEN_TEXT_EXPORT_ROSEN_TEXT_HM_SYMBOL_TXT_H
17 #define ROSEN_TEXT_EXPORT_ROSEN_TEXT_HM_SYMBOL_TXT_H
18 
19 #include <bitset>
20 #include <cstdint>
21 #include <iostream>
22 #include <memory>
23 #include <vector>
24 
25 #include "draw/color.h"
26 #include "symbol_constants.h"
27 #include "symbol_gradient.h"
28 #include "text/hm_symbol.h"
29 
30 
31 namespace OHOS {
32 namespace Rosen {
33 enum class RelayoutSymbolStyleAttribute {
34     EFFECT_STRATEGY = 0,
35     ANIMATION_MODE = 1,
36     ANIMATION_START = 2,
37     COMMONSUB_TYPE = 3,
38     COLOR_LIST = 4,
39     RENDER_MODE = 5,
40     GRADIENT_COLOR = 6,
41     SYMBOL_SHADOW = 7,
42 
43     SYMBOL_ATTRIBUTE_BUTT,
44 };
45 
46 enum VisualMode {
47     VISUAL_MEDIUM = 0,
48     VISUAL_SMALL = 1,
49     VISUAL_LARGER = 2
50 };
51 
52 using SymbolBitmapType = std::bitset<static_cast<size_t>(RelayoutSymbolStyleAttribute::SYMBOL_ATTRIBUTE_BUTT)>;
53 
54 struct SymbolColor {
55     SymbolColorType colorType = SymbolColorType::COLOR_TYPE;
56     std::vector<std::shared_ptr<SymbolGradient>> gradients;
57 };
58 
59 class RS_EXPORT HMSymbolTxt {
60 public:
HMSymbolTxt()61     HMSymbolTxt() {}
62     HMSymbolTxt(const HMSymbolTxt& other) = default;
63     HMSymbolTxt& operator=(const HMSymbolTxt& other) = default;
~HMSymbolTxt()64     ~HMSymbolTxt() {}
65 
66     void SetRenderColor(const std::vector<Drawing::DrawingSColor>& colorList);
67 
68     void SetRenderColor(const std::vector<Drawing::Color>& colorList);
69 
70     void SetRenderColor(const Drawing::Color& color);
71 
72     void SetRenderColor(const Drawing::DrawingSColor& colorList);
73 
74     void SetRenderMode(const uint32_t& renderMode);
75 
76     void SetSymbolEffect(const uint32_t& effectStrategy);
77 
78     // set animation mode: the 1 is whole or iteratuve, 0 is hierarchical or cumulative
79     void SetAnimationMode(const uint16_t animationMode);
80 
81     void SetRepeatCount(const int repeatCount);
82 
83     void SetAnimationStart(const bool animationStart);
84 
85     // set common subtype of symbol animation attribute
86     void SetCommonSubType(Drawing::DrawingCommonSubType commonSubType);
87 
88     void SetVisualMode(const VisualMode visual);
89 
90     void SetSymbolType(SymbolType symbolType);
91 
92     void SetSymbolUid(const size_t symbolUid);
93 
94     void SetSymbolBitmap(const SymbolBitmapType& symbolStyleBitmap);
95 
96     std::vector<Drawing::DrawingSColor> GetRenderColor() const;
97 
98     Drawing::DrawingSymbolRenderingStrategy GetRenderMode() const;
99 
100     Drawing::DrawingEffectStrategy GetEffectStrategy() const;
101 
102     uint16_t GetAnimationMode() const;
103 
104     int GetRepeatCount() const;
105 
106     bool GetAnimationStart() const;
107 
108     std::map<std::string, int> GetVisualMap() const;
109 
110     Drawing::DrawingCommonSubType GetCommonSubType() const;
111 
112     SymbolType GetSymbolType() const;
113 
114     size_t GetSymbolUid() const;
115 
116     const SymbolBitmapType& GetSymbolBitmap() const;
117 
118     SymbolColor GetSymbolColor() const;
119 
120     void SetSymbolColor(const SymbolColor& symbolColor);
121 
122     void SetSymbolShadow(const std::optional<SymbolShadow>& symbolShadow);
123 
124     const std::optional<SymbolShadow>& GetSymbolShadow() const;
125 private:
126     SymbolColor symbolColor_;
127     Drawing::DrawingSymbolRenderingStrategy renderMode_ = Drawing::DrawingSymbolRenderingStrategy::SINGLE;
128     Drawing::DrawingEffectStrategy effectStrategy_ = Drawing::DrawingEffectStrategy::NONE;
129 
130     // animationMode_ is the implementation mode of the animation effect:
131     // common_animations: the 0 is the byLayer effect and 1 is the wholeSymbol effect;
132     // variable_color : the 0 is the cumulative effect and 1 is the iteratuve effect.
133     size_t symbolUid_ { 0 };
134     uint16_t animationMode_ { 0 };
135     int repeatCount_ { 1 };
136     bool animationStart_ { false };
137     std::map<std::string, int> visualMap_;
138     Drawing::DrawingCommonSubType commonSubType_ = Drawing::DrawingCommonSubType::DOWN;
139     SymbolType symbolType_{SymbolType::SYSTEM};
140     SymbolBitmapType relayoutChangeBitmap_;
141     std::optional<SymbolShadow> symbolShadow_;
142 };
143 }
144 }
145 #endif