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