Pass optimisation setting through to subtitle XML writers.
[libdcp.git] / src / subtitle_asset_internal.h
index 8a9ffe18980679a5d80a48e153e3f8181a8226bc..620d627442184d5c0263e7ed9742a54401c87745 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
     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 "raw_convert.h"
-#include "types.h"
 #include "dcp_time.h"
+#include "h_align.h"
+#include "raw_convert.h"
+#include "subtitle_asset.h"
+#include "v_align.h"
+#include "warnings.h"
+LIBDCP_DISABLE_WARNINGS
 #include <libxml++/libxml++.h>
-#include <boost/foreach.hpp>
+LIBDCP_ENABLE_WARNINGS
+
 
 struct take_intersection_test;
 struct take_difference_test;
@@ -48,21 +59,33 @@ struct pull_fonts_test1;
 struct pull_fonts_test2;
 struct pull_fonts_test3;
 
+
 namespace dcp {
 
+
+class Ruby;
 class SubtitleString;
 
+
 namespace order {
 
+
 struct Context
 {
-       std::string xmlns () const;
+       Context(int time_code_rate_, Standard standard_, int spot_number_, SubtitleOptimisation optimisation_)
+               : time_code_rate(time_code_rate_)
+               , standard(standard_)
+               , spot_number(spot_number_)
+               , optimisation(optimisation_)
+       {}
 
        int time_code_rate;
        Standard standard;
        int spot_number;
+       SubtitleOptimisation optimisation;
 };
 
+
 class Font
 {
 public:
@@ -88,6 +111,7 @@ private:
        std::map<std::string, std::string> _values;
 };
 
+
 class Part
 {
 public:
@@ -110,41 +134,51 @@ public:
        std::vector<std::shared_ptr<Part>> children;
 };
 
+
 class String : public Part
 {
 public:
-       String (std::shared_ptr<Part> parent, Font font, std::string text_)
+       String (std::shared_ptr<Part> 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 (std::shared_ptr<Part> parent, HAlign h_align, float h_position, VAlign v_align, float v_position, Direction direction)
+       Text(std::shared_ptr<Part> parent, HAlign h_align, float h_position, VAlign v_align, float v_position, float z_position, Direction direction, std::vector<Ruby> rubies)
                : Part (parent)
                , _h_align (h_align)
                , _h_position (h_position)
                , _v_align (v_align)
                , _v_position (v_position)
+               , _z_position(z_position)
                , _direction (direction)
+               , _rubies(rubies)
        {}
 
-       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;
+       std::vector<Ruby> _rubies;
 };
 
+
 class Subtitle : public Part
 {
 public:
@@ -156,7 +190,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;
@@ -165,10 +199,11 @@ private:
        Time _fade_down;
 };
 
+
 class Image : public Part
 {
 public:
-       Image (std::shared_ptr<Part> parent, std::string id, ArrayData png_data, HAlign h_align, float h_position, VAlign v_align, float v_position)
+       Image (std::shared_ptr<Part> 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)
@@ -176,9 +211,10 @@ 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:
        ArrayData _png_data;
@@ -187,10 +223,12 @@ private:
        float _h_position;
        VAlign _v_align;
        float _v_position;
+       float _z_position;
 };
 
-}
 
 }
+}
+
 
 #endif