/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
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
*/
+/** @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 <boost/optional.hpp>
#include <string>
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<std::string> 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<std::string> font () const {
return _font;
}
return _italic;
}
- Color color () const {
- return _color;
+ Colour colour () const {
+ return _colour;
}
Time in () const {
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;
}
return _effect;
}
- Color effect_color () const {
- return _effect_color;
+ Colour effect_colour () const {
+ return _effect_colour;
}
Time fade_up_time () const {
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_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<std::string> _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;
};