Fix widths of time columns for times >10h

An unfortunate consequence of this is that the grid widths have to
be computed on every change to line timing, which will probably
have an impact on timing performance when autocommit is enabled.
It's probably not a huge impact but it's worth keeping an eye on.
This commit is contained in:
arch1t3cht 2024-02-08 21:22:35 +01:00
parent 8fcb7c61e8
commit eaf09b2850
2 changed files with 8 additions and 12 deletions

View File

@ -130,14 +130,10 @@ void BaseGrid::OnSubtitlesCommit(int type) {
if (type == AssFile::COMMIT_NEW || type & AssFile::COMMIT_ORDER || type & AssFile::COMMIT_DIAG_ADDREM)
UpdateMaps();
if (type & AssFile::COMMIT_DIAG_META) {
if (type & AssFile::COMMIT_DIAG_META || type & AssFile::COMMIT_DIAG_TIME) {
SetColumnWidths();
Refresh(false);
return;
}
if (type & AssFile::COMMIT_DIAG_TIME)
Refresh(false);
else if (type & AssFile::COMMIT_DIAG_TEXT) {
} else if (type & AssFile::COMMIT_DIAG_TEXT) {
for (auto const& rect : text_refresh_rects)
RefreshRect(rect, false);
}

View File

@ -158,10 +158,10 @@ struct GridColumnStartTime final : GridColumnTime {
}
int Width(const agi::Context *c, WidthHelper &helper) const override {
agi::Time max_time = max_value(&AssDialogue::Start, c->ass->Events);
if (!by_frame)
return helper(wxS("0:00:00.00"));
int frame = c->videoController->FrameAtTime(max_value(&AssDialogue::Start, c->ass->Events), agi::vfr::START);
return helper(std::to_wstring(frame));
return helper(max_time.GetAssFormatted());
return helper(std::to_wstring(c->videoController->FrameAtTime(max_time, agi::vfr::START)));
}
};
@ -176,10 +176,10 @@ struct GridColumnEndTime final : GridColumnTime {
}
int Width(const agi::Context *c, WidthHelper &helper) const override {
agi::Time max_time = max_value(&AssDialogue::End, c->ass->Events);
if (!by_frame)
return helper(wxS("0:00:00.00"));
int frame = c->videoController->FrameAtTime(max_value(&AssDialogue::End, c->ass->Events), agi::vfr::END);
return helper(std::to_wstring(frame));
return helper(max_time.GetAssFormatted());
return helper(std::to_wstring(c->videoController->FrameAtTime(max_time, agi::vfr::END)));
}
};