2 * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
4 * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
5 * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
6 * Copyright (C) 2006 Sampo Savolainen <v2@iki.fi>
7 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
8 * Copyright (C) 2014-2015 Ben Loftis <ben@harrisonconsoles.com>
9 * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #ifndef __ardour_gtk_automation_time_axis_h__
27 #define __ardour_gtk_automation_time_axis_h__
33 #include <boost/shared_ptr.hpp>
35 #include "ardour/types.h"
36 #include "ardour/automatable.h"
37 #include "ardour/automation_list.h"
39 #include "canvas/rectangle.h"
41 #include "widgets/ardour_button.h"
42 #include "widgets/ardour_dropdown.h"
44 #include "time_axis_view.h"
45 #include "automation_controller.h"
50 class AutomationControl;
55 class RegionSelection;
60 class AutomationStreamView;
61 class AutomationController;
64 class AutomationTimeAxisView : public TimeAxisView
67 AutomationTimeAxisView (ARDOUR::Session*,
68 boost::shared_ptr<ARDOUR::Stripable>,
69 boost::shared_ptr<ARDOUR::Automatable>,
70 boost::shared_ptr<ARDOUR::AutomationControl>,
75 ArdourCanvas::Canvas& canvas,
76 const std::string & name, /* translatable */
77 const std::string & plug_name = "");
79 ~AutomationTimeAxisView();
81 virtual void set_height (uint32_t, TrackHeightMode m = OnlySelf);
82 void set_samples_per_pixel (double);
83 std::string name() const { return _name; }
84 Gdk::Color color () const;
86 boost::shared_ptr<ARDOUR::Stripable> stripable() const;
87 ARDOUR::PresentationInfo const & presentation_info () const;
89 void add_automation_event (GdkEvent *, samplepos_t, double, bool with_guard_points);
93 /** @return Our AutomationLine, if this view has one, or 0 if it uses AutomationRegionViews */
94 boost::shared_ptr<AutomationLine> line() { return _line; }
96 /** @return All AutomationLines associated with this view */
97 std::list<boost::shared_ptr<AutomationLine> > lines () const;
99 void set_selected_points (PointSelection&);
100 void get_selectables (ARDOUR::samplepos_t start, ARDOUR::samplepos_t end, double top, double bot, std::list<Selectable *>&, bool within = false);
101 void get_inverted_selectables (Selection&, std::list<Selectable*>& results);
103 void show_timestretch (samplepos_t /*start*/, samplepos_t /*end*/, int /*layers*/, int /*layer*/) {}
104 void hide_timestretch () {}
106 /* editing operations */
108 void cut_copy_clear (Selection&, Editing::CutCopyOp);
109 bool paste (ARDOUR::samplepos_t, const Selection&, PasteContext&, const int32_t sub_num);
111 int set_state (const XMLNode&, int version);
113 std::string state_id() const;
114 static bool parse_state_id (std::string const &, PBD::ID &, bool &, Evoral::Parameter &);
116 boost::shared_ptr<ARDOUR::AutomationControl> control() const { return _control; }
117 boost::shared_ptr<AutomationController> controller() const { return _controller; }
118 Evoral::Parameter parameter () const {
122 ArdourCanvas::Item* base_item () const {
126 bool has_automation () const;
128 boost::shared_ptr<ARDOUR::Stripable> parent_stripable () {
132 bool show_regions () const {
133 return _show_regions;
136 static void what_has_visible_automation (const boost::shared_ptr<ARDOUR::Automatable>& automatable, std::set<Evoral::Parameter>& visible);
139 /* Note that for MIDI controller "automation" (in regions), all of these
140 * may be set. In this case, _automatable is likely _route so the
141 * controller will send immediate events out the route's MIDI port. */
144 boost::shared_ptr<ARDOUR::Stripable> _stripable;
146 boost::shared_ptr<ARDOUR::AutomationControl> _control;
147 /** control owner; may be _stripable, something else (e.g. a pan control), or NULL */
148 boost::shared_ptr<ARDOUR::Automatable> _automatable;
149 /** controller owner */
150 boost::shared_ptr<AutomationController> _controller;
151 Evoral::Parameter _parameter;
153 ArdourCanvas::Rectangle* _base_rect;
154 boost::shared_ptr<AutomationLine> _line;
158 /** AutomationStreamView if we are editing region-based automation (for MIDI), otherwise 0 */
159 AutomationStreamView* _view;
162 bool first_call_to_set_height;
164 ArdourWidgets::ArdourButton hide_button;
165 ArdourWidgets::ArdourDropdown auto_dropdown;
166 Gtk::Label* plugname;
167 bool plugname_packed;
169 Gtk::CheckMenuItem* auto_off_item;
170 Gtk::CheckMenuItem* auto_play_item;
171 Gtk::CheckMenuItem* auto_touch_item;
172 Gtk::CheckMenuItem* auto_write_item;
173 Gtk::CheckMenuItem* auto_latch_item;
175 Gtk::CheckMenuItem* mode_discrete_item;
176 Gtk::CheckMenuItem* mode_line_item;
177 Gtk::CheckMenuItem* mode_log_item;
178 Gtk::CheckMenuItem* mode_exp_item;
182 void add_line (boost::shared_ptr<AutomationLine>);
184 void clear_clicked ();
185 void hide_clicked ();
187 virtual bool can_edit_name() const {return false;}
189 void build_display_menu ();
191 void cut_copy_clear_one (AutomationLine&, Selection&, Editing::CutCopyOp);
192 bool paste_one (ARDOUR::samplepos_t, unsigned, float times, const Selection&, ItemCounts& counts, bool greedy=false);
193 void route_going_away ();
195 void set_automation_state (ARDOUR::AutoState);
196 bool ignore_state_request;
197 bool ignore_mode_request;
199 bool propagate_time_selection () const;
201 void automation_state_changed ();
203 void set_interpolation (ARDOUR::AutomationList::InterpolationStyle);
204 void interpolation_changed (ARDOUR::AutomationList::InterpolationStyle);
206 PBD::ScopedConnectionList _list_connections;
207 PBD::ScopedConnectionList _stripable_connections;
212 //void set_colors ();
213 void color_handler ();
215 static Pango::FontDescription name_font;
216 static bool have_name_font;
218 std::string automation_state_off_string () const;
221 int set_state_2X (const XMLNode &, int);
224 #endif /* __ardour_gtk_automation_time_axis_h__ */