From 006758f349c13380916ca9e8c6fb3bf9b15f1327 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 5 Dec 2022 03:34:04 +0100 Subject: [PATCH] Library/Timeline: now able to scroll to extreme positions (closes #1263) ...building on these Library changes, plus the safe-add function developed some days ago, it is now possible to mark a large displacement as `time::Offset`, and apply this to yield any valid time position, even extreme negative values --- src/stage/model/zoom-window.hpp | 2 +- tests/basics/time/time-value-test.cpp | 29 ++++- tests/stage/model/zoom-window-test.cpp | 20 ++-- wiki/thinkPad.ichthyo.mm | 159 +++++++++++++++++++++++-- 4 files changed, 184 insertions(+), 26 deletions(-) diff --git a/src/stage/model/zoom-window.hpp b/src/stage/model/zoom-window.hpp index 650c1ce49..0c9b490fb 100644 --- a/src/stage/model/zoom-window.hpp +++ b/src/stage/model/zoom-window.hpp @@ -904,7 +904,7 @@ namespace model { Rat posFactor = canvasOffset / FSecs{afterAll_-startAll_}; posFactor = parabolicAnchorRule (posFactor); // also limited 0...1 FSecs partBeforeAnchor = scaleSafe (duration, posFactor); - startWin_ = startAll_ + addSafe (canvasOffset, -partBeforeAnchor); + startWin_ = startAll_ + Offset{addSafe (canvasOffset, -partBeforeAnchor)}; establishWindowDuration (duration); startAll_ = min (startAll_, startWin_); afterAll_ = max (afterAll_, afterWin_); diff --git a/tests/basics/time/time-value-test.cpp b/tests/basics/time/time-value-test.cpp index b0e44b87c..a3c611c7d 100644 --- a/tests/basics/time/time-value-test.cpp +++ b/tests/basics/time/time-value-test.cpp @@ -77,6 +77,7 @@ namespace test{ buildTimeSpan (ref); compareTimeSpan (Time(ref)); relateTimeIntervals (ref); + verify_extremeValues(); verify_fractionalOffset(); } @@ -289,7 +290,33 @@ namespace test{ void - verify_fractionalOffset () + verify_extremeValues() + { + CHECK (Time::MIN < Time::MAX); + CHECK (_raw(Time::MAX) < std::numeric_limits::max()); + CHECK (_raw(Time::MIN) > std::numeric_limits::min()); + + // Values are limited at construction, but not in calculations + CHECK (Time::MAX - Time(0,1) < Time::MAX); + CHECK (Time::MAX - Time(0,1) + Time(0,3) > Time::MAX); + CHECK (TimeValue{_raw(Time::MAX-Time(0,1)+Time(0,3))} == Time::MAX); // clipped at max + CHECK (TimeValue{_raw(Time::MIN+Time(0,5)-Time(0,9))} == Time::MIN); // clipped at min + + CHECK (Duration::MAX > Time::MAX); + CHECK (_raw(Duration::MAX) < std::numeric_limits::max()); + CHECK (Duration::MAX == Time::MAX - Time::MIN); + CHECK (-Duration::MAX == Offset{Time::MIN - Time::MAX}); + + CHECK ( Time::MAX + Duration::MAX > Duration::MAX); + CHECK ( Time::MIN - Duration::MAX < -Duration::MAX); + CHECK ( Offset{Time::MAX + Duration::MAX} == Duration::MAX); // clipped at max + CHECK ( Offset{Time::MIN - Duration::MAX} == -Duration::MAX); // clipped at min + CHECK (Duration{Offset{Time::MIN - Duration::MAX}} == Duration::MAX); // duration is absolute + } + + + void + verify_fractionalOffset() { typedef boost::rational Frac; diff --git a/tests/stage/model/zoom-window-test.cpp b/tests/stage/model/zoom-window-test.cpp index 993d75e9b..bd5b7b6f7 100644 --- a/tests/stage/model/zoom-window-test.cpp +++ b/tests/stage/model/zoom-window-test.cpp @@ -664,22 +664,18 @@ namespace test { CHECK (win.overallSpan().duration() == TimeValue{288}); // window (and canvas) were expanded to comply to maximum zoom factor CHECK (win.px_per_sec() == 17968750_r/9); // zoom factor was then slightly reduced to match next pixel boundary CHECK (win.pxWidth() == 575); // established pixel size was retained - SHOW_EXPR(win.overallSpan()); - SHOW_EXPR(_raw(win.overallSpan().start())); - SHOW_EXPR(_raw(win.overallSpan().end())); - SHOW_EXPR(_raw(win.overallSpan().duration())); - SHOW_EXPR(_raw(win.visible().duration())); /*--Test-4-----------*/ win.setVisiblePos(Time{Time::MIN + TimeValue(13)}); // Test: implicitly provoke poisonous factor through extreme offset + CHECK (win.visible().start() == Time::MIN + TimeValue(13)); // even while this position is far off, window start was alinget to it + CHECK (win.visible().end() == win.visible().start() + TimeValue{288}); + CHECK (win.visible().duration() == TimeValue{288}); - SHOW_EXPR(win.overallSpan()); - SHOW_EXPR(_raw(win.overallSpan().start())); - SHOW_EXPR(_raw(win.overallSpan().end())); - SHOW_EXPR(_raw(win.overallSpan().duration())); - SHOW_EXPR(_raw(win.visible().duration())); - SHOW_EXPR(win.px_per_sec()); - SHOW_EXPR(win.pxWidth()); + CHECK (win.overallSpan().start() == win.visible().start()); // canvas start at window start + CHECK (win.overallSpan().end() == TimeValue{307445734561825860}); // canvas end not changed + CHECK (_raw(win.overallSpan().duration()) == 614891469123651707); // canvas size was expanded to encompass changed window position + CHECK (win.px_per_sec() == 17968750_r/9); // zoom factor not changed + CHECK (win.pxWidth() == 575); // established pixel size retained } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index ee4cd81ae..b5fb84485 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -40891,8 +40891,8 @@ - - + + @@ -40917,7 +40917,7 @@ - + @@ -40960,6 +40960,7 @@ + @@ -40976,6 +40977,7 @@ + @@ -41195,10 +41197,32 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -58067,7 +58091,7 @@ - + @@ -58148,13 +58172,11 @@ + - - - @@ -58204,9 +58226,15 @@ - + - + + + + + + + @@ -58229,7 +58257,7 @@ - + @@ -58296,6 +58324,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ Begründung: sie entstehen als Delta aus validen Zeitpunkten +

+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +