Line data Source code
1 : /**
2 : Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
3 :
4 : Permission is hereby granted, free of charge, to any person obtaining a copy
5 : of this software and associated documentation files (the "Software"), to deal
6 : in the Software without restriction, including without limitation the rights
7 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 : copies of the Software, and to permit persons to whom the Software is
9 : furnished to do so, subject to the following conditions:
10 :
11 : The above copyright notice and this permission notice shall be included in
12 : all copies or substantial portions of the Software.
13 :
14 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 : THE SOFTWARE.
21 : **/
22 :
23 : #ifndef XENOLITH_RENDERER_MATERIAL2D_BASE_MATERIALLABEL_H_
24 : #define XENOLITH_RENDERER_MATERIAL2D_BASE_MATERIALLABEL_H_
25 :
26 : #include "MaterialColorScheme.h"
27 : #include "XL2dLabel.h"
28 :
29 : namespace STAPPLER_VERSIONIZED stappler::xenolith::material2d {
30 :
31 : enum class TypescaleRole {
32 : DisplayLarge, // 57 400
33 : DisplayMedium, // 45 400
34 : DisplaySmall, // 36 400
35 : HeadlineLarge, // 32 400
36 : HeadlineMedium, // 28 400
37 : HeadlineSmall, // 24 400
38 : TitleLarge, // 22 400
39 : TitleMedium, // 16 500
40 : TitleSmall, // 14 500
41 : LabelLarge, // 14 500
42 : LabelMedium, // 12 500
43 : LabelSmall, // 11 500
44 : BodyLarge, // 16 400 0.5
45 : BodyMedium, // 14 400 0.25
46 : BodySmall, // 12 400 0.4
47 : Unknown,
48 : };
49 :
50 : class TypescaleLabel : public Label {
51 : public:
52 : static DescriptionStyle getTypescaleRoleStyle(TypescaleRole, float density = 0.0f);
53 :
54 1044 : virtual ~TypescaleLabel() { }
55 :
56 : virtual bool init(TypescaleRole);
57 : virtual bool init(TypescaleRole, StringView);
58 : virtual bool init(TypescaleRole, StringView, float w, TextAlign = TextAlign::Left);
59 :
60 0 : virtual TypescaleRole getRole() const { return _role; }
61 : virtual void setRole(TypescaleRole);
62 :
63 : virtual void setBlendColor(ColorRole, float value);
64 : virtual void setBlendColor(const Color4F &, float value);
65 0 : virtual ColorRole getBlendColorRule() const { return _blendColorRule; }
66 0 : virtual const Color4F &getBlendColor() const { return _blendColor; }
67 10 : virtual float getBlendColorValue() const { return _blendValue; }
68 :
69 : virtual void setPreserveOpacity(bool);
70 : virtual bool isPreserveOpacity() const;
71 :
72 : virtual bool visitDraw(FrameInfo &, NodeFlags parentFlags) override;
73 :
74 : protected:
75 : virtual void specializeStyle(DescriptionStyle &style, float density) const override;
76 :
77 : using Label::init;
78 :
79 : bool _preserveOpacity = false;
80 : float _blendValue = 0.0f;
81 : Color4F _blendColor = Color4F::WHITE;
82 : ColorRole _blendColorRule = ColorRole::Undefined;
83 :
84 : TypescaleRole _role = TypescaleRole::Unknown;
85 : ThemeType _themeType = ThemeType::LightTheme;
86 : };
87 :
88 : }
89 :
90 : #endif /* XENOLITH_RENDERER_MATERIAL2D_BASE_MATERIALLABEL_H_ */
|