MCPcopy Create free account
hub / github.com/audacity/audacity / ChooseTimeBoundary

Function ChooseTimeBoundary

src/tracks/ui/SelectHandle.cpp:131–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129 };
130
131 SelectionBoundary ChooseTimeBoundary
132 (
133 const double t0, const double t1,
134 const ViewInfo &viewInfo,
135 double selend, bool onlyWithinSnapDistance,
136 wxInt64 *pPixelDist, double *pPinValue)
137 {
138 const wxInt64 posS = viewInfo.TimeToPosition(selend);
139 const wxInt64 pos0 = viewInfo.TimeToPosition(t0);
140 wxInt64 pixelDist = std::abs(posS - pos0);
141 bool chooseLeft = true;
142
143 if (t1<=t0)
144 // Special case when selection is a point, and thus left
145 // and right distances are the same
146 chooseLeft = (selend < t0);
147 else {
148 const wxInt64 pos1 = viewInfo.TimeToPosition(t1);
149 const wxInt64 rightDist = std::abs(posS - pos1);
150 if (rightDist < pixelDist)
151 chooseLeft = false, pixelDist = rightDist;
152 }
153
154 SetIfNotNull(pPixelDist, pixelDist);
155
156 if (onlyWithinSnapDistance &&
157 pixelDist >= SELECTION_RESIZE_REGION) {
158 SetIfNotNull(pPinValue, -1.0);
159 return SBNone;
160 }
161 else if (chooseLeft) {
162 SetIfNotNull(pPinValue, t1);
163 return SBLeft;
164 }
165 else {
166 SetIfNotNull(pPinValue, t0);
167 return SBRight;
168 }
169 }
170
171 SelectionBoundary ChooseBoundary(
172 const ViewInfo &viewInfo,

Callers 1

ChooseBoundaryFunction · 0.85

Calls 2

TimeToPositionMethod · 0.80
SetIfNotNullFunction · 0.70

Tested by

no test coverage detected