mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-11 15:15:57 +01:00
TrackView handles its own special XML attributes via virtual functions
This commit is contained in:
@@ -1191,9 +1191,10 @@ void Track::WriteCommonXMLAttributes(
|
|||||||
xmlFile.WriteAttr(wxT("name"), GetName());
|
xmlFile.WriteAttr(wxT("name"), GetName());
|
||||||
xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
|
xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
|
||||||
}
|
}
|
||||||
auto &view = TrackView::Get( *this );
|
if ( mpView )
|
||||||
xmlFile.WriteAttr(wxT("height"), view.GetActualHeight());
|
mpView->WriteXMLAttributes( xmlFile );
|
||||||
xmlFile.WriteAttr(wxT("minimized"), view.GetMinimized());
|
if ( mpControls )
|
||||||
|
mpControls->WriteXMLAttributes( xmlFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true iff the attribute is recognized.
|
// Return true iff the attribute is recognized.
|
||||||
@@ -1201,21 +1202,15 @@ bool Track::HandleCommonXMLAttribute(const wxChar *attr, const wxChar *value)
|
|||||||
{
|
{
|
||||||
long nValue = -1;
|
long nValue = -1;
|
||||||
wxString strValue( value );
|
wxString strValue( value );
|
||||||
if (!wxStrcmp(attr, wxT("name")) &&
|
if ( mpView && mpView->HandleXMLAttribute( attr, value ) )
|
||||||
|
;
|
||||||
|
else if ( mpControls && mpControls->HandleXMLAttribute( attr, value ) )
|
||||||
|
;
|
||||||
|
else if (!wxStrcmp(attr, wxT("name")) &&
|
||||||
XMLValueChecker::IsGoodString(strValue)) {
|
XMLValueChecker::IsGoodString(strValue)) {
|
||||||
SetName( strValue );
|
SetName( strValue );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (!wxStrcmp(attr, wxT("height")) &&
|
|
||||||
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
|
||||||
TrackView::Get( *this ).SetHeight(nValue);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (!wxStrcmp(attr, wxT("minimized")) &&
|
|
||||||
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
|
||||||
TrackView::Get( *this ).SetMinimized(nValue != 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (!wxStrcmp(attr, wxT("isSelected")) &&
|
else if (!wxStrcmp(attr, wxT("isSelected")) &&
|
||||||
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
||||||
this->SetSelected(nValue != 0);
|
this->SetSelected(nValue != 0);
|
||||||
|
|||||||
@@ -66,3 +66,12 @@ std::shared_ptr<Track> CommonTrackCell::DoFindTrack()
|
|||||||
{
|
{
|
||||||
return mwTrack.lock();
|
return mwTrack.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommonTrackCell::WriteXMLAttributes( XMLWriter & ) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CommonTrackCell::HandleXMLAttribute( const wxChar *, const wxChar * )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class Track;
|
class Track;
|
||||||
|
class XMLWriter;
|
||||||
|
|
||||||
class AUDACITY_DLL_API CommonTrackPanelCell /* not final */
|
class AUDACITY_DLL_API CommonTrackPanelCell /* not final */
|
||||||
: public TrackPanelCell
|
: public TrackPanelCell
|
||||||
@@ -65,6 +66,12 @@ public:
|
|||||||
|
|
||||||
virtual void Reparent( const std::shared_ptr<Track> &parent );
|
virtual void Reparent( const std::shared_ptr<Track> &parent );
|
||||||
|
|
||||||
|
// default does nothing
|
||||||
|
virtual void WriteXMLAttributes( XMLWriter & ) const;
|
||||||
|
|
||||||
|
// default recognizes no attributes, and returns false
|
||||||
|
virtual bool HandleXMLAttribute( const wxChar *attr, const wxChar *value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::weak_ptr< Track > mwTrack;
|
std::weak_ptr< Track > mwTrack;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
|
|
||||||
#include "../../ClientData.h"
|
#include "../../ClientData.h"
|
||||||
#include "../../Project.h"
|
#include "../../Project.h"
|
||||||
|
#include "../../xml/XMLTagHandler.h"
|
||||||
|
#include "../../xml/XMLWriter.h"
|
||||||
|
|
||||||
TrackView::~TrackView()
|
TrackView::~TrackView()
|
||||||
{
|
{
|
||||||
@@ -74,6 +76,30 @@ void TrackView::SetMinimized(bool isMinimized)
|
|||||||
leader->AdjustPositions();
|
leader->AdjustPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackView::WriteXMLAttributes( XMLWriter &xmlFile ) const
|
||||||
|
{
|
||||||
|
xmlFile.WriteAttr(wxT("height"), GetActualHeight());
|
||||||
|
xmlFile.WriteAttr(wxT("minimized"), GetMinimized());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TrackView::HandleXMLAttribute( const wxChar *attr, const wxChar *value )
|
||||||
|
{
|
||||||
|
wxString strValue;
|
||||||
|
long nValue;
|
||||||
|
if (!wxStrcmp(attr, wxT("height")) &&
|
||||||
|
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
||||||
|
SetHeight(nValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!wxStrcmp(attr, wxT("minimized")) &&
|
||||||
|
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
|
||||||
|
SetMinimized(nValue != 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void TrackView::DoSetMinimized(bool isMinimized)
|
void TrackView::DoSetMinimized(bool isMinimized)
|
||||||
{
|
{
|
||||||
mMinimized = isMinimized;
|
mMinimized = isMinimized;
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ public:
|
|||||||
std::shared_ptr<TrackPanelCell> GetResizer();
|
std::shared_ptr<TrackPanelCell> GetResizer();
|
||||||
std::shared_ptr<const TrackPanelCell> GetResizer() const;
|
std::shared_ptr<const TrackPanelCell> GetResizer() const;
|
||||||
|
|
||||||
|
void WriteXMLAttributes( XMLWriter & ) const override;
|
||||||
|
bool HandleXMLAttribute( const wxChar *attr, const wxChar *value ) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoSetMinimized( bool isMinimized );
|
virtual void DoSetMinimized( bool isMinimized );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user