Make characters red if they are too long in the closed caption view.
authorCarl Hetherington <cth@carlh.net>
Wed, 25 Jul 2018 15:59:37 +0000 (16:59 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 25 Jul 2018 15:59:37 +0000 (16:59 +0100)
src/wx/closed_captions_dialog.cc

index 3e240c6e86fc739de66db0f21388ebd51055d0c6..857db66a8b396c13de0f8c2ff273ba30d6491b0b 100644 (file)
@@ -63,7 +63,15 @@ ClosedCaptionsDialog::paint ()
        dc.SetFont (font);
 
        for (int i = 0; i < _num_lines; ++i) {
-               dc.DrawText (_lines[i], 8, line_height * i);
+               wxString const good = _lines[i].Left (_num_chars_per_line);
+               dc.DrawText (good, 8, line_height * i);
+               if (_lines[i].Length() > _num_chars_per_line) {
+                       wxString const bad = _lines[i].Right (_lines[i].Length() - _num_chars_per_line);
+                       wxSize size = dc.GetTextExtent (good);
+                       dc.SetTextForeground (*wxRED);
+                       dc.DrawText (bad, 8 + size.GetWidth(), line_height * i);
+                       dc.SetTextForeground (*wxWHITE);
+               }
        }
 }