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 OnShowRMS (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 55 of file ViewMenus.cpp.

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

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 28 of file ViewMenus.cpp.

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

212{
213 auto &project = context.project;
216}
AudacityProject & project
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
void CollapseAllTracks()
Definition: Viewport.cpp:743

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 218 of file ViewMenus.cpp.

219{
220 auto &project = context.project;
223}
void ExpandAllTracks()
Definition: Viewport.cpp:733

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 239 of file ViewMenus.cpp.

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

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 225 of file ViewMenus.cpp.

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

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 265 of file ViewMenus.cpp.

266{
267 auto &project = context.project;
268 auto &commandManager = CommandManager::Get( project );
269 auto &trackPanel = TrackPanel::Get( project );
270
272 gPrefs->Flush();
273
274 trackPanel.Refresh(false);
275}
BoolSetting & ShowClippingPref()
Definition: GUIPrefs.cpp:196
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
bool Toggle()
Write the negation of the previous value, and return true if successful.
Definition: Prefs.cpp:555
static CommandManager & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
virtual bool Flush() noexcept=0

References audacity::BasicSettings::Flush(), CommandManager::Get(), TrackPanel::Get(), gPrefs, CommandContext::project, project, ShowClippingPref(), and BoolSetting::Toggle().

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 253 of file ViewMenus.cpp.

254{
255 auto &project = context.project;
256 auto &commandManager = CommandManager::Get( project );
257
258 bool checked = !gPrefs->Read(wxT("/GUI/ShowExtraMenus"), 0L);
259 gPrefs->Write(wxT("/GUI/ShowExtraMenus"), checked);
260 gPrefs->Flush();
261 commandManager.Check(wxT("ShowExtraMenus"), checked);
263}
wxT("CloseDown"))
static void RebuildAllMenuBars()
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0

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:

◆ OnShowRMS()

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

Definition at line 277 of file ViewMenus.cpp.

278{
279 auto &project = context.project;
280 auto &trackPanel = TrackPanel::Get( project );
281
283 gPrefs->Flush();
284
286
287 trackPanel.Refresh(false);
288}
BoolSetting & ShowRMSPref()
Definition: GUIPrefs.cpp:190
static void ModifyAllProjectToolbarMenus()

References audacity::BasicSettings::Flush(), TrackPanel::Get(), gPrefs, ToolManager::ModifyAllProjectToolbarMenus(), CommandContext::project, project, ShowRMSPref(), and BoolSetting::Toggle().

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 196 of file ViewMenus.cpp.

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

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 203 of file ViewMenus.cpp.

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

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 126 of file ViewMenus.cpp.

127{
128 auto &project = context.project;
129 auto &trackPanel = TrackPanel::Get( project );
130 auto &viewport = Viewport::Get(project);
131
132 auto gAudioIO = AudioIO::Get();
133 // LLL: Handling positioning differently when audio is
134 // actively playing. Don't do this if paused.
135 if (gAudioIO->IsStreamActive(
137 !gAudioIO->IsPaused()){
138 viewport.ZoomBy(2.0);
139 viewport.ScrollIntoView(gAudioIO->GetStreamTime());
140 }
141 else
142 viewport.ZoomAboutSelection(2.0);
143
144 trackPanel.Refresh(false);
145}
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 147 of file ViewMenus.cpp.

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

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 156 of file ViewMenus.cpp.

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

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 163 of file ViewMenus.cpp.

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

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 172 of file ViewMenus.cpp.

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

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 297 of file ViewMenus.cpp.

298{
299 static auto menu = std::shared_ptr{
300 Menu( wxT("View"), XXO("&View"),
301 Section( "Basic",
302 Menu( wxT("Zoom"), XXO("&Zoom"),
303 Command( wxT("ZoomIn"), XXO("Zoom &In"), OnZoomIn,
304 ZoomInAvailableFlag(), wxT("Ctrl+1") ),
305 Command( wxT("ZoomNormal"), XXO("Zoom &Normal"), OnZoomNormal,
306 TracksExistFlag(), wxT("Ctrl+2") ),
307 Command( wxT("ZoomOut"), XXO("Zoom &Out"), OnZoomOut,
308 ZoomOutAvailableFlag(), wxT("Ctrl+3") ),
309 Command( wxT("ZoomSel"), XXO("&Zoom to Selection"), OnZoomSel,
310 TimeSelectedFlag(), wxT("Ctrl+E") ),
311 Command( wxT("ZoomToggle"), XXO("Zoom &Toggle"), OnZoomToggle,
312 TracksExistFlag(), wxT("Shift+Z") )
313 ),
314
315 Menu( wxT("TrackSize"), XXO("T&rack Size"),
316 Command( wxT("FitInWindow"), XXO("&Fit to Width"), OnZoomFit,
317 TracksExistFlag(), wxT("Ctrl+F") ),
318 Command( wxT("FitV"), XXO("Fit to &Height"), OnZoomFitV,
319 TracksExistFlag(), wxT("Ctrl+Shift+F") ),
320 Command( wxT("CollapseAllTracks"), XXO("&Collapse All Tracks"),
321 OnCollapseAllTracks, TracksExistFlag(), wxT("Ctrl+Shift+C") ),
322 Command( wxT("ExpandAllTracks"), XXO("E&xpand Collapsed Tracks"),
323 OnExpandAllTracks, TracksExistFlag(), wxT("Ctrl+Shift+X") )
324 ),
325
326 Menu( wxT("SkipTo"), XXO("Sk&ip to"),
327 Command( wxT("SkipSelStart"), XXO("Selection Sta&rt"),
329 Options{ wxT("Ctrl+["), XO("Skip to Selection Start") } ),
330 Command( wxT("SkipSelEnd"), XXO("Selection En&d"), OnGoSelEnd,
332 Options{ wxT("Ctrl+]"), XO("Skip to Selection End") } )
333 )
334 ),
335
336 Section( "Windows" ),
337
338 Section( "Other",
339 Command( wxT("ShowExtraMenus"), XXO("E&xtra Menus"),
341 Options{}.CheckTest( wxT("/GUI/ShowExtraMenus"), false ) ),
342 Command( wxT("ShowClipping"), XXO("&Show Clipping in Waveform"),
345 Command( wxT("ShowRMS"), XXO("Sho&w RMS in Waveform"),
348 )
349 ) };
350 return menu;
351}
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:265
void OnCollapseAllTracks(const CommandContext &context)
Definition: ViewMenus.cpp:211
void OnZoomFit(const CommandContext &context)
Definition: ViewMenus.cpp:196
void OnShowExtraMenus(const CommandContext &context)
Definition: ViewMenus.cpp:253
void OnZoomFitV(const CommandContext &context)
Definition: ViewMenus.cpp:203
void OnZoomToggle(const CommandContext &context)
Definition: ViewMenus.cpp:172
void OnZoomIn(const CommandContext &context)
Definition: ViewMenus.cpp:126
void OnZoomNormal(const CommandContext &context)
Definition: ViewMenus.cpp:147
void OnShowRMS(const CommandContext &context)
Definition: ViewMenus.cpp:277
void OnZoomSel(const CommandContext &context)
Definition: ViewMenus.cpp:163
void OnGoSelEnd(const CommandContext &context)
Definition: ViewMenus.cpp:239
void OnZoomOut(const CommandContext &context)
Definition: ViewMenus.cpp:156
void OnGoSelStart(const CommandContext &context)
Definition: ViewMenus.cpp:225
void OnExpandAllTracks(const CommandContext &context)
Definition: ViewMenus.cpp:218
Options && CheckTest(const CheckFn &fn) &&
Definition: MenuRegistry.h:74

References AlwaysEnabledFlag, MenuRegistry::Options::CheckTest(), MenuRegistry::Command, MenuRegistry::Menu, OnCollapseAllTracks(), OnExpandAllTracks(), OnGoSelEnd(), OnGoSelStart(), OnShowClipping(), OnShowExtraMenus(), OnShowRMS(), OnZoomFit(), OnZoomFitV(), OnZoomIn(), OnZoomNormal(), OnZoomOut(), OnZoomSel(), OnZoomToggle(), MenuRegistry::Section, ShowClippingPref(), ShowRMSPref(), 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 353 of file ViewMenus.cpp.