diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/movable.h | 15 | ||||
-rw-r--r-- | libs/ardour/ardour/region.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/trimmable.h | 36 | ||||
-rw-r--r-- | libs/ardour/region.cc | 28 | ||||
-rw-r--r-- | libs/pbd/enumwriter.cc | 51 | ||||
-rw-r--r-- | libs/pbd/pbd/enumwriter.h | 3 |
6 files changed, 133 insertions, 6 deletions
diff --git a/libs/ardour/ardour/movable.h b/libs/ardour/ardour/movable.h new file mode 100644 index 0000000000..26b6125888 --- /dev/null +++ b/libs/ardour/ardour/movable.h @@ -0,0 +1,15 @@ +#ifndef __libardour_movable_h__ +#define __libardour_movable_h__ + +namespace ARDOUR { + +class Movable { + public: + Movable() {} + + bool locked () const { return false; } +}; + +} + +#endif /* __libardour_movable_h__ */ diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index 0ae325d124..ef86dce4b2 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -31,8 +31,10 @@ #include "ardour/ardour.h" #include "ardour/data_type.h" #include "ardour/automatable.h" +#include "ardour/movable.h" #include "ardour/readable.h" #include "ardour/session_object.h" +#include "ardour/trimmable.h" class XMLNode; @@ -81,6 +83,8 @@ class Region : public SessionObject , public boost::enable_shared_from_this<Region> , public Readable + , public Trimmable + , public Movable { public: typedef std::vector<boost::shared_ptr<Source> > SourceList; @@ -147,6 +151,8 @@ class Region bool sync_marked() const { return _sync_marked; } bool external() const { return _external; } bool import() const { return _import; } + + Trimmable::CanTrim can_trim() const; PositionLockStyle position_lock_style() const { return _position_lock_style; } void set_position_lock_style (PositionLockStyle ps); diff --git a/libs/ardour/ardour/trimmable.h b/libs/ardour/ardour/trimmable.h new file mode 100644 index 0000000000..e053a2deed --- /dev/null +++ b/libs/ardour/ardour/trimmable.h @@ -0,0 +1,36 @@ +#ifndef __libardour_trimmable_h__ +#define __libardour_trimmable_h__ + +namespace ARDOUR { + +class Trimmable { + public: + Trimmable() {} + virtual ~Trimmable() {} + + enum CanTrim { + FrontTrimEarlier, + FrontTrimLater, + EndTrimEarlier, + EndTrimLater, + TopTrimUp, + TopTrimDown, + BottomTrimUp, + BottomTrimDown + } ; + + virtual CanTrim can_trim() const { + return CanTrim (FrontTrimEarlier | + FrontTrimLater | + EndTrimEarlier | + EndTrimLater | + TopTrimUp | + TopTrimDown | + BottomTrimUp | + BottomTrimDown); + } +}; + +} + +#endif /* __libardour_trimmable_h__ */ diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 7e78475eb3..6d4be37b6d 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1587,3 +1587,31 @@ Region::use_sources (SourceList const & s) } } } + +Trimmable::CanTrim +Region::can_trim () const +{ + CanTrim ct = CanTrim (0); + + if (locked()) { + return ct; + } + + /* if not locked, we can always move the front later, and the end earlier + */ + + ct = CanTrim (ct | FrontTrimLater | EndTrimEarlier); + + if (start() != 0) { + ct = CanTrim (ct | FrontTrimEarlier); + } + + if (!_sources.empty()) { + if (last_frame() < _sources.front()->length (0)) { + ct = CanTrim (ct | EndTrimLater); + } + } + + return ct; +} + diff --git a/libs/pbd/enumwriter.cc b/libs/pbd/enumwriter.cc index 2c6e5c73c8..5263a886fb 100644 --- a/libs/pbd/enumwriter.cc +++ b/libs/pbd/enumwriter.cc @@ -182,6 +182,41 @@ EnumWriter::write_distinct (EnumRegistration& er, int value) } int +EnumWriter::validate (EnumRegistration& er, int val) +{ + if (er.values.empty()) { + return val; + } + + if (val == 0) { + /* zero is always a legal value for our enumerations, just about + */ + return val; + } + + vector<int>::iterator i; + string enum_name = _("unknown enumeration"); + + for (Registry::iterator x = registry.begin(); x != registry.end(); ++x) { + if (&er == &(*x).second) { + enum_name = (*x).first; + } + } + + + for (i = er.values.begin(); i != er.values.end(); ++i) { + if (*i == val) { + return val; + } + } + + warning << string_compose (_("Illegal value loaded for %1 (%2) - %3 used instead"), + enum_name, val, er.names.front()) + << endmsg; + return er.values.front(); +} + +int EnumWriter::read_bits (EnumRegistration& er, string str) { vector<int>::iterator i; @@ -193,14 +228,16 @@ EnumWriter::read_bits (EnumRegistration& er, string str) /* catch old-style hex numerics */ if (str.length() > 2 && str[0] == '0' && str[1] == 'x') { - return strtol (str.c_str(), (char **) 0, 16); + int val = strtol (str.c_str(), (char **) 0, 16); + return validate (er, val); } /* catch old style dec numerics */ if (strspn (str.c_str(), "0123456789") == str.length()) { - return strtol (str.c_str(), (char **) 0, 10); - } + int val = strtol (str.c_str(), (char **) 0, 10); + return validate (er, val); + } do { @@ -238,14 +275,16 @@ EnumWriter::read_distinct (EnumRegistration& er, string str) /* catch old-style hex numerics */ if (str.length() > 2 && str[0] == '0' && str[1] == 'x') { - return strtol (str.c_str(), (char **) 0, 16); + int val = strtol (str.c_str(), (char **) 0, 16); + return validate (er, val); } /* catch old style dec numerics */ if (strspn (str.c_str(), "0123456789") == str.length()) { - return strtol (str.c_str(), (char **) 0, 10); - } + int val = strtol (str.c_str(), (char **) 0, 10); + return validate (er, val); + } for (i = er.values.begin(), s = er.names.begin(); i != er.values.end(); ++i, ++s) { if (str == (*s) || nocase_cmp (str, *s) == 0) { diff --git a/libs/pbd/pbd/enumwriter.h b/libs/pbd/pbd/enumwriter.h index 461665d739..a253719c85 100644 --- a/libs/pbd/pbd/enumwriter.h +++ b/libs/pbd/pbd/enumwriter.h @@ -71,6 +71,9 @@ class EnumWriter { static EnumWriter* _instance; static std::map<std::string,std::string> hack_table; + + + int validate (EnumRegistration& er, int value); }; } |