Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
zoom-metric.hpp
Go to the documentation of this file.
1/*
2 ZOOM-METRIC.hpp - mix-in to provide a DisplayMetric based on a ZoomWindow
3
4 Copyright (C)
5 2022, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
37#ifndef STAGE_MODEL_ZOOM_METRIC_H
38#define STAGE_MODEL_ZOOM_METRIC_H
39
40
42#include "lib/meta/trait.hpp"
45
46
47
48namespace stage {
49namespace model {
50
54 using lib::time::Time;
55
56
63 template<class I>
65 : public I
66 {
68
69 protected:
71
73 : zoomWindow_{}
74 { }
75
76
77 public:
78 /* ==== Interface : DisplayMetric ==== */
79
81 coveredTime() const override
82 {
83 return zoomWindow_.overallSpan();
84 }
85
86 int
87 translateTimeToPixels (TimeValue startTimePoint) const override
88 {
89 return ZoomMetric::translateScreenDelta (Offset{zoomWindow_.overallSpan().start(), startTimePoint});
90 }
91
92 int
93 translateScreenDelta (Offset timeOffset) const override
94 {
95 auto pxOffset = rational_cast<int64_t> (zoomWindow_.px_per_sec() * _FSecs(timeOffset));
96 // // use 64-bit for the division to prevent numeric-wrap...
97 REQUIRE (abs (pxOffset) <= std::numeric_limits<int>::max());
98 return int(pxOffset);
99 }
100
102 applyScreenDelta(Time anchor, double deltaPx) const override
103 {
104 return anchor + Offset{int64_t(deltaPx) / zoomWindow_.px_per_sec()};
105 }
106 };
107
108
109}} // namespace stage::model
110#endif /*STAGE_MODEL_ZOOM_METRIC_H*/
Specialised (abstracted) presentation context with positioning by coordinates.
Offset measures a distance in time.
A time interval anchored at a specific point in time.
basic constant internal time value.
Lumiera's internal time value datatype.
Mix-In to implement the DisplayMetric interface on top of a ZoomWindow component, directly embedded h...
int translateTimeToPixels(TimeValue startTimePoint) const override
TimeValue applyScreenDelta(Time anchor, double deltaPx) const override
TimeSpan coveredTime() const override
int translateScreenDelta(Offset timeOffset) const override
A component to ensure uniform handling of zoom scale and visible interval on the timeline.
TimeSpan overallSpan() const
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
a family of time value like entities and their relationships.
Helpers for type detection, type rewriting and metaprogramming.
Abstraction: the current zoom- and navigation state of a view, possibly in multiple dimensions.