X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fsubtitle_string.h;h=2317af5f21a19d06d58d82a6121282780702aa36;hb=d97e1600057d796c4163cecf28f9f04a6ea6402b;hp=076a6ec7437210b9dfcbd11a76c67512cdd2736d;hpb=77b0ffe6c50796b8fb132f56394995e0df089713;p=libdcp.git diff --git a/src/subtitle_string.h b/src/subtitle_string.h index 076a6ec7..2317af5f 100644 --- a/src/subtitle_string.h +++ b/src/subtitle_string.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,35 +17,47 @@ */ +/** @file src/subtitle_string.h + * @brief SubtitleString class. + */ + #ifndef LIBDCP_SUBTITLE_STRING_H #define LIBDCP_SUBTITLE_STRING_H #include "types.h" #include "dcp_time.h" +#include #include namespace dcp { +/** @class SubtitleString + * @brief A single line of subtitle text with all the associated attributes. + */ class SubtitleString { public: SubtitleString ( - std::string font, + boost::optional font, bool italic, - Color color, + Colour colour, int size, + float aspect_adjust, Time in, Time out, + float h_position, + HAlign h_align, float v_position, VAlign v_align, std::string text, Effect effect, - Color effect_color, + Colour effect_colour, Time fade_up_time, Time fade_down_time ); - std::string font () const { + /** @return font ID */ + boost::optional font () const { return _font; } @@ -53,8 +65,8 @@ public: return _italic; } - Color color () const { - return _color; + Colour colour () const { + return _colour; } Time in () const { @@ -69,6 +81,17 @@ public: return _text; } + float h_position () const { + return _h_position; + } + + HAlign h_align () const { + return _h_align; + } + + /** @return vertical position as a proportion of the screen height from the top + * (between 0 and 1) + */ float v_position () const { return _v_position; } @@ -81,8 +104,8 @@ public: return _effect; } - Color effect_color () const { - return _effect_color; + Colour effect_colour () const { + return _effect_colour; } Time fade_up_time () const { @@ -96,27 +119,71 @@ public: int size () const { return _size; } - + int size_in_pixels (int screen_height) const; + /** @return Aspect ratio `adjustment' of the font size. + * Values greater than 1 widen each character, values less than 1 narrow each character, + * and the value must be between 0.25 and 4. + */ + float aspect_adjust () const { + return _aspect_adjust; + } + + void set_in (Time i) { + _in = i; + } + + void set_out (Time o) { + _out = o; + } + + void set_h_position (float p) { + _h_position = p; + } + + /** @param p New vertical position as a proportion of the screen height + * from the top (between 0 and 1) + */ + void set_v_position (float p) { + _v_position = p; + } + + void set_size (int s) { + _size = s; + } + + void set_aspect_adjust (float a) { + _aspect_adjust = a; + } + private: - std::string _font; + /** font ID */ + boost::optional _font; + /** true if the text is italic */ bool _italic; - Color _color; + /** text colour */ + Colour _colour; /** Size in points as if the screen height is 11 inches, so a 72pt font * would be 1/11th of the screen height. - */ + */ int _size; + float _aspect_adjust; Time _in; Time _out; - /** Vertical position as a proportion of the screen height from the top + /** Horizontal position as a proportion of the screen width from the _h_align + * (between 0 and 1) + */ + float _h_position; + HAlign _h_align; + /** Vertical position as a proportion of the screen height from the _v_align * (between 0 and 1) */ float _v_position; VAlign _v_align; std::string _text; Effect _effect; - Color _effect_color; + Colour _effect_colour; Time _fade_up_time; Time _fade_down_time; };