summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-08-13 18:10:19 +0200
committerCarl Hetherington <cth@carlh.net>2024-08-13 18:19:32 +0200
commit29a92559cfb410cb83143bd36d41d4d69f9b5462 (patch)
tree2af583971981d75ad9eb061f5bdddc907431b265
parentf3da0b18b9949913c8e2de725d12c71802713ed1 (diff)
Don't display duplicate times in the text view.
-rw-r--r--src/wx/text_view.cc17
-rw-r--r--src/wx/text_view.h2
2 files changed, 9 insertions, 10 deletions
diff --git a/src/wx/text_view.cc b/src/wx/text_view.cc
index 7e5267886..8e6af22a7 100644
--- a/src/wx/text_view.cc
+++ b/src/wx/text_view.cc
@@ -110,29 +110,28 @@ TextView::TextView (
void
TextView::data_start (ContentStringText cts)
{
+ bool first = true;
for (auto const& i: cts.subs) {
wxListItem list_item;
list_item.SetId (_subs);
_list->InsertItem (list_item);
- _list->SetItem (_subs, 0, std_to_wx (cts.from().timecode (_frc->source)));
+ if (first) {
+ _list->SetItem(_subs, 0, std_to_wx(cts.from().timecode(_frc->source)));
+ _last_start = _subs;
+ first = false;
+ }
_list->SetItem (_subs, 2, std_to_wx (i.text ()));
_start_times.push_back (cts.from ());
++_subs;
}
-
- _last_count = cts.subs.size ();
}
void
TextView::data_stop (ContentTime time)
{
- if (!_last_count) {
- return;
- }
-
- for (int i = _subs - *_last_count; i < _subs; ++i) {
- _list->SetItem (i, 1, std_to_wx (time.timecode (_frc->source)));
+ if (_last_start) {
+ _list->SetItem(*_last_start, 1, std_to_wx(time.timecode(_frc->source)));
}
}
diff --git a/src/wx/text_view.h b/src/wx/text_view.h
index 8cf3c78bb..9dc031d17 100644
--- a/src/wx/text_view.h
+++ b/src/wx/text_view.h
@@ -49,7 +49,7 @@ private:
wxListCtrl* _list;
int _subs;
boost::optional<FrameRateChange> _frc;
- boost::optional<int> _last_count;
+ boost::optional<int> _last_start;
std::vector<dcpomatic::ContentTime> _start_times;
std::weak_ptr<Content> _content;
FilmViewer& _film_viewer;