diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-02-08 19:39:17 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-02-08 19:39:17 +0000 |
commit | e2baff4f7d00c97dc4192c5ac573aeee8950b2ae (patch) | |
tree | d099f62d821f86980b062d2fc93aa6e8c9203ba2 /libs/ardour/ardour | |
parent | 1afb1cfea4f2ea66962faef01d729014bdc9eb56 (diff) |
new RegionCommand object; remove unused string argument from Region::thaw(); add map<ID,Region> in RegionFactory so that we can look up regions by ID
git-svn-id: svn://localhost/ardour2/branches/3.0@6652 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/region.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/region_command.h | 104 | ||||
-rw-r--r-- | libs/ardour/ardour/region_factory.h | 12 |
3 files changed, 117 insertions, 1 deletions
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 4cae00c532..310bd582cd 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -162,7 +162,7 @@ class Region void recompute_position_from_lock_style (); void freeze (); - void thaw (const std::string& why); + void thaw (); bool covers (nframes_t frame) const { return first_frame() <= frame && frame <= last_frame(); diff --git a/libs/ardour/ardour/region_command.h b/libs/ardour/ardour/region_command.h new file mode 100644 index 0000000000..07589b70c7 --- /dev/null +++ b/libs/ardour/ardour/region_command.h @@ -0,0 +1,104 @@ +#ifndef __libardour_region_command_h__ +#define __libardour_region_command_h__ + +#include <sstream> +#include <string> +#include <vector> + +#include "pbd/command.h" + +namespace ARDOUR { + +class Region; + +class RegionCommand : public Command { + public: + enum Property { + Name, + PositionLockStyle, + Length, + Start, + Position, + PositionOnTop, + Layer, + SyncPosition, + Hidden, + Muted, + Opaque, + Locked, + PositionLocked, + + /* audio */ + ScaleAmplitude, + FadeInActive, + FadeInShape, + FadeInLength, + FadeIn, + FadeOutActive, + FadeOutShape, + FadeOutLength, + FadeOut, + EnvelopActive, + DefaultEnvelope + }; + + RegionCommand (boost::shared_ptr<Region>); + RegionCommand (boost::shared_ptr<Region>, const XMLNode&); + RegionCommand (boost::shared_ptr<Region>, Property, const std::string& target_value); + + + /* this is mildly type-unsafe, in that we could pass in the wrong types for before&after + given the value of `property'. however, its just as safe as a variant that accepts + strings, and makes this whole class much easier to use. + */ + + template<typename T> void add_property_change (Property property, const T& before, const T& after) { + std::stringstream sb, sa; + + /* in case T is a floating point value ... + */ + + sb.precision (15); + sa.precision (15); + + /* format */ + + sb << before; + sa << after; + + /* and stash it away */ + + _add_property_change (property, sb.str(), sa.str()); + } + + void set_name (const std::string& str) { _name = str; } + const std::string& name() const { return _name; } + + void operator() (); + void undo(); + void redo() { (*this)(); } + + XMLNode &get_state(); + int set_state (const XMLNode&, int /*version*/); + + private: + struct PropertyTriple { + Property property; + std::string before; + std::string after; + + PropertyTriple (Property p, const std::string& b, const std::string& a) + : property (p), before (b), after (a) {} + }; + + boost::shared_ptr<Region> region; + typedef std::vector<PropertyTriple> PropertyTriples; + PropertyTriples property_changes; + + void do_property_change (Property prop, const std::string& value); + void _add_property_change (Property, const std::string& before_value, const std::string& after_value); +}; + +} + +#endif /* __libardour_region_command_h__ */ diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h index b53e9490de..64d3417287 100644 --- a/libs/ardour/ardour/region_factory.h +++ b/libs/ardour/ardour/region_factory.h @@ -20,6 +20,10 @@ #ifndef __ardour_region_factory_h__ #define __ardour_region_factory_h__ +#include <map> + +#include "pbd/id.h" + #include "ardour/types.h" #include "ardour/region.h" @@ -33,6 +37,10 @@ class AudioRegion; class RegionFactory { public: + + static boost::shared_ptr<Region> region_by_id (const PBD::ID&); + static void clear_map (); + /** This is emitted only when a new id is assigned. Therefore, in a pure Region copy, it will not be emitted. @@ -59,6 +67,10 @@ class RegionFactory { static boost::shared_ptr<Region> create (const SourceList &, nframes_t start, nframes_t length, const std::string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true); static boost::shared_ptr<Region> create (Session&, XMLNode&, bool); static boost::shared_ptr<Region> create (SourceList &, const XMLNode&); + + private: + static std::map<PBD::ID,boost::weak_ptr<Region> > region_map; + static void map_add (boost::shared_ptr<Region>); }; } |