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