xbmc
SubtitlesStyle.h
1 /*
2  * Copyright (C) 2005-2021 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "utils/ColorUtils.h"
12 
13 #include <string>
14 
15 namespace KODI
16 {
17 namespace SUBTITLES
18 {
19 namespace STYLE
20 {
21 
22 constexpr double VIEWPORT_HEIGHT = 1080.0;
23 constexpr double VIEWPORT_WIDTH = 1920.0;
24 constexpr int MARGIN_VERTICAL = 75;
25 
26 enum class HorizontalAlign
27 {
28  DISABLED = 0,
29  LEFT,
30  CENTER,
31  RIGHT
32 };
33 
34 enum class FontAlign
35 {
36  TOP_LEFT = 0,
37  TOP_CENTER,
38  TOP_RIGHT,
39  MIDDLE_LEFT,
40  MIDDLE_CENTER,
41  MIDDLE_RIGHT,
42  SUB_LEFT,
43  SUB_CENTER,
44  SUB_RIGHT
45 };
46 
47 enum class FontStyle
48 {
49  NORMAL = 0,
50  BOLD,
51  ITALIC,
52  BOLD_ITALIC
53 };
54 
55 enum class BorderType
56 {
57  OUTLINE_NO_SHADOW,
58  OUTLINE,
59  BOX,
60  SQUARE_BOX
61 };
62 
63 enum class OverrideStyles
64 {
65  DISABLED = 0,
66  POSITIONS,
67  STYLES,
68  STYLES_POSITIONS
69 };
70 
71 enum class MarginsMode
72 {
73  // Use style margins only
74  DEFAULT,
75  // Apply margins to position text within the video area (cropped videos)
76  INSIDE_VIDEO,
77  // Disable any kind of margin
78  DISABLED
79 };
80 
81 struct style
82 {
83  std::string fontName; // Font family name
84  double fontSize; // Font size in pixel
85  FontStyle fontStyle = FontStyle::NORMAL;
86  UTILS::COLOR::Color fontColor = UTILS::COLOR::WHITE;
87  int fontBorderSize = 15; // In %
88  UTILS::COLOR::Color fontBorderColor = UTILS::COLOR::BLACK;
89  int fontOpacity = 100; // In %
90  BorderType borderStyle = BorderType::OUTLINE;
91  UTILS::COLOR::Color backgroundColor = UTILS::COLOR::BLACK;
92  int backgroundOpacity = 0; // In %
93  int shadowSize = 0; // In %
94  UTILS::COLOR::Color shadowColor = UTILS::COLOR::BLACK;
95  int shadowOpacity = 100; // In %
96  FontAlign alignment = FontAlign::TOP_LEFT;
97  // Override styles to native ASS/SSA format type only
98  OverrideStyles assOverrideStyles = OverrideStyles::DISABLED;
99  // Override fonts to native ASS/SSA format type only
100  bool assOverrideFont = false;
101  // Vertical margin value in pixels scaled for VIEWPORT_HEIGHT
102  int marginVertical = MARGIN_VERTICAL;
103  int blur = 0; // In %
104 };
105 
107 {
108  bool useMargins = false;
109  int marginLeft;
110  int marginRight;
111  int marginVertical;
112 };
113 
115 {
116  float frameWidth;
117  float frameHeight;
118  // Video size width, may be influenced by video settings (e.g. zoom)
119  float videoWidth;
120  // Video size height, may be influenced by video settings (e.g. zoom)
121  float videoHeight;
122  float sourceWidth;
123  float sourceHeight;
124  float m_par; // Set the pixel aspect ratio
125  MarginsMode marginsMode = MarginsMode::DEFAULT;
126  // Vertical line position of subtitles in percentage
127  // only for bottom alignment, 0 = bottom (no change), 100 = on top
128  double position = 0;
129  HorizontalAlign horizontalAlignment = HorizontalAlign::DISABLED;
130 };
131 
132 } // namespace STYLE
133 } // namespace SUBTITLES
134 } // namespace KODI
Definition: SubtitlesStyle.h:114
Controller configuration window.
Definition: AudioDecoder.h:18
Definition: SubtitlesStyle.h:81
Definition: SubtitlesStyle.h:106