X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fsubtitle_asset_internal.h;h=7fe142fc18518c74e0768678460b0329e1710a77;hb=2da55dbe6da21975612584365db17db2ae9935b8;hp=366123c51afaaa8a4f9f1068fd22db51459109fd;hpb=3a69e2805f4b2119194ba2357fa9895bf1ae147f;p=libdcp.git diff --git a/src/subtitle_asset_internal.h b/src/subtitle_asset_internal.h index 366123c5..7fe142fc 100644 --- a/src/subtitle_asset_internal.h +++ b/src/subtitle_asset_internal.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of libdcp. @@ -31,15 +31,25 @@ files in the program, then also delete it here. */ + +/** @file src/subtitle_asset_internal.h + * @brief Internal SubtitleAsset helpers + */ + + #ifndef LIBDCP_SUBTITLE_ASSET_INTERNAL_H #define LIBDCP_SUBTITLE_ASSET_INTERNAL_H + +#include "array_data.h" +#include "dcp_time.h" #include "raw_convert.h" #include "types.h" -#include "dcp_time.h" -#include "data.h" +#include "warnings.h" +LIBDCP_DISABLE_WARNINGS #include -#include +LIBDCP_ENABLE_WARNINGS + struct take_intersection_test; struct take_difference_test; @@ -47,27 +57,30 @@ struct pull_fonts_test1; struct pull_fonts_test2; struct pull_fonts_test3; + namespace dcp { + class SubtitleString; + namespace order { + struct Context { - std::string xmlns () const; - int time_code_rate; Standard standard; int spot_number; }; + class Font { public: Font () {} - Font (boost::shared_ptr s, Standard standard); + Font (std::shared_ptr s, Standard standard); xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const; @@ -87,14 +100,15 @@ private: std::map _values; }; + class Part { public: - Part (boost::shared_ptr parent_) + Part (std::shared_ptr parent_) : parent (parent_) {} - Part (boost::shared_ptr parent_, Font font_) + Part (std::shared_ptr parent_, Font font_) : parent (parent_) , font (font_) {} @@ -104,50 +118,58 @@ public: virtual xmlpp::Element* as_xml (xmlpp::Element* parent, Context &) const; void write_xml (xmlpp::Element* parent, order::Context& context) const; - boost::shared_ptr parent; + std::shared_ptr parent; Font font; - std::list > children; + std::vector> children; }; + class String : public Part { public: - String (boost::shared_ptr parent, Font font, std::string text_) + String (std::shared_ptr parent, Font font, std::string text, float space_before) : Part (parent, font) - , text (text_) + , _text (text) + , _space_before (space_before) {} - virtual xmlpp::Element* as_xml (xmlpp::Element* parent, Context &) const; + virtual xmlpp::Element* as_xml (xmlpp::Element* parent, Context &) const override; - std::string text; +private: + std::string _text; + float _space_before; }; + class Text : public Part { public: - Text (boost::shared_ptr parent, HAlign h_align, float h_position, VAlign v_align, float v_position, Direction direction) + Text (std::shared_ptr parent, HAlign h_align, float h_position, VAlign v_align, float v_position, float z_position, Direction direction) : Part (parent) , _h_align (h_align) , _h_position (h_position) , _v_align (v_align) , _v_position (v_position) + , _z_position(z_position) , _direction (direction) {} - xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const; + xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const override; private: HAlign _h_align; float _h_position; VAlign _v_align; float _v_position; + float _z_position; Direction _direction; }; + class Subtitle : public Part { public: - Subtitle (boost::shared_ptr parent, Time in, Time out, Time fade_up, Time fade_down) + Subtitle (std::shared_ptr parent, Time in, Time out, Time fade_up, Time fade_down) : Part (parent) , _in (in) , _out (out) @@ -155,7 +177,7 @@ public: , _fade_down (fade_down) {} - xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const; + xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const override; private: Time _in; @@ -164,10 +186,11 @@ private: Time _fade_down; }; + class Image : public Part { public: - Image (boost::shared_ptr parent, std::string id, Data png_data, HAlign h_align, float h_position, VAlign v_align, float v_position) + Image (std::shared_ptr parent, std::string id, ArrayData png_data, HAlign h_align, float h_position, VAlign v_align, float v_position, float z_position) : Part (parent) , _png_data (png_data) , _id (id) @@ -175,21 +198,24 @@ public: , _h_position (h_position) , _v_align (v_align) , _v_position (v_position) + , _z_position(z_position) {} - xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const; + xmlpp::Element* as_xml (xmlpp::Element* parent, Context& context) const override; private: - Data _png_data; + ArrayData _png_data; std::string _id; ///< the ID of this image HAlign _h_align; float _h_position; VAlign _v_align; float _v_position; + float _z_position; }; -} } +} + #endif