X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fsubtitle.h;h=2b6867d4aad695b6b82020239ac1852794a9e3f9;hb=1c82568fa688351444b56dd190de33df29f688f5;hp=3afd0f33b5f95921efbbad641b6d19c73d4ee297;hpb=c8c3db36a4593e396681b4acd5e9d318a28b1648;p=libsub.git diff --git a/src/subtitle.h b/src/subtitle.h index 3afd0f3..2b6867d 100644 --- a/src/subtitle.h +++ b/src/subtitle.h @@ -20,56 +20,113 @@ #ifndef LIBSUB_SUBTITLE_H #define LIBSUB_SUBTITLE_H -#include "frame_time.h" +#include "colour.h" +#include "vertical_reference.h" +#include "effect.h" +#include "font_size.h" +#include "vertical_position.h" +#include "horizontal_position.h" +#include "raw_subtitle.h" #include #include +#include namespace sub { -class Subtitle +/** @class Block + * @brief A block of text within a subtitle's line + * + * This represents a block of text which has a particular style (font, size, effect, colour etc.) + */ +class Block { public: - Subtitle () - : font_size (0) + Block () + : colour (1, 1, 1) , bold (false) , italic (false) , underline (false) - , line (0) {} - Subtitle ( - std::string text, - std::string font, - int font_size, - bool bold, - bool italic, - bool underline, - int line, - FrameTime from, - FrameTime to - ) - : text (text) - , font (font) - , font_size (font_size) - , bold (bold) - , italic (italic) - , underline (underline) - , line (line) - , frame_from (from) - , frame_to (to) - {} + /** Construct a Block taking any relevant information from a RawSubtitle */ + Block (RawSubtitle s); + /** Subtitle text in UTF-8 */ std::string text; - std::string font; - int font_size; - bool bold; - bool italic; - bool underline; - int line; - boost::optional frame_from; - boost::optional frame_to; + boost::optional font; + + /** font size */ + FontSize font_size; + + boost::optional effect; + boost::optional effect_colour; + + Colour colour; + bool bold; ///< true to use a bold version of font + bool italic; ///< true to use an italic version of font + bool underline; ///< true to underline +}; + +extern bool operator== (Block const & a, Block const & b); + +/** @class Line + * @brief A line of text within a subtitle. + * + * This represents a line of text which has a particular vertical position. + */ +class Line +{ +public: + Line () + { + horizontal_position.reference = HORIZONTAL_CENTRE_OF_SCREEN; + } + + /** Construct a Line taking any relevant information from a RawSubtitle */ + Line (RawSubtitle s); + + HorizontalPosition horizontal_position; + + /** vertical position of the baseline of the text */ + VerticalPosition vertical_position; + + std::list blocks; + + bool same_metadata (RawSubtitle) const; }; +extern bool operator== (Line const & a, Line const & b); + +/** @class Subtitle + * @brief A subtitle which has been collected into lines and blocks. + * + * This represents a chunk of text which appears and disappears at some particular + * times. + */ +class Subtitle +{ +public: + Subtitle () + {} + + /** Construct a Line taking any relevant information from a RawSubtitle */ + Subtitle (RawSubtitle s); + + /** from time */ + Time from; + /** to time */ + Time to; + + boost::optional