Fix broken whitespace. I'd apologize for the compile times if it was my fault :D
[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 <glibmm/thread.h>
28
29 #include "pbd/undo.h"
30 #include "pbd/xml++.h"
31 #include "pbd/statefuldestructible.h"
32
33 #include "ardour/ardour.h"
34
35 #include "evoral/ControlList.hpp"
36
37 namespace ARDOUR {
38
39 class AutomationList : public PBD::StatefulDestructible, public Evoral::ControlList
40 {
41   public:
42         AutomationList (Evoral::Parameter id);
43         AutomationList (const XMLNode&, Evoral::Parameter id);
44         AutomationList (const AutomationList&);
45         AutomationList (const AutomationList&, double start, double end);
46         ~AutomationList();
47
48         virtual boost::shared_ptr<Evoral::ControlList> create(Evoral::Parameter id);
49
50         AutomationList& operator= (const AutomationList&);
51         bool operator== (const AutomationList&);
52
53         void thaw ();
54
55         void set_automation_state (AutoState);
56         AutoState automation_state() const { return _state; }
57         PBD::Signal1<void, AutoState> automation_state_changed;
58
59         void set_automation_style (AutoStyle m);
60         AutoStyle automation_style() const { return _style; }
61         PBD::Signal0<void> automation_style_changed;
62
63         bool automation_playback() const {
64                 return (_state & Play) || ((_state & Touch) && !touching());
65         }
66         bool automation_write () const {
67                 return ((_state & Write) || ((_state & Touch) && touching()));
68         }
69
70         PBD::Signal0<void> StateChanged;
71
72         static PBD::Signal1<void,AutomationList*> AutomationListCreated;
73
74         void start_touch (double when);
75         void stop_touch (bool mark, double when);
76         bool touching() const { return g_atomic_int_get (&_touching); }
77         bool writing() const { return _state == Write; }
78         bool touch_enabled() const { return _state == Touch; }
79
80         XMLNode& get_state ();
81         int set_state (const XMLNode &, int version);
82         XMLNode& state (bool full);
83         XMLNode& serialize_events ();
84
85   private:
86         void create_curve_if_necessary ();
87         int deserialize_events (const XMLNode&);
88
89         void maybe_signal_changed ();
90
91         AutoState    _state;
92         AutoStyle    _style;
93         gint         _touching;
94 };
95
96 } // namespace
97
98 #endif /* __ardour_automation_event_h__ */