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 131 of file SelectMenus.cpp.

◆ SelectionOperation

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

Definition at line 136 of file SelectMenus.cpp.

◆ TimeUnit

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

Definition at line 142 of file SelectMenus.cpp.

Function Documentation

◆ CursorMenu()

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

Definition at line 1092 of file SelectMenus.cpp.

1093{
1094 static const auto CanStopFlags = AudioIONotBusyFlag() | CanStopAudioStreamFlag();
1095
1096 // JKC: ANSWER-ME: How is 'cursor to' different to 'Skip To' and how is it
1097 // useful?
1098 // GA: 'Skip to' moves the viewpoint to center of the track and preserves the
1099 // selection. 'Cursor to' does neither. 'Center at' might describe it better
1100 // than 'Skip'.
1101 static auto menu = std::shared_ptr{
1103 Menu( wxT("Cursor"), XXO("&Cursor to"),
1104 Command( wxT("CursSelStart"), XXO("Selection Star&t"),
1105 FN(OnCursorSelStart),
1107 Options{}.LongName( XO("Cursor to Selection Start") ) ),
1108 Command( wxT("CursSelEnd"), XXO("Selection En&d"),
1109 FN(OnCursorSelEnd),
1111 Options{}.LongName( XO("Cursor to Selection End") ) ),
1112
1113 Command( wxT("CursTrackStart"), XXO("Track &Start"),
1114 FN(OnCursorTrackStart),
1116 Options{ wxT("J"), XO("Cursor to Track Start") } ),
1117 Command( wxT("CursTrackEnd"), XXO("Track &End"),
1118 FN(OnCursorTrackEnd),
1120 Options{ wxT("K"), XO("Cursor to Track End") } ),
1121
1122 Command( wxT("CursProjectStart"), XXO("&Project Start"),
1123 FN(OnSkipStart),
1125 Options{ wxT("Home"), XO("Cursor to Project Start") } ),
1126 Command( wxT("CursProjectEnd"), XXO("Project E&nd"), FN(OnSkipEnd),
1128 Options{ wxT("End"), XO("Cursor to Project End") } )
1129 ) ) };
1130 return menu;
1131}
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 367 of file SelectMenus.cpp.

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

References PackedArray::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 351 of file SelectMenus.cpp.

354{
355 if (ProjectAudioIO::Get( project ).IsAudioActive()) {
356 SeekWhenAudioActive(seekStep, lastSelectionAdjustment);
357 }
358 else
359 {
360 lastSelectionAdjustment = ::wxGetUTCTimeMillis();
362 }
363
365}
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 1137 of file SelectMenus.cpp.

1138{
1139 static auto menu = std::shared_ptr{
1141 Menu( wxT("Cursor"), XXO("&Cursor"),
1142 Command( wxT("CursorLeft"), XXO("Cursor &Left"), FN(OnCursorLeft),
1144 Options{ wxT("Left") }.WantKeyUp().AllowDup() ),
1145 Command( wxT("CursorRight"), XXO("Cursor &Right"), FN(OnCursorRight),
1147 Options{ wxT("Right") }.WantKeyUp().AllowDup() ),
1148 Command( wxT("CursorShortJumpLeft"), XXO("Cursor Sh&ort Jump Left"),
1149 FN(OnCursorShortJumpLeft),
1151 Command( wxT("CursorShortJumpRight"), XXO("Cursor Shor&t Jump Right"),
1152 FN(OnCursorShortJumpRight),
1154 Command( wxT("CursorLongJumpLeft"), XXO("Cursor Long J&ump Left"),
1155 FN(OnCursorLongJumpLeft),
1156 TracksExistFlag() | TrackPanelHasFocus(), wxT("Shift+,") ),
1157 Command( wxT("CursorLongJumpRight"), XXO("Cursor Long Ju&mp Right"),
1158 FN(OnCursorLongJumpRight),
1159 TracksExistFlag() | TrackPanelHasFocus(), wxT("Shift+.") )
1160 ) ) };
1161 return menu;
1162}
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 1168 of file SelectMenus.cpp.

1169{
1170 static auto menu = std::shared_ptr{
1172 Menu( wxT("Seek"), XXO("See&k"),
1173 Command( wxT("SeekLeftShort"), XXO("Short Seek &Left During Playback"),
1174 FN(OnSeekLeftShort), AudioIOBusyFlag(),
1175 Options{ wxT("Left") }.AllowDup() ),
1176 Command( wxT("SeekRightShort"),
1177 XXO("Short Seek &Right During Playback"), FN(OnSeekRightShort),
1179 Options{ wxT("Right") }.AllowDup() ),
1180 Command( wxT("SeekLeftLong"), XXO("Long Seek Le&ft During Playback"),
1181 FN(OnSeekLeftLong), AudioIOBusyFlag(),
1182 Options{ wxT("Shift+Left") }.AllowDup() ),
1183 Command( wxT("SeekRightLong"), XXO("Long Seek Rig&ht During Playback"),
1184 FN(OnSeekRightLong), AudioIOBusyFlag(),
1185 Options{ wxT("Shift+Right") }.AllowDup() )
1186 ) ) };
1187 return menu;
1188}
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 1045 of file SelectMenus.cpp.

1046{
1047 static auto menu = std::shared_ptr{
1049 Menu( wxT("Select"), XXO("&Selection"),
1050 Command( wxT("SnapToOff"), XXO("Snap-To &Off"), FN(OnSnapToOff),
1052 Command( wxT("SnapToNearest"), XXO("Snap-To &Nearest"),
1053 FN(OnSnapToNearest), AlwaysEnabledFlag ),
1054 Command( wxT("SnapToPrior"), XXO("Snap-To &Prior"), FN(OnSnapToPrior),
1056 Command( wxT("SelStart"), XXO("Selection to &Start"), FN(OnSelToStart),
1057 AlwaysEnabledFlag, wxT("Shift+Home") ),
1058 Command( wxT("SelEnd"), XXO("Selection to En&d"), FN(OnSelToEnd),
1059 AlwaysEnabledFlag, wxT("Shift+End") ),
1060 Command( wxT("SelExtLeft"), XXO("Selection Extend &Left"),
1061 FN(OnSelExtendLeft),
1063 Options{ wxT("Shift+Left") }.WantKeyUp().AllowDup() ),
1064 Command( wxT("SelExtRight"), XXO("Selection Extend &Right"),
1065 FN(OnSelExtendRight),
1067 Options{ wxT("Shift+Right") }.WantKeyUp().AllowDup() ),
1068 Command( wxT("SelSetExtLeft"), XXO("Set (or Extend) Le&ft Selection"),
1069 FN(OnSelSetExtendLeft),
1071 Command( wxT("SelSetExtRight"), XXO("Set (or Extend) Rig&ht Selection"),
1072 FN(OnSelSetExtendRight),
1074 Command( wxT("SelCntrLeft"), XXO("Selection Contract L&eft"),
1075 FN(OnSelContractLeft),
1077 Options{ wxT("Ctrl+Shift+Right") }.WantKeyUp() ),
1078 Command( wxT("SelCntrRight"), XXO("Selection Contract R&ight"),
1079 FN(OnSelContractRight),
1081 Options{ wxT("Ctrl+Shift+Left") }.WantKeyUp() )
1082 ) ) };
1083 return menu;
1084}
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 30 of file SelectMenus.cpp.

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

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 175 of file SelectMenus.cpp.

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}
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 209 of file SelectMenus.cpp.

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

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

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 193 of file SelectMenus.cpp.

196{
197 auto &viewInfo = ViewInfo::Get( project );
198
199 if (timeUnit == TIME_UNIT_SECONDS)
200 return t + offset; // snapping is currently ignored for non-pixel moves
201
202 if (snapMode == SnapMode::SNAP_OFF)
203 return viewInfo.OffsetTimeByPixels(t, (int)offset);
204
205 return GridMove(project, t, (int)offset);
206}
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 116 of file SelectMenus.cpp.

117{
118 auto &project = context.project;
119 auto evt = context.pEvt;
120 bool bKeyUp = (evt) && evt->GetEventType() == wxEVT_KEY_UP;
121
123 return bKeyUp;
124 if( !bKeyUp )
125 return false;
126
128 return true;
129}
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 313 of file SelectMenus.cpp.

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

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

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 268 of file SelectMenus.cpp.

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

References CURSOR_MOVE, PackedArray::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 955 of file SelectMenus.cpp.

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

◆ sAttachment1

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

Definition at line 1043 of file SelectMenus.cpp.

◆ sAttachment2

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

Definition at line 1086 of file SelectMenus.cpp.

◆ sAttachment4

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

Definition at line 1164 of file SelectMenus.cpp.

◆ sAttachment5

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

Definition at line 1190 of file SelectMenus.cpp.