From eaf09b28501674bc3242e5ce011e362bb372ff23 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Thu, 8 Feb 2024 21:22:35 +0100 Subject: [PATCH] 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. --- src/base_grid.cpp | 8 ++------ src/grid_column.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/base_grid.cpp b/src/base_grid.cpp index 5d8bf17eed..f3c2361964 100644 --- a/src/base_grid.cpp +++ b/src/base_grid.cpp @@ -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); } diff --git a/src/grid_column.cpp b/src/grid_column.cpp index 321a09439f..aff1985137 100644 --- a/src/grid_column.cpp +++ b/src/grid_column.cpp @@ -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))); } };