Fix deletion of VCA with slaved controls.
[ardour.git] / gtk2_ardour / automation_controller.h
1 /*
2     Copyright (C) 2007 Paul Davis
3     Author: David Robillard
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __ardour_gtk_automation_controller_h__
22 #define __ardour_gtk_automation_controller_h__
23
24 #ifdef YES
25 #undef YES
26 #endif
27 #ifdef NO
28 #undef NO
29 #endif
30
31 #include <boost/shared_ptr.hpp>
32 #include <gtkmm.h>
33
34 #include "gtkmm2ext/barcontroller.h"
35 #include "pbd/signals.h"
36 #include "evoral/Parameter.hpp"
37
38 namespace ARDOUR {
39         class Session;
40         class AutomationList;
41         class AutomationControl;
42 }
43
44 class AutomationBarController : public Gtkmm2ext::BarController {
45 public:
46         AutomationBarController(boost::shared_ptr<ARDOUR::AutomationControl> ac,
47                                 Gtk::Adjustment*                             adj);
48         ~AutomationBarController();
49 private:
50         std::string get_label (double&);
51         boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
52 };
53
54 /** A BarController which displays the value and allows control of an AutomationControl */
55 class AutomationController : public Gtk::Alignment {
56 public:
57         static boost::shared_ptr<AutomationController> create (
58                 const Evoral::Parameter&                     param,
59                 const ARDOUR::ParameterDescriptor&           desc,
60                 boost::shared_ptr<ARDOUR::AutomationControl> ac,
61                 bool                                         use_knob = false);
62
63         ~AutomationController();
64
65         boost::shared_ptr<ARDOUR::AutomationControl> controllable() { return _controllable; }
66
67         void disable_vertical_scroll();
68
69         Gtk::Adjustment* adjustment() { return _adjustment; }
70         Gtk::Widget*     widget()     { return _widget; }
71
72         void display_effective_value();
73         void value_adjusted();
74
75         void stop_updating ();
76
77 private:
78         AutomationController (boost::shared_ptr<ARDOUR::AutomationControl> ac,
79                               Gtk::Adjustment*                             adj,
80                               bool                                         use_knob);
81
82         void start_touch();
83         void end_touch();
84         bool button_press(GdkEventButton*);
85         bool button_release(GdkEventButton*);
86
87         void run_note_select_dialog();
88         void set_ratio(double ratio);
89         void set_freq_beats(double beats);
90         bool on_button_release(GdkEventButton* ev);
91
92         Gtk::Widget*                                 _widget;
93         boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
94         Gtk::Adjustment*                             _adjustment;
95         sigc::connection                             _screen_update_connection;
96         PBD::ScopedConnection                        _changed_connection;
97         bool                                         _ignore_change;
98 };
99
100
101 #endif /* __ardour_gtk_automation_controller_h__ */