More STL binary reading stuff.
[libsub.git] / src / subtitle.h
index 3afd0f33b5f95921efbbad641b6d19c73d4ee297..fc08ac7ce9ad9b001b234a0c68d9750a63e50e98 100644 (file)
 #define LIBSUB_SUBTITLE_H
 
 #include "frame_time.h"
+#include "metric_time.h"
+#include "colour.h"
+#include "vertical_reference.h"
+#include "effect.h"
 #include <boost/optional.hpp>
 #include <string>
+#include <list>
 
 namespace sub {
 
@@ -30,46 +35,69 @@ class Subtitle
 {
 public:
        Subtitle ()
-               : font_size (0)
+               : colour (1, 1, 1)
                , bold (false)
                , italic (false)
                , underline (false)
                , line (0)
        {}
 
-       Subtitle (
-               std::string text,
-               std::string font,
-               int font_size,
-               bool bold,
-               bool italic,
-               bool underline,
-               int line,
-               FrameTime from,
-               FrameTime to
-               )
-               : text (text)
-               , font (font)
-               , font_size (font_size)
-               , bold (bold)
-               , italic (italic)
-               , underline (underline)
-               , line (line)
-               , frame_from (from)
-               , frame_to (to)
-       {}
-
+       /** Subtitle text in UTF-8 */
        std::string text;
        std::string font;
-       int font_size;
-       bool bold;
-       bool italic;
-       bool underline;
-       int line;
-       boost::optional<FrameTime> frame_from;
-       boost::optional<FrameTime> frame_to;
+
+       /** font size */
+       struct {
+               /** as a proportion of screen height */
+               boost::optional<float> proportional;
+               /** in points */
+               boost::optional<int> points;
+       } font_size;
+
+       float font_size_proportional (int screen_height_in_points) const;
+       int font_size_points (int screen_height_in_points) const;
+
+       /** vertical position of the baseline of the text */
+       struct {
+               /** as a proportion of screen height offset from some reference point */
+               boost::optional<float> proportional;
+               /** reference position for proportional */
+               boost::optional<VerticalReference> reference;
+       } vertical_position;
+
+       boost::optional<Effect> effect;
+       boost::optional<Colour> effect_colour;
+       
+       Colour colour;
+       bool bold;      ///< true to use a bold version of font
+       bool italic;    ///< true to use an italic version of font
+       bool underline; ///< true to underline
+       int line;       ///< line number, starting from 0
+
+       /** from time */
+       struct {
+               boost::optional<FrameTime> frame;
+               boost::optional<MetricTime> metric;
+       } from;
+
+       FrameTime  from_frame  (float frames_per_second) const;
+       MetricTime from_metric (float frames_per_second) const;
+
+       /** to time */
+       struct {
+               boost::optional<FrameTime> frame;
+               boost::optional<MetricTime> metric;
+       } to;
+
+       FrameTime  to_frame  (float frames_per_second) const;
+       MetricTime to_metric (float frames_per_second) const;
+       
+       boost::optional<MetricTime> fade_up;
+       boost::optional<MetricTime> fade_down;
 };
 
+bool operator< (Subtitle const & a, Subtitle const & b);       
+
 }
 
 #endif