13namespace tracktion {
inline namespace engine {
namespace legacy
37 double getStart()
const {
return start; }
38 double getEnd()
const {
return end; }
39 double getLength()
const {
return end - start; }
40 double getCentre()
const {
return (start + end) * 0.5; }
41 double clipValue (
double value)
const {
return juce::jlimit (start, end, value); }
43 bool isEmpty()
const {
return end <= start; }
45 bool operator== (
const EditTimeRange& other)
const {
return start == other.start && end == other.end; }
46 bool operator!= (
const EditTimeRange& other)
const {
return ! operator== (other); }
48 bool overlaps (
const EditTimeRange& other)
const {
return other.start < end && start < other.end; }
49 bool contains (
const EditTimeRange& other)
const {
return other.start >= start && other.end <= end; }
50 bool contains (
double time)
const {
return time >= start &&
time < end; }
51 bool containsInclusive (
double time)
const {
return time >= start &&
time <= end; }
55 EditTimeRange rescaled (
double anchorTime,
double factor)
const;
66 EditTimeRange operator- (
double amount)
const {
return operator+ (-amount); }
80inline EditTimeRange::EditTimeRange (
double s,
double e) : start (s), end (e)
109 return {
std::min (start, other.start),
115 auto newStart =
std::max (start, other.start);
119inline EditTimeRange EditTimeRange::constrainRange (EditTimeRange rangeToConstrain)
const
121 auto otherLen = rangeToConstrain.getLength();
123 return getLength() <= otherLen
125 : rangeToConstrain.movedToStartAt (
juce::jlimit (start, end - otherLen,
126 rangeToConstrain.getStart()));
129inline EditTimeRange EditTimeRange::rescaled (
double anchorTime,
double factor)
const
132 return { anchorTime + (start - anchorTime) * factor,
133 anchorTime + (end - anchorTime) * factor };
136inline EditTimeRange EditTimeRange::expanded (
double amount)
const
139 return { start - amount, end + amount };
142inline EditTimeRange EditTimeRange::reduced (
double amount)
const
145 amount =
std::min (amount, getLength() / 2.0);
146 return { start + amount, end - amount };
149inline EditTimeRange EditTimeRange::movedToStartAt (
double newStart)
const
151 return { newStart, end + (newStart - start) };
154inline EditTimeRange EditTimeRange::movedToEndAt (
double newEnd)
const
156 return { start + (newEnd - end), newEnd };
159inline EditTimeRange EditTimeRange::withStart (
double newStart)
const
162 return { newStart,
std::max (end, newStart) };
165inline EditTimeRange EditTimeRange::withEnd (
double newEnd)
const
168 return {
std::min (start, newEnd), newEnd };
171inline EditTimeRange EditTimeRange::withLength (
double newLength)
const
174 return { start, start +
std::max (0.0, newLength) };
177inline EditTimeRange EditTimeRange::operator+ (
double amount)
const
179 return { start + amount, end + amount };
187 return { TimePosition::fromSeconds (r.getStart()), TimePosition::fromSeconds (r.getEnd()) };
193 return { r.getStart().inSeconds(), r.getEnd().inSeconds() };
static Range withStartAndLength(const ValueType startValue, const ValueType length) noexcept
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
TimeRange toTimeRange(legacy::EditTimeRange r)
@temporary
legacy::EditTimeRange toEditTimeRange(TimeRange r)
@temporary
Represents a time range in an Edit stored as either time or beats.
static EditTimeRange emptyRange(double start)
Returns a range with the specified start position and a length of zero.
static EditTimeRange between(double time1, double time2)
Returns the range that lies between two positions (in either order).
static EditTimeRange withStartAndLength(double time1, double length)
Returns a range with a given start and length.