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