Simplify time representation; better in-tree DCP subtitle parser.
[libsub.git] / src / raw_subtitle.h
1 /*
2     Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef LIBSUB_RAW_SUBTITLE_H
21 #define LIBSUB_RAW_SUBTITLE_H
22
23 #include "sub_time.h"
24 #include "colour.h"
25 #include "vertical_reference.h"
26 #include "effect.h"
27 #include "font_size.h"
28 #include "vertical_position.h"
29 #include <boost/optional.hpp>
30 #include <string>
31 #include <list>
32
33 namespace sub {
34
35 /** @class RawSubtitle
36  *  @brief A bit of a subtitle, created with no regard for any nearby bits.
37  */
38 class RawSubtitle
39 {
40 public:
41         RawSubtitle ()
42                 : colour (1, 1, 1)
43                 , bold (false)
44                 , italic (false)
45                 , underline (false)
46         {}
47
48         /** Subtitle text in UTF-8 */
49         std::string text;
50         boost::optional<std::string> font;
51
52         /** font size */
53         FontSize font_size;
54
55         boost::optional<Effect> effect;
56         boost::optional<Colour> effect_colour;
57         
58         Colour colour;
59         bool bold;      ///< true to use a bold version of font
60         bool italic;    ///< true to use an italic version of font
61         bool underline; ///< true to underline
62
63         /** vertical position of the baseline of the text */
64         VerticalPosition vertical_position;
65
66         /** from time */
67         Time from;
68         /** to time */
69         Time to;
70         
71         boost::optional<Time> fade_up;
72         boost::optional<Time> fade_down;
73 };
74
75 bool operator< (RawSubtitle const &, RawSubtitle const &);      
76
77 }
78
79 #endif