summaryrefslogtreecommitdiffstats
path: root/xbmc/settings/SubtitlesSettings.h
blob: 3927de10690fd6fbc7281b14cacd1d84b57df260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
 *  Copyright (C) 2012-2021 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "settings/lib/ISettingCallback.h"
#include "utils/ColorUtils.h"
#include "utils/Observer.h"

#include <memory>
#include <string>

class CSetting;
class CSettings;
struct StringSettingOption;

namespace KODI
{
namespace SUBTITLES
{
// This is a placeholder to keep the fontname setting valid
// even if the default app font could be changed
constexpr const char* FONT_DEFAULT_FAMILYNAME = "DEFAULT";

enum class Align
{
  MANUAL = 0,
  BOTTOM_INSIDE,
  BOTTOM_OUTSIDE,
  TOP_INSIDE,
  TOP_OUTSIDE
};

enum class HorizontalAlign
{
  LEFT = 0,
  CENTER,
  RIGHT
};

enum class BackgroundType
{
  NONE = 0,
  SHADOW,
  BOX,
  SQUAREBOX
};

enum class FontStyle
{
  NORMAL = 0,
  BOLD,
  ITALIC,
  BOLD_ITALIC
};

enum class OverrideStyles
{
  DISABLED = 0,
  POSITIONS,
  STYLES,
  STYLES_POSITIONS
};

class CSubtitlesSettings : public ISettingCallback, public Observable
{
public:
  explicit CSubtitlesSettings(const std::shared_ptr<CSettings>& settings);
  ~CSubtitlesSettings() override;

  // Inherited from ISettingCallback
  void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;

  /*!
   * \brief Get subtitle alignment
   * \return The alignment
   */
  Align GetAlignment();

  /*!
   * \brief Set the subtitle alignment
   * \param align The alignment
   */
  void SetAlignment(Align align);

  /*!
   * \brief Get horizontal text alignment
   * \return The alignment
   */
  HorizontalAlign GetHorizontalAlignment();

  /*!
   * \brief Get font name
   * \return The font name
   */
  std::string GetFontName();

  /*!
   * \brief Get font style
   * \return The font style
   */
  FontStyle GetFontStyle();

  /*!
   * \brief Get font size
   * \return The font size in PX
   */
  int GetFontSize();

  /*!
   * \brief Get font color
   * \return The font color
   */
  UTILS::COLOR::Color GetFontColor();

  /*!
   * \brief Get font opacity
   * \return The font opacity in %
   */
  int GetFontOpacity();

  /*!
   * \brief Get border size
   * \return The border size in %
   */
  int GetBorderSize();

  /*!
   * \brief Get border color
   * \return The border color
   */
  UTILS::COLOR::Color GetBorderColor();

  /*!
   * \brief Get shadow size
   * \return The shadow size in %
   */
  int GetShadowSize();

  /*!
   * \brief Get shadow color
   * \return The shadow color
   */
  UTILS::COLOR::Color GetShadowColor();

  /*!
   * \brief Get shadow opacity
   * \return The shadow opacity in %
   */
  int GetShadowOpacity();

  /*!
   * \brief Get blur size
   * \return The blur size in %
   */
  int GetBlurSize();

  /*!
   * \brief Get background type
   * \return The background type
   */
  BackgroundType GetBackgroundType();

  /*!
   * \brief Get background color
   * \return The background color
   */
  UTILS::COLOR::Color GetBackgroundColor();

  /*!
   * \brief Get background opacity
   * \return The background opacity in %
   */
  int GetBackgroundOpacity();

  /*!
   * \brief Check if font override is enabled
   * \return True if fonts must be overriden, otherwise false
   */
  bool IsOverrideFonts();

  /*!
   * \brief Get override styles
   * \return The styles to be overriden
   */
  OverrideStyles GetOverrideStyles();

  /*!
   * \brief Get the subtitle vertical margin
   * \return The vertical margin in %
   */
  float GetVerticalMarginPerc();

  static void SettingOptionsSubtitleFontsFiller(const std::shared_ptr<const CSetting>& setting,
                                                std::vector<StringSettingOption>& list,
                                                std::string& current,
                                                void* data);

private:
  CSubtitlesSettings() = delete;

  const std::shared_ptr<CSettings> m_settings;
};

} // namespace SUBTITLES
} // namespace KODI