mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-23 15:41:09 +02:00
Added zoom presets
Please Note: In ViewInfo.h there is the comment left by Paul: // There is NO GetZoom()! // Use TimeToPosition and PositionToTime and OffsetTimeByPixels! I needed to get the value of the current zoom so that I could use the functions AudacityProject::ZoomInByFactor and AudacityProject::ZoomOutByFactor to handle the change in zoom when a preset zoom is chosen. So I added GetZoom() for this use.
This commit is contained in:
parent
c1592d2a1a
commit
1fa97a4b37
@ -696,6 +696,13 @@ void AudacityProject::CreateMenusAndCommands()
|
|||||||
c->AddItem(wxT("ZoomSel"), _("&Zoom to Selection"), FN(OnZoomSel), wxT("Ctrl+E"), TimeSelectedFlag, TimeSelectedFlag);
|
c->AddItem(wxT("ZoomSel"), _("&Zoom to Selection"), FN(OnZoomSel), wxT("Ctrl+E"), TimeSelectedFlag, TimeSelectedFlag);
|
||||||
c->EndSubMenu();
|
c->EndSubMenu();
|
||||||
|
|
||||||
|
c->BeginSubMenu(_("Set One &Pixel to"));
|
||||||
|
c->AddItem(wxT("ZoomOneSecond"), _("&One Second"), FN(OnZoomOneSecond));
|
||||||
|
c->AddItem(wxT("ZoomTenthSecond"), _("&Tenth Second"), FN(OnZoomTenthSecond));
|
||||||
|
c->AddItem(wxT("ZoomHundredthSecond"), _("&Hundredth Second"), FN(OnZoomHundredthSecond));
|
||||||
|
c->AddItem(wxT("ZoomThousandthSecond"), _("Thou&sandth Second"), FN(OnZoomThousandthSecond));
|
||||||
|
c->EndSubMenu();
|
||||||
|
|
||||||
c->AddSeparator();
|
c->AddSeparator();
|
||||||
c->BeginSubMenu(_("&Track Size"));
|
c->BeginSubMenu(_("&Track Size"));
|
||||||
c->AddItem(wxT("FitInWindow"), _("&Fit to Width"), FN(OnZoomFit), wxT("Ctrl+F"));
|
c->AddItem(wxT("FitInWindow"), _("&Fit to Width"), FN(OnZoomFit), wxT("Ctrl+F"));
|
||||||
@ -5653,6 +5660,39 @@ void AudacityProject::OnZoomNormal()
|
|||||||
mTrackPanel->Refresh(false);
|
mTrackPanel->Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudacityProject::OnZoomOneSecond()
|
||||||
|
{
|
||||||
|
OnZoomPreset(1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudacityProject::OnZoomTenthSecond()
|
||||||
|
{
|
||||||
|
OnZoomPreset(10.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudacityProject::OnZoomHundredthSecond()
|
||||||
|
{
|
||||||
|
OnZoomPreset(100.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudacityProject::OnZoomThousandthSecond()
|
||||||
|
{
|
||||||
|
OnZoomPreset(1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudacityProject::OnZoomPreset(double newZoom)
|
||||||
|
{
|
||||||
|
double currentZoom = mViewInfo.GetZoom();
|
||||||
|
|
||||||
|
if (currentZoom != 0.0) {
|
||||||
|
double ratio = newZoom/currentZoom;
|
||||||
|
if (ratio > 1.0 )
|
||||||
|
ZoomInByFactor(ratio);
|
||||||
|
else if (ratio < 1.0)
|
||||||
|
ZoomOutByFactor(ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AudacityProject::OnZoomFit()
|
void AudacityProject::OnZoomFit()
|
||||||
{
|
{
|
||||||
const double end = mTracks->GetEndTime();
|
const double end = mTracks->GetEndTime();
|
||||||
|
@ -301,6 +301,11 @@ void OnZoomIn();
|
|||||||
void OnZoomOut();
|
void OnZoomOut();
|
||||||
// void OnZoomToggle();
|
// void OnZoomToggle();
|
||||||
void OnZoomNormal();
|
void OnZoomNormal();
|
||||||
|
void OnZoomOneSecond();
|
||||||
|
void OnZoomTenthSecond();
|
||||||
|
void OnZoomHundredthSecond();
|
||||||
|
void OnZoomThousandthSecond();
|
||||||
|
void OnZoomPreset(double newZoom);
|
||||||
void OnZoomFit();
|
void OnZoomFit();
|
||||||
void OnZoomFitV();
|
void OnZoomFitV();
|
||||||
void DoZoomFitV();
|
void DoZoomFitV();
|
||||||
|
@ -86,6 +86,9 @@ public:
|
|||||||
|
|
||||||
// There is NO GetZoom()!
|
// There is NO GetZoom()!
|
||||||
// Use TimeToPosition and PositionToTime and OffsetTimeByPixels!
|
// Use TimeToPosition and PositionToTime and OffsetTimeByPixels!
|
||||||
|
// DB added GetZoom() - needed for zoom presets.
|
||||||
|
|
||||||
|
double GetZoom() const {return zoom; }
|
||||||
|
|
||||||
// Limits zoom to certain bounds
|
// Limits zoom to certain bounds
|
||||||
void SetZoom(double pixelsPerSecond);
|
void SetZoom(double pixelsPerSecond);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user