1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-08 14:13:57 +01:00

Bug812 - Vertical scrollbar position should be persistent too, as is horizontal

Effective but perhaps inelegant fix.
This commit is contained in:
Paul-Licameli
2015-04-09 20:20:51 -04:00
parent c6455312aa
commit 5d19887da6
2 changed files with 34 additions and 16 deletions

View File

@@ -773,6 +773,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
mLastEffectType(0), mLastEffectType(0),
mTimerRecordCanceled(false), mTimerRecordCanceled(false),
mMenuClose(false) mMenuClose(false)
, mbInitializingScrollbar(false)
{ {
int widths[] = {-2, -1}; int widths[] = {-2, -1};
mStatusBar = CreateStatusBar(2); mStatusBar = CreateStatusBar(2);
@@ -1508,7 +1509,16 @@ void AudacityProject::FixScrollbars()
mViewInfo.sbarH = (wxInt64) (mViewInfo.h * mViewInfo.zoom); mViewInfo.sbarH = (wxInt64) (mViewInfo.h * mViewInfo.zoom);
int lastv = mViewInfo.vpos; int lastv = mViewInfo.vpos;
mViewInfo.vpos = mVsbar->GetThumbPosition() * mViewInfo.scrollStep; // PRL: Can someone else find a more elegant solution to bug 812, than
// introducing this boolean member variable?
// Setting mVSbar earlier, int HandlXMLTag, didn't succeed in restoring
// the vertical scrollbar to its saved position. So defer that till now.
// mbInitializingScrollbar should be true only at the start of the life
// of an AudacityProject reopened from disk.
if (!mbInitializingScrollbar) {
mViewInfo.vpos = mVsbar->GetThumbPosition() * mViewInfo.scrollStep;
}
mbInitializingScrollbar = false;
if (mViewInfo.vpos >= totalHeight) if (mViewInfo.vpos >= totalHeight)
mViewInfo.vpos = totalHeight - 1; mViewInfo.vpos = totalHeight - 1;
@@ -2808,6 +2818,7 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
wxString fileVersion = _("<unrecognized version -- possibly corrupt project file>"); wxString fileVersion = _("<unrecognized version -- possibly corrupt project file>");
wxString audacityVersion = _("<unrecognized version -- possibly corrupt project file>"); wxString audacityVersion = _("<unrecognized version -- possibly corrupt project file>");
int requiredTags = 0; int requiredTags = 0;
long longVpos = 0;
// loop through attrs, which is a null-terminated list of // loop through attrs, which is a null-terminated list of
// attribute-value pairs // attribute-value pairs
@@ -2834,19 +2845,19 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
} }
} }
if (!wxStrcmp(attr, wxT("version"))) else if (!wxStrcmp(attr, wxT("version")))
{ {
fileVersion = value; fileVersion = value;
bFileVersionFound = true; bFileVersionFound = true;
requiredTags++; requiredTags++;
} }
if (!wxStrcmp(attr, wxT("audacityversion"))) { else if (!wxStrcmp(attr, wxT("audacityversion"))) {
audacityVersion = value; audacityVersion = value;
requiredTags++; requiredTags++;
} }
if (!wxStrcmp(attr, wxT("projname"))) { else if (!wxStrcmp(attr, wxT("projname"))) {
wxString projName; wxString projName;
wxString projPath; wxString projPath;
@@ -2911,13 +2922,13 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
requiredTags++; requiredTags++;
} }
if (!wxStrcmp(attr, wxT("sel0"))) { else if (!wxStrcmp(attr, wxT("sel0"))) {
double t0; double t0;
Internat::CompatibleToDouble(value, &t0); Internat::CompatibleToDouble(value, &t0);
mViewInfo.selectedRegion.setT0(t0, false); mViewInfo.selectedRegion.setT0(t0, false);
} }
if (!wxStrcmp(attr, wxT("sel1"))) { else if (!wxStrcmp(attr, wxT("sel1"))) {
double t1; double t1;
Internat::CompatibleToDouble(value, &t1); Internat::CompatibleToDouble(value, &t1);
mViewInfo.selectedRegion.setT1(t1, false); mViewInfo.selectedRegion.setT1(t1, false);
@@ -2925,32 +2936,37 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
// PRL: to do: persistence of other fields of the selection // PRL: to do: persistence of other fields of the selection
long longVpos = 0; else if (!wxStrcmp(attr, wxT("vpos")))
if (!wxStrcmp(attr, wxT("vpos"))) // Just assign a variable, put the value in its place later
wxString(value).ToLong(&longVpos); wxString(value).ToLong(&longVpos);
mViewInfo.track = NULL;
mViewInfo.vpos = longVpos;
if (!wxStrcmp(attr, wxT("h"))) else if (!wxStrcmp(attr, wxT("h")))
Internat::CompatibleToDouble(value, &mViewInfo.h); Internat::CompatibleToDouble(value, &mViewInfo.h);
if (!wxStrcmp(attr, wxT("zoom"))) else if (!wxStrcmp(attr, wxT("zoom")))
Internat::CompatibleToDouble(value, &mViewInfo.zoom); Internat::CompatibleToDouble(value, &mViewInfo.zoom);
if (!wxStrcmp(attr, wxT("rate"))) { else if (!wxStrcmp(attr, wxT("rate"))) {
Internat::CompatibleToDouble(value, &mRate); Internat::CompatibleToDouble(value, &mRate);
GetSelectionBar()->SetRate(mRate); GetSelectionBar()->SetRate(mRate);
} }
if (!wxStrcmp(attr, wxT("snapto"))) { else if (!wxStrcmp(attr, wxT("snapto"))) {
SetSnapTo(wxString(value) == wxT("on") ? true : false); SetSnapTo(wxString(value) == wxT("on") ? true : false);
} }
if (!wxStrcmp(attr, wxT("selectionformat"))) { else if (!wxStrcmp(attr, wxT("selectionformat"))) {
SetSelectionFormat(value); SetSelectionFormat(value);
} }
} // while } // while
if (longVpos != 0) {
// PRL: It seems this must happen after SetSnapTo
mViewInfo.track = NULL;
mViewInfo.vpos = longVpos;
mbInitializingScrollbar = true;
}
// Specifically detect newer versions of Audacity // Specifically detect newer versions of Audacity
// WARNING: This will need review/revision if we ever have a version string // WARNING: This will need review/revision if we ever have a version string
// such as 1.5.10, i.e. with 2 digit numbers. // such as 1.5.10, i.e. with 2 digit numbers.

View File

@@ -618,7 +618,9 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
// Are we currently closing as the result of a menu command? // Are we currently closing as the result of a menu command?
bool mMenuClose; bool mMenuClose;
DECLARE_EVENT_TABLE() bool mbInitializingScrollbar;
DECLARE_EVENT_TABLE()
}; };
typedef void (AudacityProject::*audCommandFunction)(); typedef void (AudacityProject::*audCommandFunction)();