7122350dee6007bbd2e476aa5b31376250811904
[ardour.git] / gtk2_ardour / automation_time_axis.h
1 /*
2     Copyright (C) 2000-2007 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_gtk_automation_time_axis_h__
21 #define __ardour_gtk_automation_time_axis_h__
22
23 #include <list>
24 #include <string>
25 #include <utility>
26
27 #include <boost/shared_ptr.hpp>
28
29 #include "ardour/types.h"
30 #include "ardour/automatable.h"
31 #include "ardour/automation_list.h"
32
33 #include "canvas.h"
34 #include "time_axis_view.h"
35 #include "simplerect.h"
36 #include "automation_controller.h"
37 #include "shared_ptrs.h"
38
39 namespace ARDOUR {
40         class Session;
41         class Route;
42         class AutomationControl;
43 }
44
45 class PublicEditor;
46 class TimeSelection;
47 class RegionSelection;
48 class PointSelection;
49 class AutomationLine;
50 class Selection;
51 class Selectable;
52 class AutomationStreamView;
53 class AutomationController;
54
55
56 class AutomationTimeAxisView : public TimeAxisView {
57   public:
58         
59         static AutomationTimeAxisViewPtr
60         create (ARDOUR::Session&,
61                 boost::shared_ptr<ARDOUR::Route>,
62                 boost::shared_ptr<ARDOUR::Automatable>,
63                 boost::shared_ptr<ARDOUR::AutomationControl>,
64                 PublicEditor&,
65                 TimeAxisViewPtr parent,
66                 bool show_regions,
67                 ArdourCanvas::Canvas& canvas,
68                 const std::string & name, /* translatable */
69                 const std::string & plug_name = "");
70
71         ~AutomationTimeAxisView();
72         
73         virtual void set_height (uint32_t);
74         void set_samples_per_unit (double);
75         std::string name() const { return _name; }
76
77         void add_automation_event (ArdourCanvas::Item *item, GdkEvent *event, nframes_t, double);
78
79         void clear_lines ();
80         boost::shared_ptr<AutomationLine> line() { return _line; }
81
82         void set_selected_points (PointSelection&);
83         void get_selectables (nframes_t start, nframes_t end, double top, double bot, std::list<Selectable *>&);
84         void get_inverted_selectables (Selection&, std::list<Selectable*>& results);
85
86         void show_timestretch (nframes_t start, nframes_t end) {}
87         void hide_timestretch () {}
88
89         /* editing operations */
90         
91         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
92         bool cut_copy_clear_objects (PointSelection&, Editing::CutCopyOp);
93         bool paste (nframes_t, float times, Selection&, size_t nth);
94         void reset_objects (PointSelection&);
95
96         int  set_state (const XMLNode&);
97         
98         guint32 show_at (double y, int& nth, Gtk::VBox *parent);
99         void hide ();
100         
101         static const std::string state_node_name;
102         XMLNode* get_state_node();
103         
104         boost::shared_ptr<ARDOUR::AutomationControl> control()    { return _control; }
105         boost::shared_ptr<AutomationController>      controller() { return _controller; }
106
107   protected:
108         boost::shared_ptr<ARDOUR::Route> _route; ///< Parent route
109         boost::shared_ptr<ARDOUR::AutomationControl> _control; ///< Control
110         boost::shared_ptr<ARDOUR::Automatable> _automatable; ///< Control owner, maybe = _route
111         
112         boost::shared_ptr<AutomationController> _controller;
113         
114         ArdourCanvas::SimpleRect* _base_rect;
115         boost::shared_ptr<AutomationLine> _line;
116         AutomationStreamView*             _view;
117         
118         std::string _name;
119         bool    ignore_toggle;
120
121         bool    first_call_to_set_height;
122
123         Gtk::Button        hide_button;
124         Gtk::Button        auto_button; 
125         Gtk::Menu*         automation_menu;
126         Gtk::Label*        plugname;
127         bool               plugname_packed;
128
129         Gtk::CheckMenuItem*     auto_off_item;
130         Gtk::CheckMenuItem*     auto_play_item;
131         Gtk::CheckMenuItem*     auto_touch_item;
132         Gtk::CheckMenuItem*     auto_write_item;
133
134         Gtk::CheckMenuItem* mode_discrete_item;
135         Gtk::CheckMenuItem* mode_line_item;
136
137         void add_line (boost::shared_ptr<AutomationLine>);
138         
139         void clear_clicked ();
140         void hide_clicked ();
141         void auto_clicked ();
142
143         void build_display_menu ();
144
145         bool cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
146         bool cut_copy_clear_objects_one (AutomationLine&, PointSelection&, Editing::CutCopyOp);
147         bool paste_one (AutomationLine&, nframes_t, float times, Selection&, size_t nth);
148         void reset_objects_one (AutomationLine&, PointSelection&);
149
150         void set_automation_state (ARDOUR::AutoState);
151         bool ignore_state_request;
152
153         void automation_state_changed ();
154
155         void set_interpolation (ARDOUR::AutomationList::InterpolationStyle);
156         void interpolation_changed ();
157
158         sigc::connection automation_connection;
159
160         void update_extra_xml_shown (bool editor_shown);
161
162         void entered ();
163         void exited ();
164
165         //void set_colors ();
166         void color_handler ();
167
168         static Pango::FontDescription* name_font;
169         static bool have_name_font;
170
171 private:
172
173         AutomationTimeAxisView (ARDOUR::Session&,
174                                 boost::shared_ptr<ARDOUR::Route>,
175                                 boost::shared_ptr<ARDOUR::Automatable>,
176                                 boost::shared_ptr<ARDOUR::AutomationControl>,
177                                 PublicEditor&,
178                                 TimeAxisViewPtr parent,
179                                 bool show_regions,
180                                 ArdourCanvas::Canvas& canvas,
181                                 const std::string & name, /* translatable */
182                                 const std::string & plug_name = "");
183
184         void 
185         init                   (ARDOUR::Session&,
186                                 boost::shared_ptr<ARDOUR::Route>,
187                                 boost::shared_ptr<ARDOUR::Automatable>,
188                                 boost::shared_ptr<ARDOUR::AutomationControl>,
189                                 PublicEditor&,
190                                 TimeAxisViewPtr parent,
191                                 bool show_regions,
192                                 ArdourCanvas::Canvas& canvas,
193                                 const std::string & name, /* translatable */
194                                 const std::string & plug_name);
195         
196 };
197
198 #endif /* __ardour_gtk_automation_time_axis_h__ */