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

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, int snapToTime)
 
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)
 
BaseItemSharedPtr SelectMenu ()
 
BaseItemSharedPtr ExtraSelectionMenu ()
 
BaseItemSharedPtr CursorMenu ()
 
BaseItemSharedPtr ExtraCursorMenu ()
 
BaseItemSharedPtr ExtraSeekMenu ()
 

Variables

AttachedItem sAttachment1
 
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 120 of file SelectMenus.cpp.

◆ SelectionOperation

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

Definition at line 125 of file SelectMenus.cpp.

◆ TimeUnit

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

Definition at line 131 of file SelectMenus.cpp.

Function Documentation

◆ CursorMenu()

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

Definition at line 1060 of file SelectMenus.cpp.

1061{
1063 static const auto CanStopFlags = AudioIONotBusyFlag() | CanStopAudioStreamFlag();
1064
1065 // JKC: ANSWER-ME: How is 'cursor to' different to 'Skip To' and how is it
1066 // useful?
1067 // GA: 'Skip to' moves the viewpoint to center of the track and preserves the
1068 // selection. 'Cursor to' does neither. 'Center at' might describe it better
1069 // than 'Skip'.
1070 static BaseItemSharedPtr menu{
1072 Menu( wxT("Cursor"), XXO("&Cursor to"),
1073 Command( wxT("CursSelStart"), XXO("Selection Star&t"),
1074 FN(OnCursorSelStart),
1076 Options{}.LongName( XO("Cursor to Selection Start") ) ),
1077 Command( wxT("CursSelEnd"), XXO("Selection En&d"),
1078 FN(OnCursorSelEnd),
1080 Options{}.LongName( XO("Cursor to Selection End") ) ),
1081
1082 Command( wxT("CursTrackStart"), XXO("Track &Start"),
1083 FN(OnCursorTrackStart),
1085 Options{ wxT("J"), XO("Cursor to Track Start") } ),
1086 Command( wxT("CursTrackEnd"), XXO("Track &End"),
1087 FN(OnCursorTrackEnd),
1089 Options{ wxT("K"), XO("Cursor to Track End") } ),
1090
1091 Command( wxT("CursProjectStart"), XXO("&Project Start"),
1092 FN(OnSkipStart),
1094 Options{ wxT("Home"), XO("Cursor to Project Start") } ),
1095 Command( wxT("CursProjectEnd"), XXO("Project E&nd"), FN(OnSkipEnd),
1097 Options{ wxT("End"), XO("Cursor to Project End") } )
1098 ) ) };
1099 return menu;
1100}
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)
std::unique_ptr< MenuItem > Menu(const Identifier &internalName, const TranslatableString &title, Args &&... args)
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:72
Options && LongName(const TranslatableString &value) &&

References AudioIONotBusyFlag(), CanStopAudioStreamFlag(), anonymous_namespace{TimerRecordDialog.cpp}::CanStopFlags, MenuTable::Command(), EditableTracksSelectedFlag(), findCommandHandler(), FN, CommandManager::Options::LongName(), MenuTable::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 357 of file SelectMenus.cpp.

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

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

344{
345 if (ProjectAudioIO::Get( project ).IsAudioActive()) {
346 SeekWhenAudioActive(seekStep, lastSelectionAdjustment);
347 }
348 else
349 {
350 lastSelectionAdjustment = ::wxGetUTCTimeMillis();
351 MoveWhenAudioInactive(project, seekStep, TIME_UNIT_SECONDS);
352 }
353
354 ProjectHistory::Get( project ).ModifyState(false);
355}
void SeekWhenAudioActive(double seekStep, wxLongLong &lastSelectionAdjustment)
void MoveWhenAudioInactive(AudacityProject &project, double seekStep, TimeUnit timeUnit)

References ProjectAudioIO::Get(), ProjectHistory::Get(), ProjectHistory::ModifyState(), MoveWhenAudioInactive(), 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()

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

Definition at line 1107 of file SelectMenus.cpp.

1108{
1110 static BaseItemSharedPtr menu{
1112 Menu( wxT("Cursor"), XXO("&Cursor"),
1113 Command( wxT("CursorLeft"), XXO("Cursor &Left"), FN(OnCursorLeft),
1115 Options{ wxT("Left") }.WantKeyUp().AllowDup() ),
1116 Command( wxT("CursorRight"), XXO("Cursor &Right"), FN(OnCursorRight),
1118 Options{ wxT("Right") }.WantKeyUp().AllowDup() ),
1119 Command( wxT("CursorShortJumpLeft"), XXO("Cursor Sh&ort Jump Left"),
1120 FN(OnCursorShortJumpLeft),
1122 Command( wxT("CursorShortJumpRight"), XXO("Cursor Shor&t Jump Right"),
1123 FN(OnCursorShortJumpRight),
1125 Command( wxT("CursorLongJumpLeft"), XXO("Cursor Long J&ump Left"),
1126 FN(OnCursorLongJumpLeft),
1127 TracksExistFlag() | TrackPanelHasFocus(), wxT("Shift+,") ),
1128 Command( wxT("CursorLongJumpRight"), XXO("Cursor Long Ju&mp Right"),
1129 FN(OnCursorLongJumpRight),
1130 TracksExistFlag() | TrackPanelHasFocus(), wxT("Shift+.") )
1131 ) ) };
1132 return menu;
1133}
const ReservedCommandFlag & TracksExistFlag()
const ReservedCommandFlag & TrackPanelHasFocus()

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

Here is the call graph for this function:

◆ ExtraSeekMenu()

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

Definition at line 1140 of file SelectMenus.cpp.

1141{
1143 static BaseItemSharedPtr menu{
1145 Menu( wxT("Seek"), XXO("See&k"),
1146 Command( wxT("SeekLeftShort"), XXO("Short Seek &Left During Playback"),
1147 FN(OnSeekLeftShort), AudioIOBusyFlag(),
1148 Options{ wxT("Left") }.AllowDup() ),
1149 Command( wxT("SeekRightShort"),
1150 XXO("Short Seek &Right During Playback"), FN(OnSeekRightShort),
1152 Options{ wxT("Right") }.AllowDup() ),
1153 Command( wxT("SeekLeftLong"), XXO("Long Seek Le&ft During Playback"),
1154 FN(OnSeekLeftLong), AudioIOBusyFlag(),
1155 Options{ wxT("Shift+Left") }.AllowDup() ),
1156 Command( wxT("SeekRightLong"), XXO("Long Seek Rig&ht During Playback"),
1157 FN(OnSeekRightLong), AudioIOBusyFlag(),
1158 Options{ wxT("Shift+Right") }.AllowDup() )
1159 ) ) };
1160 return menu;
1161}
const ReservedCommandFlag & AudioIOBusyFlag()

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

Here is the call graph for this function:

◆ ExtraSelectionMenu()

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

Definition at line 1011 of file SelectMenus.cpp.

1012{
1014 static BaseItemSharedPtr menu{
1016 Menu( wxT("Select"), XXO("&Selection"),
1017 Command( wxT("SnapToOff"), XXO("Snap-To &Off"), FN(OnSnapToOff),
1019 Command( wxT("SnapToNearest"), XXO("Snap-To &Nearest"),
1020 FN(OnSnapToNearest), AlwaysEnabledFlag ),
1021 Command( wxT("SnapToPrior"), XXO("Snap-To &Prior"), FN(OnSnapToPrior),
1023 Command( wxT("SelStart"), XXO("Selection to &Start"), FN(OnSelToStart),
1024 AlwaysEnabledFlag, wxT("Shift+Home") ),
1025 Command( wxT("SelEnd"), XXO("Selection to En&d"), FN(OnSelToEnd),
1026 AlwaysEnabledFlag, wxT("Shift+End") ),
1027 Command( wxT("SelExtLeft"), XXO("Selection Extend &Left"),
1028 FN(OnSelExtendLeft),
1030 Options{ wxT("Shift+Left") }.WantKeyUp().AllowDup() ),
1031 Command( wxT("SelExtRight"), XXO("Selection Extend &Right"),
1032 FN(OnSelExtendRight),
1034 Options{ wxT("Shift+Right") }.WantKeyUp().AllowDup() ),
1035 Command( wxT("SelSetExtLeft"), XXO("Set (or Extend) Le&ft Selection"),
1036 FN(OnSelSetExtendLeft),
1038 Command( wxT("SelSetExtRight"), XXO("Set (or Extend) Rig&ht Selection"),
1039 FN(OnSelSetExtendRight),
1041 Command( wxT("SelCntrLeft"), XXO("Selection Contract L&eft"),
1042 FN(OnSelContractLeft),
1044 Options{ wxT("Ctrl+Shift+Right") }.WantKeyUp() ),
1045 Command( wxT("SelCntrRight"), XXO("Selection Contract R&ight"),
1046 FN(OnSelContractRight),
1048 Options{ wxT("Ctrl+Shift+Left") }.WantKeyUp() )
1049 ) ) };
1050 return menu;
1051}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34

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

Here is the call graph for this function:

◆ GridMove()

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

Definition at line 164 of file SelectMenus.cpp.

166{
167 auto &formats = ProjectNumericFormats::Get(project);
168 auto rate = ProjectRate::Get(project).GetRate();
169 auto &viewInfo = ViewInfo::Get( project );
170 auto format = formats.GetSelectionFormat();
171
173
174 // Try incrementing/decrementing the value; if we've moved far enough we're
175 // done
176 double result;
177 minPix >= 0 ? nc.Increment() : nc.Decrement();
178 result = nc.GetValue();
179 if (std::abs(viewInfo.TimeToPosition(result) - viewInfo.TimeToPosition(t))
180 >= abs(minPix))
181 return result;
182
183 // Otherwise, move minPix pixels, then snap to the time.
184 result = viewInfo.OffsetTimeByPixels(t, minPix);
185 nc.SetValue(result);
186 result = nc.GetValue();
187 return result;
188}
int format
Definition: ExportPCM.cpp:53
NumericConverter provides the advanced formatting control used in the selection bar of Audacity.
static ProjectNumericFormats & Get(AudacityProject &project)
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53

References NumericConverter::Decrement(), format, ProjectNumericFormats::Get(), ProjectRate::Get(), ViewInfo::Get(), ProjectRate::GetRate(), NumericConverter::GetValue(), NumericConverter::Increment(), NumericConverter::SetValue(), and NumericConverter::TIME.

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

208{
209 auto &viewInfo = ViewInfo::Get( project );
210 auto &trackPanel = TrackPanel::Get( project );
211 auto &tracks = TrackList::Get( project );
212 auto &ruler = AdornedRulerPanel::Get( project );
213 const auto &settings = ProjectSettings::Get( project );
214 auto &window = ProjectWindow::Get( project );
215
216 // If TIME_UNIT_SECONDS, snap-to will be off.
217 int snapToTime = settings.GetSnapTo();
218 const double t0 = viewInfo.selectedRegion.t0();
219 const double end = std::max(
220 tracks.GetEndTime(),
221 viewInfo.GetScreenEndTime());
222
223 // Move the cursor
224 // Already in cursor mode?
225 if( viewInfo.selectedRegion.isPoint() )
226 {
227 double newT = OffsetTime(project,
228 t0, seekStep, timeUnit, snapToTime);
229 // constrain.
230 newT = std::max(0.0, newT);
231 newT = std::min(newT, end);
232 // Move
233 viewInfo.selectedRegion.setT0(
234 newT,
235 false); // do not swap selection boundaries
236 viewInfo.selectedRegion.collapseToT0();
237
238 // Move the visual cursor, avoiding an unnecessary complete redraw
239 trackPanel.DrawOverlays(false);
240 ruler.DrawOverlays(false);
241 }
242 else
243 {
244 // Transition to cursor mode.
245 if( seekStep < 0 )
246 viewInfo.selectedRegion.collapseToT0();
247 else
248 viewInfo.selectedRegion.collapseToT1();
249 trackPanel.Refresh(false);
250 }
251
252 // Make sure NEW position is in view
253 window.ScrollIntoView(viewInfo.selectedRegion.t1());
254 return;
255}
static Settings & settings()
Definition: TrackInfo.cpp:87
static AdornedRulerPanel & Get(AudacityProject &project)
static ProjectSettings & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:231
double OffsetTime(AudacityProject &project, double t, double offset, TimeUnit timeUnit, int snapToTime)

References PackedArray::end(), ViewInfo::Get(), TrackList::Get(), AdornedRulerPanel::Get(), ProjectSettings::Get(), ProjectWindow::Get(), TrackPanel::Get(), min(), OffsetTime(), anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), and settings().

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

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

References fillTwo, ProjectRate::Get(), TrackList::Get(), ProjectRate::GetRate(), and min().

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,
int  snapToTime 
)

Definition at line 190 of file SelectMenus.cpp.

193{
194 auto &viewInfo = ViewInfo::Get( project );
195
196 if (timeUnit == TIME_UNIT_SECONDS)
197 return t + offset; // snapping is currently ignored for non-pixel moves
198
199 if (snapToTime == SNAP_OFF)
200 return viewInfo.OffsetTimeByPixels(t, (int)offset);
201
202 return GridMove(project, t, (int)offset);
203}
@ SNAP_OFF
double GridMove(AudacityProject &project, double t, int minPix)

References ViewInfo::Get(), GridMove(), 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 105 of file SelectMenus.cpp.

106{
107 auto &project = context.project;
108 auto evt = context.pEvt;
109 bool bKeyUp = (evt) && evt->GetEventType() == wxEVT_KEY_UP;
110
111 if( ProjectAudioIO::Get( project ).IsAudioActive() )
112 return bKeyUp;
113 if( !bKeyUp )
114 return false;
115
116 ProjectHistory::Get( project ).ModifyState(false);
117 return true;
118}
const wxEvent * pEvt
AudacityProject & project

References ProjectAudioIO::Get(), ProjectHistory::Get(), ProjectAudioIO::IsAudioActive(), ProjectHistory::ModifyState(), CommandContext::pEvt, and CommandContext::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 303 of file SelectMenus.cpp.

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

144{
145 auto gAudioIO = AudioIO::Get();
146#ifdef EXPERIMENTAL_IMPROVED_SEEKING
147 if (gAudioIO->GetLastPlaybackTime() < lastSelectionAdjustment) {
148 // Allow time for the last seek to output a buffer before
149 // discarding samples again
150 // Do not advance mLastSelectionAdjustment
151 return;
152 }
153#endif
154 lastSelectionAdjustment = ::wxGetUTCTimeMillis();
155
156 gAudioIO->SeekStream(seekStep);
157}

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

260{
261 auto &viewInfo = ViewInfo::Get( project );
262 auto &tracks = TrackList::Get( project );
263 const auto &settings = ProjectSettings::Get( project );
264 auto &window = ProjectWindow::Get( project );
265
266 if( operation == CURSOR_MOVE )
267 {
268 MoveWhenAudioInactive( project, seekStep, timeUnit);
269 return;
270 }
271
272 int snapToTime = settings.GetSnapTo();
273 const double t0 = viewInfo.selectedRegion.t0();
274 const double t1 = viewInfo.selectedRegion.t1();
275 const double end = std::max(
276 tracks.GetEndTime(),
277 viewInfo.GetScreenEndTime());
278
279 // Is it t0 or t1 moving?
280 bool bMoveT0 = (operation == SELECTION_CONTRACT && seekStep > 0) ||
281 (operation == SELECTION_EXTEND && seekStep < 0);
282 // newT is where we want to move to
283 double newT = OffsetTime( project,
284 bMoveT0 ? t0 : t1, seekStep, timeUnit, snapToTime);
285 // constrain to be in the track/screen limits.
286 newT = std::max( 0.0, newT );
287 newT = std::min( newT, end);
288 // optionally constrain to be a contraction, i.e. so t0/t1 do not cross over
289 if( operation == SELECTION_CONTRACT )
290 newT = bMoveT0 ? std::min( t1, newT ) : std::max( t0, newT );
291
292 // Actually move
293 if( bMoveT0 )
294 viewInfo.selectedRegion.setT0( newT );
295 else
296 viewInfo.selectedRegion.setT1( newT );
297
298 // Ensure it is visible
299 window.ScrollIntoView(newT);
300}
STL namespace.

References CURSOR_MOVE, PackedArray::end(), ViewInfo::Get(), TrackList::Get(), ProjectSettings::Get(), ProjectWindow::Get(), min(), MoveWhenAudioInactive(), OffsetTime(), SELECTION_CONTRACT, SELECTION_EXTEND, and settings().

Referenced by SeekLeftOrRight().

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

◆ SelectMenu()

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

Definition at line 917 of file SelectMenus.cpp.

918{
920 static BaseItemSharedPtr menu{
922 /* i18n-hint: (verb) It's an item on a menu. */
923 Menu( wxT("Select"), XXO("&Select"),
924 Section( "Basic",
925 Command( wxT("SelectAll"), XXO("&All"), FN(OnSelectAll),
927 Options{ wxT("Ctrl+A"), XO("Select All") } ),
928 Command( wxT("SelectNone"), XXO("&None"), FN(OnSelectNone),
930 Options{ wxT("Ctrl+Shift+A"), XO("Select None") } ),
931
933
934 Menu( wxT("Tracks"), XXO("&Tracks"),
935 Command( wxT("SelAllTracks"), XXO("In All &Tracks"),
936 FN(OnSelectAllTracks),
938 wxT("Ctrl+Shift+K") ),
939 Command( wxT("SelSyncLockTracks"), XXO("In All &Sync-Locked Tracks"),
940 FN(OnSelectSyncLockSel),
942 Options{ wxT("Ctrl+Shift+Y"), XO("Select Sync-Locked") } )
943 ),
944
946
947 Menu( wxT("Region"), XXO("R&egion"),
948 Section( "",
949 Command( wxT("SetLeftSelection"), XXO("&Left at Playback Position"),
950 FN(OnSetLeftSelection), TracksExistFlag(),
951 Options{ wxT("["), XO("Set Selection Left at Play Position") } ),
952 Command( wxT("SetRightSelection"), XXO("&Right at Playback Position"),
953 FN(OnSetRightSelection), TracksExistFlag(),
954 Options{ wxT("]"), XO("Set Selection Right at Play Position") } ),
955 Command( wxT("SelTrackStartToCursor"), XXO("Track &Start to Cursor"),
956 FN(OnSelectStartCursor), AlwaysEnabledFlag,
957 Options{ wxT("Shift+J"), XO("Select Track Start to Cursor") } ),
958 Command( wxT("SelCursorToTrackEnd"), XXO("Cursor to Track &End"),
959 FN(OnSelectCursorEnd), AlwaysEnabledFlag,
960 Options{ wxT("Shift+K"), XO("Select Cursor to Track End") } ),
961 Command( wxT("SelTrackStartToEnd"), XXO("Track Start to En&d"),
962 FN(OnSelectTrackStartToEnd), AlwaysEnabledFlag,
963 Options{}.LongName( XO("Select Track Start to End") ) )
964 ),
965
966 Section( "",
967 // GA: Audacity had 'Store Re&gion' here previously. There is no
968 // one-step way to restore the 'Saved Cursor Position' in Select Menu,
969 // so arguably using the word 'Selection' to do duty for both saving
970 // the region or the cursor is better. But it does not belong in a
971 // 'Region' submenu.
972 Command( wxT("SelSave"), XXO("S&tore Selection"), FN(OnSelectionSave),
974 // Audacity had 'Retrieve Regio&n' here previously.
975 Command( wxT("SelRestore"), XXO("Retrieve Selectio&n"),
976 FN(OnSelectionRestore), TracksExistFlag() )
977 )
978 )
979
981
982 ),
983
984 Section( "",
985 Command( wxT("SelCursorStoredCursor"),
986 XXO("Cursor to Stored &Cursor Position"),
987 FN(OnSelectCursorStoredCursor), TracksExistFlag(),
988 Options{}.LongName( XO("Select Cursor to Stored") ) ),
989
990 Command( wxT("StoreCursorPosition"), XXO("Store Cursor Pos&ition"),
991 FN(OnCursorPositionStore),
993 // Save cursor position is used in some selections.
994 // Maybe there should be a restore for it?
995 ),
996
997 Section( "",
998 Command( wxT("ZeroCross"), XXO("At &Zero Crossings"),
999 FN(OnZeroCrossing), EditableTracksSelectedFlag(),
1000 Options{ wxT("Z"), XO("Select Zero Crossing") } )
1001 )
1002 ) ) };
1003 return menu;
1004}
const ReservedCommandFlag & IsSyncLockedFlag()
const ReservedCommandFlag & WaveTracksExistFlag()
const ReservedCommandFlag & WaveTracksSelectedFlag()
std::unique_ptr< MenuPart > Section(const Identifier &internalName, Args &&... args)

References AlwaysEnabledFlag, MenuTable::Command(), EditableTracksSelectedFlag(), findCommandHandler(), FN, IsSyncLockedFlag(), CommandManager::Options::LongName(), MenuTable::Menu(), MenuTable::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"),
}

Definition at line 1102 of file SelectMenus.cpp.

◆ sAttachment1

AttachedItem anonymous_namespace{SelectMenus.cpp}::sAttachment1
Initial value:
{
wxT(""),
}

Definition at line 1006 of file SelectMenus.cpp.

◆ sAttachment2

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

Definition at line 1053 of file SelectMenus.cpp.

◆ sAttachment4

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

Definition at line 1135 of file SelectMenus.cpp.

◆ sAttachment5

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

Definition at line 1163 of file SelectMenus.cpp.