Audacity 3.2.0
Functions | Variables
anonymous_namespace{ViewMenus.cpp} Namespace Reference

Functions

double GetZoomOfSelection (const AudacityProject &project)
 
double GetZoomOfPreset (const AudacityProject &project, int preset)
 
void OnZoomIn (const CommandContext &context)
 
void OnZoomNormal (const CommandContext &context)
 
void OnZoomOut (const CommandContext &context)
 
void OnZoomSel (const CommandContext &context)
 
void OnZoomToggle (const CommandContext &context)
 
void OnZoomFit (const CommandContext &context)
 
void OnZoomFitV (const CommandContext &context)
 
void OnCollapseAllTracks (const CommandContext &context)
 
void OnExpandAllTracks (const CommandContext &context)
 
void OnGoSelStart (const CommandContext &context)
 
void OnGoSelEnd (const CommandContext &context)
 
void OnShowExtraMenus (const CommandContext &context)
 
void OnShowClipping (const CommandContext &context)
 
void OnShowNameOverlay (const CommandContext &context)
 
auto ViewMenu ()
 

Variables

AttachedItem sAttachment1 { Indirect(ViewMenu()) }
 

Function Documentation

◆ GetZoomOfPreset()

double anonymous_namespace{ViewMenus.cpp}::GetZoomOfPreset ( const AudacityProject project,
int  preset 
)

Definition at line 53 of file ViewMenus.cpp.

54{
55
56 // Sets a limit on how far we will zoom out as a factor over zoom to fit.
57 const double maxZoomOutFactor = 4.0;
58 // Sets how many pixels we allow for one uint, such as seconds.
59 const double pixelsPerUnit = 5.0;
60
61 double result = 1.0;
62 auto &viewport = Viewport::Get(project);
63 double zoomToFit = viewport.GetZoomOfToFit();
64 using namespace WaveChannelViewConstants;
65 switch(preset) {
66 default:
67 case kZoomDefault:
68 result = ZoomInfo::GetDefaultZoom();
69 break;
70 case kZoomToFit:
71 result = zoomToFit;
72 break;
74 result = GetZoomOfSelection( project );
75 break;
76 case kZoomMinutes:
77 result = pixelsPerUnit * 1.0/60;
78 break;
79 case kZoomSeconds:
80 result = pixelsPerUnit * 1.0;
81 break;
82 case kZoom5ths:
83 result = pixelsPerUnit * 5.0;
84 break;
85 case kZoom10ths:
86 result = pixelsPerUnit * 10.0;
87 break;
88 case kZoom20ths:
89 result = pixelsPerUnit * 20.0;
90 break;
91 case kZoom50ths:
92 result = pixelsPerUnit * 50.0;
93 break;
94 case kZoom100ths:
95 result = pixelsPerUnit * 100.0;
96 break;
97 case kZoom500ths:
98 result = pixelsPerUnit * 500.0;
99 break;
101 result = pixelsPerUnit * 1000.0;
102 break;
103 case kZoomSamples:
104 result = 44100.0;
105 break;
106 case kZoom4To1:
107 result = 44100.0 * 4;
108 break;
109 case kMaxZoom:
110 result = ZoomInfo::GetMaxZoom();
111 break;
112 };
113 if( result < (zoomToFit/maxZoomOutFactor) )
114 result = zoomToFit / maxZoomOutFactor;
115 return result;
116}
EffectReverbSettings preset
Definition: Reverb.cpp:44
const auto project
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:33
static double GetDefaultZoom()
Definition: ZoomInfo.h:116
static double GetMaxZoom()
Definition: ZoomInfo.cpp:82
double GetZoomOfSelection(const AudacityProject &project)
Definition: ViewMenus.cpp:26

References Viewport::Get(), ZoomInfo::GetDefaultZoom(), ZoomInfo::GetMaxZoom(), GetZoomOfSelection(), WaveChannelViewConstants::kMaxZoom, WaveChannelViewConstants::kZoom100ths, WaveChannelViewConstants::kZoom10ths, WaveChannelViewConstants::kZoom20ths, WaveChannelViewConstants::kZoom4To1, WaveChannelViewConstants::kZoom500ths, WaveChannelViewConstants::kZoom50ths, WaveChannelViewConstants::kZoom5ths, WaveChannelViewConstants::kZoomDefault, WaveChannelViewConstants::kZoomMilliSeconds, WaveChannelViewConstants::kZoomMinutes, WaveChannelViewConstants::kZoomSamples, WaveChannelViewConstants::kZoomSeconds, WaveChannelViewConstants::kZoomToFit, WaveChannelViewConstants::kZoomToSelection, preset, and project.

Referenced by OnZoomToggle().

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

◆ GetZoomOfSelection()

double anonymous_namespace{ViewMenus.cpp}::GetZoomOfSelection ( const AudacityProject project)

Definition at line 26 of file ViewMenus.cpp.

27{
28 auto &viewInfo = ViewInfo::Get( project );
29 auto &viewport = Viewport::Get(project);
30
31 const double lowerBound =
32 std::max(viewInfo.selectedRegion.t0(),
33 viewport.ScrollingLowerBoundTime());
34 const double denom =
35 viewInfo.selectedRegion.t1() - lowerBound;
36 if (denom <= 0.0)
37 return viewInfo.GetZoom();
38
39 // LL: The "-1" is just a hack to get around an issue where zooming to
40 // selection doesn't actually get the entire selected region within the
41 // visible area. This causes a problem with scrolling at end of playback
42 // where the selected region may be scrolled off the left of the screen.
43 // I know this isn't right, but until the real rounding or 1-off issue is
44 // found, this will have to work.
45 // PRL: Did I fix this? I am not sure, so I leave the hack in place.
46 // Fixes might have resulted from commits
47 // 1b8f44d0537d987c59653b11ed75a842b48896ea and
48 // e7c7bb84a966c3b3cc4b3a9717d5f247f25e7296
49 auto width = viewInfo.GetTracksUsableWidth();
50 return (width - 1) / denom;
51}
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

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

Referenced by GetZoomOfPreset(), and OnZoomSel().

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

◆ OnCollapseAllTracks()

void anonymous_namespace{ViewMenus.cpp}::OnCollapseAllTracks ( const CommandContext context)

Definition at line 209 of file ViewMenus.cpp.

210{
211 auto &project = context.project;
214}
AudacityProject & project
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
void CollapseAllTracks()
Definition: Viewport.cpp:739

References Viewport::CollapseAllTracks(), ProjectHistory::Get(), Viewport::Get(), ProjectHistory::ModifyState(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnExpandAllTracks()

void anonymous_namespace{ViewMenus.cpp}::OnExpandAllTracks ( const CommandContext context)

Definition at line 216 of file ViewMenus.cpp.

217{
218 auto &project = context.project;
221}
void ExpandAllTracks()
Definition: Viewport.cpp:729

References Viewport::ExpandAllTracks(), ProjectHistory::Get(), Viewport::Get(), ProjectHistory::ModifyState(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnGoSelEnd()

void anonymous_namespace{ViewMenus.cpp}::OnGoSelEnd ( const CommandContext context)

Definition at line 237 of file ViewMenus.cpp.

238{
239 auto &project = context.project;
240 auto &viewInfo = ViewInfo::Get( project );
241 auto &selectedRegion = viewInfo.selectedRegion;
242 auto &viewport = Viewport::Get(project);
243
244 if (selectedRegion.isPoint())
245 return;
246
247 viewport.SetHorizontalThumb(
248 selectedRegion.t1() - ((viewInfo.GetScreenEndTime() - viewInfo.hpos) / 2));
249}

References ViewInfo::Get(), Viewport::Get(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnGoSelStart()

void anonymous_namespace{ViewMenus.cpp}::OnGoSelStart ( const CommandContext context)

Definition at line 223 of file ViewMenus.cpp.

224{
225 auto &project = context.project;
226 auto &viewInfo = ViewInfo::Get( project );
227 auto &selectedRegion = viewInfo.selectedRegion;
228 auto &viewport = Viewport::Get(project);
229
230 if (selectedRegion.isPoint())
231 return;
232
233 viewport.SetHorizontalThumb(
234 selectedRegion.t0() - ((viewInfo.GetScreenEndTime() - viewInfo.hpos) / 2));
235}

References ViewInfo::Get(), Viewport::Get(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnShowClipping()

void anonymous_namespace{ViewMenus.cpp}::OnShowClipping ( const CommandContext context)

Definition at line 263 of file ViewMenus.cpp.

264{
265 auto &project = context.project;
266 auto &commandManager = CommandManager::Get( project );
267 auto &trackPanel = TrackPanel::Get( project );
268
269 bool checked = !gPrefs->Read(wxT("/GUI/ShowClipping"), 0L);
270 gPrefs->Write(wxT("/GUI/ShowClipping"), checked);
271 gPrefs->Flush();
272 commandManager.Check(wxT("ShowClipping"), checked);
273
275
276 trackPanel.Refresh(false);
277}
wxT("CloseDown"))
int ShowClippingPrefsID()
Definition: GUIPrefs.cpp:228
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
static CommandManager & Get(AudacityProject &project)
static void Broadcast(int id=0)
Call this static function to notify all PrefsListener objects.
Definition: Prefs.cpp:128
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0

References PrefsListener::Broadcast(), audacity::BasicSettings::Flush(), CommandManager::Get(), TrackPanel::Get(), gPrefs, CommandContext::project, project, audacity::BasicSettings::Read(), ShowClippingPrefsID(), audacity::BasicSettings::Write(), and wxT().

Referenced by ViewMenu().

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

◆ OnShowExtraMenus()

void anonymous_namespace{ViewMenus.cpp}::OnShowExtraMenus ( const CommandContext context)

Definition at line 251 of file ViewMenus.cpp.

252{
253 auto &project = context.project;
254 auto &commandManager = CommandManager::Get( project );
255
256 bool checked = !gPrefs->Read(wxT("/GUI/ShowExtraMenus"), 0L);
257 gPrefs->Write(wxT("/GUI/ShowExtraMenus"), checked);
258 gPrefs->Flush();
259 commandManager.Check(wxT("ShowExtraMenus"), checked);
261}
static void RebuildAllMenuBars()

References audacity::BasicSettings::Flush(), CommandManager::Get(), gPrefs, CommandContext::project, project, audacity::BasicSettings::Read(), MenuCreator::RebuildAllMenuBars(), audacity::BasicSettings::Write(), and wxT().

Referenced by ViewMenu().

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

◆ OnShowNameOverlay()

void anonymous_namespace{ViewMenus.cpp}::OnShowNameOverlay ( const CommandContext context)

Definition at line 279 of file ViewMenus.cpp.

280{
281 auto &project = context.project;
282 auto &commandManager = CommandManager::Get( project );
283 auto &trackPanel = TrackPanel::Get( project );
284
285 bool checked = !gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), 0L);
286 gPrefs->Write(wxT("/GUI/ShowTrackNameInWaveform"), checked);
287 gPrefs->Flush();
288 commandManager.Check(wxT("ShowTrackNameInWaveform"), checked);
289
291
292 trackPanel.Refresh(false);
293}
int ShowTrackNameInWaveformPrefsID()
Definition: GUIPrefs.cpp:234

References PrefsListener::Broadcast(), audacity::BasicSettings::Flush(), CommandManager::Get(), TrackPanel::Get(), gPrefs, CommandContext::project, project, audacity::BasicSettings::Read(), ShowTrackNameInWaveformPrefsID(), audacity::BasicSettings::Write(), and wxT().

Referenced by ViewMenu().

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

◆ OnZoomFit()

void anonymous_namespace{ViewMenus.cpp}::OnZoomFit ( const CommandContext context)

Definition at line 194 of file ViewMenus.cpp.

195{
196 auto &project = context.project;
197 auto &viewport = Viewport::Get(project);
198 viewport.ZoomFitHorizontally();
199}

References Viewport::Get(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnZoomFitV()

void anonymous_namespace{ViewMenus.cpp}::OnZoomFitV ( const CommandContext context)

Definition at line 201 of file ViewMenus.cpp.

202{
203 auto &project = context.project;
204 auto &viewport = Viewport::Get(project);
205 viewport.ZoomFitVertically();
207}

References ProjectHistory::Get(), Viewport::Get(), ProjectHistory::ModifyState(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnZoomIn()

void anonymous_namespace{ViewMenus.cpp}::OnZoomIn ( const CommandContext context)

Definition at line 124 of file ViewMenus.cpp.

125{
126 auto &project = context.project;
127 auto &trackPanel = TrackPanel::Get( project );
128 auto &viewport = Viewport::Get(project);
129
130 auto gAudioIO = AudioIO::Get();
131 // LLL: Handling positioning differently when audio is
132 // actively playing. Don't do this if paused.
133 if (gAudioIO->IsStreamActive(
135 !gAudioIO->IsPaused()){
136 viewport.ZoomBy(2.0);
137 viewport.ScrollIntoView(gAudioIO->GetStreamTime());
138 }
139 else
140 viewport.ZoomAboutSelection(2.0);
141
142 trackPanel.Refresh(false);
143}
static AudioIO * Get()
Definition: AudioIO.cpp:126
int GetAudioIOToken() const
static ProjectAudioIO & Get(AudacityProject &project)

References AudioIO::Get(), ProjectAudioIO::Get(), Viewport::Get(), TrackPanel::Get(), ProjectAudioIO::GetAudioIOToken(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnZoomNormal()

void anonymous_namespace{ViewMenus.cpp}::OnZoomNormal ( const CommandContext context)

Definition at line 145 of file ViewMenus.cpp.

146{
147 auto &project = context.project;
148 auto &trackPanel = TrackPanel::Get( project );
149 auto &viewport = Viewport::Get(project);
150 viewport.Zoom(ZoomInfo::GetDefaultZoom());
151 trackPanel.Refresh(false);
152}

References Viewport::Get(), TrackPanel::Get(), ZoomInfo::GetDefaultZoom(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnZoomOut()

void anonymous_namespace{ViewMenus.cpp}::OnZoomOut ( const CommandContext context)

Definition at line 154 of file ViewMenus.cpp.

155{
156 auto &project = context.project;
157 auto &viewport = Viewport::Get(project);
158 viewport.ZoomAboutCenter(0.5);
159}

References Viewport::Get(), CommandContext::project, and project.

Referenced by ViewMenu().

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

◆ OnZoomSel()

void anonymous_namespace{ViewMenus.cpp}::OnZoomSel ( const CommandContext context)

Definition at line 161 of file ViewMenus.cpp.

162{
163 auto &project = context.project;
164 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
165 auto &viewport = Viewport::Get(project);
166 viewport.Zoom(GetZoomOfSelection(project));
167 viewport.SetHorizontalThumb(selectedRegion.t0());
168}
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215

References ViewInfo::Get(), Viewport::Get(), GetZoomOfSelection(), CommandContext::project, project, and ViewInfo::selectedRegion.

Referenced by ViewMenu().

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

◆ OnZoomToggle()

void anonymous_namespace{ViewMenus.cpp}::OnZoomToggle ( const CommandContext context)

Definition at line 170 of file ViewMenus.cpp.

171{
172 auto &project = context.project;
173 auto &viewInfo = ViewInfo::Get( project );
174 auto &trackPanel = TrackPanel::Get( project );
175 auto &viewport = Viewport::Get(project);
176
177// const double origLeft = viewInfo.h;
178// const double origWidth = viewInfo.GetScreenEndTime() - origLeft;
179
180 // Choose the zoom that is most different to the current zoom.
183 double Z = viewInfo.GetZoom();// Current Zoom.
184 double ChosenZoom =
185 fabs(log(Zoom1 / Z)) > fabs(log( Z / Zoom2)) ? Zoom1:Zoom2;
186
187 viewport.Zoom(ChosenZoom);
188 trackPanel.Refresh(false);
189// const double newWidth = GetScreenEndTime() - viewInfo.h;
190// const double newh = origLeft + (origWidth - newWidth) / 2;
191// SetHorizontalThumb(newh);
192}
static WaveChannelViewConstants::ZoomPresets Zoom1Choice()
static WaveChannelViewConstants::ZoomPresets Zoom2Choice()
double GetZoomOfPreset(const AudacityProject &project, int preset)
Definition: ViewMenus.cpp:53

References ViewInfo::Get(), Viewport::Get(), TrackPanel::Get(), GetZoomOfPreset(), CommandContext::project, project, TracksPrefs::Zoom1Choice(), and TracksPrefs::Zoom2Choice().

Referenced by ViewMenu().

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

◆ ViewMenu()

auto anonymous_namespace{ViewMenus.cpp}::ViewMenu ( )

Definition at line 302 of file ViewMenus.cpp.

303{
304 static auto menu = std::shared_ptr{
305 Menu( wxT("View"), XXO("&View"),
306 Section( "Basic",
307 Menu( wxT("Zoom"), XXO("&Zoom"),
308 Command( wxT("ZoomIn"), XXO("Zoom &In"), OnZoomIn,
309 ZoomInAvailableFlag(), wxT("Ctrl+1") ),
310 Command( wxT("ZoomNormal"), XXO("Zoom &Normal"), OnZoomNormal,
311 TracksExistFlag(), wxT("Ctrl+2") ),
312 Command( wxT("ZoomOut"), XXO("Zoom &Out"), OnZoomOut,
313 ZoomOutAvailableFlag(), wxT("Ctrl+3") ),
314 Command( wxT("ZoomSel"), XXO("&Zoom to Selection"), OnZoomSel,
315 TimeSelectedFlag(), wxT("Ctrl+E") ),
316 Command( wxT("ZoomToggle"), XXO("Zoom &Toggle"), OnZoomToggle,
317 TracksExistFlag(), wxT("Shift+Z") )
318 ),
319
320 Menu( wxT("TrackSize"), XXO("T&rack Size"),
321 Command( wxT("FitInWindow"), XXO("&Fit to Width"), OnZoomFit,
322 TracksExistFlag(), wxT("Ctrl+F") ),
323 Command( wxT("FitV"), XXO("Fit to &Height"), OnZoomFitV,
324 TracksExistFlag(), wxT("Ctrl+Shift+F") ),
325 Command( wxT("CollapseAllTracks"), XXO("&Collapse All Tracks"),
326 OnCollapseAllTracks, TracksExistFlag(), wxT("Ctrl+Shift+C") ),
327 Command( wxT("ExpandAllTracks"), XXO("E&xpand Collapsed Tracks"),
328 OnExpandAllTracks, TracksExistFlag(), wxT("Ctrl+Shift+X") )
329 ),
330
331 Menu( wxT("SkipTo"), XXO("Sk&ip to"),
332 Command( wxT("SkipSelStart"), XXO("Selection Sta&rt"),
334 Options{ wxT("Ctrl+["), XO("Skip to Selection Start") } ),
335 Command( wxT("SkipSelEnd"), XXO("Selection En&d"), OnGoSelEnd,
337 Options{ wxT("Ctrl+]"), XO("Skip to Selection End") } )
338 )
339 ),
340
341 Section( "Windows" ),
342
343 Section( "Other",
344 Command( wxT("ShowExtraMenus"), XXO("Enable E&xtra Menus"),
346 Options{}.CheckTest( wxT("/GUI/ShowExtraMenus"), false ) ),
347 Command( wxT("ShowTrackNameInWaveform"), XXO("Show Track &Name as overlay"),
349 Options{}.CheckTest( wxT("/GUI/ShowTrackNameInWaveform"), false ) ),
350 Command( wxT("ShowClipping"), XXO("&Show Clipping in Waveform"),
352 Options{}.CheckTest( wxT("/GUI/ShowClipping"), false ) )
353 )
354 ) };
355 return menu;
356}
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const ReservedCommandFlag & ZoomInAvailableFlag()
const ReservedCommandFlag & ZoomOutAvailableFlag()
const ReservedCommandFlag & TimeSelectedFlag()
const ReservedCommandFlag & TracksExistFlag()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
constexpr auto Section
Definition: MenuRegistry.h:436
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
void OnShowClipping(const CommandContext &context)
Definition: ViewMenus.cpp:263
void OnCollapseAllTracks(const CommandContext &context)
Definition: ViewMenus.cpp:209
void OnZoomFit(const CommandContext &context)
Definition: ViewMenus.cpp:194
void OnShowNameOverlay(const CommandContext &context)
Definition: ViewMenus.cpp:279
void OnShowExtraMenus(const CommandContext &context)
Definition: ViewMenus.cpp:251
void OnZoomFitV(const CommandContext &context)
Definition: ViewMenus.cpp:201
void OnZoomToggle(const CommandContext &context)
Definition: ViewMenus.cpp:170
void OnZoomIn(const CommandContext &context)
Definition: ViewMenus.cpp:124
void OnZoomNormal(const CommandContext &context)
Definition: ViewMenus.cpp:145
void OnZoomSel(const CommandContext &context)
Definition: ViewMenus.cpp:161
void OnGoSelEnd(const CommandContext &context)
Definition: ViewMenus.cpp:237
void OnZoomOut(const CommandContext &context)
Definition: ViewMenus.cpp:154
void OnGoSelStart(const CommandContext &context)
Definition: ViewMenus.cpp:223
void OnExpandAllTracks(const CommandContext &context)
Definition: ViewMenus.cpp:216
Options && CheckTest(const CheckFn &fn) &&
Definition: MenuRegistry.h:74

References AlwaysEnabledFlag, MenuRegistry::Options::CheckTest(), MenuRegistry::Command, MenuRegistry::Menu, OnCollapseAllTracks(), OnExpandAllTracks(), OnGoSelEnd(), OnGoSelStart(), OnShowClipping(), OnShowExtraMenus(), OnShowNameOverlay(), OnZoomFit(), OnZoomFitV(), OnZoomIn(), OnZoomNormal(), OnZoomOut(), OnZoomSel(), OnZoomToggle(), MenuRegistry::Section, TimeSelectedFlag(), TracksExistFlag(), wxT(), XO(), XXO(), ZoomInAvailableFlag(), and ZoomOutAvailableFlag().

Here is the call graph for this function:

Variable Documentation

◆ sAttachment1

AttachedItem anonymous_namespace{ViewMenus.cpp}::sAttachment1 { Indirect(ViewMenu()) }

Definition at line 358 of file ViewMenus.cpp.