NO-OP whitespace & foratting of header files
[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/rectangle.h"
34
35 #include "time_axis_view.h"
36 #include "automation_controller.h"
37 #include "ardour_button.h"
38 #include "ardour_dropdown.h"
39
40 namespace ARDOUR {
41         class Session;
42         class Stripable;
43         class AutomationControl;
44 }
45
46 class PublicEditor;
47 class TimeSelection;
48 class RegionSelection;
49 class PointSelection;
50 class AutomationLine;
51 class Selection;
52 class Selectable;
53 class AutomationStreamView;
54 class AutomationController;
55 class ItemCounts;
56
57 class AutomationTimeAxisView : public TimeAxisView
58 {
59 public:
60         AutomationTimeAxisView (ARDOUR::Session*,
61                                 boost::shared_ptr<ARDOUR::Stripable>,
62                                 boost::shared_ptr<ARDOUR::Automatable>,
63                                 boost::shared_ptr<ARDOUR::AutomationControl>,
64                                 Evoral::Parameter,
65                                 PublicEditor&,
66                                 TimeAxisView& parent,
67                                 bool show_regions,
68                                 ArdourCanvas::Canvas& canvas,
69                                 const std::string & name, /* translatable */
70                                 const std::string & plug_name = "");
71
72         ~AutomationTimeAxisView();
73
74         virtual void set_height (uint32_t, TrackHeightMode m = OnlySelf);
75         void set_samples_per_pixel (double);
76         std::string name() const { return _name; }
77         Gdk::Color color () const;
78
79         boost::shared_ptr<ARDOUR::Stripable> stripable() const;
80         ARDOUR::PresentationInfo const & presentation_info () const;
81
82         void add_automation_event (GdkEvent *, framepos_t, double, bool with_guard_points);
83
84         void clear_lines ();
85
86         /** @return Our AutomationLine, if this view has one, or 0 if it uses AutomationRegionViews */
87         boost::shared_ptr<AutomationLine> line() { return _line; }
88
89         /** @return All AutomationLines associated with this view */
90         std::list<boost::shared_ptr<AutomationLine> > lines () const;
91
92         void set_selected_points (PointSelection&);
93         void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, double top, double bot, std::list<Selectable *>&, bool within = false);
94         void get_inverted_selectables (Selection&, std::list<Selectable*>& results);
95
96         void show_timestretch (framepos_t /*start*/, framepos_t /*end*/, int /*layers*/, int /*layer*/) {}
97         void hide_timestretch () {}
98
99         /* editing operations */
100
101         void cut_copy_clear (Selection&, Editing::CutCopyOp);
102         bool paste (ARDOUR::framepos_t, const Selection&, PasteContext&, const int32_t sub_num);
103
104         int  set_state (const XMLNode&, int version);
105
106         std::string state_id() const;
107         static bool parse_state_id (std::string const &, PBD::ID &, bool &, Evoral::Parameter &);
108
109         boost::shared_ptr<ARDOUR::AutomationControl> control() const   { return _control; }
110         boost::shared_ptr<AutomationController>      controller() const { return _controller; }
111         Evoral::Parameter parameter () const {
112                 return _parameter;
113         }
114
115         ArdourCanvas::Item* base_item () const {
116                 return _base_rect;
117         }
118
119         bool has_automation () const;
120
121         boost::shared_ptr<ARDOUR::Stripable> parent_stripable () {
122                 return _stripable;
123         }
124
125         bool show_regions () const {
126                 return _show_regions;
127         }
128
129         static void what_has_visible_automation (const boost::shared_ptr<ARDOUR::Automatable>& automatable, std::set<Evoral::Parameter>& visible);
130
131 protected:
132         /* Note that for MIDI controller "automation" (in regions), all of these
133          * may be set.  In this case, _automatable is likely _route so the
134          * controller will send immediate events out the route's MIDI port. */
135
136         /** parent strip */
137         boost::shared_ptr<ARDOUR::Stripable> _stripable;
138         /** control */
139         boost::shared_ptr<ARDOUR::AutomationControl> _control;
140         /** control owner; may be _stripable, something else (e.g. a pan control), or NULL */
141         boost::shared_ptr<ARDOUR::Automatable> _automatable;
142         /** controller owner */
143         boost::shared_ptr<AutomationController> _controller;
144         Evoral::Parameter _parameter;
145
146         ArdourCanvas::Rectangle* _base_rect;
147         boost::shared_ptr<AutomationLine> _line;
148
149         std::string _name;
150
151         /** AutomationStreamView if we are editing region-based automation (for MIDI), otherwise 0 */
152         AutomationStreamView* _view;
153
154         bool    ignore_toggle;
155         bool    first_call_to_set_height;
156
157         ArdourButton       hide_button;
158         ArdourDropdown     auto_dropdown;
159         Gtk::Label*        plugname;
160         bool               plugname_packed;
161
162         Gtk::CheckMenuItem*     auto_off_item;
163         Gtk::CheckMenuItem*     auto_play_item;
164         Gtk::CheckMenuItem*     auto_touch_item;
165         Gtk::CheckMenuItem*     auto_write_item;
166
167         Gtk::CheckMenuItem* mode_discrete_item;
168         Gtk::CheckMenuItem* mode_line_item;
169         Gtk::CheckMenuItem* mode_log_item;
170         Gtk::CheckMenuItem* mode_exp_item;
171
172         bool _show_regions;
173
174         void add_line (boost::shared_ptr<AutomationLine>);
175
176         void clear_clicked ();
177         void hide_clicked ();
178
179         virtual bool can_edit_name() const {return false;}
180
181         void build_display_menu ();
182
183         void cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
184         bool paste_one (ARDOUR::framepos_t, unsigned, float times, const Selection&, ItemCounts& counts, bool greedy=false);
185         void route_going_away ();
186
187         void set_automation_state (ARDOUR::AutoState);
188         bool ignore_state_request;
189         bool ignore_mode_request;
190
191         void automation_state_changed ();
192
193         void set_interpolation (ARDOUR::AutomationList::InterpolationStyle);
194         void interpolation_changed (ARDOUR::AutomationList::InterpolationStyle);
195
196         PBD::ScopedConnectionList _list_connections;
197         PBD::ScopedConnectionList _stripable_connections;
198
199         void entered ();
200         void exited ();
201
202         //void set_colors ();
203         void color_handler ();
204
205         static Pango::FontDescription name_font;
206         static bool have_name_font;
207
208 private:
209         int set_state_2X (const XMLNode &, int);
210 };
211
212 #endif /* __ardour_gtk_automation_time_axis_h__ */