1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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__ */
|