2 Copyright (C) 2000-2007 Paul Davis
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.
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.
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.
20 #ifndef __ardour_gtk_automation_time_axis_h__
21 #define __ardour_gtk_automation_time_axis_h__
27 #include <boost/shared_ptr.hpp>
29 #include "ardour/types.h"
30 #include "ardour/automatable.h"
31 #include "ardour/automation_list.h"
33 #include "canvas/rectangle.h"
35 #include "time_axis_view.h"
36 #include "automation_controller.h"
37 #include "ardour_button.h"
42 class AutomationControl;
47 class RegionSelection;
52 class AutomationStreamView;
53 class AutomationController;
56 class AutomationTimeAxisView : public TimeAxisView {
58 AutomationTimeAxisView (ARDOUR::Session*,
59 boost::shared_ptr<ARDOUR::Route>,
60 boost::shared_ptr<ARDOUR::Automatable>,
61 boost::shared_ptr<ARDOUR::AutomationControl>,
66 ArdourCanvas::Canvas& canvas,
67 const std::string & name, /* translatable */
68 const std::string & plug_name = "");
70 ~AutomationTimeAxisView();
72 virtual void set_height (uint32_t, TrackHeightMode m = OnlySelf);
73 void set_samples_per_pixel (double);
74 std::string name() const { return _name; }
76 void add_automation_event (GdkEvent *, framepos_t, double, bool with_guard_points);
80 /** @return Our AutomationLine, if this view has one, or 0 if it uses AutomationRegionViews */
81 boost::shared_ptr<AutomationLine> line() { return _line; }
83 /** @return All AutomationLines associated with this view */
84 std::list<boost::shared_ptr<AutomationLine> > lines () const;
86 void set_selected_points (PointSelection&);
87 void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, double top, double bot, std::list<Selectable *>&, bool within = false);
88 void get_inverted_selectables (Selection&, std::list<Selectable*>& results);
90 void show_timestretch (framepos_t /*start*/, framepos_t /*end*/, int /*layers*/, int /*layer*/) {}
91 void hide_timestretch () {}
93 /* editing operations */
95 void cut_copy_clear (Selection&, Editing::CutCopyOp);
96 bool paste (ARDOUR::framepos_t, const Selection&, PasteContext&);
98 int set_state (const XMLNode&, int version);
100 std::string state_id() const;
101 static bool parse_state_id (std::string const &, PBD::ID &, bool &, Evoral::Parameter &);
103 boost::shared_ptr<ARDOUR::AutomationControl> control() { return _control; }
104 boost::shared_ptr<AutomationController> controller() { return _controller; }
105 Evoral::Parameter parameter () const {
109 ArdourCanvas::Item* base_item () const {
113 bool has_automation () const;
115 boost::shared_ptr<ARDOUR::Route> parent_route () {
119 bool show_regions () const {
120 return _show_regions;
123 static void what_has_visible_automation (const boost::shared_ptr<ARDOUR::Automatable>& automatable, std::set<Evoral::Parameter>& visible);
126 /* Note that for MIDI controller "automation" (in regions), all of these
127 may be set. In this case, _automatable is likely _route so the
128 controller will send immediate events out the route's MIDI port. */
131 boost::shared_ptr<ARDOUR::Route> _route;
133 boost::shared_ptr<ARDOUR::AutomationControl> _control;
134 /** control owner; may be _route, something else (e.g. a pan control), or NULL */
135 boost::shared_ptr<ARDOUR::Automatable> _automatable;
136 /** controller owner */
137 boost::shared_ptr<AutomationController> _controller;
138 Evoral::Parameter _parameter;
140 ArdourCanvas::Rectangle* _base_rect;
141 boost::shared_ptr<AutomationLine> _line;
145 /** AutomationStreamView if we are editing region-based automation (for MIDI), otherwise 0 */
146 AutomationStreamView* _view;
149 bool first_call_to_set_height;
151 ArdourButton hide_button;
152 ArdourButton auto_button;
153 Gtk::Menu* automation_menu;
154 Gtk::Label* plugname;
155 bool plugname_packed;
157 Gtk::CheckMenuItem* auto_off_item;
158 Gtk::CheckMenuItem* auto_play_item;
159 Gtk::CheckMenuItem* auto_touch_item;
160 Gtk::CheckMenuItem* auto_write_item;
162 Gtk::CheckMenuItem* mode_discrete_item;
163 Gtk::CheckMenuItem* mode_line_item;
167 void add_line (boost::shared_ptr<AutomationLine>);
169 void clear_clicked ();
170 void hide_clicked ();
171 void auto_clicked ();
173 virtual bool can_edit_name() const {return false;}
175 void build_display_menu ();
177 void cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
178 bool paste_one (ARDOUR::framepos_t, unsigned, float times, const Selection&, ItemCounts& counts, bool greedy=false);
179 void route_going_away ();
181 void set_automation_state (ARDOUR::AutoState);
182 bool ignore_state_request;
184 void automation_state_changed ();
186 void set_interpolation (ARDOUR::AutomationList::InterpolationStyle);
187 void interpolation_changed (ARDOUR::AutomationList::InterpolationStyle);
189 PBD::ScopedConnectionList _list_connections;
190 PBD::ScopedConnectionList _route_connections;
195 //void set_colors ();
196 void color_handler ();
198 static Pango::FontDescription name_font;
199 static bool have_name_font;
202 int set_state_2X (const XMLNode &, int);
205 #endif /* __ardour_gtk_automation_time_axis_h__ */