Strip trailing whitespace and fix other whitespace errors (e.g. space/tab mixing...
[ardour.git] / libs / ardour / ardour / automation_list.h
1 /*
2     Copyright (C) 2002 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_automation_event_h__
21 #define __ardour_automation_event_h__
22
23 #include <stdint.h>
24 #include <list>
25 #include <cmath>
26
27 #include <sigc++/signal.h>
28 #include <glibmm/thread.h>
29
30 #include "pbd/undo.h"
31 #include "pbd/xml++.h"
32 #include "pbd/statefuldestructible.h"
33
34 #include "ardour/ardour.h"
35
36 #include "evoral/ControlList.hpp"
37
38 namespace ARDOUR {
39
40 class AutomationList : public PBD::StatefulDestructible, public Evoral::ControlList
41 {
42   public:
43         AutomationList (Evoral::Parameter id);
44         AutomationList (const XMLNode&, Evoral::Parameter id);
45         AutomationList (const AutomationList&);
46         AutomationList (const AutomationList&, double start, double end);
47         ~AutomationList();
48
49         virtual boost::shared_ptr<Evoral::ControlList> create(Evoral::Parameter id);
50
51         AutomationList& operator= (const AutomationList&);
52         bool operator== (const AutomationList&);
53
54         void freeze();
55         void thaw ();
56         void mark_dirty () const;
57
58         void set_automation_state (AutoState);
59         AutoState automation_state() const { return _state; }
60         sigc::signal<void> automation_state_changed;
61
62         void set_automation_style (AutoStyle m);
63         AutoStyle automation_style() const { return _style; }
64         sigc::signal<void> automation_style_changed;
65
66         bool automation_playback() const {
67                 return (_state & Play) || ((_state & Touch) && !_touching);
68         }
69         bool automation_write () const {
70                 return (_state & Write) || ((_state & Touch) && _touching);
71         }
72
73         sigc::signal<void> StateChanged;
74
75         static sigc::signal<void, AutomationList*> AutomationListCreated;
76         mutable sigc::signal<void> Dirty;
77
78         void start_touch ();
79         void stop_touch ();
80         bool touching() const { return _touching; }
81
82         XMLNode& get_state(void);
83         int set_state (const XMLNode &s);
84         XMLNode& state (bool full);
85         XMLNode& serialize_events ();
86
87   private:
88         void create_curve_if_necessary ();
89         int deserialize_events (const XMLNode&);
90
91         void maybe_signal_changed ();
92
93         AutoState _state;
94         AutoStyle _style;
95         bool      _touching;
96 };
97
98 } // namespace
99
100 #endif /* __ardour_automation_event_h__ */