3d767a6aa501510daf24e4b3114dd8c9cda7d658
[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
33 #include <gtkmm/alignment.h>
34
35 #include "pbd/signals.h"
36 #include "ardour/parameter_descriptor.h"
37
38 #include "widgets/barcontroller.h"
39
40 namespace ARDOUR {
41         class Session;
42         class AutomationList;
43         class AutomationControl;
44 }
45
46 namespace Gtk {
47         class Adjustment;
48         class Widget;
49 }
50
51 class AutomationBarController : public ArdourWidgets::BarController {
52 public:
53         AutomationBarController(boost::shared_ptr<ARDOUR::AutomationControl> ac,
54                                 Gtk::Adjustment*                             adj);
55         ~AutomationBarController();
56 private:
57         std::string get_label (double&);
58         boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
59 };
60
61 /** A BarController which displays the value and allows control of an AutomationControl */
62 class AutomationController : public Gtk::Alignment {
63 public:
64         static boost::shared_ptr<AutomationController> create (
65                 const Evoral::Parameter&                     param,
66                 const ARDOUR::ParameterDescriptor&           desc,
67                 boost::shared_ptr<ARDOUR::AutomationControl> ac,
68                 bool                                         use_knob = false);
69
70         ~AutomationController();
71
72         boost::shared_ptr<ARDOUR::AutomationControl> controllable() { return _controllable; }
73
74         void disable_vertical_scroll();
75
76         Gtk::Adjustment* adjustment() { return _adjustment; }
77         Gtk::Widget*     widget()     { return _widget; }
78
79         void display_effective_value ();
80         void automation_state_changed ();
81         void value_adjusted();
82
83         void stop_updating ();
84
85 private:
86         AutomationController (boost::shared_ptr<ARDOUR::AutomationControl> ac,
87                               Gtk::Adjustment*                             adj,
88                               bool                                         use_knob);
89
90         void start_touch();
91         void end_touch();
92         bool button_press(GdkEventButton*);
93         bool button_release(GdkEventButton*);
94
95         void run_note_select_dialog();
96         void set_ratio(double ratio);
97         void set_freq_beats(double beats);
98         bool on_button_release(GdkEventButton* ev);
99
100         Gtk::Widget*                                 _widget;
101         boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
102         Gtk::Adjustment*                             _adjustment;
103         sigc::connection                             _screen_update_connection;
104         PBD::ScopedConnectionList                    _changed_connections;
105         bool                                         _ignore_change;
106         bool                                         _grabbed;
107 };
108
109
110 #endif /* __ardour_gtk_automation_controller_h__ */