diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-01-07 23:04:15 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-01-07 23:04:15 +0000 |
| commit | 74765c0660239f48702ebc6d149d522b85392b63 (patch) | |
| tree | d548627669b16513d5c2e8c877a7b15eb1879919 /src | |
| parent | be2117b1ea71c535e03c02be962387829806b1da (diff) | |
Sketchy support for total line counts when describing vertical position as a line number.
Diffstat (limited to 'src')
| -rw-r--r-- | src/stl_binary_reader.cc | 1 | ||||
| -rw-r--r-- | src/stl_binary_writer.cc | 10 | ||||
| -rw-r--r-- | src/stl_text_reader.cc | 2 | ||||
| -rw-r--r-- | src/subrip_reader.cc | 2 | ||||
| -rw-r--r-- | src/vertical_position.cc | 4 | ||||
| -rw-r--r-- | src/vertical_position.h | 3 |
6 files changed, 13 insertions, 9 deletions
diff --git a/src/stl_binary_reader.cc b/src/stl_binary_reader.cc index ff3d9a0..2246a01 100644 --- a/src/stl_binary_reader.cc +++ b/src/stl_binary_reader.cc @@ -98,6 +98,7 @@ STLBinaryReader::STLBinaryReader (istream& in) sub.from.set_frame (get_timecode (5)); sub.to.set_frame (get_timecode (9)); sub.vertical_position.line = get_int (13, 1) + i; + sub.vertical_position.lines = maximum_rows; sub.vertical_position.reference = TOP_OF_SCREEN; string text; diff --git a/src/stl_binary_writer.cc b/src/stl_binary_writer.cc index aa9a032..fcdc5fe 100644 --- a/src/stl_binary_writer.cc +++ b/src/stl_binary_writer.cc @@ -235,18 +235,16 @@ sub::write_stl_binary ( break; } } else if (j->vertical_position.line) { - /* XXX: how many lines are there...? We need to correct for any difference - between the number of lines and our ROWS. - */ + float const prop = float (j->vertical_position.line.get()) / j->vertical_position.lines.get (); switch (j->vertical_position.reference.get_value_or (TOP_OF_SCREEN)) { case TOP_OF_SCREEN: - vp = j->vertical_position.line.get(); + vp = prop * ROWS; break; case CENTRE_OF_SCREEN: - vp = j->vertical_position.line.get() + (ROWS / 2); + vp = (prop + 0.5) * ROWS; break; case BOTTOM_OF_SCREEN: - vp = ROWS - (j->vertical_position.line.get()); + vp = (1 - prop) * ROWS; break; default: break; diff --git a/src/stl_text_reader.cc b/src/stl_text_reader.cc index 3c60e41..b86a656 100644 --- a/src/stl_text_reader.cc +++ b/src/stl_text_reader.cc @@ -39,6 +39,8 @@ using namespace sub; STLTextReader::STLTextReader (istream& in) { _subtitle.vertical_position.line = 0; + /* XXX: no idea what this should be */ + _subtitle.vertical_position.lines = 32; _subtitle.vertical_position.reference = TOP_OF_SCREEN; while (in.good ()) { diff --git a/src/subrip_reader.cc b/src/subrip_reader.cc index 8bd2005..0aba120 100644 --- a/src/subrip_reader.cc +++ b/src/subrip_reader.cc @@ -132,6 +132,8 @@ SubripReader::convert_line (string t, int line_number, TimePair from, TimePair t p.from = from; p.to = to; p.vertical_position.line = line_number; + /* XXX: arbitrary */ + p.vertical_position.lines = 32; p.vertical_position.reference = TOP_OF_SUBTITLE; /* XXX: missing <font> support */ diff --git a/src/vertical_position.cc b/src/vertical_position.cc index 1fdb1e1..cdf0b6c 100644 --- a/src/vertical_position.cc +++ b/src/vertical_position.cc @@ -26,8 +26,8 @@ VerticalPosition::operator== (VerticalPosition const & other) const { if (proportional && reference && other.proportional && other.reference) { return proportional.get() == other.proportional.get() && reference.get() == other.reference.get(); - } else if (reference && line && other.reference && other.line) { - return line.get() == other.line.get() && reference.get() == other.reference.get(); + } else if (reference && line && lines && other.reference && other.line && other.lines) { + return line.get() == other.line.get() && lines.get() == other.lines.get() && reference.get() == other.reference.get(); } return false; diff --git a/src/vertical_position.h b/src/vertical_position.h index 1d0b939..77b0675 100644 --- a/src/vertical_position.h +++ b/src/vertical_position.h @@ -35,11 +35,12 @@ public: boost::optional<float> proportional; /** line number offset from some reference point */ boost::optional<int> line; + /** number of lines on the whole screen (i.e. height of the screen in lines) */ + boost::optional<int> lines; /** reference point */ boost::optional<VerticalReference> reference; bool operator== (VerticalPosition const & other) const; - }; } |
