mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
Move ARDOUR::Change into PBD so that Stateful can be aware of
what Change a State reflects. Hence allow Stateful to do some of the work of set/get_state in Region. git-svn-id: svn://localhost/ardour2/branches/3.0@6671 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
c9d433d9b3
commit
3c00a7ca2a
30 changed files with 202 additions and 170 deletions
|
|
@ -167,7 +167,7 @@ AudioRegionEditor::~AudioRegionEditor ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioRegionEditor::region_changed (Change what_changed)
|
AudioRegionEditor::region_changed (PBD::Change what_changed)
|
||||||
{
|
{
|
||||||
if (what_changed & NameChanged) {
|
if (what_changed & NameChanged) {
|
||||||
name_changed ();
|
name_changed ();
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,8 @@ class AudioRegionEditor : public RegionEditor
|
||||||
PBD::ScopedConnection state_connection;
|
PBD::ScopedConnection state_connection;
|
||||||
PBD::ScopedConnection audition_connection;
|
PBD::ScopedConnection audition_connection;
|
||||||
|
|
||||||
void region_changed (ARDOUR::Change);
|
void region_changed (PBD::Change);
|
||||||
void bounds_changed (ARDOUR::Change);
|
void bounds_changed (PBD::Change);
|
||||||
void name_changed ();
|
void name_changed ();
|
||||||
void gain_changed ();
|
void gain_changed ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ class AudioRegionView : public RegionView
|
||||||
|
|
||||||
AudioRegionGainLine* get_gain_line() const { return gain_line; }
|
AudioRegionGainLine* get_gain_line() const { return gain_line; }
|
||||||
|
|
||||||
void region_changed (ARDOUR::Change);
|
void region_changed (PBD::Change);
|
||||||
void envelope_active_changed ();
|
void envelope_active_changed ();
|
||||||
|
|
||||||
GhostRegion* add_ghost (TimeAxisView&);
|
GhostRegion* add_ghost (TimeAxisView&);
|
||||||
|
|
@ -150,7 +150,7 @@ class AudioRegionView : public RegionView
|
||||||
void fade_in_active_changed ();
|
void fade_in_active_changed ();
|
||||||
void fade_out_active_changed ();
|
void fade_out_active_changed ();
|
||||||
|
|
||||||
void region_resized (ARDOUR::Change);
|
void region_resized (PBD::Change);
|
||||||
void region_muted ();
|
void region_muted ();
|
||||||
void region_scale_amplitude_changed ();
|
void region_scale_amplitude_changed ();
|
||||||
void region_renamed ();
|
void region_renamed ();
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ AutomationRegionView::reset_width_dependent_items (double pixel_width)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AutomationRegionView::region_resized (ARDOUR::Change what_changed)
|
AutomationRegionView::region_resized (PBD::Change what_changed)
|
||||||
{
|
{
|
||||||
RegionView::region_resized(what_changed);
|
RegionView::region_resized(what_changed);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void create_line(boost::shared_ptr<ARDOUR::AutomationList> list);
|
void create_line(boost::shared_ptr<ARDOUR::AutomationList> list);
|
||||||
bool set_position(nframes64_t pos, void* src, double* ignored);
|
bool set_position(nframes64_t pos, void* src, double* ignored);
|
||||||
void region_resized(ARDOUR::Change what_changed);
|
void region_resized (PBD::Change what_changed);
|
||||||
bool canvas_event(GdkEvent* ev);
|
bool canvas_event(GdkEvent* ev);
|
||||||
void add_automation_event (GdkEvent* event, nframes_t when, double y);
|
void add_automation_event (GdkEvent* event, nframes_t when, double y);
|
||||||
void entered();
|
void entered();
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ class CrossfadeEditor : public ArdourDialog
|
||||||
void audition_right_dry ();
|
void audition_right_dry ();
|
||||||
void audition_right ();
|
void audition_right ();
|
||||||
|
|
||||||
void xfade_changed (ARDOUR::Change);
|
void xfade_changed (PBD::Change);
|
||||||
|
|
||||||
void dump ();
|
void dump ();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ struct CrossfadeView : public TimeAxisViewItem
|
||||||
ArdourCanvas::Line *fade_out;
|
ArdourCanvas::Line *fade_out;
|
||||||
ArdourCanvas::Item *active_button;
|
ArdourCanvas::Item *active_button;
|
||||||
|
|
||||||
void crossfade_changed (ARDOUR::Change);
|
void crossfade_changed (PBD::Change);
|
||||||
void active_changed ();
|
void active_changed ();
|
||||||
void redraw_curves ();
|
void redraw_curves ();
|
||||||
void color_handler ();
|
void color_handler ();
|
||||||
|
|
|
||||||
|
|
@ -520,7 +520,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||||
void location_changed (ARDOUR::Location *);
|
void location_changed (ARDOUR::Location *);
|
||||||
void location_flags_changed (ARDOUR::Location *, void *);
|
void location_flags_changed (ARDOUR::Location *, void *);
|
||||||
void refresh_location_display ();
|
void refresh_location_display ();
|
||||||
void refresh_location_display_s (ARDOUR::Change);
|
void refresh_location_display_s (PBD::Change);
|
||||||
void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
|
void refresh_location_display_internal (ARDOUR::Locations::LocationList&);
|
||||||
void add_new_location (ARDOUR::Location *);
|
void add_new_location (ARDOUR::Location *);
|
||||||
void location_gone (ARDOUR::Location *);
|
void location_gone (ARDOUR::Location *);
|
||||||
|
|
@ -1475,7 +1475,7 @@ public:
|
||||||
void draw_metric_marks (const ARDOUR::Metrics& metrics);
|
void draw_metric_marks (const ARDOUR::Metrics& metrics);
|
||||||
|
|
||||||
void compute_current_bbt_points (nframes_t left, nframes_t right);
|
void compute_current_bbt_points (nframes_t left, nframes_t right);
|
||||||
void tempo_map_changed (ARDOUR::Change);
|
void tempo_map_changed (PBD::Change);
|
||||||
void redisplay_tempo (bool immediate_redraw);
|
void redisplay_tempo (bool immediate_redraw);
|
||||||
|
|
||||||
void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
|
void snap_to (nframes64_t& first, int32_t direction = 0, bool for_mark = false);
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ private:
|
||||||
|
|
||||||
Columns _columns;
|
Columns _columns;
|
||||||
|
|
||||||
void region_changed (ARDOUR::Change, boost::weak_ptr<ARDOUR::Region>);
|
void region_changed (PBD::Change, boost::weak_ptr<ARDOUR::Region>);
|
||||||
void selection_changed ();
|
void selection_changed ();
|
||||||
sigc::connection _change_connection;
|
sigc::connection _change_connection;
|
||||||
bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
|
bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,7 @@ class MidiRegionView : public RegionView
|
||||||
Gdk::Color& basic_color,
|
Gdk::Color& basic_color,
|
||||||
TimeAxisViewItem::Visibility);
|
TimeAxisViewItem::Visibility);
|
||||||
|
|
||||||
void region_resized (ARDOUR::Change);
|
void region_resized (PBD::Change);
|
||||||
|
|
||||||
void set_flags (XMLNode *);
|
void set_flags (XMLNode *);
|
||||||
void store_flags ();
|
void store_flags ();
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class RegionView : public TimeAxisViewItem
|
||||||
virtual void show_region_editor () {}
|
virtual void show_region_editor () {}
|
||||||
virtual void hide_region_editor();
|
virtual void hide_region_editor();
|
||||||
|
|
||||||
virtual void region_changed (ARDOUR::Change);
|
virtual void region_changed (PBD::Change);
|
||||||
|
|
||||||
virtual GhostRegion* add_ghost (TimeAxisView&) = 0;
|
virtual GhostRegion* add_ghost (TimeAxisView&) = 0;
|
||||||
void remove_ghost_in (TimeAxisView&);
|
void remove_ghost_in (TimeAxisView&);
|
||||||
|
|
@ -104,7 +104,7 @@ class RegionView : public TimeAxisViewItem
|
||||||
bool recording,
|
bool recording,
|
||||||
TimeAxisViewItem::Visibility);
|
TimeAxisViewItem::Visibility);
|
||||||
|
|
||||||
virtual void region_resized (ARDOUR::Change);
|
virtual void region_resized (PBD::Change);
|
||||||
virtual void region_muted ();
|
virtual void region_muted ();
|
||||||
void region_locked ();
|
void region_locked ();
|
||||||
void region_opacity ();
|
void region_opacity ();
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
#include "pbd/failed_constructor.h"
|
#include "pbd/failed_constructor.h"
|
||||||
#include "pbd/locale_guard.h"
|
#include "pbd/locale_guard.h"
|
||||||
|
#include "pbd/stateful.h"
|
||||||
|
|
||||||
#include "ardour/types.h"
|
#include "ardour/types.h"
|
||||||
|
|
||||||
|
|
@ -64,13 +65,11 @@ namespace ARDOUR {
|
||||||
return (microseconds_t) jack_get_time();
|
return (microseconds_t) jack_get_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
Change new_change ();
|
extern PBD::Change StartChanged;
|
||||||
|
extern PBD::Change LengthChanged;
|
||||||
extern Change StartChanged;
|
extern PBD::Change PositionChanged;
|
||||||
extern Change LengthChanged;
|
extern PBD::Change NameChanged;
|
||||||
extern Change PositionChanged;
|
extern PBD::Change BoundsChanged;
|
||||||
extern Change NameChanged;
|
|
||||||
extern Change BoundsChanged;
|
|
||||||
|
|
||||||
static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
|
static const double SHUTTLE_FRACT_SPEED1=0.48412291827; /* derived from A1,A2 */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,8 @@ class AudioPlaylist : public ARDOUR::Playlist
|
||||||
XMLNode& state (bool full_state);
|
XMLNode& state (bool full_state);
|
||||||
void dump () const;
|
void dump () const;
|
||||||
|
|
||||||
bool region_changed (Change, boost::shared_ptr<Region>);
|
bool region_changed (PBD::Change, boost::shared_ptr<Region>);
|
||||||
void crossfade_changed (Change);
|
void crossfade_changed (PBD::Change);
|
||||||
void add_crossfade (boost::shared_ptr<Crossfade>);
|
void add_crossfade (boost::shared_ptr<Crossfade>);
|
||||||
|
|
||||||
void source_offset_changed (boost::shared_ptr<AudioRegion> region);
|
void source_offset_changed (boost::shared_ptr<AudioRegion> region);
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,13 @@ class AudioSource;
|
||||||
class AudioRegion : public Region
|
class AudioRegion : public Region
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Change FadeInChanged;
|
static PBD::Change FadeInChanged;
|
||||||
static Change FadeOutChanged;
|
static PBD::Change FadeOutChanged;
|
||||||
static Change FadeInActiveChanged;
|
static PBD::Change FadeInActiveChanged;
|
||||||
static Change FadeOutActiveChanged;
|
static PBD::Change FadeOutActiveChanged;
|
||||||
static Change EnvelopeActiveChanged;
|
static PBD::Change EnvelopeActiveChanged;
|
||||||
static Change ScaleAmplitudeChanged;
|
static PBD::Change ScaleAmplitudeChanged;
|
||||||
static Change EnvelopeChanged;
|
static PBD::Change EnvelopeChanged;
|
||||||
|
|
||||||
~AudioRegion();
|
~AudioRegion();
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ class AudioRegion : public Region
|
||||||
|
|
||||||
AudioRegion (Session& s, nframes_t, nframes_t, std::string name);
|
AudioRegion (Session& s, nframes_t, nframes_t, std::string name);
|
||||||
|
|
||||||
int set_live_state (const XMLNode&, int version, Change&, bool send);
|
int set_live_state (const XMLNode&, int version, PBD::Change&, bool send);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ARDOUR */
|
} /* namespace ARDOUR */
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ class Crossfade : public ARDOUR::AudioRegion
|
||||||
nframes_t overlap_length() const;
|
nframes_t overlap_length() const;
|
||||||
|
|
||||||
PBD::Signal1<void,boost::shared_ptr<Region> > Invalidated;
|
PBD::Signal1<void,boost::shared_ptr<Region> > Invalidated;
|
||||||
PBD::Signal1<void,Change> StateChanged;
|
PBD::Signal1<void,PBD::Change> StateChanged;
|
||||||
|
|
||||||
bool covers (nframes_t frame) const {
|
bool covers (nframes_t frame) const {
|
||||||
return _position <= frame && frame < _position + _length;
|
return _position <= frame && frame < _position + _length;
|
||||||
|
|
@ -136,8 +136,8 @@ class Crossfade : public ARDOUR::AudioRegion
|
||||||
static nframes_t short_xfade_length() { return _short_xfade_length; }
|
static nframes_t short_xfade_length() { return _short_xfade_length; }
|
||||||
static void set_short_xfade_length (nframes_t n);
|
static void set_short_xfade_length (nframes_t n);
|
||||||
|
|
||||||
static Change ActiveChanged;
|
static PBD::Change ActiveChanged;
|
||||||
static Change FollowOverlapChanged;
|
static PBD::Change FollowOverlapChanged;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct CrossfadeComparePtr;
|
friend struct CrossfadeComparePtr;
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ class Diskstream : public SessionObject
|
||||||
|
|
||||||
/* XXX fix this redundancy ... */
|
/* XXX fix this redundancy ... */
|
||||||
|
|
||||||
virtual void playlist_changed (Change);
|
virtual void playlist_changed (PBD::Change);
|
||||||
virtual void playlist_deleted (boost::weak_ptr<Playlist>);
|
virtual void playlist_deleted (boost::weak_ptr<Playlist>);
|
||||||
virtual void playlist_ranges_moved (std::list< Evoral::RangeMove<nframes_t> > const &);
|
virtual void playlist_ranges_moved (std::list< Evoral::RangeMove<nframes_t> > const &);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ class Locations : public PBD::StatefulDestructible
|
||||||
PBD::Signal0<void> changed;
|
PBD::Signal0<void> changed;
|
||||||
PBD::Signal1<void,Location*> added;
|
PBD::Signal1<void,Location*> added;
|
||||||
PBD::Signal1<void,Location*> removed;
|
PBD::Signal1<void,Location*> removed;
|
||||||
PBD::Signal1<void,Change> StateChanged;
|
PBD::Signal1<void,PBD::Change> StateChanged;
|
||||||
|
|
||||||
template<class T> void apply (T& obj, void (T::*method)(LocationList&)) {
|
template<class T> void apply (T& obj, void (T::*method)(LocationList&)) {
|
||||||
Glib::Mutex::Lock lm (lock);
|
Glib::Mutex::Lock lm (lock);
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void dump () const;
|
void dump () const;
|
||||||
|
|
||||||
bool region_changed (Change, boost::shared_ptr<Region>);
|
bool region_changed (PBD::Change, boost::shared_ptr<Region>);
|
||||||
|
|
||||||
NoteMode _note_mode;
|
NoteMode _note_mode;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ class MidiRegion : public Region
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int set_live_state (const XMLNode&, int version, Change&, bool send);
|
int set_live_state (const XMLNode&, int version, PBD::Change&, bool send);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ARDOUR */
|
} /* namespace ARDOUR */
|
||||||
|
|
|
||||||
|
|
@ -249,15 +249,15 @@ class Playlist : public SessionObject
|
||||||
void notify_length_changed ();
|
void notify_length_changed ();
|
||||||
void notify_layering_changed ();
|
void notify_layering_changed ();
|
||||||
void notify_contents_changed ();
|
void notify_contents_changed ();
|
||||||
void notify_state_changed (Change);
|
void notify_state_changed (PBD::Change);
|
||||||
void notify_region_moved (boost::shared_ptr<Region>);
|
void notify_region_moved (boost::shared_ptr<Region>);
|
||||||
|
|
||||||
void mark_session_dirty();
|
void mark_session_dirty();
|
||||||
|
|
||||||
void region_changed_proxy (Change, boost::weak_ptr<Region>);
|
void region_changed_proxy (PBD::Change, boost::weak_ptr<Region>);
|
||||||
virtual bool region_changed (Change, boost::shared_ptr<Region>);
|
virtual bool region_changed (PBD::Change, boost::shared_ptr<Region>);
|
||||||
|
|
||||||
void region_bounds_changed (Change, boost::shared_ptr<Region>);
|
void region_bounds_changed (PBD::Change, boost::shared_ptr<Region>);
|
||||||
void region_deleted (boost::shared_ptr<Region>);
|
void region_deleted (boost::shared_ptr<Region>);
|
||||||
|
|
||||||
void sort_regions ();
|
void sort_regions ();
|
||||||
|
|
|
||||||
|
|
@ -87,15 +87,15 @@ class Region
|
||||||
|
|
||||||
static const Flag DefaultFlags = Flag (Opaque|DefaultFadeIn|DefaultFadeOut|FadeIn|FadeOut);
|
static const Flag DefaultFlags = Flag (Opaque|DefaultFadeIn|DefaultFadeOut|FadeIn|FadeOut);
|
||||||
|
|
||||||
static Change FadeChanged;
|
static PBD::Change FadeChanged;
|
||||||
static Change SyncOffsetChanged;
|
static PBD::Change SyncOffsetChanged;
|
||||||
static Change MuteChanged;
|
static PBD::Change MuteChanged;
|
||||||
static Change OpacityChanged;
|
static PBD::Change OpacityChanged;
|
||||||
static Change LockChanged;
|
static PBD::Change LockChanged;
|
||||||
static Change LayerChanged;
|
static PBD::Change LayerChanged;
|
||||||
static Change HiddenChanged;
|
static PBD::Change HiddenChanged;
|
||||||
|
|
||||||
PBD::Signal1<void,Change> StateChanged;
|
PBD::Signal1<void,PBD::Change> StateChanged;
|
||||||
static PBD::Signal1<void,boost::shared_ptr<ARDOUR::Region> > RegionPropertyChanged;
|
static PBD::Signal1<void,boost::shared_ptr<ARDOUR::Region> > RegionPropertyChanged;
|
||||||
void unlock_property_changes () { _flags = Flag (_flags & ~DoNotSendPropertyChanges); }
|
void unlock_property_changes () { _flags = Flag (_flags & ~DoNotSendPropertyChanges); }
|
||||||
void block_property_changes () { _flags = Flag (_flags | DoNotSendPropertyChanges); }
|
void block_property_changes () { _flags = Flag (_flags | DoNotSendPropertyChanges); }
|
||||||
|
|
@ -242,7 +242,7 @@ class Region
|
||||||
XMLNode& get_state ();
|
XMLNode& get_state ();
|
||||||
virtual XMLNode& state (bool);
|
virtual XMLNode& state (bool);
|
||||||
virtual int set_state (const XMLNode&, int version);
|
virtual int set_state (const XMLNode&, int version);
|
||||||
virtual int set_live_state (const XMLNode&, int version, Change&, bool send);
|
virtual int set_live_state (const XMLNode&, int version, PBD::Change&, bool send);
|
||||||
|
|
||||||
virtual boost::shared_ptr<Region> get_parent() const;
|
virtual boost::shared_ptr<Region> get_parent() const;
|
||||||
|
|
||||||
|
|
@ -296,7 +296,7 @@ class Region
|
||||||
|
|
||||||
XMLNode& get_short_state (); /* used only by Session */
|
XMLNode& get_short_state (); /* used only by Session */
|
||||||
|
|
||||||
void send_change (Change);
|
void send_change (PBD::Change);
|
||||||
|
|
||||||
void trim_to_internal (nframes_t position, nframes_t length, void *src);
|
void trim_to_internal (nframes_t position, nframes_t length, void *src);
|
||||||
virtual void set_position_internal (nframes_t pos, bool allow_bbt_recompute);
|
virtual void set_position_internal (nframes_t pos, bool allow_bbt_recompute);
|
||||||
|
|
@ -333,7 +333,7 @@ class Region
|
||||||
AnalysisFeatureList _transients;
|
AnalysisFeatureList _transients;
|
||||||
bool _valid_transients;
|
bool _valid_transients;
|
||||||
mutable uint32_t _read_data_count; ///< modified in read()
|
mutable uint32_t _read_data_count; ///< modified in read()
|
||||||
Change _pending_changed;
|
PBD::Change _pending_changed;
|
||||||
uint64_t _last_layer_op; ///< timestamp
|
uint64_t _last_layer_op; ///< timestamp
|
||||||
Glib::Mutex _lock;
|
Glib::Mutex _lock;
|
||||||
SourceList _sources;
|
SourceList _sources;
|
||||||
|
|
|
||||||
|
|
@ -1210,7 +1210,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||||
void xrun_recovery ();
|
void xrun_recovery ();
|
||||||
|
|
||||||
TempoMap *_tempo_map;
|
TempoMap *_tempo_map;
|
||||||
void tempo_map_changed (Change);
|
void tempo_map_changed (PBD::Change);
|
||||||
|
|
||||||
/* edit/mix groups */
|
/* edit/mix groups */
|
||||||
|
|
||||||
|
|
@ -1257,7 +1257,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||||
RegionList regions;
|
RegionList regions;
|
||||||
|
|
||||||
void add_region (boost::shared_ptr<Region>);
|
void add_region (boost::shared_ptr<Region>);
|
||||||
void region_changed (Change, boost::weak_ptr<Region>);
|
void region_changed (PBD::Change, boost::weak_ptr<Region>);
|
||||||
void remove_region (boost::weak_ptr<Region>);
|
void remove_region (boost::weak_ptr<Region>);
|
||||||
|
|
||||||
int load_regions (const XMLNode& node);
|
int load_regions (const XMLNode& node);
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ class TempoMap : public PBD::StatefulDestructible
|
||||||
|
|
||||||
nframes_t frame_rate () const { return _frame_rate; }
|
nframes_t frame_rate () const { return _frame_rate; }
|
||||||
|
|
||||||
PBD::Signal1<void,ARDOUR::Change> StateChanged;
|
PBD::Signal1<void,PBD::Change> StateChanged;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Tempo _default_tempo;
|
static Tempo _default_tempo;
|
||||||
|
|
|
||||||
|
|
@ -261,11 +261,6 @@ namespace ARDOUR {
|
||||||
SyncPoint
|
SyncPoint
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Change {
|
|
||||||
range_guarantee = ~0
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
enum Placement {
|
enum Placement {
|
||||||
PreFader,
|
PreFader,
|
||||||
PostFader
|
PostFader
|
||||||
|
|
|
||||||
|
|
@ -54,13 +54,13 @@ using namespace PBD;
|
||||||
|
|
||||||
/* a Session will reset these to its chosen defaults by calling AudioRegion::set_default_fade() */
|
/* a Session will reset these to its chosen defaults by calling AudioRegion::set_default_fade() */
|
||||||
|
|
||||||
Change AudioRegion::FadeInChanged = ARDOUR::new_change();
|
Change AudioRegion::FadeInChanged = PBD::new_change();
|
||||||
Change AudioRegion::FadeOutChanged = ARDOUR::new_change();
|
Change AudioRegion::FadeOutChanged = PBD::new_change();
|
||||||
Change AudioRegion::FadeInActiveChanged = ARDOUR::new_change();
|
Change AudioRegion::FadeInActiveChanged = PBD::new_change();
|
||||||
Change AudioRegion::FadeOutActiveChanged = ARDOUR::new_change();
|
Change AudioRegion::FadeOutActiveChanged = PBD::new_change();
|
||||||
Change AudioRegion::EnvelopeActiveChanged = ARDOUR::new_change();
|
Change AudioRegion::EnvelopeActiveChanged = PBD::new_change();
|
||||||
Change AudioRegion::ScaleAmplitudeChanged = ARDOUR::new_change();
|
Change AudioRegion::ScaleAmplitudeChanged = PBD::new_change();
|
||||||
Change AudioRegion::EnvelopeChanged = ARDOUR::new_change();
|
Change AudioRegion::EnvelopeChanged = PBD::new_change();
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioRegion::init ()
|
AudioRegion::init ()
|
||||||
|
|
|
||||||
|
|
@ -99,11 +99,11 @@ MIDI::Port *ARDOUR::default_mtc_port = 0;
|
||||||
MIDI::Port *ARDOUR::default_midi_port = 0;
|
MIDI::Port *ARDOUR::default_midi_port = 0;
|
||||||
MIDI::Port *ARDOUR::default_midi_clock_port = 0;
|
MIDI::Port *ARDOUR::default_midi_clock_port = 0;
|
||||||
|
|
||||||
Change ARDOUR::StartChanged = ARDOUR::new_change ();
|
PBD::Change ARDOUR::StartChanged = PBD::new_change ();
|
||||||
Change ARDOUR::LengthChanged = ARDOUR::new_change ();
|
PBD::Change ARDOUR::LengthChanged = PBD::new_change ();
|
||||||
Change ARDOUR::PositionChanged = ARDOUR::new_change ();
|
PBD::Change ARDOUR::PositionChanged = PBD::new_change ();
|
||||||
Change ARDOUR::NameChanged = ARDOUR::new_change ();
|
PBD::Change ARDOUR::NameChanged = PBD::new_change ();
|
||||||
Change ARDOUR::BoundsChanged = Change (0); // see init(), below
|
PBD::Change ARDOUR::BoundsChanged = Change (0); // see init(), below
|
||||||
|
|
||||||
compute_peak_t ARDOUR::compute_peak = 0;
|
compute_peak_t ARDOUR::compute_peak = 0;
|
||||||
find_peaks_t ARDOUR::find_peaks = 0;
|
find_peaks_t ARDOUR::find_peaks = 0;
|
||||||
|
|
@ -388,27 +388,6 @@ ARDOUR::cleanup ()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ARDOUR::Change
|
|
||||||
ARDOUR::new_change ()
|
|
||||||
{
|
|
||||||
Change c;
|
|
||||||
static uint32_t change_bit = 1;
|
|
||||||
|
|
||||||
/* catch out-of-range */
|
|
||||||
if (!change_bit)
|
|
||||||
{
|
|
||||||
fatal << _("programming error: ")
|
|
||||||
<< "change_bit out of range in ARDOUR::new_change()"
|
|
||||||
<< endmsg;
|
|
||||||
/*NOTREACHED*/
|
|
||||||
}
|
|
||||||
|
|
||||||
c = Change (change_bit);
|
|
||||||
change_bit <<= 1; // if it shifts too far, change_bit == 0
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
string
|
string
|
||||||
ARDOUR::get_ardour_revision ()
|
ARDOUR::get_ardour_revision ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ MidiPlaylist::contained_automation()
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MidiPlaylist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
|
MidiPlaylist::region_changed (PBD::Change what_changed, boost::shared_ptr<Region> region)
|
||||||
{
|
{
|
||||||
if (in_flush || in_set_state) {
|
if (in_flush || in_set_state) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -423,7 +423,7 @@ MidiPlaylist::region_changed (Change what_changed, boost::shared_ptr<Region> reg
|
||||||
|
|
||||||
// Feeling rather uninterested today, but thanks for the heads up anyway!
|
// Feeling rather uninterested today, but thanks for the heads up anyway!
|
||||||
|
|
||||||
Change our_interests = Change (/*MidiRegion::FadeInChanged|
|
PBD::Change our_interests = PBD::Change (/*MidiRegion::FadeInChanged|
|
||||||
MidiRegion::FadeOutChanged|
|
MidiRegion::FadeOutChanged|
|
||||||
MidiRegion::FadeInActiveChanged|
|
MidiRegion::FadeInActiveChanged|
|
||||||
MidiRegion::FadeOutActiveChanged|
|
MidiRegion::FadeOutActiveChanged|
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,13 @@ using namespace std;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
|
|
||||||
Change Region::FadeChanged = ARDOUR::new_change ();
|
Change Region::FadeChanged = PBD::new_change ();
|
||||||
Change Region::SyncOffsetChanged = ARDOUR::new_change ();
|
Change Region::SyncOffsetChanged = PBD::new_change ();
|
||||||
Change Region::MuteChanged = ARDOUR::new_change ();
|
Change Region::MuteChanged = PBD::new_change ();
|
||||||
Change Region::OpacityChanged = ARDOUR::new_change ();
|
Change Region::OpacityChanged = PBD::new_change ();
|
||||||
Change Region::LockChanged = ARDOUR::new_change ();
|
Change Region::LockChanged = PBD::new_change ();
|
||||||
Change Region::LayerChanged = ARDOUR::new_change ();
|
Change Region::LayerChanged = PBD::new_change ();
|
||||||
Change Region::HiddenChanged = ARDOUR::new_change ();
|
Change Region::HiddenChanged = PBD::new_change ();
|
||||||
|
|
||||||
PBD::Signal1<void,boost::shared_ptr<ARDOUR::Region> > Region::RegionPropertyChanged;
|
PBD::Signal1<void,boost::shared_ptr<ARDOUR::Region> > Region::RegionPropertyChanged;
|
||||||
|
|
||||||
|
|
@ -70,13 +70,13 @@ Region::Region (Session& s, nframes_t start, nframes_t length, const string& nam
|
||||||
: SessionObject(s, name)
|
: SessionObject(s, name)
|
||||||
, _type(type)
|
, _type(type)
|
||||||
, _flags(Flag (flags|DoNotSendPropertyChanges))
|
, _flags(Flag (flags|DoNotSendPropertyChanges))
|
||||||
, _start (X_("start"), start)
|
, _start (X_("start"), StartChanged, start)
|
||||||
, _length(length)
|
, _length(length)
|
||||||
, _position (X_("position"), 0)
|
, _position (X_("position"), PositionChanged, 0)
|
||||||
, _last_position(0)
|
, _last_position(0)
|
||||||
, _positional_lock_style(AudioTime)
|
, _positional_lock_style(AudioTime)
|
||||||
, _sync_position(_start)
|
, _sync_position(_start)
|
||||||
, _layer (X_("layer"), layer)
|
, _layer (X_("layer"), LayerChanged, layer)
|
||||||
, _first_edit(EditChangesNothing)
|
, _first_edit(EditChangesNothing)
|
||||||
, _frozen(0)
|
, _frozen(0)
|
||||||
, _ancestral_start (0)
|
, _ancestral_start (0)
|
||||||
|
|
@ -98,13 +98,13 @@ Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length
|
||||||
: SessionObject(src->session(), name)
|
: SessionObject(src->session(), name)
|
||||||
, _type(type)
|
, _type(type)
|
||||||
, _flags(Flag (flags|DoNotSendPropertyChanges))
|
, _flags(Flag (flags|DoNotSendPropertyChanges))
|
||||||
, _start (X_("start"), start)
|
, _start (X_("start"), StartChanged, start)
|
||||||
, _length(length)
|
, _length(length)
|
||||||
, _position (X_("position"), 0)
|
, _position (X_("position"), PositionChanged, 0)
|
||||||
, _last_position(0)
|
, _last_position(0)
|
||||||
, _positional_lock_style(AudioTime)
|
, _positional_lock_style(AudioTime)
|
||||||
, _sync_position(_start)
|
, _sync_position(_start)
|
||||||
, _layer (X_("layer"), layer)
|
, _layer (X_("layer"), LayerChanged, layer)
|
||||||
, _first_edit(EditChangesNothing)
|
, _first_edit(EditChangesNothing)
|
||||||
, _frozen(0)
|
, _frozen(0)
|
||||||
, _ancestral_start (0)
|
, _ancestral_start (0)
|
||||||
|
|
@ -133,13 +133,13 @@ Region::Region (const SourceList& srcs, nframes_t start, nframes_t length, const
|
||||||
: SessionObject(srcs.front()->session(), name)
|
: SessionObject(srcs.front()->session(), name)
|
||||||
, _type(type)
|
, _type(type)
|
||||||
, _flags(Flag (flags|DoNotSendPropertyChanges))
|
, _flags(Flag (flags|DoNotSendPropertyChanges))
|
||||||
, _start (X_("start"), start)
|
, _start (X_("start"), StartChanged, start)
|
||||||
, _length(length)
|
, _length(length)
|
||||||
, _position (X_("position"), 0)
|
, _position (X_("position"), PositionChanged, 0)
|
||||||
, _last_position(0)
|
, _last_position(0)
|
||||||
, _positional_lock_style(AudioTime)
|
, _positional_lock_style(AudioTime)
|
||||||
, _sync_position(_start)
|
, _sync_position(_start)
|
||||||
, _layer (X_("layer"), layer)
|
, _layer (X_("layer"), LayerChanged, layer)
|
||||||
, _first_edit(EditChangesNothing)
|
, _first_edit(EditChangesNothing)
|
||||||
, _frozen(0)
|
, _frozen(0)
|
||||||
, _ancestral_start (0)
|
, _ancestral_start (0)
|
||||||
|
|
@ -161,9 +161,9 @@ Region::Region (const SourceList& srcs, nframes_t start, nframes_t length, const
|
||||||
Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
|
Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
|
||||||
: SessionObject(other->session(), name)
|
: SessionObject(other->session(), name)
|
||||||
, _type (other->data_type())
|
, _type (other->data_type())
|
||||||
, _start (X_("start"), 0)
|
, _start (X_("start"), StartChanged, 0)
|
||||||
, _position (X_("position"), 0)
|
, _position (X_("position"), PositionChanged, 0)
|
||||||
, _layer (X_("layer"), 0)
|
, _layer (X_("layer"), LayerChanged, 0)
|
||||||
, _pending_explicit_relayer (false)
|
, _pending_explicit_relayer (false)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -206,9 +206,9 @@ Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes
|
||||||
Region::Region (boost::shared_ptr<const Region> other, nframes_t length, const string& name, layer_t layer, Flag flags)
|
Region::Region (boost::shared_ptr<const Region> other, nframes_t length, const string& name, layer_t layer, Flag flags)
|
||||||
: SessionObject(other->session(), name)
|
: SessionObject(other->session(), name)
|
||||||
, _type (other->data_type())
|
, _type (other->data_type())
|
||||||
, _start (X_("start"), 0)
|
, _start (X_("start"), StartChanged, 0)
|
||||||
, _position (X_("position"), 0)
|
, _position (X_("position"), PositionChanged, 0)
|
||||||
, _layer (X_("layer"), 0)
|
, _layer (X_("layer"), LayerChanged, 0)
|
||||||
, _pending_explicit_relayer (false)
|
, _pending_explicit_relayer (false)
|
||||||
{
|
{
|
||||||
register_states ();
|
register_states ();
|
||||||
|
|
@ -306,13 +306,13 @@ Region::Region (const SourceList& srcs, const XMLNode& node)
|
||||||
: SessionObject(srcs.front()->session(), X_("error: XML did not reset this"))
|
: SessionObject(srcs.front()->session(), X_("error: XML did not reset this"))
|
||||||
, _type(DataType::NIL) // to be loaded from XML
|
, _type(DataType::NIL) // to be loaded from XML
|
||||||
, _flags(DoNotSendPropertyChanges)
|
, _flags(DoNotSendPropertyChanges)
|
||||||
, _start (X_("start"), 0)
|
, _start (X_("start"), StartChanged, 0)
|
||||||
, _length(0)
|
, _length(0)
|
||||||
, _position (X_("position"), 0)
|
, _position (X_("position"), PositionChanged, 0)
|
||||||
, _last_position(0)
|
, _last_position(0)
|
||||||
, _positional_lock_style(AudioTime)
|
, _positional_lock_style(AudioTime)
|
||||||
, _sync_position(_start)
|
, _sync_position(_start)
|
||||||
, _layer (X_("layer"), 0)
|
, _layer (X_("layer"), LayerChanged, 0)
|
||||||
, _first_edit(EditChangesNothing)
|
, _first_edit(EditChangesNothing)
|
||||||
, _frozen(0)
|
, _frozen(0)
|
||||||
, _stretch(1.0)
|
, _stretch(1.0)
|
||||||
|
|
@ -338,13 +338,13 @@ Region::Region (boost::shared_ptr<Source> src, const XMLNode& node)
|
||||||
: SessionObject(src->session(), X_("error: XML did not reset this"))
|
: SessionObject(src->session(), X_("error: XML did not reset this"))
|
||||||
, _type(DataType::NIL)
|
, _type(DataType::NIL)
|
||||||
, _flags(DoNotSendPropertyChanges)
|
, _flags(DoNotSendPropertyChanges)
|
||||||
, _start (X_("start"), 0)
|
, _start (X_("start"), StartChanged, 0)
|
||||||
, _length(0)
|
, _length(0)
|
||||||
, _position (X_("position"), 0)
|
, _position (X_("position"), PositionChanged, 0)
|
||||||
, _last_position(0)
|
, _last_position(0)
|
||||||
, _positional_lock_style(AudioTime)
|
, _positional_lock_style(AudioTime)
|
||||||
, _sync_position(_start)
|
, _sync_position(_start)
|
||||||
, _layer (X_("layer"), 0)
|
, _layer (X_("layer"), LayerChanged, 0)
|
||||||
, _first_edit(EditChangesNothing)
|
, _first_edit(EditChangesNothing)
|
||||||
, _frozen(0)
|
, _frozen(0)
|
||||||
, _stretch(1.0)
|
, _stretch(1.0)
|
||||||
|
|
@ -1092,16 +1092,14 @@ Region::state (bool /*full_state*/)
|
||||||
char buf[64];
|
char buf[64];
|
||||||
const char* fe = NULL;
|
const char* fe = NULL;
|
||||||
|
|
||||||
|
add_states (*node);
|
||||||
|
|
||||||
_id.print (buf, sizeof (buf));
|
_id.print (buf, sizeof (buf));
|
||||||
node->add_property ("id", buf);
|
node->add_property ("id", buf);
|
||||||
node->add_property ("name", _name);
|
node->add_property ("name", _name);
|
||||||
node->add_property ("type", _type.to_string());
|
node->add_property ("type", _type.to_string());
|
||||||
snprintf (buf, sizeof (buf), "%u", _start.get ());
|
|
||||||
node->add_property ("start", buf);
|
|
||||||
snprintf (buf, sizeof (buf), "%u", _length);
|
snprintf (buf, sizeof (buf), "%u", _length);
|
||||||
node->add_property ("length", buf);
|
node->add_property ("length", buf);
|
||||||
snprintf (buf, sizeof (buf), "%u", _position.get ());
|
|
||||||
node->add_property ("position", buf);
|
|
||||||
snprintf (buf, sizeof (buf), "%" PRIi64, _ancestral_start);
|
snprintf (buf, sizeof (buf), "%" PRIi64, _ancestral_start);
|
||||||
node->add_property ("ancestral-start", buf);
|
node->add_property ("ancestral-start", buf);
|
||||||
snprintf (buf, sizeof (buf), "%" PRIi64, _ancestral_length);
|
snprintf (buf, sizeof (buf), "%" PRIi64, _ancestral_length);
|
||||||
|
|
@ -1130,8 +1128,6 @@ Region::state (bool /*full_state*/)
|
||||||
|
|
||||||
/* note: flags are stored by derived classes */
|
/* note: flags are stored by derived classes */
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf), "%d", (int) _layer.get());
|
|
||||||
node->add_property ("layer", buf);
|
|
||||||
snprintf (buf, sizeof (buf), "%" PRIu32, _sync_position);
|
snprintf (buf, sizeof (buf), "%" PRIu32, _sync_position);
|
||||||
node->add_property ("sync-position", buf);
|
node->add_property ("sync-position", buf);
|
||||||
|
|
||||||
|
|
@ -1172,15 +1168,6 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
|
||||||
_type = DataType(prop->value());
|
_type = DataType(prop->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prop = node.property ("start")) != 0) {
|
|
||||||
sscanf (prop->value().c_str(), "%" PRIu32, &val);
|
|
||||||
if (val != _start) {
|
|
||||||
what_changed = Change (what_changed|StartChanged);
|
|
||||||
cerr << _name << " start changed\n";
|
|
||||||
_start = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((prop = node.property ("length")) != 0) {
|
if ((prop = node.property ("length")) != 0) {
|
||||||
sscanf (prop->value().c_str(), "%" PRIu32, &val);
|
sscanf (prop->value().c_str(), "%" PRIu32, &val);
|
||||||
if (val != _length) {
|
if (val != _length) {
|
||||||
|
|
@ -1191,26 +1178,6 @@ Region::set_live_state (const XMLNode& node, int /*version*/, Change& what_chang
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prop = node.property ("position")) != 0) {
|
|
||||||
sscanf (prop->value().c_str(), "%" PRIu32, &val);
|
|
||||||
if (val != _position) {
|
|
||||||
what_changed = Change (what_changed|PositionChanged);
|
|
||||||
cerr << _name << " position changed\n";
|
|
||||||
_last_position = _position;
|
|
||||||
_position = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((prop = node.property ("layer")) != 0) {
|
|
||||||
layer_t x;
|
|
||||||
x = (layer_t) atoi (prop->value().c_str());
|
|
||||||
if (x != _layer) {
|
|
||||||
what_changed = Change (what_changed|LayerChanged);
|
|
||||||
cerr << _name << " layer changed\n";
|
|
||||||
_layer = x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((prop = node.property ("sync-position")) != 0) {
|
if ((prop = node.property ("sync-position")) != 0) {
|
||||||
sscanf (prop->value().c_str(), "%" PRIu32, &val);
|
sscanf (prop->value().c_str(), "%" PRIu32, &val);
|
||||||
if (val != _sync_position) {
|
if (val != _sync_position) {
|
||||||
|
|
@ -1309,7 +1276,6 @@ int
|
||||||
Region::set_state (const XMLNode& node, int version)
|
Region::set_state (const XMLNode& node, int version)
|
||||||
{
|
{
|
||||||
const XMLProperty *prop;
|
const XMLProperty *prop;
|
||||||
Change what_changed = Change (0);
|
|
||||||
|
|
||||||
/* ID is not allowed to change, ever */
|
/* ID is not allowed to change, ever */
|
||||||
|
|
||||||
|
|
@ -1319,6 +1285,8 @@ Region::set_state (const XMLNode& node, int version)
|
||||||
|
|
||||||
_first_edit = EditChangesNothing;
|
_first_edit = EditChangesNothing;
|
||||||
|
|
||||||
|
Change what_changed = set_state_using_states (node);
|
||||||
|
|
||||||
set_live_state (node, version, what_changed, true);
|
set_live_state (node, version, what_changed, true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,20 @@ namespace sys {
|
||||||
class path;
|
class path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Change {
|
||||||
|
range_guarantee = ~0
|
||||||
|
};
|
||||||
|
|
||||||
|
Change new_change ();
|
||||||
|
|
||||||
/** Base (non template) part of State */
|
/** Base (non template) part of State */
|
||||||
class StateBase
|
class StateBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StateBase (std::string const & p)
|
StateBase (std::string const & p, Change c)
|
||||||
: _have_old (false)
|
: _have_old (false)
|
||||||
, _xml_property_name (p)
|
, _xml_property_name (p)
|
||||||
|
, _change (c)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -47,6 +54,7 @@ public:
|
||||||
StateBase (StateBase const & s)
|
StateBase (StateBase const & s)
|
||||||
: _have_old (s._have_old)
|
: _have_old (s._have_old)
|
||||||
, _xml_property_name (s._xml_property_name)
|
, _xml_property_name (s._xml_property_name)
|
||||||
|
, _change (s._change)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -57,10 +65,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void diff (XMLNode *, XMLNode *) const = 0;
|
virtual void diff (XMLNode *, XMLNode *) const = 0;
|
||||||
|
virtual Change set_state (XMLNode const &) = 0;
|
||||||
|
virtual void add_state (XMLNode &) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _have_old;
|
bool _have_old;
|
||||||
std::string _xml_property_name;
|
std::string _xml_property_name;
|
||||||
|
Change _change;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Class to represent a single piece of state in a Stateful object */
|
/** Class to represent a single piece of state in a Stateful object */
|
||||||
|
|
@ -68,8 +79,8 @@ template <class T>
|
||||||
class State : public StateBase
|
class State : public StateBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
State (std::string const & p, T const & v)
|
State (std::string const & p, Change c, T const & v)
|
||||||
: StateBase (p)
|
: StateBase (p, c)
|
||||||
, _current (v)
|
, _current (v)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -86,6 +97,7 @@ public:
|
||||||
/* XXX: isn't there a nicer place to do this? */
|
/* XXX: isn't there a nicer place to do this? */
|
||||||
_have_old = s._have_old;
|
_have_old = s._have_old;
|
||||||
_xml_property_name = s._xml_property_name;
|
_xml_property_name = s._xml_property_name;
|
||||||
|
_change = s._change;
|
||||||
|
|
||||||
_current = s._current;
|
_current = s._current;
|
||||||
_old = s._old;
|
_old = s._old;
|
||||||
|
|
@ -112,21 +124,50 @@ public:
|
||||||
|
|
||||||
void diff (XMLNode* old, XMLNode* current) const {
|
void diff (XMLNode* old, XMLNode* current) const {
|
||||||
if (_have_old) {
|
if (_have_old) {
|
||||||
std::stringstream o;
|
old->add_property (_xml_property_name.c_str(), to_string (_old));
|
||||||
o << _old;
|
current->add_property (_xml_property_name.c_str(), to_string (_current));
|
||||||
old->add_property (_xml_property_name.c_str(), o.str().c_str());
|
|
||||||
std::stringstream c;
|
|
||||||
c << _current;
|
|
||||||
current->add_property (_xml_property_name.c_str(), c.str().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Try to set state from the property of an XML node.
|
||||||
|
* @param node XML node.
|
||||||
|
* @return Change effected, or 0.
|
||||||
|
*/
|
||||||
|
Change set_state (XMLNode const & node) {
|
||||||
|
XMLProperty const * p = node.property (_xml_property_name.c_str());
|
||||||
|
|
||||||
|
if (p) {
|
||||||
|
std::stringstream s (p->value ());
|
||||||
|
T v;
|
||||||
|
s >> v;
|
||||||
|
|
||||||
|
if (v == _current) {
|
||||||
|
return Change (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
set (v);
|
||||||
|
return _change;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Change (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_state (XMLNode & node) const {
|
||||||
|
node.add_property (_xml_property_name.c_str(), to_string (_current));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set (T const & v) {
|
void set (T const & v) {
|
||||||
_old = _current;
|
_old = _current;
|
||||||
_have_old = true;
|
_have_old = true;
|
||||||
_current = v;
|
_current = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string to_string (T const & v) const {
|
||||||
|
std::stringstream s;
|
||||||
|
s << v;
|
||||||
|
return s.str ();
|
||||||
|
}
|
||||||
|
|
||||||
T _current;
|
T _current;
|
||||||
T _old;
|
T _old;
|
||||||
|
|
@ -163,6 +204,8 @@ class Stateful {
|
||||||
|
|
||||||
void add_instant_xml (XMLNode&, const sys::path& directory_path);
|
void add_instant_xml (XMLNode&, const sys::path& directory_path);
|
||||||
XMLNode *instant_xml (const std::string& str, const sys::path& directory_path);
|
XMLNode *instant_xml (const std::string& str, const sys::path& directory_path);
|
||||||
|
Change set_state_using_states (XMLNode const &);
|
||||||
|
void add_states (XMLNode &);
|
||||||
|
|
||||||
XMLNode *_extra_xml;
|
XMLNode *_extra_xml;
|
||||||
XMLNode *_instant_xml;
|
XMLNode *_instant_xml;
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,27 @@ namespace PBD {
|
||||||
int Stateful::current_state_version = 0;
|
int Stateful::current_state_version = 0;
|
||||||
int Stateful::loading_state_version = 0;
|
int Stateful::loading_state_version = 0;
|
||||||
|
|
||||||
|
PBD::Change
|
||||||
|
new_change ()
|
||||||
|
{
|
||||||
|
Change c;
|
||||||
|
static uint32_t change_bit = 1;
|
||||||
|
|
||||||
|
/* catch out-of-range */
|
||||||
|
if (!change_bit)
|
||||||
|
{
|
||||||
|
fatal << _("programming error: ")
|
||||||
|
<< "change_bit out of range in ARDOUR::new_change()"
|
||||||
|
<< endmsg;
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
||||||
|
c = Change (change_bit);
|
||||||
|
change_bit <<= 1; // if it shifts too far, change_bit == 0
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
Stateful::Stateful ()
|
Stateful::Stateful ()
|
||||||
{
|
{
|
||||||
_extra_xml = 0;
|
_extra_xml = 0;
|
||||||
|
|
@ -175,5 +196,32 @@ Stateful::diff ()
|
||||||
|
|
||||||
return make_pair (old, current);
|
return make_pair (old, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set state of _states from an XML node.
|
||||||
|
* @param node Node.
|
||||||
|
* @return Changes made.
|
||||||
|
*/
|
||||||
|
Change
|
||||||
|
Stateful::set_state_using_states (XMLNode const & node)
|
||||||
|
{
|
||||||
|
Change c = Change (0);
|
||||||
|
|
||||||
|
for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
|
||||||
|
c = Change (c | (*i)->set_state (node));
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add state of _states to an XML node.
|
||||||
|
* @param node Node.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Stateful::add_states (XMLNode & node)
|
||||||
|
{
|
||||||
|
for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
|
||||||
|
(*i)->add_state (node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace PBD
|
} // namespace PBD
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue