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 DoZoomFitV (AudacityProject &project)
 
BaseItemSharedPtr ViewMenu ()
 

Variables

AttachedItem sAttachment1
 

Function Documentation

◆ DoZoomFitV()

void anonymous_namespace{ViewMenus.cpp}::DoZoomFitV ( AudacityProject project)

Definition at line 121 of file ViewMenus.cpp.

122{
123 auto &viewInfo = ViewInfo::Get( project );
124 auto &tracks = TrackList::Get( project );
125
126 // Only nonminimized audio tracks will be resized
127 auto range = tracks.Any<AudioTrack>()
128 - [](const Track *pTrack){
129 return TrackView::Get( *pTrack ).GetMinimized(); };
130 auto count = range.size();
131 if (count == 0)
132 return;
133
134 // Find total height to apportion
135 auto height = viewInfo.GetHeight();
136 height -= 28;
137
138 // The height of minimized and non-audio tracks cannot be apportioned
139 height -=
140 tracks.Any().sum( TrackView::GetTrackHeight )
141 - range.sum( TrackView::GetTrackHeight );
142
143 // Give each resized track the average of the remaining height
144 // Bug 2803: Cast count to int, because otherwise the result of
145 // division will be unsigned too, and will be a very large number
146 // if height was negative!
147 height = height / (int)count;
148 // Use max() so that we don't set a negative height when there is
149 // not enough room.
150 height = std::max( (int)TrackInfo::MinimumTrackHeight(), height );
151
152 for (auto t : range)
153 TrackView::Get( *t ).SetExpandedHeight(height);
154}
Track subclass holding data representing sound (as notes, or samples, or ...)
Definition: Track.h:897
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
bool GetMinimized() const
Definition: TrackView.h:52
void SetExpandedHeight(int height)
Definition: TrackView.cpp:172
static int GetTrackHeight(const Track *pTrack)
Definition: TrackView.cpp:29
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:234
AUDACITY_DLL_API unsigned MinimumTrackHeight()
Definition: TrackInfo.cpp:196

References ViewInfo::Get(), TrackList::Get(), TrackView::Get(), TrackView::GetMinimized(), TrackView::GetTrackHeight(), TrackInfo::MinimumTrackHeight(), and TrackView::SetExpandedHeight().

Referenced by ViewActions::Handler::OnUndoPushed(), and ViewActions::Handler::OnZoomFitV().

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

◆ 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 &window = ProjectWindow::Get( project );
63 double zoomToFit = window.GetZoomOfToFit();
64 using namespace WaveTrackViewConstants;
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:45
static ProjectWindow & Get(AudacityProject &project)
static double GetDefaultZoom()
Definition: ZoomInfo.h:117
static double GetMaxZoom()
Definition: ZoomInfo.cpp:76
double GetZoomOfSelection(const AudacityProject &project)
Definition: ViewMenus.cpp:26

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

Referenced by ViewActions::Handler::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 &window = ProjectWindow::Get( project );
30
31 const double lowerBound =
32 std::max(viewInfo.selectedRegion.t0(),
33 window.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}

References ViewInfo::Get(), and ProjectWindow::Get().

Referenced by GetZoomOfPreset(), and ViewActions::Handler::OnZoomSel().

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

◆ ViewMenu()

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

Definition at line 396 of file ViewMenus.cpp.

397{
399
400 static BaseItemSharedPtr menu{
402 Menu( wxT("View"), XXO("&View"),
403 Section( "Basic",
404 Menu( wxT("Zoom"), XXO("&Zoom"),
405 Section( "",
406 Command( wxT("ZoomIn"), XXO("Zoom &In"), FN(OnZoomIn),
407 ZoomInAvailableFlag(), wxT("Ctrl+1") ),
408 Command( wxT("ZoomNormal"), XXO("Zoom &Normal"), FN(OnZoomNormal),
409 TracksExistFlag(), wxT("Ctrl+2") ),
410 Command( wxT("ZoomOut"), XXO("Zoom &Out"), FN(OnZoomOut),
411 ZoomOutAvailableFlag(), wxT("Ctrl+3") ),
412 Command( wxT("ZoomSel"), XXO("&Zoom to Selection"), FN(OnZoomSel),
413 TimeSelectedFlag(), wxT("Ctrl+E") ),
414 Command( wxT("ZoomToggle"), XXO("Zoom &Toggle"), FN(OnZoomToggle),
415 TracksExistFlag(), wxT("Shift+Z") )
416 ),
417 Section( "",
418 Command( wxT("AdvancedVZoom"), XXO("Advanced &Vertical Zooming"),
419 FN(OnAdvancedVZoom), AlwaysEnabledFlag,
420 Options{}.CheckTest( wxT("/GUI/VerticalZooming"), false ) )
421 )
422 ),
423
424 Menu( wxT("TrackSize"), XXO("T&rack Size"),
425 Command( wxT("FitInWindow"), XXO("&Fit to Width"), FN(OnZoomFit),
426 TracksExistFlag(), wxT("Ctrl+F") ),
427 Command( wxT("FitV"), XXO("Fit to &Height"), FN(OnZoomFitV),
428 TracksExistFlag(), wxT("Ctrl+Shift+F") ),
429 Command( wxT("CollapseAllTracks"), XXO("&Collapse All Tracks"),
430 FN(OnCollapseAllTracks), TracksExistFlag(), wxT("Ctrl+Shift+C") ),
431 Command( wxT("ExpandAllTracks"), XXO("E&xpand Collapsed Tracks"),
432 FN(OnExpandAllTracks), TracksExistFlag(), wxT("Ctrl+Shift+X") )
433 ),
434
435 Menu( wxT("SkipTo"), XXO("Sk&ip to"),
436 Command( wxT("SkipSelStart"), XXO("Selection Sta&rt"),
437 FN(OnGoSelStart), TimeSelectedFlag(),
438 Options{ wxT("Ctrl+["), XO("Skip to Selection Start") } ),
439 Command( wxT("SkipSelEnd"), XXO("Selection En&d"), FN(OnGoSelEnd),
441 Options{ wxT("Ctrl+]"), XO("Skip to Selection End") } )
442 )
443 ),
444
445 Section( "Windows" ),
446
447 Section( "Other",
448 Command( wxT("ShowExtraMenus"), XXO("&Extra Menus (on/off)"),
449 FN(OnShowExtraMenus), AlwaysEnabledFlag,
450 Options{}.CheckTest( wxT("/GUI/ShowExtraMenus"), false ) ),
451 Command( wxT("ShowTrackNameInWaveform"), XXO("Track &Name (on/off)"),
452 FN(OnShowNameOverlay), AlwaysEnabledFlag,
453 Options{}.CheckTest( wxT("/GUI/ShowTrackNameInWaveform"), false ) ),
454 Command( wxT("ShowClipping"), XXO("&Show Clipping (on/off)"),
455 FN(OnShowClipping), AlwaysEnabledFlag,
456 Options{}.CheckTest( wxT("/GUI/ShowClipping"), false ) )
457 )
458 ) ) };
459 return menu;
460
461}
wxT("CloseDown"))
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")
#define FN(X)
Definition: ViewMenus.cpp:391
static CommandHandlerObject & findCommandHandler(AudacityProject &project)
Definition: ViewMenus.cpp:385
std::unique_ptr< MenuItem > Menu(const Identifier &internalName, const TranslatableString &title, Args &&... args)
std::unique_ptr< MenuPart > Section(const Identifier &internalName, 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 && CheckTest(const CheckFn &fn) &&

References AlwaysEnabledFlag, CommandManager::Options::CheckTest(), MenuTable::Command(), findCommandHandler(), FN, MenuTable::Menu(), MenuTable::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
Initial value:

Definition at line 463 of file ViewMenus.cpp.