diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-07-28 15:50:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-07-28 15:50:26 +0100 |
| commit | 9d44328087d41016745ace95e7e989135056149b (patch) | |
| tree | 9b7208d6364a949ded183ff380c54602075a26ca /src | |
| parent | 084eff7331b1a7c9923282c5860f490648ad633a (diff) | |
Make HorizontalPosition a class containing a reference enum.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dcp_reader.cc | 6 | ||||
| -rw-r--r-- | src/horizontal_position.h | 13 | ||||
| -rw-r--r-- | src/stl_binary_reader.cc | 6 | ||||
| -rw-r--r-- | src/stl_binary_writer.cc | 8 | ||||
| -rw-r--r-- | src/subtitle.h | 5 | ||||
| -rw-r--r-- | src/wscript | 2 |
6 files changed, 23 insertions, 17 deletions
diff --git a/src/dcp_reader.cc b/src/dcp_reader.cc index bedd0e2..6103470 100644 --- a/src/dcp_reader.cc +++ b/src/dcp_reader.cc @@ -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; } diff --git a/src/horizontal_position.h b/src/horizontal_position.h index df592d9..1f4b161 100644 --- a/src/horizontal_position.h +++ b/src/horizontal_position.h @@ -20,15 +20,18 @@ #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 diff --git a/src/stl_binary_reader.cc b/src/stl_binary_reader.cc index 0c24a14..55e0188 100644 --- a/src/stl_binary_reader.cc +++ b/src/stl_binary_reader.cc @@ -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; } diff --git a/src/stl_binary_writer.cc b/src/stl_binary_writer.cc index e4e06fb..d4fe9ed 100644 --- a/src/stl_binary_writer.cc +++ b/src/stl_binary_writer.cc @@ -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; } diff --git a/src/subtitle.h b/src/subtitle.h index f4295a2..2b6867d 100644 --- a/src/subtitle.h +++ b/src/subtitle.h @@ -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); diff --git a/src/wscript b/src/wscript index 0840c72..655c5b5 100644 --- a/src/wscript +++ b/src/wscript @@ -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 |
