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