2 Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef DCPOMATIC_SUBTITLE_CONTENT_H
22 #define DCPOMATIC_SUBTITLE_CONTENT_H
24 #include "content_part.h"
25 #include <libcxml/cxml.h>
26 #include <dcp/types.h>
27 #include <boost/signals2.hpp>
31 class SubtitleContentProperty
34 static int const X_OFFSET;
35 static int const Y_OFFSET;
36 static int const X_SCALE;
37 static int const Y_SCALE;
39 static int const BURN;
40 static int const LANGUAGE;
41 static int const FONTS;
42 static int const COLOUR;
43 static int const OUTLINE;
44 static int const OUTLINE_COLOUR;
47 /** @class SubtitleContent
48 * @brief Description of how some subtitle content should be presented.
50 * There are `image' subtitles (bitmaps) and `text' subtitles (plain text),
51 * and not all of the settings in this class correspond to both types.
53 class SubtitleContent : public ContentPart
56 SubtitleContent (Content* parent);
57 SubtitleContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
59 void as_xml (xmlpp::Node *) const;
60 std::string identifier () const;
62 void add_font (boost::shared_ptr<Font> font);
66 void set_x_offset (double);
67 void set_y_offset (double);
68 void set_x_scale (double);
69 void set_y_scale (double);
70 void set_language (std::string language);
73 boost::mutex::scoped_lock lm (_mutex);
78 boost::mutex::scoped_lock lm (_mutex);
82 double x_offset () const {
83 boost::mutex::scoped_lock lm (_mutex);
87 double y_offset () const {
88 boost::mutex::scoped_lock lm (_mutex);
92 double x_scale () const {
93 boost::mutex::scoped_lock lm (_mutex);
97 double y_scale () const {
98 boost::mutex::scoped_lock lm (_mutex);
102 std::list<boost::shared_ptr<Font> > fonts () const {
103 boost::mutex::scoped_lock lm (_mutex);
107 std::string language () const {
108 boost::mutex::scoped_lock lm (_mutex);
112 void set_colour (dcp::Colour);
114 dcp::Colour colour () const {
115 boost::mutex::scoped_lock lm (_mutex);
119 void set_outline (bool);
121 bool outline () const {
122 boost::mutex::scoped_lock lm (_mutex);
126 void set_outline_colour (dcp::Colour);
128 dcp::Colour outline_colour () const {
129 boost::mutex::scoped_lock lm (_mutex);
130 return _outline_colour;
133 static boost::shared_ptr<SubtitleContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
136 /** subtitle language (e.g. "German") or empty if it is not known */
137 std::string _language;
140 friend struct ffmpeg_pts_offset_test;
142 SubtitleContent (Content* parent, cxml::ConstNodePtr, int version);
143 void font_changed ();
144 void connect_to_fonts ();
148 /** x offset for placing subtitles, as a proportion of the container width;
149 * +ve is further right, -ve is further left.
152 /** y offset for placing subtitles, as a proportion of the container height;
153 * +ve is further down the frame, -ve is further up.
156 /** x scale factor to apply to subtitles */
158 /** y scale factor to apply to subtitles */
160 std::list<boost::shared_ptr<Font> > _fonts;
163 dcp::Colour _outline_colour;
164 std::list<boost::signals2::connection> _font_connections;