Skip to content

Commit

Permalink
Fisheye project proper
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Licameli committed Jun 12, 2015
2 parents 6e52155 + 579de3c commit 92f31c6
Show file tree
Hide file tree
Showing 11 changed files with 1,178 additions and 35 deletions.
2 changes: 2 additions & 0 deletions src/Experimental.h
Expand Up @@ -203,5 +203,7 @@
// interpolating in frequency domain.
#define EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS

// PRL 22 Feb 2015
#define EXPERIMENTAL_FISHEYE

#endif
72 changes: 72 additions & 0 deletions src/Menus.cpp
Expand Up @@ -1247,6 +1247,13 @@ void AudacityProject::CreateMenusAndCommands()
c->AddCommand(wxT("PlaySpeedInc"), _("Increase playback speed"), FN(OnPlaySpeedInc));
c->AddCommand(wxT("PlaySpeedDec"), _("Decrease playback speed"), FN(OnPlaySpeedDec));

#ifdef EXPERIMENTAL_FISHEYE
c->AddCommand(wxT("ShowHideFisheye"), _("Show/Hide Fisheye"), FN(OnShowHideFisheye),
wxT("F"), AlwaysEnabledFlag, AlwaysEnabledFlag);
c->AddCommand(wxT("PlayFisheye"), _("Play Fisheye"), FN(OnPlayFisheye),
wxT("G"), AlwaysEnabledFlag, AlwaysEnabledFlag);
#endif

mLastFlags = 0;

#if defined(__WXDEBUG__)
Expand Down Expand Up @@ -4888,6 +4895,17 @@ void AudacityProject::ZoomInByFactor( double ZoomFactor )
return;
}

#ifdef EXPERIMENTAL_FISHEYE
wxPoint position(mTrackPanel->ScreenToClient(::wxGetMousePosition()));
if (mTrackPanel->InFisheyeFocus(position)) {
// Don't zoom the background, just change the fisheye magnification
if (mViewInfo.ZoomFisheyeBy(position.x, mTrackPanel->GetLeftOffset(),
ZoomFactor))
mTrackPanel->Refresh(false);
return;
}
#endif

// DMM: Here's my attempt to get logical zooming behavior
// when there's a selection that's currently at least
// partially on-screen
Expand Down Expand Up @@ -4953,6 +4971,17 @@ void AudacityProject::OnZoomOut()

void AudacityProject::ZoomOutByFactor( double ZoomFactor )
{
#ifdef EXPERIMENTAL_FISHEYE
wxPoint position(mTrackPanel->ScreenToClient(::wxGetMousePosition()));
if (mTrackPanel->InFisheyeFocus(position)) {
// Don't zoom the background, just change the fisheye magnification
if (mViewInfo.ZoomFisheyeBy(position.x, mTrackPanel->GetLeftOffset(),
ZoomFactor))
mTrackPanel->Refresh(false);
return;
}
#endif

//Zoom() may change these, so record original values:
double origLeft = mViewInfo.h;
double origWidth = mViewInfo.screen;
Expand Down Expand Up @@ -4991,6 +5020,15 @@ void AudacityProject::OnZoomToggle()

void AudacityProject::OnZoomNormal()
{
#ifdef EXPERIMENTAL_FISHEYE
wxPoint position(mTrackPanel->ScreenToClient(::wxGetMousePosition()));
if (mTrackPanel->InFisheyeFocus(position)) {
if(mViewInfo.DefaultFisheyeZoom(position.x, mTrackPanel->GetLeftOffset()))
mTrackPanel->Refresh(false);
return;
}
#endif

Zoom(ZoomInfo::GetDefaultZoom());
mTrackPanel->Refresh(false);
}
Expand Down Expand Up @@ -5273,6 +5311,40 @@ void AudacityProject::OnResetToolBars()
ModifyToolbarMenus();
}

#ifdef EXPERIMENTAL_FISHEYE
void AudacityProject::OnShowHideFisheye()
{
ZoomInfo::FisheyeState state = mViewInfo.GetFisheyeState();
switch (state) {
case ZoomInfo::HIDDEN:
// show, pin, recenter
mViewInfo.SetFisheyeState(ZoomInfo::PINNED);
GetTrackPanel()->MoveFisheye();
break;

default:
// hide
mViewInfo.SetFisheyeState(ZoomInfo::HIDDEN);
break;
};

// Either way, redraw panel and time ruler
GetTrackPanel()->RefreshFisheye();
}

void AudacityProject::OnPlayFisheye()
{
if (mViewInfo.GetFisheyeState() == ZoomInfo::HIDDEN)
return;

if (!MakeReadyToPlay())
return;

const SelectedRegion selectedRegion(mViewInfo.GetFisheyeFocusRegion());
GetControlToolBar()->PlayPlayRegion(selectedRegion, GetDefaultPlayOptions());
}
#endif

void AudacityProject::OnSimplifiedView()
{
mCommandManager.mbHideFlaggedItems = !mCommandManager.mbHideFlaggedItems;
Expand Down
4 changes: 4 additions & 0 deletions src/Menus.h
Expand Up @@ -298,6 +298,10 @@ void OnShowSpectralSelectionToolBar();
void OnShowToolsToolBar();
void OnShowTranscriptionToolBar();
void OnResetToolBars();
#ifdef EXPERIMENTAL_FISHEYE
void OnShowHideFisheye();
void OnPlayFisheye();
#endif
void OnSimplifiedView();

// Transport Menu
Expand Down
22 changes: 16 additions & 6 deletions src/Project.cpp
Expand Up @@ -1826,12 +1826,19 @@ void AudacityProject::OnScroll(wxScrollEvent & WXUNUSED(event))
mViewInfo.SetBeforeScreenWidth(mViewInfo.sbarH, lowerBound);

if (mScrollBeyondZero) {
enum { SCROLL_PIXEL_TOLERANCE = 10 };
if (abs(mViewInfo.TimeToPosition(0.0, 0
)) < SCROLL_PIXEL_TOLERANCE) {
// Snap the scrollbar to 0
mViewInfo.h = 0;
SetHorizontalThumb(0.0);
// Snapping the scroll to zero is not so nice when fine-adjusting
// the fisheye. This test, however, disables the snap
// whenever fisheye is visible.
if (ZoomInfo::HIDDEN == mViewInfo.GetFisheyeState())
{
enum { SCROLL_PIXEL_TOLERANCE = 10 };
if (abs(mViewInfo.TimeToPosition(0.0, 0
, true
)) < SCROLL_PIXEL_TOLERANCE) {
// Snap the scrollbar to 0
mViewInfo.h = 0;
SetHorizontalThumb(0.0);
}
}
}

Expand Down Expand Up @@ -2995,6 +3002,9 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
SetBandwidthSelectionFormatName(value);
} // while

// For fisheye
mViewInfo.UpdatePrefs();

if (longVpos != 0) {
// PRL: It seems this must happen after SetSnapTo
mViewInfo.track = NULL;
Expand Down

0 comments on commit 92f31c6

Please sign in to comment.