mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-09 16:41:14 +02:00
ViewInfo is becoming a smart class, not a dumb struct
Now it has: A constructor XML attribute serializer functions (but no XML tag of its own) Also removed unused lastZoom
This commit is contained in:
parent
35e0897bf7
commit
ab21f75c77
@ -25,7 +25,7 @@ class TrackList;
|
||||
class RowData;
|
||||
class EmptyLabelRenderer;
|
||||
class LabelTrack;
|
||||
struct ViewInfo;
|
||||
class ViewInfo;
|
||||
|
||||
WX_DEFINE_ARRAY(RowData *, RowDataArray);
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
|
||||
#include "Audacity.h"
|
||||
#include "Printing.h"
|
||||
|
||||
#include <wx/defs.h>
|
||||
#include <wx/dc.h>
|
||||
@ -29,7 +30,6 @@
|
||||
#include "ViewInfo.h"
|
||||
#include "WaveTrack.h"
|
||||
#include "widgets/Ruler.h"
|
||||
#include "Printing.h"
|
||||
|
||||
// Globals, so that we remember settings from session to session
|
||||
static wxPrintData *gPrintData = NULL;
|
||||
@ -80,13 +80,8 @@ bool AudacityPrintout::OnPrintPage(int WXUNUSED(page))
|
||||
TrackArtist artist;
|
||||
artist.SetBackgroundBrushes(*wxWHITE_BRUSH, *wxWHITE_BRUSH,
|
||||
*wxWHITE_PEN, *wxWHITE_PEN);
|
||||
ViewInfo viewInfo;
|
||||
viewInfo.selectedRegion = SelectedRegion();
|
||||
viewInfo.vpos = 0;
|
||||
viewInfo.h = 0.0;
|
||||
viewInfo.screen = mTracks->GetEndTime() - viewInfo.h;
|
||||
viewInfo.total = viewInfo.screen;
|
||||
viewInfo.zoom = width / viewInfo.screen;
|
||||
const double screenDuration = mTracks->GetEndTime();
|
||||
ViewInfo viewInfo(0.0, screenDuration, width / screenDuration);
|
||||
int y = rulerPageHeight;
|
||||
|
||||
TrackListIterator iter(mTracks);
|
||||
|
@ -780,6 +780,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
mTimerRecordCanceled(false),
|
||||
mMenuClose(false)
|
||||
, mbInitializingScrollbar(false)
|
||||
, mViewInfo(0.0, 1.0, (44100.0 / 512.0))
|
||||
{
|
||||
// Note that the first field of the status bar is a dummy, and it's width is set
|
||||
// to zero latter in the code. This field is needed for wxWidgets 2.8.12 because
|
||||
@ -810,26 +811,6 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
// Initialize view info (shared with TrackPanel)
|
||||
//
|
||||
|
||||
// Selection
|
||||
mViewInfo.selectedRegion = SelectedRegion();
|
||||
|
||||
// Horizontal scrollbar
|
||||
mViewInfo.total = 1.0;
|
||||
mViewInfo.screen = 1.0;
|
||||
mViewInfo.h = 0.0;
|
||||
mViewInfo.zoom = 44100.0 / 512.0;
|
||||
|
||||
// Vertical scrollbar
|
||||
mViewInfo.track = NULL;
|
||||
mViewInfo.vpos = 0;
|
||||
|
||||
mViewInfo.scrollStep = 16;
|
||||
|
||||
mViewInfo.sbarH = 0;
|
||||
mViewInfo.sbarScreen = 1;
|
||||
mViewInfo.sbarTotal = 1;
|
||||
mViewInfo.sbarScale = 1.0;
|
||||
|
||||
UpdatePrefs();
|
||||
|
||||
mLockPlayRegion = false;
|
||||
@ -2902,6 +2883,12 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
if (!value || !XMLValueChecker::IsGoodString(value))
|
||||
break;
|
||||
|
||||
if (mViewInfo.ReadXMLAttribute(attr, value)) {
|
||||
// We need to save vpos now and restore it below
|
||||
longVpos = std::max(longVpos, long(mViewInfo.vpos));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!wxStrcmp(attr, wxT("datadir")))
|
||||
{
|
||||
//
|
||||
@ -2995,20 +2982,6 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
requiredTags++;
|
||||
}
|
||||
|
||||
else if (mViewInfo.selectedRegion
|
||||
.HandleXMLAttribute(attr, value, wxT("sel0"), wxT("sel1"))) {
|
||||
}
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("vpos")))
|
||||
// Just assign a variable, put the value in its place later
|
||||
wxString(value).ToLong(&longVpos);
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("h")))
|
||||
Internat::CompatibleToDouble(value, &mViewInfo.h);
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("zoom")))
|
||||
Internat::CompatibleToDouble(value, &mViewInfo.zoom);
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("rate"))) {
|
||||
Internat::CompatibleToDouble(value, &mRate);
|
||||
GetSelectionBar()->SetRate(mRate);
|
||||
@ -3202,12 +3175,8 @@ void AudacityProject::WriteXML(XMLWriter &xmlFile)
|
||||
xmlFile.WriteAttr(wxT("projname"), projName);
|
||||
xmlFile.WriteAttr(wxT("version"), wxT(AUDACITY_FILE_FORMAT_VERSION));
|
||||
xmlFile.WriteAttr(wxT("audacityversion"), AUDACITY_VERSION_STRING);
|
||||
mViewInfo.selectedRegion
|
||||
.WriteXMLAttributes(xmlFile, wxT("sel0"), wxT("sel1"));
|
||||
// PRL: to do: persistence of other fields of the selection
|
||||
xmlFile.WriteAttr(wxT("vpos"), mViewInfo.vpos);
|
||||
xmlFile.WriteAttr(wxT("h"), mViewInfo.h, 10);
|
||||
xmlFile.WriteAttr(wxT("zoom"), mViewInfo.zoom, 10);
|
||||
|
||||
mViewInfo.WriteXMLAttributes(xmlFile);
|
||||
xmlFile.WriteAttr(wxT("rate"), mRate);
|
||||
xmlFile.WriteAttr(wxT("snapto"), GetSnapTo() ? wxT("on") : wxT("off"));
|
||||
xmlFile.WriteAttr(wxT("selectionformat"), GetSelectionFormat());
|
||||
|
@ -325,7 +325,7 @@ class GuiWaveTrack;
|
||||
class AdornedRulerPanel;
|
||||
class RulerPanel;
|
||||
class AttachableScrollBar;
|
||||
struct ViewInfo;
|
||||
class ViewInfo;
|
||||
#include <wx/scrolbar.h> // to get wxSB_HORIZONTAL
|
||||
|
||||
// CreateStdButtonSizer defs...should probably move to widgets subdir
|
||||
|
@ -37,7 +37,7 @@ class LabelTrack;
|
||||
class TimeTrack;
|
||||
class TrackList;
|
||||
class Ruler;
|
||||
struct ViewInfo;
|
||||
class ViewInfo;
|
||||
|
||||
#ifndef uchar
|
||||
typedef unsigned char uchar;
|
||||
|
@ -45,7 +45,7 @@ class AudacityProject;
|
||||
|
||||
class TrackPanelAx;
|
||||
|
||||
struct ViewInfo;
|
||||
class ViewInfo;
|
||||
|
||||
WX_DEFINE_ARRAY(LWSlider *, LWSliderArray);
|
||||
|
||||
|
@ -0,0 +1,66 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ViewInfo.cpp
|
||||
|
||||
Paul Licameli
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "ViewInfo.h"
|
||||
|
||||
#include "Internat.h"
|
||||
#include "xml/XMLWriter.h"
|
||||
|
||||
ViewInfo::ViewInfo(double start, double screenDuration, double pixelsPerSecond)
|
||||
: selectedRegion()
|
||||
, track(0)
|
||||
, vpos(0)
|
||||
, h(start)
|
||||
, screen(screenDuration)
|
||||
, total(screen)
|
||||
, zoom(pixelsPerSecond)
|
||||
|
||||
, sbarH(0)
|
||||
, sbarScreen(1)
|
||||
, sbarTotal(1)
|
||||
, sbarScale(1.0)
|
||||
, scrollStep(16)
|
||||
|
||||
, bUpdateTrackIndicator(true)
|
||||
{
|
||||
}
|
||||
|
||||
void ViewInfo::WriteXMLAttributes(XMLWriter &xmlFile)
|
||||
{
|
||||
selectedRegion.WriteXMLAttributes(xmlFile, wxT("sel0"), wxT("sel1"));
|
||||
xmlFile.WriteAttr(wxT("vpos"), vpos);
|
||||
xmlFile.WriteAttr(wxT("h"), h, 10);
|
||||
xmlFile.WriteAttr(wxT("zoom"), zoom, 10);
|
||||
}
|
||||
|
||||
bool ViewInfo::ReadXMLAttribute(const wxChar *attr, const wxChar *value)
|
||||
{
|
||||
if (selectedRegion.HandleXMLAttribute(attr, value, wxT("sel0"), wxT("sel1")))
|
||||
return true;
|
||||
|
||||
if (!wxStrcmp(attr, wxT("vpos"))) {
|
||||
long longVpos;
|
||||
wxString(value).ToLong(&longVpos);
|
||||
vpos = int(longVpos);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!wxStrcmp(attr, wxT("h"))) {
|
||||
Internat::CompatibleToDouble(value, &h);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!wxStrcmp(attr, wxT("zoom"))) {
|
||||
Internat::CompatibleToDouble(value, &zoom);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -18,7 +18,11 @@ const double gMaxZoom = 6000000,
|
||||
|
||||
class Track;
|
||||
|
||||
struct ViewInfo {
|
||||
class AUDACITY_DLL_API ViewInfo
|
||||
{
|
||||
public:
|
||||
|
||||
ViewInfo(double start, double screenDuration, double pixelsPerSecond);
|
||||
|
||||
// Current selection
|
||||
|
||||
@ -52,6 +56,9 @@ struct ViewInfo {
|
||||
// drawing the waveform. Maybe this should be put somewhere else?
|
||||
|
||||
bool bUpdateTrackIndicator;
|
||||
|
||||
void WriteXMLAttributes(XMLWriter &xmlFile);
|
||||
bool ReadXMLAttribute(const wxChar *attr, const wxChar *value);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <wx/scrolbar.h>
|
||||
|
||||
struct ViewInfo;
|
||||
class ViewInfo;
|
||||
|
||||
class AUDACITY_DLL_API AttachableScrollBar :
|
||||
public wxScrollBar
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "../Envelope.h"
|
||||
#include "../Experimental.h"
|
||||
|
||||
struct ViewInfo;
|
||||
class ViewInfo;
|
||||
class AudacityProject;
|
||||
class TimeTrack;
|
||||
class SnapManager;
|
||||
|
Loading…
x
Reference in New Issue
Block a user