1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-08 04:32:00 +01:00

Lower ViewActions as member functions of ProjectWindow

This commit is contained in:
Paul Licameli
2019-06-21 23:08:31 -04:00
parent b6077fd3cd
commit c6478f43af
7 changed files with 52 additions and 57 deletions

View File

@@ -1606,7 +1606,7 @@ void ProjectWindow::ZoomAfterImport(Track *pTrack)
auto &project = mProject;
auto &trackPanel = TrackPanel::Get( project );
ViewActions::DoZoomFit( project );
DoZoomFit();
trackPanel.SetFocus();
RedrawProject();
@@ -1888,6 +1888,43 @@ void ProjectWindow::ZoomOutByFactor( double ZoomFactor )
TP_ScrollWindow(newh);
}
double ProjectWindow::GetZoomOfToFit() const
{
auto &project = mProject;
auto &tracks = TrackList::Get( project );
auto &viewInfo = ViewInfo::Get( project );
auto &trackPanel = TrackPanel::Get( project );
const double end = tracks.GetEndTime();
const double start = viewInfo.bScrollBeyondZero
? std::min( tracks.GetStartTime(), 0.0)
: 0;
const double len = end - start;
if (len <= 0.0)
return viewInfo.GetZoom();
int w;
trackPanel.GetTracksUsableArea(&w, NULL);
w -= 10;
return w/len;
}
void ProjectWindow::DoZoomFit()
{
auto &project = mProject;
auto &viewInfo = ViewInfo::Get( project );
auto &tracks = TrackList::Get( project );
auto &window = *this;
const double start = viewInfo.bScrollBeyondZero
? std::min(tracks.GetStartTime(), 0.0)
: 0;
window.Zoom( window.GetZoomOfToFit() );
window.TP_ScrollWindow(start);
}
static struct InstallTopPanelHook{ InstallTopPanelHook() {
ToolManager::SetGetTopPanelHook(
[]( wxWindow &window ){