Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
ZoomWindow Class Reference

#include "stage/model/zoom-window.hpp"

Description

A component to ensure uniform handling of zoom scale and visible interval on the timeline.

Changes through the mutator functions are validated and harmonised to meet the internal invariants; a change listener is possibly notified to pick up the new settings.

A ZoomWindow...

  • is a visible TimeSpan
  • which is completely inside an #overalSpan
  • and is rendered at a scale factor px_per_sec
  • 0 < px_per_sec <= ZOOM_MAX_RESOLUTION
  • zoom operations are applied around an anchorPoint

Definition at line 213 of file zoom-window.hpp.

Public Member Functions

 ZoomWindow (uint pxWidth, TimeSpan timeline=TimeSpan{Time::ZERO, DEFAULT_CANVAS})
 
 ZoomWindow (TimeSpan timeline=TimeSpan{Time::ZERO, DEFAULT_CANVAS})
 
TimeSpan overallSpan () const
 
TimeSpan visible () const
 
Rat px_per_sec () const
 
uint pxWidth () const
 
void calibrateExtension (uint pxWidth)
 Define the extension of the window in pixels.
 
void setMetric (Rat px_per_sec)
 explicitly set the zoom factor, defined as pixel per second
 
void nudgeMetric (int steps)
 scale up or down on a 2-logarithmic scale.
 
void setRanges (TimeSpan overall, TimeSpan visible)
 Set both the overall canvas, as well as the visible part within that canvas.
 
void setOverallRange (TimeSpan range)
 redefine the overall canvas range.
 
void setOverallStart (TimeValue start)
 
void setOverallDuration (Duration duration)
 
void setVisibleStart (TimeValue start)
 
void setVisibleRange (TimeSpan newWindow)
 explicitly set the visible window, possibly expanding the canvas to fit.
 
void expandVisibleRange (TimeSpan target)
 the »reverse zoom operation«: zoom out such as to bring the current window at the designated time span.
 
void setVisibleDuration (Duration duration)
 explicitly set the duration of the visible window range, working around the relative anchor point; possibly expand canvas.
 
void offsetVisiblePos (Offset offset)
 scroll by arbitrary offset, possibly expanding canvas.
 
void nudgeVisiblePos (int64_t steps)
 scroll by increments of half window size, possibly expanding.
 
void setVisiblePos (Time posToShow)
 scroll the window to bring the denoted position in sight, retaining the current zoom factor, possibly expanding canvas.
 
void setVisiblePos (Rat percentage)
 scroll to reveal position designated relative to overall canvas
 
void setVisiblePos (double percentage)
 
void navHistory ()
 
template<class FUN >
void attachChangeNotification (FUN &&trigger)
 Attach a λ or functor to be triggered on each actual change.
 
void detachChangeNotification ()
 

Private Member Functions

void fireChangeNotification ()
 
Rat optimiseMetric (uint pxWidth, FSecs dur, Rat rawMetric)
 Reform the effective metric in all dangerous corner cases.
 
void conformWindowToMetric (Rat changedMetric)
 this is the centrepiece of the whole zoom metric logic...
 
Rat conformMetricToWindow (uint pxWidth)
 
void conformWindowToMetricLimits (uint pxWidth)
 The zoom metric factor must not become "poisonous".
 
void conformWindowToCanvas ()
 
void conformToBounds (Rat changedMetric)
 
void ensureInvariants (uint px=0)
 Procedure to (re)establish the invariants.
 
void mutateCanvas (TimeSpan canvas)
 
void mutateWindow (TimeSpan window)
 
void mutateRanges (TimeSpan canvas, TimeSpan window)
 
void mutateScale (Rat changedMetric)
 
void mutateDuration (FSecs duration, uint px=0)
 
void adaptWindowToPixels (uint pxWidth)
 
void anchorWindowAtPosition (FSecs canvasOffset)
 
void placeWindowRelativeToAnchor (FSecs duration)
 
void establishWindowDuration (Duration duration)
 
FSecs anchorPoint () const
 The anchor point or centre for zooming operations applied to the visible window.
 
Rat relativeAnchor () const
 define at which proportion to the visible window's duration the anchor should be placed
 
- Private Member Functions inherited from NonCopyable
 ~NonCopyable ()=default
 
 NonCopyable ()=default
 
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Static Private Member Functions

static Rat detox (Rat poison)
 Check and possibly sanitise a rational number to avoid internal numeric overflow.
 
static FSecs scaleSafe (FSecs duration, Rat factor)
 Scale a possibly large time duration by a rational factor, while attempting to avoid integer wrap-around.
 
static FSecs addSafe (FSecs t1, FSecs t2)
 Calculate sum (or difference) of possibly large time durations, avoiding integer wrap-around.
 
static TimeSpan ensureNonEmpty (TimeSpan const &span)
 
static void ENSURE_matchesExpectedPixWidth (Rat zoomFactor, FSecs duration, uint pxWidth)
 Assertion helper: resulting pxWidth matches expectations.
 
static int64_t calcPixelsForDurationAtScale (Rat zoomFactor, FSecs duration)
 calculate rational_cast<uint> (zoomFactor * duration)
 
static FSecs maxSaneWinExtension (uint pxWidth)
 window size beyond that limit would lead to numerically dangerous zoom factors (pixel/duration)
 
static Rat establishMetric (uint pxWidth, Time startWin, Time afterWin)
 
static Rat parabolicAnchorRule (Rat posFactor)
 A counter movement rule to place an anchor point, based on a percentage factor.
 

Private Attributes

TimeVar startAll_
 
TimeVar afterAll_
 
TimeVar startWin_
 
TimeVar afterWin_
 
Rat px_per_sec_
 
std::function< void()> changeSignal_ {}
 

Constructor & Destructor Documentation

◆ ZoomWindow() [1/2]

ZoomWindow ( uint  pxWidth,
TimeSpan  timeline = TimeSpan{Time::ZERO, DEFAULT_CANVAS} 
)
inline

Definition at line 223 of file zoom-window.hpp.

References Time::ZERO.

◆ ZoomWindow() [2/2]

ZoomWindow ( TimeSpan  timeline = TimeSpan{Time::ZERO, DEFAULT_CANVAS})
inline

Definition at line 236 of file zoom-window.hpp.

References Time::ZERO.

Member Function Documentation

◆ overallSpan()

TimeSpan overallSpan ( ) const
inline

Definition at line 241 of file zoom-window.hpp.

References ZoomWindow::afterAll_, and ZoomWindow::startAll_.

Referenced by ZoomMetric< I >::coveredTime(), TimelineLayout::syncZoomWindow(), ZoomMetric< I >::translateTimeToPixels(), ZoomWindow_test::verify_calibration(), ZoomWindow_test::verify_setup(), and ZoomWindow_test::verify_simpleUsage().

+ Here is the caller graph for this function:

◆ visible()

TimeSpan visible ( ) const
inline

Definition at line 247 of file zoom-window.hpp.

References ZoomWindow::afterWin_, and ZoomWindow::startWin_.

Referenced by TimelineLayout::establishLayout(), ZoomWindow::setRanges(), ZoomWindow_test::verify_calibration(), ZoomWindow_test::verify_setup(), and ZoomWindow_test::verify_simpleUsage().

+ Here is the caller graph for this function:

◆ px_per_sec()

Rat px_per_sec ( ) const
inline

Definition at line 253 of file zoom-window.hpp.

References ZoomWindow::px_per_sec_.

Referenced by ZoomMetric< I >::applyScreenDelta(), ZoomWindow::pxWidth(), ZoomWindow::setMetric(), ZoomMetric< I >::translateScreenDelta(), ZoomWindow_test::verify_calibration(), ZoomWindow_test::verify_setup(), and ZoomWindow_test::verify_simpleUsage().

+ Here is the caller graph for this function:

◆ pxWidth()

◆ calibrateExtension()

void calibrateExtension ( uint  pxWidth)
inline

Define the extension of the window in pixels.

The existing logical scale factor is retained, meaning that the logical duration of the actually visible window is adjusted alongside to match the new given pixel size, if necessary, also the canvas is expanded to fit.

Note
all other manipulations will always retain this value

Definition at line 278 of file zoom-window.hpp.

References ZoomWindow::adaptWindowToPixels(), ZoomWindow::fireChangeNotification(), and ZoomWindow::pxWidth().

Referenced by TimelineLayout::sizeZoomWindow(), and ZoomWindow_test::verify_calibration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMetric()

void setMetric ( Rat  px_per_sec)
inline

explicitly set the zoom factor, defined as pixel per second

Note
the given factor will be capped to remain below a maximal zoom of 2px per µ-tick; also the window may not be expanded beyond the current overall canvas size

Definition at line 291 of file zoom-window.hpp.

References ZoomWindow::fireChangeNotification(), ZoomWindow::mutateScale(), and ZoomWindow::px_per_sec().

Referenced by ZoomWindow::nudgeMetric().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nudgeMetric()

void nudgeMetric ( int  steps)
inline

scale up or down on a 2-logarithmic scale.

Each step either doubles or halves the zoom level, and the visible window is adjusted accordingly, using the current anchorPoint as centre for scaling.

Note
the zoom factor is limited to be between 2px per µ-tick and showing the full canvas

Definition at line 306 of file zoom-window.hpp.

References ZoomWindow::px_per_sec_, and ZoomWindow::setMetric().

Referenced by ZoomWindow_test::verify_simpleUsage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRanges()

void setRanges ( TimeSpan  overall,
TimeSpan  visible 
)
inline

Set both the overall canvas, as well as the visible part within that canvas.

Given values will possibly be adjusted to retain overall consistency, according to the following rules:

  • all ranges are non empty and properly oriented
  • the extension in pixels will always be retained
  • zoom factor is only allowed to range between showing the full canvas and a maximum factor (2 pixel per µ-tick)
  • the visible window will always be within the canvas area

Definition at line 326 of file zoom-window.hpp.

References ZoomWindow::fireChangeNotification(), ZoomWindow::mutateRanges(), and ZoomWindow::visible().

Referenced by ZoomWindow_test::verify_calibration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOverallRange()

void setOverallRange ( TimeSpan  range)
inline

redefine the overall canvas range.

Note
the currently visible window may be shifted or capped to fit within the new range, which may also change the zoom factor, while the overall pixel width is always retained unaltered

Definition at line 340 of file zoom-window.hpp.

References ZoomWindow::fireChangeNotification(), and ZoomWindow::mutateCanvas().

Referenced by ZoomWindow_test::verify_calibration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOverallStart()

void setOverallStart ( TimeValue  start)
inline

Definition at line 347 of file zoom-window.hpp.

References ZoomWindow::afterAll_, ZoomWindow::fireChangeNotification(), ZoomWindow::mutateCanvas(), and ZoomWindow::startAll_.

+ Here is the call graph for this function:

◆ setOverallDuration()

void setOverallDuration ( Duration  duration)
inline

Definition at line 354 of file zoom-window.hpp.

References ZoomWindow::fireChangeNotification(), ZoomWindow::mutateCanvas(), and ZoomWindow::startAll_.

Referenced by ZoomWindow_test::verify_calibration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setVisibleStart()

void setVisibleStart ( TimeValue  start)
inline

Definition at line 361 of file zoom-window.hpp.

References ZoomWindow::afterWin_, ZoomWindow::fireChangeNotification(), ZoomWindow::mutateWindow(), and ZoomWindow::startWin_.

Referenced by TimelineLayout::syncZoomWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setVisibleRange()

void setVisibleRange ( TimeSpan  newWindow)
inline

explicitly set the visible window, possibly expanding the canvas to fit.

Typically used to zoom into a user selected range.

Definition at line 373 of file zoom-window.hpp.

References ZoomWindow::fireChangeNotification(), and ZoomWindow::mutateWindow().

Referenced by ZoomWindow::nudgeVisiblePos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expandVisibleRange()

void expandVisibleRange ( TimeSpan  target)
inline

the »reverse zoom operation«: zoom out such as to bring the current window at the designated time span.

Typically the user selects a sub-range, and the current view is then collapsed accordingly to fit into that range. As a side effect, the canvas may be expanded significantly.

Definition at line 387 of file zoom-window.hpp.

References ZoomWindow::afterWin_, TimeSpan::end(), ZoomWindow::fireChangeNotification(), ZoomWindow::mutateWindow(), TimeSpan::start(), and ZoomWindow::startWin_.

+ Here is the call graph for this function:

◆ setVisibleDuration()

void setVisibleDuration ( Duration  duration)
inline

explicitly set the duration of the visible window range, working around the relative anchor point; possibly expand canvas.

Remarks
the anchor point is based on the relative position of the window within canvas — however, other than for scaling, the canvas will possibly be expanded and the given duration will thus always be realised.

Definition at line 411 of file zoom-window.hpp.

References ZoomWindow::fireChangeNotification(), and ZoomWindow::mutateDuration().

Referenced by ZoomWindow_test::safeguard_reversed_intervals().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ offsetVisiblePos()

void offsetVisiblePos ( Offset  offset)
inline

scroll by arbitrary offset, possibly expanding canvas.

Definition at line 419 of file zoom-window.hpp.

References ZoomWindow::afterWin_, ZoomWindow::fireChangeNotification(), ZoomWindow::mutateWindow(), and ZoomWindow::startWin_.

+ Here is the call graph for this function:

◆ nudgeVisiblePos()

void nudgeVisiblePos ( int64_t  steps)
inline

scroll by increments of half window size, possibly expanding.

Definition at line 427 of file zoom-window.hpp.

References ZoomWindow::afterWin_, util::limited(), ZoomWindow::setVisibleRange(), and ZoomWindow::startWin_.

Referenced by ZoomWindow_test::verify_simpleUsage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setVisiblePos() [1/3]

void setVisiblePos ( Time  posToShow)
inline

scroll the window to bring the denoted position in sight, retaining the current zoom factor, possibly expanding canvas.

Definition at line 442 of file zoom-window.hpp.

References ZoomWindow::anchorWindowAtPosition(), ZoomWindow::fireChangeNotification(), and ZoomWindow::startAll_.

Referenced by ZoomWindow::setVisiblePos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setVisiblePos() [2/3]

void setVisiblePos ( Rat  percentage)
inline

scroll to reveal position designated relative to overall canvas

Definition at line 451 of file zoom-window.hpp.

References ZoomWindow::afterAll_, ZoomWindow::anchorWindowAtPosition(), ZoomWindow::fireChangeNotification(), ZoomWindow::scaleSafe(), and ZoomWindow::startAll_.

+ Here is the call graph for this function:

◆ setVisiblePos() [3/3]

void setVisiblePos ( double  percentage)
inline

Definition at line 459 of file zoom-window.hpp.

References ZoomWindow::afterAll_, ZoomWindow::setVisiblePos(), and ZoomWindow::startAll_.

+ Here is the call graph for this function:

◆ navHistory()

void navHistory ( )
inline

Definition at line 467 of file zoom-window.hpp.

◆ attachChangeNotification()

template<class FUN >
void attachChangeNotification ( FUN &&  trigger)
inline

Attach a λ or functor to be triggered on each actual change.

Definition at line 476 of file zoom-window.hpp.

References ZoomWindow::changeSignal_.

Referenced by TimelineLayout::TimelineLayout().

+ Here is the caller graph for this function:

◆ detachChangeNotification()

void detachChangeNotification ( )
inline

Definition at line 482 of file zoom-window.hpp.

References ZoomWindow::changeSignal_.

◆ fireChangeNotification()

◆ detox()

static Rat detox ( Rat  poison)
inlinestaticprivate

Check and possibly sanitise a rational number to avoid internal numeric overflow.

Fractional arithmetics can be insidious, due to the frequent re-normalisation; seemingly "harmless" numbers with a large denominator can cause numeric wrap-around. As safeguard, by introducing a tiny error, problematic numbers can be re-quantised to smaller denominators; moreover, large numbers must be limit checked.

Remarks
Both the denominator and the numerator must be kept below a toxic limit, which is defined by the ability to multiply with Time::Scale without wrap-around. This heuristic is based on the actual computations done with the zoom factor and is thus specific to the ZoomWindow implementation. To sanitise, the denominator is reduced logarithmically (bit-shift) sufficiently and then used as new quantiser, thus ensuring that both denominator (=quantiser) and numerator are below limit.
Warning
the rational number must not be too large overall; this heuristic will fail on fractions with very large numerator and small denominator — however, for the ZoomWindow, this case is not relevant, since the zoom factor is limited, and other usages of rational numbers can be range checked explicitly.
Note
the check is based on the 2-logarithm of numerator and denominator, which is pretty much the fastest possibility (even a simple comparison would have to do the same). Values below threshold are simply passed-through.
Todo:
this utility function could be factored out into a FSecs or RSec class //////////////////TICKET #1262

Definition at line 520 of file zoom-window.hpp.

Referenced by ZoomWindow::addSafe(), ZoomWindow::conformWindowToMetric(), ZoomWindow::mutateScale(), ZoomWindow::parabolicAnchorRule(), and ZoomWindow::scaleSafe().

+ Here is the caller graph for this function:

◆ scaleSafe()

static FSecs scaleSafe ( FSecs  duration,
Rat  factor 
)
inlinestaticprivate

Scale a possibly large time duration by a rational factor, while attempting to avoid integer wrap-around.

In the typical use-case, the multiplication can be just computed precisely and safe, but at least we check the limits. In the danger and boundary zone, a slight error is introduced to allow cancelling out a common factor, so that the result can be just constructed without any further dangerous computation. Obviously this is only a heuristic, yet adequate within the framework of ZoomWindow, where the end result is pixel aligned anyway.

Todo:
this utility function could be factored out into a FSecs or RSec class //////////////////TICKET #1262

Descriptor for a Strategy to reduce the numbers to keep them in domain. After cross-wise cancelling out one part in each factor, the result can be constructed without any further multiplication. To achieve that, a slight error is introduced into one of the four participating numbers

< factor one is safe and will not be changed

< the counterpart of f1 is used as quantiser and cancelled out

< the diagonal counterpart of u is scaled to u and cancelled

< the counterpart of #q is re-quantised to u; it acts as limit

< Strategy will be applied to the inverse 1/x

Definition at line 538 of file zoom-window.hpp.

References util::can_represent_Product(), ZoomWindow::detox(), util::iDiv(), util::ilog2(), and TimeValue::SCALE.

Referenced by ZoomWindow::anchorPoint(), ZoomWindow::anchorWindowAtPosition(), ZoomWindow::placeWindowRelativeToAnchor(), and ZoomWindow::setVisiblePos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addSafe()

static FSecs addSafe ( FSecs  t1,
FSecs  t2 
)
inlinestaticprivate

Calculate sum (or difference) of possibly large time durations, avoiding integer wrap-around.

Again, this is a heuristics, based on re-quantisation to a smaller common denominator.

Returns
exact result if representable, otherwise approximation
Note
result is capped to MAX_TIMESPAN when exceeding domain
Todo:
this utility function could be factored out into a FSecs or RSec class //////////////////TICKET #1262

Definition at line 636 of file zoom-window.hpp.

References util::can_represent_Sum(), ZoomWindow::detox(), util::ilog2(), and TimeValue::SCALE.

Referenced by ZoomWindow::anchorWindowAtPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureNonEmpty()

static TimeSpan ensureNonEmpty ( TimeSpan const &  span)
inlinestaticprivate

Definition at line 689 of file zoom-window.hpp.

References TimeSpan::duration(), util::isnil(), and TimeSpan::start().

Referenced by ZoomWindow::mutateCanvas(), ZoomWindow::mutateRanges(), and ZoomWindow::mutateWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ENSURE_matchesExpectedPixWidth()

static void ENSURE_matchesExpectedPixWidth ( Rat  zoomFactor,
FSecs  duration,
uint  pxWidth 
)
inlinestaticprivate

Assertion helper: resulting pxWidth matches expectations.

Definition at line 699 of file zoom-window.hpp.

References ZoomWindow::pxWidth().

Referenced by ZoomWindow::conformWindowToMetric().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calcPixelsForDurationAtScale()

static int64_t calcPixelsForDurationAtScale ( Rat  zoomFactor,
FSecs  duration 
)
inlinestaticprivate

calculate rational_cast<uint> (zoomFactor * duration)

Remarks
indirect calculation to avoid overflow on large durations

Definition at line 712 of file zoom-window.hpp.

References util::iDiv().

Referenced by ZoomWindow::conformMetricToWindow(), ZoomWindow::conformWindowToMetric(), ZoomWindow::establishMetric(), ZoomWindow::optimiseMetric(), and ZoomWindow::pxWidth().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maxSaneWinExtension()

static FSecs maxSaneWinExtension ( uint  pxWidth)
inlinestaticprivate

window size beyond that limit would lead to numerically dangerous zoom factors (pixel/duration)

Definition at line 729 of file zoom-window.hpp.

References ZoomWindow::pxWidth().

Referenced by ZoomWindow::adaptWindowToPixels(), ZoomWindow::conformWindowToMetricLimits(), ZoomWindow::mutateDuration(), and ZoomWindow::mutateScale().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ optimiseMetric()

Rat optimiseMetric ( uint  pxWidth,
FSecs  dur,
Rat  rawMetric 
)
inlineprivate

Reform the effective metric in all dangerous corner cases.

Ensure the metric value is not »poisonous« and can be multiplied even with Time::SCALE without numeric wrap-around.

Note
this function introduces a slight error to simplify the numbers; then the result is optimised to conform to pxWith and duration

Definition at line 743 of file zoom-window.hpp.

References ZoomWindow::calcPixelsForDurationAtScale(), util::ilog2(), ZoomWindow::pxWidth(), and util::reQuant().

Referenced by ZoomWindow::conformMetricToWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ establishMetric()

static Rat establishMetric ( uint  pxWidth,
Time  startWin,
Time  afterWin 
)
inlinestaticprivate

Definition at line 788 of file zoom-window.hpp.

References ZoomWindow::calcPixelsForDurationAtScale(), and ZoomWindow::pxWidth().

+ Here is the call graph for this function:

◆ conformWindowToMetric()

void conformWindowToMetric ( Rat  changedMetric)
inlineprivate

this is the centrepiece of the whole zoom metric logic...

Note
control flow for every scale adjustment passes here

Definition at line 804 of file zoom-window.hpp.

References ZoomWindow::afterWin_, ZoomWindow::calcPixelsForDurationAtScale(), ZoomWindow::conformMetricToWindow(), ZoomWindow::detox(), ZoomWindow::ENSURE_matchesExpectedPixWidth(), ZoomWindow::establishWindowDuration(), ZoomWindow::placeWindowRelativeToAnchor(), ZoomWindow::px_per_sec_, ZoomWindow::pxWidth(), and ZoomWindow::startWin_.

Referenced by ZoomWindow::conformToBounds(), and ZoomWindow::mutateScale().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ conformMetricToWindow()

Rat conformMetricToWindow ( uint  pxWidth)
inlineprivate

Definition at line 827 of file zoom-window.hpp.

References ZoomWindow::afterWin_, ZoomWindow::calcPixelsForDurationAtScale(), ZoomWindow::optimiseMetric(), ZoomWindow::pxWidth(), and ZoomWindow::startWin_.

Referenced by ZoomWindow::conformWindowToMetric(), ZoomWindow::ensureInvariants(), and ZoomWindow::mutateDuration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ conformWindowToMetricLimits()

void conformWindowToMetricLimits ( uint  pxWidth)
inlineprivate

The zoom metric factor must not become "poisonous".

This leads to a minimum possible zoom factor for a given pixWidth, thereby effectively limiting the maximum window extension. This constraint is enforced by reducing the current window size.

Definition at line 847 of file zoom-window.hpp.

References ZoomWindow::afterWin_, ZoomWindow::establishWindowDuration(), ZoomWindow::maxSaneWinExtension(), ZoomWindow::placeWindowRelativeToAnchor(), ZoomWindow::pxWidth(), and ZoomWindow::startWin_.

Referenced by ZoomWindow::mutateRanges(), and ZoomWindow::mutateWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ conformWindowToCanvas()

void conformWindowToCanvas ( )
inlineprivate

Definition at line 860 of file zoom-window.hpp.

References ZoomWindow::afterAll_, ZoomWindow::afterWin_, Time::MAX, Time::MIN, ZoomWindow::startAll_, and ZoomWindow::startWin_.

Referenced by ZoomWindow::ensureInvariants().

+ Here is the caller graph for this function:

◆ conformToBounds()

void conformToBounds ( Rat  changedMetric)
inlineprivate

Definition at line 894 of file zoom-window.hpp.

References ZoomWindow::afterAll_, ZoomWindow::afterWin_, ZoomWindow::conformWindowToMetric(), Time::MAX, Time::MIN, ZoomWindow::px_per_sec_, ZoomWindow::startAll_, ZoomWindow::startWin_, and stage::model::ZOOM_MAX_RESOLUTION.

Referenced by ZoomWindow::ensureInvariants().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureInvariants()

void ensureInvariants ( uint  px = 0)
inlineprivate

Procedure to (re)establish the invariants.

Adjustments should be done first to windows, then to the metric, using conformWindowToMetric(). Then this function shall be called and will first shift and possibly cap the window, then reestablish the metric and possibly increase the canvas to keep ensure the ZOOM_MAX_RESOLUTION is not exceeded. These steps ensure overall pixel size remains stable.

Definition at line 922 of file zoom-window.hpp.

References ZoomWindow::conformMetricToWindow(), ZoomWindow::conformToBounds(), ZoomWindow::conformWindowToCanvas(), ZoomWindow::px_per_sec_, and ZoomWindow::pxWidth().

Referenced by ZoomWindow::adaptWindowToPixels(), ZoomWindow::anchorWindowAtPosition(), ZoomWindow::mutateCanvas(), ZoomWindow::mutateDuration(), ZoomWindow::mutateRanges(), ZoomWindow::mutateScale(), and ZoomWindow::mutateWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutateCanvas()

void mutateCanvas ( TimeSpan  canvas)
inlineprivate

set a different overall canvas range, possibly set window and metrics to fit

Definition at line 937 of file zoom-window.hpp.

References ZoomWindow::afterAll_, TimeSpan::end(), ZoomWindow::ensureInvariants(), ZoomWindow::ensureNonEmpty(), TimeSpan::start(), and ZoomWindow::startAll_.

Referenced by ZoomWindow::setOverallDuration(), ZoomWindow::setOverallRange(), and ZoomWindow::setOverallStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutateWindow()

void mutateWindow ( TimeSpan  window)
inlineprivate

change Window TimeSpan, possibly also outside of the current canvas, which is then expanded; validate and adjust all params accordingly

Definition at line 948 of file zoom-window.hpp.

References ZoomWindow::afterAll_, ZoomWindow::afterWin_, ZoomWindow::conformWindowToMetricLimits(), TimeSpan::end(), ZoomWindow::ensureInvariants(), ZoomWindow::ensureNonEmpty(), ZoomWindow::pxWidth(), TimeSpan::start(), ZoomWindow::startAll_, and ZoomWindow::startWin_.

Referenced by ZoomWindow::expandVisibleRange(), ZoomWindow::offsetVisiblePos(), ZoomWindow::setVisibleRange(), and ZoomWindow::setVisibleStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutateRanges()

void mutateRanges ( TimeSpan  canvas,
TimeSpan  window 
)
inlineprivate

change canvas and window position in one call, then validate and adjust to maintain invariants

Definition at line 962 of file zoom-window.hpp.

References ZoomWindow::afterAll_, ZoomWindow::afterWin_, ZoomWindow::conformWindowToMetricLimits(), TimeSpan::end(), ZoomWindow::ensureInvariants(), ZoomWindow::ensureNonEmpty(), ZoomWindow::pxWidth(), TimeSpan::start(), ZoomWindow::startAll_, and ZoomWindow::startWin_.

Referenced by ZoomWindow::setRanges().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutateScale()

void mutateScale ( Rat  changedMetric)
inlineprivate

adjust Window to match given scale, validate and adjust all params

Definition at line 977 of file zoom-window.hpp.

References ZoomWindow::conformWindowToMetric(), ZoomWindow::detox(), ZoomWindow::ensureInvariants(), ZoomWindow::maxSaneWinExtension(), ZoomWindow::px_per_sec_, ZoomWindow::pxWidth(), and stage::model::ZOOM_MAX_RESOLUTION.

Referenced by ZoomWindow::setMetric().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutateDuration()

void mutateDuration ( FSecs  duration,
uint  px = 0 
)
inlineprivate

change visible duration centred around anchor point, validate and adjust all params

Definition at line 990 of file zoom-window.hpp.

References ZoomWindow::conformMetricToWindow(), ZoomWindow::ensureInvariants(), ZoomWindow::establishWindowDuration(), ZoomWindow::maxSaneWinExtension(), ZoomWindow::placeWindowRelativeToAnchor(), ZoomWindow::px_per_sec_, and ZoomWindow::pxWidth().

Referenced by ZoomWindow::setVisibleDuration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adaptWindowToPixels()

void adaptWindowToPixels ( uint  pxWidth)
inlineprivate

resize window to span the given pixel with, validate and adjust all other params

Definition at line 1007 of file zoom-window.hpp.

References ZoomWindow::ensureInvariants(), ZoomWindow::establishWindowDuration(), util::limited(), ZoomWindow::maxSaneWinExtension(), ZoomWindow::px_per_sec_, and ZoomWindow::pxWidth().

Referenced by ZoomWindow::calibrateExtension().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ anchorWindowAtPosition()

void anchorWindowAtPosition ( FSecs  canvasOffset)
inlineprivate

relocate window anchored at a position relative to canvas, also placing the anchor position relative within the window in accordance with the position relative to canvas. Window will enclose the given position, possibly extending canvas to fit, afterwards reestablishing all invariants.

Definition at line 1023 of file zoom-window.hpp.

References ZoomWindow::addSafe(), ZoomWindow::afterAll_, ZoomWindow::afterWin_, ZoomWindow::ensureInvariants(), ZoomWindow::establishWindowDuration(), ZoomWindow::parabolicAnchorRule(), ZoomWindow::pxWidth(), ZoomWindow::scaleSafe(), ZoomWindow::startAll_, and ZoomWindow::startWin_.

Referenced by ZoomWindow::setVisiblePos(), and ZoomWindow::setVisiblePos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ placeWindowRelativeToAnchor()

void placeWindowRelativeToAnchor ( FSecs  duration)
inlineprivate

similar operation as anchorWindowAtPosition(), but based on the current window position and without relocation, rather intended for changing the scale

Definition at line 1044 of file zoom-window.hpp.

References ZoomWindow::anchorPoint(), ZoomWindow::relativeAnchor(), ZoomWindow::scaleSafe(), and ZoomWindow::startWin_.

Referenced by ZoomWindow::conformWindowToMetric(), ZoomWindow::conformWindowToMetricLimits(), and ZoomWindow::mutateDuration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ establishWindowDuration()

void establishWindowDuration ( Duration  duration)
inlineprivate

Definition at line 1051 of file zoom-window.hpp.

References ZoomWindow::afterWin_, Time::MAX, and ZoomWindow::startWin_.

Referenced by ZoomWindow::adaptWindowToPixels(), ZoomWindow::anchorWindowAtPosition(), ZoomWindow::conformWindowToMetric(), ZoomWindow::conformWindowToMetricLimits(), and ZoomWindow::mutateDuration().

+ Here is the caller graph for this function:

◆ anchorPoint()

FSecs anchorPoint ( ) const
inlineprivate

The anchor point or centre for zooming operations applied to the visible window.

Returns
where the visible window should currently be anchored
Remarks
this point can sometimes be outside the current visible window, but any further zooming/scaling/scrolling operation should bring it back into sight. Moreover, the function relativeAnchor() defines the position where this anchor point should be placed relative to the visible window.
Todo:
10/2022 we use a numerical rule currently, but that could be contextual state, like e.g. the current position of the play head or edit cursor or mouse.

Definition at line 1075 of file zoom-window.hpp.

References ZoomWindow::afterWin_, ZoomWindow::relativeAnchor(), ZoomWindow::scaleSafe(), and ZoomWindow::startWin_.

Referenced by ZoomWindow::placeWindowRelativeToAnchor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ relativeAnchor()

Rat relativeAnchor ( ) const
inlineprivate

define at which proportion to the visible window's duration the anchor should be placed

Returns
a fraction 0 ... 1, where 0 means at start and 1 means after end.
Note
as of 10/2022 we use a numerical rule to place the anchor point in accordance to the current visible window's position within the overall timeline; if it's close to the beginning, the anchor point is also rather to the beginning...

Definition at line 1088 of file zoom-window.hpp.

References ZoomWindow::afterAll_, ZoomWindow::afterWin_, ZoomWindow::parabolicAnchorRule(), ZoomWindow::startAll_, and ZoomWindow::startWin_.

Referenced by ZoomWindow::anchorPoint(), and ZoomWindow::placeWindowRelativeToAnchor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parabolicAnchorRule()

static Rat parabolicAnchorRule ( Rat  posFactor)
inlinestaticprivate

A counter movement rule to place an anchor point, based on a percentage factor.

Used to define the anchor point within the window, depending on the window's position relative to the overall canvas. Implemented using a cubic parabola, which moves quick away from the boundaries, while hovering most of the time in the middle area.

Returns
factor effectively between 0 ... 1 (inclusive)
Warning
in case of a "poisonous" input the calculation may go astray; yet results are limited at least...

Definition at line 1110 of file zoom-window.hpp.

References ZoomWindow::detox(), util::limited(), and util::reQuant().

Referenced by ZoomWindow::anchorWindowAtPosition(), and ZoomWindow::relativeAnchor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ startAll_

◆ afterAll_

◆ startWin_

◆ afterWin_

◆ px_per_sec_

◆ changeSignal_

std::function<void()> changeSignal_ {}
private
+ Inheritance diagram for ZoomWindow:
+ Collaboration diagram for ZoomWindow:

The documentation for this class was generated from the following file: