Make HorizontalPosition a class containing a reference enum.
authorCarl Hetherington <cth@carlh.net>
Fri, 28 Jul 2017 14:50:26 +0000 (15:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 28 Jul 2017 14:50:26 +0000 (15:50 +0100)
src/dcp_reader.cc
src/horizontal_position.h
src/stl_binary_reader.cc
src/stl_binary_writer.cc
src/subtitle.h
src/wscript

index bedd0e24bc9861ce926fbe9876ac12317cded0a5..6103470a8de4bb33bfd8c35447ab0ff2068a2c47 100644 (file)
@@ -97,13 +97,13 @@ DCPReader::DCPReader (boost::filesystem::path file)
 
                switch (i.h_align()) {
                case dcp::HALIGN_LEFT:
-                       rs.horizontal_position = LEFT;
+                       rs.horizontal_position.reference = LEFT_OF_SCREEN;
                        break;
                case dcp::HALIGN_CENTER:
-                       rs.horizontal_position = CENTRE;
+                       rs.horizontal_position.reference = HORIZONTAL_CENTRE_OF_SCREEN;
                        break;
                case dcp::HALIGN_RIGHT:
-                       rs.horizontal_position = RIGHT;
+                       rs.horizontal_position.reference = RIGHT_OF_SCREEN;
                        break;
                }
 
index df592d9a46c6b8bb90176ae36d54424b619b8ac2..1f4b1614072604086b75ccefd75a58ed1224619e 100644 (file)
 #ifndef LIBSUB_HORIZONTAL_POSITION_H
 #define LIBSUB_HORIZONTAL_POSITION_H
 
+#include "horizontal_reference.h"
+
 namespace sub {
 
-enum HorizontalPosition
+class HorizontalPosition
 {
-       LEFT,
-       CENTRE,
-       RIGHT
+public:
+       HorizontalReference reference;
+
+       bool operator== (HorizontalPosition const & other) const;
 };
-       
+
 }
 
 #endif
index 0c24a141188e40031b9bb418f416e639782ced9b..55e0188fdcc8011f25400cb13ae45f212ff64f97 100644 (file)
@@ -115,13 +115,13 @@ STLBinaryReader::STLBinaryReader (istream& in)
                        switch (h) {
                        case 0:
                        case 2:
-                               sub.horizontal_position = CENTRE;
+                               sub.horizontal_position.reference = HORIZONTAL_CENTRE_OF_SCREEN;
                                break;
                        case 1:
-                               sub.horizontal_position = LEFT;
+                               sub.horizontal_position.reference = LEFT_OF_SCREEN;
                                break;
                        case 3:
-                               sub.horizontal_position = RIGHT;
+                               sub.horizontal_position.reference = RIGHT_OF_SCREEN;
                                break;
                        }
 
index e4e06fb5cbb9eed672d268dbb2491c436d6ea267..d4fe9ed69c9185ee2101ff584d5c846c1ce88bde 100644 (file)
@@ -268,14 +268,14 @@ sub::write_stl_binary (
 
                /* Justification code */
                /* XXX: this assumes the first line has the right value */
-               switch (i->lines.front().horizontal_position) {
-               case LEFT:
+               switch (i->lines.front().horizontal_position.reference) {
+               case LEFT_OF_SCREEN:
                        put_int_as_int (buffer + 14, tables.justification_enum_to_file (JUSTIFICATION_LEFT), 1);
                        break;
-               case CENTRE:
+               case HORIZONTAL_CENTRE_OF_SCREEN:
                        put_int_as_int (buffer + 14, tables.justification_enum_to_file (JUSTIFICATION_CENTRE), 1);
                        break;
-               case RIGHT:
+               case RIGHT_OF_SCREEN:
                        put_int_as_int (buffer + 14, tables.justification_enum_to_file (JUSTIFICATION_RIGHT), 1);
                        break;
                }
index f4295a2ccec6b872c99fc83370b6b759d8974d4d..2b6867d4aad695b6b82020239ac1852794a9e3f9 100644 (file)
@@ -78,8 +78,9 @@ class Line
 {
 public:
        Line ()
-               : horizontal_position (CENTRE)
-       {}
+       {
+               horizontal_position.reference = HORIZONTAL_CENTRE_OF_SCREEN;
+       }
 
        /** Construct a Line taking any relevant information from a RawSubtitle */
        Line (RawSubtitle s);
index 0840c723bd1472b642316f7a9f01850378a4f634..655c5b5452978f1c65132e4222490d36a60fa430 100644 (file)
@@ -17,6 +17,7 @@ def build(bld):
                  effect.cc
                  exceptions.cc
                  font_size.cc
+                 horizontal_position.cc
                  iso6937.cc
                  iso6937_tables.cc
                  rational.cc
@@ -45,6 +46,7 @@ def build(bld):
               exceptions.h
               font_size.h
               horizontal_position.h
+              horizontal_reference.h
               rational.h
               raw_subtitle.h
               reader.h