Audacity 3.2.0
Classes | Enumerations | Functions | Variables
anonymous_namespace{SelectMenus.cpp} Namespace Reference

Classes

struct  SeekInfo
 

Enumerations

enum  CursorDirection { DIRECTION_LEFT = -1 , DIRECTION_RIGHT = +1 }
 
enum  SelectionOperation { SELECTION_EXTEND , SELECTION_CONTRACT , CURSOR_MOVE }
 
enum  TimeUnit { TIME_UNIT_SECONDS , TIME_UNIT_PIXELS }
 

Functions

constexpr auto GetWindowSize (double projectRate)
 
double NearestZeroCrossing (AudacityProject &project, double t0)
 
bool OnlyHandleKeyUp (const CommandContext &context)
 
void SeekWhenAudioActive (double seekStep, wxLongLong &lastSelectionAdjustment)
 
double GridMove (AudacityProject &project, double t, int minPix)
 
double OffsetTime (AudacityProject &project, double t, double offset, TimeUnit timeUnit, SnapMode snapMode)
 
void MoveWhenAudioInactive (AudacityProject &project, double seekStep, TimeUnit timeUnit)
 
void SeekWhenAudioInactive (AudacityProject &project, double seekStep, TimeUnit timeUnit, SelectionOperation operation)
 
void SeekLeftOrRight (AudacityProject &project, double direction, SelectionOperation operation, SeekInfo &info)
 
void DoCursorMove (AudacityProject &project, double seekStep, wxLongLong &lastSelectionAdjustment)
 
void DoBoundaryMove (AudacityProject &project, int step, SeekInfo &info)
 
auto SelectMenu ()
 
auto ExtraSelectionMenu ()
 
auto CursorMenu ()
 
auto ExtraCursorMenu ()
 
auto ExtraSeekMenu ()
 

Variables

AttachedItem sAttachment1 { Indirect(SelectMenu()) }
 
AttachedItem sAttachment2
 
AttachedItem sAttachment0
 
AttachedItem sAttachment4
 
AttachedItem sAttachment5
 

Enumeration Type Documentation

◆ CursorDirection

enum anonymous_namespace{SelectMenus.cpp}::CursorDirection
Enumerator
DIRECTION_LEFT 
DIRECTION_RIGHT 

Definition at line 132 of file SelectMenus.cpp.

◆ SelectionOperation

enum anonymous_namespace{SelectMenus.cpp}::SelectionOperation
Enumerator
SELECTION_EXTEND 
SELECTION_CONTRACT 
CURSOR_MOVE 

Definition at line 137 of file SelectMenus.cpp.

◆ TimeUnit

enum anonymous_namespace{SelectMenus.cpp}::TimeUnit
Enumerator
TIME_UNIT_SECONDS 
TIME_UNIT_PIXELS 

Definition at line 143 of file SelectMenus.cpp.

Function Documentation

◆ CursorMenu()

auto anonymous_namespace{SelectMenus.cpp}::CursorMenu ( )

Definition at line 1091 of file SelectMenus.cpp.

1092{
1093 static const auto CanStopFlags = AudioIONotBusyFlag() | CanStopAudioStreamFlag();
1094
1095 // JKC: ANSWER-ME: How is 'cursor to' different to 'Skip To' and how is it
1096 // useful?
1097 // GA: 'Skip to' moves the viewpoint to center of the track and preserves the
1098 // selection. 'Cursor to' does neither. 'Center at' might describe it better
1099 // than 'Skip'.
1100 static auto menu = std::shared_ptr{
1102 Menu( wxT("Cursor"), XXO("&Cursor to"),
1103 Command( wxT("CursSelStart"), XXO("Selection Star&t"),
1104 FN(OnCursorSelStart),
1106 Options{}.LongName( XO("Cursor to Selection Start") ) ),
1107 Command( wxT("CursSelEnd"), XXO("Selection En&d"),
1108 FN(OnCursorSelEnd),
1110 Options{}.LongName( XO("Cursor to Selection End") ) ),
1111
1112 Command( wxT("CursTrackStart"), XXO("Track &Start"),
1113 FN(OnCursorTrackStart),
1115 Options{ wxT("J"), XO("Cursor to Track Start") } ),
1116 Command( wxT("CursTrackEnd"), XXO("Track &End"),
1117 FN(OnCursorTrackEnd),
1119 Options{ wxT("K"), XO("Cursor to Track End") } ),
1120
1121 Command( wxT("CursProjectStart"), XXO("&Project Start"),
1122 FN(OnSkipStart),
1124 Options{ wxT("Home"), XO("Cursor to Project Start") } ),
1125 Command( wxT("CursProjectEnd"), XXO("Project E&nd"), FN(OnSkipEnd),
1127 Options{ wxT("End"), XO("Cursor to Project End") } )
1128 ) ) };
1129 return menu;
1130}
wxT("CloseDown"))
const ReservedCommandFlag & AudioIONotBusyFlag()
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & EditableTracksSelectedFlag()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
const ReservedCommandFlag & CanStopAudioStreamFlag()
#define FN(X)
static CommandHandlerObject & findCommandHandler(AudacityProject &project)
constexpr auto Command
Definition: MenuRegistry.h:456
constexpr auto Menu
Items will appear in a main toolbar menu or in a sub-menu.
Definition: MenuRegistry.h:445
Options && LongName(const TranslatableString &value) &&
Definition: MenuRegistry.h:54

References AudioIONotBusyFlag(), CanStopAudioStreamFlag(), anonymous_namespace{TimerRecordDialog.cpp}::CanStopFlags, MenuRegistry::Command, EditableTracksSelectedFlag(), findCommandHandler(), FN, MenuRegistry::Options::LongName(), MenuRegistry::Menu, TimeSelectedFlag(), wxT(), XO(), and XXO().

Here is the call graph for this function:

◆ DoBoundaryMove()

void anonymous_namespace{SelectMenus.cpp}::DoBoundaryMove ( AudacityProject project,
int  step,
SeekInfo info 
)

Definition at line 368 of file SelectMenus.cpp.

369{
370 auto &viewInfo = ViewInfo::Get(project);
372 auto &viewport = Viewport::Get(project);
373
374 // step is negative, then is moving left. step positive, moving right.
375 // Move the left/right selection boundary, to expand the selection
376
377 // If the last adjustment was very recent, we are
378 // holding the key down and should move faster.
379 wxLongLong curtime = ::wxGetUTCTimeMillis();
380 int pixels = step;
381 if (curtime - info.mLastSelectionAdjustment < 50)
382 pixels *= 4;
383 info.mLastSelectionAdjustment = curtime;
384
385 // we used to have a parameter boundaryContract to say if expanding or
386 // contracting. it is no longer needed.
387 bool bMoveT0 = (step < 0 );// ^ boundaryContract ;
388
390 auto gAudioIO = AudioIO::Get();
391 double indicator = gAudioIO->GetStreamTime();
392 if( bMoveT0 )
393 viewInfo.selectedRegion.setT0(indicator, false);
394 else
395 viewInfo.selectedRegion.setT1(indicator);
396
398 return;
399 }
400
401 const double t0 = viewInfo.selectedRegion.t0();
402 const double t1 = viewInfo.selectedRegion.t1();
403 const double end = std::max(
404 tracks.GetEndTime(), viewInfo.GetScreenEndTime());
405
406 double newT = viewInfo.OffsetTimeByPixels( bMoveT0 ? t0 : t1, pixels);
407 // constrain to be in the track/screen limits.
408 newT = std::max( 0.0, newT );
409 newT = std::min( newT, end);
410 // optionally constrain to be a contraction, i.e. so t0/t1 do not cross over
411 //if( boundaryContract )
412 // newT = bMoveT0 ? std::min( t1, newT ) : std::max( t0, newT );
413
414 // Actually move
415 if( bMoveT0 )
416 viewInfo.selectedRegion.setT0( newT );
417 else
418 viewInfo.selectedRegion.setT1( newT );
419
420 // Ensure it is visible
421 viewport.ScrollIntoView(newT);
422
424}
int min(int a, int b)
const auto tracks
const auto project
static AudioIO * Get()
Definition: AudioIO.cpp:126
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end(), AudioIO::Get(), ProjectAudioIO::Get(), ProjectHistory::Get(), ViewInfo::Get(), TrackList::Get(), Viewport::Get(), ProjectAudioIO::IsAudioActive(), min(), anonymous_namespace{SelectMenus.cpp}::SeekInfo::mLastSelectionAdjustment, ProjectHistory::ModifyState(), project, and tracks.

Referenced by SelectActions::Handler::OnSelSetExtendLeft(), and SelectActions::Handler::OnSelSetExtendRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoCursorMove()

void anonymous_namespace{SelectMenus.cpp}::DoCursorMove ( AudacityProject project,
double  seekStep,
wxLongLong &  lastSelectionAdjustment 
)

Definition at line 352 of file SelectMenus.cpp.

355{
356 if (ProjectAudioIO::Get( project ).IsAudioActive()) {
357 SeekWhenAudioActive(seekStep, lastSelectionAdjustment);
358 }
359 else
360 {
361 lastSelectionAdjustment = ::wxGetUTCTimeMillis();
363 }
364
366}
void SeekWhenAudioActive(double seekStep, wxLongLong &lastSelectionAdjustment)
void MoveWhenAudioInactive(AudacityProject &project, double seekStep, TimeUnit timeUnit)

References ProjectAudioIO::Get(), ProjectHistory::Get(), ProjectHistory::ModifyState(), MoveWhenAudioInactive(), project, SeekWhenAudioActive(), and TIME_UNIT_SECONDS.

Referenced by SelectActions::Handler::OnCursorLongJumpLeft(), SelectActions::Handler::OnCursorLongJumpRight(), SelectActions::Handler::OnCursorShortJumpLeft(), and SelectActions::Handler::OnCursorShortJumpRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtraCursorMenu()

auto anonymous_namespace{SelectMenus.cpp}::ExtraCursorMenu ( )

Definition at line 1136 of file SelectMenus.cpp.

1137{
1138 static auto menu = std::shared_ptr{
1140 Menu( wxT("Cursor"), XXO("&Cursor"),
1141 Command( wxT("CursorLeft"), XXO("Cursor &Left"), FN(OnCursorLeft),
1143 Options{ wxT("Left") }.WantKeyUp().AllowDup() ),
1144 Command( wxT("CursorRight"), XXO("Cursor &Right"), FN(OnCursorRight),
1146 Options{ wxT("Right") }.WantKeyUp().AllowDup() ),
1147 Command( wxT("CursorShortJumpLeft"), XXO("Cursor Sh&ort Jump Left"),
1148 FN(OnCursorShortJumpLeft),
1150 Command( wxT("CursorShortJumpRight"), XXO("Cursor Shor&t Jump Right"),
1151 FN(OnCursorShortJumpRight),
1153 Command( wxT("CursorLongJumpLeft"), XXO("Cursor Long J&ump Left"),
1154 FN(OnCursorLongJumpLeft),
1155 TracksExistFlag() | TrackPanelHasFocus(), wxT("Shift+,") ),
1156 Command( wxT("CursorLongJumpRight"), XXO("Cursor Long Ju&mp Right"),
1157 FN(OnCursorLongJumpRight),
1158 TracksExistFlag() | TrackPanelHasFocus(), wxT("Shift+.") )
1159 ) ) };
1160 return menu;
1161}
const ReservedCommandFlag & TracksExistFlag()
const ReservedCommandFlag & TrackPanelHasFocus()

References MenuRegistry::Command, findCommandHandler(), FN, MenuRegistry::Menu, TrackPanelHasFocus(), TracksExistFlag(), wxT(), and XXO().

Here is the call graph for this function:

◆ ExtraSeekMenu()

auto anonymous_namespace{SelectMenus.cpp}::ExtraSeekMenu ( )

Definition at line 1167 of file SelectMenus.cpp.

1168{
1169 static auto menu = std::shared_ptr{
1171 Menu( wxT("Seek"), XXO("See&k"),
1172 Command( wxT("SeekLeftShort"), XXO("Short Seek &Left During Playback"),
1173 FN(OnSeekLeftShort), AudioIOBusyFlag(),
1174 Options{ wxT("Left") }.AllowDup() ),
1175 Command( wxT("SeekRightShort"),
1176 XXO("Short Seek &Right During Playback"), FN(OnSeekRightShort),
1178 Options{ wxT("Right") }.AllowDup() ),
1179 Command( wxT("SeekLeftLong"), XXO("Long Seek Le&ft During Playback"),
1180 FN(OnSeekLeftLong), AudioIOBusyFlag(),
1181 Options{ wxT("Shift+Left") }.AllowDup() ),
1182 Command( wxT("SeekRightLong"), XXO("Long Seek Rig&ht During Playback"),
1183 FN(OnSeekRightLong), AudioIOBusyFlag(),
1184 Options{ wxT("Shift+Right") }.AllowDup() )
1185 ) ) };
1186 return menu;
1187}
const ReservedCommandFlag & AudioIOBusyFlag()

References AudioIOBusyFlag(), MenuRegistry::Command, findCommandHandler(), FN, MenuRegistry::Menu, wxT(), and XXO().

Here is the call graph for this function:

◆ ExtraSelectionMenu()

auto anonymous_namespace{SelectMenus.cpp}::ExtraSelectionMenu ( )

Definition at line 1044 of file SelectMenus.cpp.

1045{
1046 static auto menu = std::shared_ptr{
1048 Menu( wxT("Select"), XXO("&Selection"),
1049 Command( wxT("SnapToOff"), XXO("Snap-To &Off"), FN(OnSnapToOff),
1051 Command( wxT("SnapToNearest"), XXO("Snap-To &Nearest"),
1052 FN(OnSnapToNearest), AlwaysEnabledFlag ),
1053 Command( wxT("SnapToPrior"), XXO("Snap-To &Prior"), FN(OnSnapToPrior),
1055 Command( wxT("SelStart"), XXO("Selection to &Start"), FN(OnSelToStart),
1056 AlwaysEnabledFlag, wxT("Shift+Home") ),
1057 Command( wxT("SelEnd"), XXO("Selection to En&d"), FN(OnSelToEnd),
1058 AlwaysEnabledFlag, wxT("Shift+End") ),
1059 Command( wxT("SelExtLeft"), XXO("Selection Extend &Left"),
1060 FN(OnSelExtendLeft),
1062 Options{ wxT("Shift+Left") }.WantKeyUp().AllowDup() ),
1063 Command( wxT("SelExtRight"), XXO("Selection Extend &Right"),
1064 FN(OnSelExtendRight),
1066 Options{ wxT("Shift+Right") }.WantKeyUp().AllowDup() ),
1067 Command( wxT("SelSetExtLeft"), XXO("Set (or Extend) Le&ft Selection"),
1068 FN(OnSelSetExtendLeft),
1070 Command( wxT("SelSetExtRight"), XXO("Set (or Extend) Rig&ht Selection"),
1071 FN(OnSelSetExtendRight),
1073 Command( wxT("SelCntrLeft"), XXO("Selection Contract L&eft"),
1074 FN(OnSelContractLeft),
1076 Options{ wxT("Ctrl+Shift+Right") }.WantKeyUp() ),
1077 Command( wxT("SelCntrRight"), XXO("Selection Contract R&ight"),
1078 FN(OnSelContractRight),
1080 Options{ wxT("Ctrl+Shift+Left") }.WantKeyUp() )
1081 ) ) };
1082 return menu;
1083}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34

References AlwaysEnabledFlag, MenuRegistry::Command, findCommandHandler(), FN, MenuRegistry::Menu, TrackPanelHasFocus(), TracksExistFlag(), wxT(), and XXO().

Here is the call graph for this function:

◆ GetWindowSize()

constexpr auto anonymous_namespace{SelectMenus.cpp}::GetWindowSize ( double  projectRate)
constexpr

Definition at line 31 of file SelectMenus.cpp.

32{
33 return size_t(std::max(1.0, projectRate / 100));
34}

Referenced by NearestZeroCrossing(), and SelectActions::Handler::OnZeroCrossing().

Here is the caller graph for this function:

◆ GridMove()

double anonymous_namespace{SelectMenus.cpp}::GridMove ( AudacityProject project,
double  t,
int  minPix 
)

Definition at line 176 of file SelectMenus.cpp.

178{
179 auto& projectSnap = ProjectSnap::Get(project);
180 auto &viewInfo = ViewInfo::Get( project );
181
182 auto result = projectSnap.SingleStep(t, minPix >= 0).time;
183
184 if (
185 std::abs(viewInfo.TimeToPosition(result) - viewInfo.TimeToPosition(t)) >=
186 abs(minPix))
187 return result;
188
189 // Otherwise, move minPix pixels, then snap to the time.
190 result = viewInfo.OffsetTimeByPixels(t, minPix);
191 return projectSnap.SnapTime(result).time;
192}
static ProjectSnap & Get(AudacityProject &project)
Definition: ProjectSnap.cpp:27

References ProjectSnap::Get(), ViewInfo::Get(), and project.

Referenced by OffsetTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MoveWhenAudioInactive()

void anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive ( AudacityProject project,
double  seekStep,
TimeUnit  timeUnit 
)

Definition at line 210 of file SelectMenus.cpp.

212{
213 auto &viewInfo = ViewInfo::Get(project);
214 auto &trackPanel = TrackPanel::Get(project);
217 const auto &settings = ProjectSnap::Get(project);
218 auto &viewport = Viewport::Get(project);
219
220 // If TIME_UNIT_SECONDS, snap-to will be off.
221 auto snapMode = settings.GetSnapMode();
222
223 // Move the cursor
224 // Already in cursor mode?
225 if (viewInfo.selectedRegion.isPoint())
226 {
227 double newT = OffsetTime(
228 project, viewInfo.selectedRegion.t0(), seekStep, timeUnit, snapMode);
229 // constrain.
230 newT = std::max(0.0, newT);
231 // Move
232 viewInfo.selectedRegion.setT0(
233 newT,
234 false); // do not swap selection boundaries
235 viewInfo.selectedRegion.collapseToT0();
236
237 // Move the visual cursor, avoiding an unnecessary complete redraw
238 trackPanel.DrawOverlays(false);
239 ruler.DrawOverlays(false);
240 }
241 else
242 {
243 // Transition to cursor mode.
244 constexpr auto maySwapBoundaries = false;
245 if (seekStep < 0)
246 {
247 if (snapMode != SnapMode::SNAP_OFF)
248 viewInfo.selectedRegion.setT0(
249 settings.SnapTime(viewInfo.selectedRegion.t0()).time,
250 maySwapBoundaries);
251 viewInfo.selectedRegion.collapseToT0();
252 }
253 else
254 {
255 if (snapMode != SnapMode::SNAP_OFF)
256 viewInfo.selectedRegion.setT1(
257 settings.SnapTime(viewInfo.selectedRegion.t1()).time,
258 maySwapBoundaries);
259 viewInfo.selectedRegion.collapseToT1();
260 }
261 trackPanel.Refresh(false);
262 }
263
264 // Make sure NEW position is in view
265 viewport.ScrollIntoView(viewInfo.selectedRegion.t1());
266 return;
267}
static Settings & settings()
Definition: TrackInfo.cpp:47
static AdornedRulerPanel & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
double OffsetTime(AudacityProject &project, double t, double offset, TimeUnit timeUnit, SnapMode snapMode)

References ProjectSnap::Get(), ViewInfo::Get(), TrackList::Get(), Viewport::Get(), AdornedRulerPanel::Get(), TrackPanel::Get(), OffsetTime(), project, anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), settings(), SNAP_OFF, and tracks.

Referenced by DoCursorMove(), and SeekWhenAudioInactive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NearestZeroCrossing()

double anonymous_namespace{SelectMenus.cpp}::NearestZeroCrossing ( AudacityProject project,
double  t0 
)

Definition at line 36 of file SelectMenus.cpp.

37{
38 auto rate = ProjectRate::Get(project).GetRate();
39 auto &tracks = TrackList::Get( project );
40
41 // Window is 1/100th of a second.
42 auto windowSize = GetWindowSize(rate);
43 Floats dist{ windowSize, true };
44
45 int nTracks = 0;
46 for (auto one : tracks.Selected<const WaveTrack>()) {
47 const auto nChannels = one->NChannels();
48 auto oneWindowSize = size_t(std::max(1.0, one->GetRate() / 100));
49 Floats buffer1{ oneWindowSize };
50 Floats buffer2{ oneWindowSize };
51 float *const buffers[]{ buffer1.get(), buffer2.get() };
52 auto s = one->TimeToLongSamples(t0);
53
54 // fillTwo to ensure that missing values are treated as 2, and hence do
55 // not get used as zero crossings.
56 one->GetFloats(0, nChannels, buffers,
57 s - (int)oneWindowSize/2, oneWindowSize, false, FillFormat::fillTwo);
58
59
60 // Looking for actual crossings. Update dist
61 for (size_t iChannel = 0; iChannel < nChannels; ++iChannel) {
62 const auto oneDist = buffers[iChannel];
63 double prev = 2.0;
64 for (size_t i = 0; i < oneWindowSize; ++i) {
65 float fDist = fabs(oneDist[i]); // score is absolute value
66 if (prev * oneDist[i] > 0) // both same sign? No good.
67 fDist = fDist + 0.4; // No good if same sign.
68 else if (prev > 0.0)
69 fDist = fDist + 0.1; // medium penalty for downward crossing.
70 prev = oneDist[i];
71 oneDist[i] = fDist;
72 }
73
74 // TODO: The mixed rate zero crossing code is broken,
75 // if oneWindowSize > windowSize we'll miss out some
76 // samples - so they will still be zero, so we'll use them.
77 for (size_t i = 0; i < windowSize; i++) {
78 size_t j;
79 if (windowSize != oneWindowSize)
80 j = i * (oneWindowSize - 1) / (windowSize - 1);
81 else
82 j = i;
83
84 dist[i] += oneDist[j];
85 // Apply a small penalty for distance from the original endpoint
86 // We'll always prefer an upward
87 dist[i] +=
88 0.1 * (abs(int(i) - int(windowSize / 2))) / float(windowSize / 2);
89 }
90 }
91 nTracks++;
92 }
93
94 // Find minimum
95 int argmin = 0;
96 float min = 3.0;
97 for (size_t i = 0; i < windowSize; ++i) {
98 if (dist[i] < min) {
99 argmin = i;
100 min = dist[i];
101 }
102 }
103
104 // If we're worse than 0.2 on average, on one track, then no good.
105 if ((nTracks == 1) && (min > (0.2 * nTracks)))
106 return t0;
107 // If we're worse than 0.6 on average, on multi-track, then no good.
108 if ((nTracks > 1) && (min > (0.6 * nTracks)))
109 return t0;
110
111 return t0 + (argmin - (int)windowSize / 2) / rate;
112}
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
constexpr auto GetWindowSize(double projectRate)
Definition: SelectMenus.cpp:31

References fillTwo, ProjectRate::Get(), TrackList::Get(), ProjectRate::GetRate(), GetWindowSize(), anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, min(), project, and tracks.

Referenced by SelectActions::Handler::OnZeroCrossing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OffsetTime()

double anonymous_namespace{SelectMenus.cpp}::OffsetTime ( AudacityProject project,
double  t,
double  offset,
TimeUnit  timeUnit,
SnapMode  snapMode 
)

Definition at line 194 of file SelectMenus.cpp.

197{
198 auto &viewInfo = ViewInfo::Get( project );
199
200 if (timeUnit == TIME_UNIT_SECONDS)
201 return t + offset; // snapping is currently ignored for non-pixel moves
202
203 if (snapMode == SnapMode::SNAP_OFF)
204 return viewInfo.OffsetTimeByPixels(t, (int)offset);
205
206 return GridMove(project, t, (int)offset);
207}
double GridMove(AudacityProject &project, double t, int minPix)

References ViewInfo::Get(), GridMove(), project, SNAP_OFF, and TIME_UNIT_SECONDS.

Referenced by MoveWhenAudioInactive(), and SeekWhenAudioInactive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnlyHandleKeyUp()

bool anonymous_namespace{SelectMenus.cpp}::OnlyHandleKeyUp ( const CommandContext context)

Definition at line 117 of file SelectMenus.cpp.

118{
119 auto &project = context.project;
120 auto evt = context.pEvt;
121 bool bKeyUp = (evt) && evt->GetEventType() == wxEVT_KEY_UP;
122
124 return bKeyUp;
125 if( !bKeyUp )
126 return false;
127
129 return true;
130}
const wxEvent * pEvt
AudacityProject & project

References ProjectAudioIO::Get(), ProjectHistory::Get(), ProjectAudioIO::IsAudioActive(), ProjectHistory::ModifyState(), CommandContext::pEvt, CommandContext::project, and project.

Referenced by SelectActions::Handler::OnCursorLeft(), SelectActions::Handler::OnCursorRight(), SelectActions::Handler::OnSelContractLeft(), SelectActions::Handler::OnSelContractRight(), SelectActions::Handler::OnSelExtendLeft(), and SelectActions::Handler::OnSelExtendRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SeekLeftOrRight()

void anonymous_namespace{SelectMenus.cpp}::SeekLeftOrRight ( AudacityProject project,
double  direction,
SelectionOperation  operation,
SeekInfo info 
)

Definition at line 314 of file SelectMenus.cpp.

317{
318 // PRL: What I found and preserved, strange though it be:
319 // During playback: jump depends on preferences and is independent of the
320 // zoom and does not vary if the key is held
321 // Else: jump depends on the zoom and gets bigger if the key is held
322
323 if( ProjectAudioIO::Get( project ).IsAudioActive() )
324 {
325 if( operation == CURSOR_MOVE )
326 SeekWhenAudioActive( info.mSeekShort * direction,
328 else if( operation == SELECTION_EXTEND )
329 SeekWhenAudioActive( info.mSeekLong * direction,
331 // Note: no action for CURSOR_CONTRACT
332 return;
333 }
334
335 // If the last adjustment was very recent, we are
336 // holding the key down and should move faster.
337 const wxLongLong curtime = ::wxGetUTCTimeMillis();
338 enum { MIN_INTERVAL = 50 };
339 const bool fast =
340 (curtime - info.mLastSelectionAdjustment < MIN_INTERVAL);
341
342 info.mLastSelectionAdjustment = curtime;
343
344 // How much faster should the cursor move if shift is down?
345 enum { LARGER_MULTIPLIER = 4 };
346 const double seekStep = (fast ? LARGER_MULTIPLIER : 1.0) * direction;
347
348 SeekWhenAudioInactive( project, seekStep, TIME_UNIT_PIXELS, operation);
349}
void SeekWhenAudioInactive(AudacityProject &project, double seekStep, TimeUnit timeUnit, SelectionOperation operation)

References CURSOR_MOVE, ProjectAudioIO::Get(), anonymous_namespace{SelectMenus.cpp}::SeekInfo::mLastSelectionAdjustment, anonymous_namespace{SelectMenus.cpp}::SeekInfo::mSeekLong, anonymous_namespace{SelectMenus.cpp}::SeekInfo::mSeekShort, project, SeekWhenAudioActive(), SeekWhenAudioInactive(), SELECTION_EXTEND, and TIME_UNIT_PIXELS.

Referenced by SelectActions::Handler::OnCursorLeft(), SelectActions::Handler::OnCursorRight(), SelectActions::Handler::OnSeekLeftLong(), SelectActions::Handler::OnSeekLeftShort(), SelectActions::Handler::OnSeekRightLong(), SelectActions::Handler::OnSeekRightShort(), SelectActions::Handler::OnSelContractLeft(), SelectActions::Handler::OnSelContractRight(), SelectActions::Handler::OnSelExtendLeft(), and SelectActions::Handler::OnSelExtendRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SeekWhenAudioActive()

void anonymous_namespace{SelectMenus.cpp}::SeekWhenAudioActive ( double  seekStep,
wxLongLong &  lastSelectionAdjustment 
)

Definition at line 155 of file SelectMenus.cpp.

156{
157 auto gAudioIO = AudioIO::Get();
158#ifdef EXPERIMENTAL_IMPROVED_SEEKING
159 if (gAudioIO->GetLastPlaybackTime() < lastSelectionAdjustment) {
160 // Allow time for the last seek to output a buffer before
161 // discarding samples again
162 // Do not advance mLastSelectionAdjustment
163 return;
164 }
165#endif
166 lastSelectionAdjustment = ::wxGetUTCTimeMillis();
167
168 gAudioIO->SeekStream(seekStep);
169}

References AudioIO::Get().

Referenced by DoCursorMove(), and SeekLeftOrRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SeekWhenAudioInactive()

void anonymous_namespace{SelectMenus.cpp}::SeekWhenAudioInactive ( AudacityProject project,
double  seekStep,
TimeUnit  timeUnit,
SelectionOperation  operation 
)

Definition at line 269 of file SelectMenus.cpp.

272{
273 auto &viewInfo = ViewInfo::Get(project);
275 const auto &settings = ProjectSnap::Get(project);
276 auto &viewport = Viewport::Get(project);
277
278 if (operation == CURSOR_MOVE)
279 {
280 MoveWhenAudioInactive( project, seekStep, timeUnit);
281 return;
282 }
283
284 auto snapMode = settings.GetSnapMode();
285 const double t0 = viewInfo.selectedRegion.t0();
286 const double t1 = viewInfo.selectedRegion.t1();
287 const double end = std::max(
288 tracks.GetEndTime(), viewInfo.GetScreenEndTime());
289
290 // Is it t0 or t1 moving?
291 bool bMoveT0 = (operation == SELECTION_CONTRACT && seekStep > 0) ||
292 (operation == SELECTION_EXTEND && seekStep < 0);
293 // newT is where we want to move to
294 double newT = OffsetTime( project,
295 bMoveT0 ? t0 : t1, seekStep, timeUnit, snapMode);
296 // constrain to be in the track/screen limits.
297 newT = std::max( 0.0, newT );
298 newT = std::min( newT, end);
299 // optionally constrain to be a contraction, i.e. so t0/t1 do not cross over
300 if( operation == SELECTION_CONTRACT )
301 newT = bMoveT0 ? std::min( t1, newT ) : std::max( t0, newT );
302
303 // Actually move
304 if( bMoveT0 )
305 viewInfo.selectedRegion.setT0( newT );
306 else
307 viewInfo.selectedRegion.setT1( newT );
308
309 // Ensure it is visible
310 viewport.ScrollIntoView(newT);
311}
STL namespace.

References CURSOR_MOVE, details::end(), ProjectSnap::Get(), ViewInfo::Get(), TrackList::Get(), Viewport::Get(), min(), MoveWhenAudioInactive(), OffsetTime(), project, SELECTION_CONTRACT, SELECTION_EXTEND, settings(), and tracks.

Referenced by SeekLeftOrRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SelectMenu()

auto anonymous_namespace{SelectMenus.cpp}::SelectMenu ( )

Definition at line 954 of file SelectMenus.cpp.

955{
956 static auto menu = std::shared_ptr{
958 /* i18n-hint: (verb) It's an item on a menu. */
959 Menu( wxT("Select"), XXO("&Select"),
960 Section( "Basic",
961 Command( wxT("SelectAll"), XXO("&All"), FN(OnSelectAll),
963 Options{ wxT("Ctrl+A"), XO("Select All") } ),
964 Command( wxT("SelectNone"), XXO("&None"), FN(OnSelectNone),
966 Options{ wxT("Ctrl+Shift+A"), XO("Select None") } ),
967
969
970 Menu( wxT("Tracks"), XXO("&Tracks"),
971 Command( wxT("SelAllTracks"), XXO("In All &Tracks"),
972 FN(OnSelectAllTracks),
974 wxT("Ctrl+Shift+K") ),
975 Command( wxT("SelSyncLockTracks"), XXO("In All &Sync-Locked Tracks"),
976 FN(OnSelectSyncLockSel),
978 Options{ wxT("Ctrl+Shift+Y"), XO("Select Sync-Locked") } )
979 ),
980
982
983 Menu( wxT("Region"), XXO("R&egion"),
984 Section( "",
985 Command( wxT("SetLeftSelection"), XXO("&Left at Playback Position"),
986 FN(OnSetLeftSelection), TracksExistFlag(),
987 Options{ wxT("["), XO("Set Selection Left at Play Position") } ),
988 Command( wxT("SetRightSelection"), XXO("&Right at Playback Position"),
989 FN(OnSetRightSelection), TracksExistFlag(),
990 Options{ wxT("]"), XO("Set Selection Right at Play Position") } ),
991 Command( wxT("SelTrackStartToCursor"), XXO("Track &Start to Cursor"),
992 FN(OnSelectStartCursor), AlwaysEnabledFlag,
993 Options{ wxT("Shift+J"), XO("Select Track Start to Cursor") } ),
994 Command( wxT("SelCursorToTrackEnd"), XXO("Cursor to Track &End"),
995 FN(OnSelectCursorEnd), AlwaysEnabledFlag,
996 Options{ wxT("Shift+K"), XO("Select Cursor to Track End") } ),
997 Command( wxT("SelTrackStartToEnd"), XXO("Track Start to En&d"),
998 FN(OnSelectTrackStartToEnd), AlwaysEnabledFlag,
999 Options{}.LongName( XO("Select Track Start to End") ) )
1000 ),
1001
1002 Section( "",
1003 // GA: Audacity had 'Store Re&gion' here previously. There is no
1004 // one-step way to restore the 'Saved Cursor Position' in Select Menu,
1005 // so arguably using the word 'Selection' to do duty for both saving
1006 // the region or the cursor is better. But it does not belong in a
1007 // 'Region' submenu.
1008 Command( wxT("SelSave"), XXO("S&tore Selection"), FN(OnSelectionSave),
1010 // Audacity had 'Retrieve Regio&n' here previously.
1011 Command( wxT("SelRestore"), XXO("Retrieve Selectio&n"),
1012 FN(OnSelectionRestore), TracksExistFlag() )
1013 )
1014 )
1015
1017
1018 ),
1019
1020 Section( "",
1021 Command( wxT("SelCursorStoredCursor"),
1022 XXO("Cursor to Stored &Cursor Position"),
1023 FN(OnSelectCursorStoredCursor), TracksExistFlag(),
1024 Options{}.LongName( XO("Select Cursor to Stored") ) ),
1025
1026 Command( wxT("StoreCursorPosition"), XXO("Store Cursor Pos&ition"),
1027 FN(OnCursorPositionStore),
1029 // Save cursor position is used in some selections.
1030 // Maybe there should be a restore for it?
1031 ),
1032
1033 Section( "",
1034 Command( wxT("ZeroCross"), XXO("At &Zero Crossings"),
1035 FN(OnZeroCrossing), EditableTracksSelectedFlag(),
1036 Options{ wxT("Z"), XO("Select Zero Crossing") } )
1037 )
1038 ) ) };
1039 return menu;
1040}
const ReservedCommandFlag & IsSyncLockedFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
constexpr auto Section
Definition: MenuRegistry.h:436

References AlwaysEnabledFlag, MenuRegistry::Command, EditableTracksSelectedFlag(), findCommandHandler(), FN, IsSyncLockedFlag(), MenuRegistry::Options::LongName(), MenuRegistry::Menu, MenuRegistry::Section, TracksExistFlag(), WaveTracksExistFlag(), WaveTracksSelectedFlag(), wxT(), XO(), and XXO().

Here is the call graph for this function:

Variable Documentation

◆ sAttachment0

AttachedItem anonymous_namespace{SelectMenus.cpp}::sAttachment0
Initial value:
wxT("Transport/Basic")
}
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:175

Definition at line 1132 of file SelectMenus.cpp.

◆ sAttachment1

AttachedItem anonymous_namespace{SelectMenus.cpp}::sAttachment1 { Indirect(SelectMenu()) }

Definition at line 1042 of file SelectMenus.cpp.

◆ sAttachment2

AttachedItem anonymous_namespace{SelectMenus.cpp}::sAttachment2
Initial value:
wxT("Optional/Extra/Part1")
}

Definition at line 1085 of file SelectMenus.cpp.

◆ sAttachment4

AttachedItem anonymous_namespace{SelectMenus.cpp}::sAttachment4
Initial value:
wxT("Optional/Extra/Part2")
}

Definition at line 1163 of file SelectMenus.cpp.

◆ sAttachment5

AttachedItem anonymous_namespace{SelectMenus.cpp}::sAttachment5
Initial value:
wxT("Optional/Extra/Part1")
}

Definition at line 1189 of file SelectMenus.cpp.