From 14da237d5cb9ca9859ecdbcdb762a23ed32efe84 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 7 Nov 2022 01:30:27 +0100 Subject: [PATCH] Timeline: integrate relative scaling into ZoomWindow invariant handling Since conformWindowToMetric() is always called prior to performing the complete invariant-reestablishment sequence, we can even integrate the rule for relative scaling into this central function, which simplifies the mutation implementation significantly. Should relative positioning go south, the following sanity checks will push the window back into bounds. With these changes, the verify_simpleUsage() test passes! --- src/stage/model/zoom-window.hpp | 23 ++----------- wiki/thinkPad.ichthyo.mm | 60 ++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/stage/model/zoom-window.hpp b/src/stage/model/zoom-window.hpp index af38a9f53..c555d7629 100644 --- a/src/stage/model/zoom-window.hpp +++ b/src/stage/model/zoom-window.hpp @@ -397,6 +397,8 @@ namespace model { // prefer bias towards increased window instead of increased metric if (not isMicroGridAligned (dur)) timeDur = timeDur + TimeValue(1); + // resize window relative to anchor point + startWin_ = Time{anchorPoint()} - Time{dur*relativeAnchor()}; if (startWin_<= Time::MAX - timeDur) afterWin_ = startWin_ + timeDur; else @@ -528,33 +530,14 @@ namespace model { if (duration <= 0) duration = DEFAULT_CANVAS; uint px{pxWidth()}; - TimeVar start{anchorPoint() - duration*relativeAnchor()}; - TimeVar after{start + duration}; - if (start == startWin_ and after == afterWin_) - return; // nothing changed effectively + Rat changedMetric = Rat(px) / duration; - Rat changedMetric = adjustedScale (start,after, startWin_,afterWin_); conformWindowToMetric (changedMetric); ensureInvariants(px); fireChangeNotification(); } - /** - * Adjust the display scale such as to match the given changed time interval - * @param startNew changed start point - * @param afterNew changed end point - * @param startOld previous start point - * @param afterOld previous end point - * @return adapted scale factor in pixel per second, rounded half up to the next pixel. - */ - Rat - adjustedScale (TimeVar startNew, TimeVar afterNew, TimeVar startOld, TimeVar afterOld) - { - REQUIRE (startNew < afterNew and startOld < afterOld); - Rat change{_raw(afterNew - startNew), _raw(afterOld - startOld)}; - return px_per_sec_ / change; - } /** * The anchor point or centre for zooming operations applied to the visible window diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 695ee5845..2e58f0c2c 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -38522,17 +38522,17 @@ - - + + - - + + - + @@ -38560,7 +38560,7 @@ - + @@ -38592,6 +38592,7 @@ + @@ -38609,7 +38610,7 @@ - + @@ -38627,8 +38628,8 @@ - - + + @@ -38638,8 +38639,10 @@ - + + + @@ -38650,17 +38653,17 @@ - - + + - - + + - - + + @@ -38675,7 +38678,7 @@ - + @@ -38692,7 +38695,7 @@ - + @@ -38780,7 +38783,7 @@ - + @@ -38845,7 +38848,15 @@ - + + + + + + + + + @@ -38861,7 +38872,7 @@ - + @@ -39019,7 +39030,7 @@ - + @@ -39295,6 +39306,7 @@ + @@ -39368,7 +39380,9 @@ - + + +