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

Function GridMove

src/menus/SelectMenus.cpp:175–191  ·  view source on GitHub ↗

Handles moving a selection edge with the keyboard in snap-to-time mode; returns the moved value. Will move at least minPix pixels -- set minPix positive to move forward, negative to move backward. Helper for moving by keyboard with snap-to-grid enabled

Source from the content-addressed store, hash-verified

173// negative to move backward.
174// Helper for moving by keyboard with snap-to-grid enabled
175double GridMove
176(AudacityProject &project, double t, int minPix)
177{
178 auto& projectSnap = ProjectSnap::Get(project);
179 auto &viewInfo = ViewInfo::Get( project );
180
181 auto result = projectSnap.SingleStep(t, minPix >= 0).time;
182
183 if (
184 std::abs(viewInfo.TimeToPosition(result) - viewInfo.TimeToPosition(t)) >=
185 abs(minPix))
186 return result;
187
188 // Otherwise, move minPix pixels, then snap to the time.
189 result = viewInfo.OffsetTimeByPixels(t, minPix);
190 return projectSnap.SnapTime(result).time;
191}
192
193double OffsetTime
194(AudacityProject &project,

Callers 1

OffsetTimeFunction · 0.85

Calls 4

GetFunction · 0.85
TimeToPositionMethod · 0.80
SnapTimeMethod · 0.80
SingleStepMethod · 0.45

Tested by

no test coverage detected