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