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
| 173 | // negative to move backward. |
| 174 | // Helper for moving by keyboard with snap-to-grid enabled |
| 175 | double 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 | |
| 193 | double OffsetTime |
| 194 | (AudacityProject &project, |
no test coverage detected