From fa4fbe522574fcc5394ecb56bfd03e6000b89fae Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 9 Nov 2022 03:25:35 +0100 Subject: [PATCH] Timeline: clarify or fix further ZoomWindow_test failures - forgot the bias towards the next larger grid aligned size - implement safeguard against empty window --- src/stage/model/zoom-window.hpp | 1 + tests/stage/model/zoom-window-test.cpp | 12 ++++++--- wiki/thinkPad.ichthyo.mm | 36 +++++++++++++++----------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/stage/model/zoom-window.hpp b/src/stage/model/zoom-window.hpp index 58f9a74f5..40a880fdc 100644 --- a/src/stage/model/zoom-window.hpp +++ b/src/stage/model/zoom-window.hpp @@ -632,6 +632,7 @@ namespace model { { pxWidth = util::limited (1u, pxWidth, MAX_PX_WIDTH); FSecs adaptedWindow{Rat{pxWidth} / px_per_sec_}; + adaptedWindow = max (adaptedWindow, MICRO_TICK); // prevent void window establishWindowDuration (adaptedWindow); px_per_sec_ = conformMetricToWindow (pxWidth); ensureInvariants (pxWidth); diff --git a/tests/stage/model/zoom-window-test.cpp b/tests/stage/model/zoom-window-test.cpp index e8436a4b0..3a900c7f7 100644 --- a/tests/stage/model/zoom-window-test.cpp +++ b/tests/stage/model/zoom-window-test.cpp @@ -220,11 +220,15 @@ namespace test { win.nudgeMetric(+15); CHECK (win.overallSpan() == TimeSpan(_t(0), _t(64))); - CHECK (win.visible() == TimeSpan(_t(0), FSecs(32,32768))); // now anchor position is at left bound - CHECK (win.px_per_sec() == 40*32768); - CHECK (win.pxWidth() == 1200); + CHECK (win.visible() == TimeSpan(_t(0), FSecs(32,32768) +MICRO_TICK)); + CHECK (win.visible().start() == _t(0)); // now anchor position is at left bound + CHECK (win.visible().end() == TimeValue(977)); // length was rounded up to the next grid position + CHECK (Time{FSecs(32,32768)+MICRO_TICK} == TimeValue(977)); // (preferring slightly larger window unless perfect fit) + CHECK (Time{FSecs(32,32768) } == TimeValue(976)); + // scale factor calculated back from actual window width + CHECK (win.px_per_sec() == 1280_r/977 * Time::SCALE); + CHECK (win.pxWidth() == 1280); // Note: already getting close to the time grid... - CHECK (win.visible().end() == TimeValue(976)); CHECK (Time(FSecs(32,32768)) == TimeValue(976)); CHECK (rational_cast (32_r/32768 * Time::SCALE) == 976.5625); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 94ae5c952..0c467cd5a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -39346,34 +39346,40 @@ - - - - + + + + - - + + - - + + - + - + - - - - - + + + + + + + + + + +