diff options
Diffstat (limited to 'src/text_string.h')
| -rw-r--r-- | src/text_string.h | 83 |
1 files changed, 69 insertions, 14 deletions
diff --git a/src/text_string.h b/src/text_string.h index 78788786..bd668a0d 100644 --- a/src/text_string.h +++ b/src/text_string.h @@ -45,6 +45,7 @@ #include "ruby.h" #include "text.h" #include <boost/optional.hpp> +#include <boost/variant.hpp> #include <string> @@ -52,7 +53,7 @@ namespace dcp { /** @class TextString - * @brief A single line of subtitle text with all the associated attributes. + * @brief A single piece of subtitle text with all the associated attributes. */ class TextString : public Text { @@ -103,8 +104,57 @@ public: Colour effect_colour, Time fade_up_time, Time fade_down_time, - float space_before, - std::vector<Ruby> rubies + float space_before + ); + + TextString( + boost::optional<std::string> font, + bool italic, + bool bold, + bool underline, + Colour colour, + int size, + float aspect_adjust, + Time in, + Time out, + float h_position, + HAlign h_align, + float v_position, + VAlign v_align, + float z_position, + std::vector<VariableZPosition> variable_z_positions, + Direction direction, + Ruby text, + Effect effect, + Colour effect_colour, + Time fade_up_time, + Time fade_down_time, + float space_before + ); + + TextString( + boost::optional<std::string> font, + bool italic, + bool bold, + bool underline, + Colour colour, + int size, + float aspect_adjust, + Time in, + Time out, + float h_position, + HAlign h_align, + float v_position, + VAlign v_align, + float z_position, + std::vector<VariableZPosition> variable_z_positions, + Direction direction, + boost::variant<std::string, Ruby> text, + Effect effect, + Colour effect_colour, + Time fade_up_time, + Time fade_down_time, + float space_before ); /** @return font ID */ @@ -128,10 +178,24 @@ public: return _colour; } - std::string text () const { + boost::variant<std::string, Ruby> text() const { return _text; } + boost::optional<std::string> string_text() const { + if (_text.which() != 0) { + return {}; + } + return boost::get<std::string>(_text); + } + + boost::optional<Ruby> ruby_text() const { + if (_text.which() != 1) { + return {}; + } + return boost::get<Ruby>(_text); + } + Direction direction () const { return _direction; } @@ -162,10 +226,6 @@ public: return _aspect_adjust; } - std::vector<Ruby> const& rubies() const { - return _rubies; - } - void set_font (std::string id) { _font = id; } @@ -198,10 +258,6 @@ public: _effect_colour = c; } - void set_rubies(std::vector<Ruby> rubies) { - _rubies = std::move(rubies); - } - bool equals(std::shared_ptr<const dcp::Text> other_sub, EqualityOptions const& options, NoteHandler node) const override; private: @@ -221,11 +277,10 @@ private: int _size; float _aspect_adjust; Direction _direction; - std::string _text; + boost::variant<std::string, Ruby> _text; Effect _effect; Colour _effect_colour; float _space_before; - std::vector<Ruby> _rubies; }; |
