X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fsubtitle.h;h=2d22dac651bf1965200df7114caeb3356aa7edee;hb=f187e4a08ca777c6e3e5de8037d165f9eea262f2;hp=70a8eb6d0ed73f98ef8547353b3bfb867cbb2219;hpb=8181d97d7f9ef0d44af748a5bd5666cf575955fe;p=libsub.git diff --git a/src/subtitle.h b/src/subtitle.h index 70a8eb6..2d22dac 100644 --- a/src/subtitle.h +++ b/src/subtitle.h @@ -20,82 +20,100 @@ #ifndef LIBSUB_SUBTITLE_H #define LIBSUB_SUBTITLE_H -#include "frame_time.h" -#include "metric_time.h" #include "colour.h" #include "vertical_reference.h" #include "effect.h" +#include "font_size.h" +#include "vertical_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 () + Block () : colour (1, 1, 1) , bold (false) , italic (false) , underline (false) - , line (0) {} + /** Construct a Block taking any relevant information from a RawSubtitle */ + Block (RawSubtitle s); + + /** Subtitle text in UTF-8 */ std::string text; - std::string font; + boost::optional font; /** font size */ - struct { - /** as a proportion of screen height */ - boost::optional proportional; - /** in points */ - boost::optional points; - } font_size; - - float font_size_proportional (int screen_height_in_points) const; - int font_size_points (int screen_height_in_points) const; - - /** vertical position of the baseline of the text */ - struct { - /** as a proportion of screen height offset from some reference point */ - boost::optional proportional; - /** reference position for proportional */ - boost::optional reference; - } vertical_position; + 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 - int line; +}; - /** from time */ - struct { - boost::optional frame; - boost::optional metric; - } from; +/** @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 () {} - FrameTime from_frame (float frames_per_second) const; - MetricTime from_metric (float frames_per_second) const; + /** Construct a Line taking any relevant information from a RawSubtitle */ + Line (RawSubtitle s); - /** to time */ - struct { - boost::optional frame; - boost::optional metric; - } to; - - FrameTime to_frame (float frames_per_second) const; - MetricTime to_metric (float frames_per_second) const; - - boost::optional fade_up; - boost::optional fade_down; + /** vertical position of the baseline of the text */ + VerticalPosition vertical_position; + + std::list blocks; + + bool same_metadata (RawSubtitle) const; }; -bool operator< (Subtitle const & a, Subtitle 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