Vkeybd: add a mod-wheel
[ardour.git] / gtk2_ardour / stereo_panner.h
1 /*
2  * Copyright (C) 2010-2015 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2011-2012 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2011-2014 David Robillard <d@drobilla.net>
5  * Copyright (C) 2014-2017 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 __gtk_ardour_stereo_panner_h__
23 #define __gtk_ardour_stereo_panner_h__
24
25 #include "pbd/signals.h"
26 #include "widgets/binding_proxy.h"
27 #include "panner_interface.h"
28
29 namespace ARDOUR {
30         class PannerShell;
31 }
32
33 namespace PBD {
34         class Controllable;
35 }
36
37 namespace ARDOUR {
38         class Panner;
39 }
40
41 class StereoPanner : public PannerInterface
42 {
43 public:
44         StereoPanner (boost::shared_ptr<ARDOUR::PannerShell>);
45         ~StereoPanner ();
46
47         boost::shared_ptr<PBD::Controllable> get_position_controllable() const { return position_control; }
48         boost::shared_ptr<PBD::Controllable> get_width_controllable() const { return width_control; }
49
50         sigc::signal<void> StartPositionGesture;
51         sigc::signal<void> StopPositionGesture;
52         sigc::signal<void> StartWidthGesture;
53         sigc::signal<void> StopWidthGesture;
54
55 protected:
56         bool on_expose_event (GdkEventExpose*);
57         bool on_button_press_event (GdkEventButton*);
58         bool on_button_release_event (GdkEventButton*);
59         bool on_motion_notify_event (GdkEventMotion*);
60         bool on_scroll_event (GdkEventScroll*);
61         bool on_key_press_event (GdkEventKey*);
62
63         boost::weak_ptr<PBD::Controllable> proxy_controllable () const
64         {
65                 return boost::weak_ptr<PBD::Controllable> (position_binder.get_controllable());
66         }
67
68 private:
69         PannerEditor* editor ();
70         boost::shared_ptr<ARDOUR::PannerShell> _panner_shell;
71
72         boost::shared_ptr<PBD::Controllable> position_control;
73         boost::shared_ptr<PBD::Controllable> width_control;
74         PBD::ScopedConnectionList panvalue_connections;
75         PBD::ScopedConnectionList panshell_connections;
76         bool dragging_position;
77         bool dragging_left;
78         bool dragging_right;
79         int drag_start_x;
80         int last_drag_x;
81         double accumulated_delta;
82         bool detented;
83
84         ArdourWidgets::BindingProxy position_binder;
85         ArdourWidgets::BindingProxy width_binder;
86
87         void set_tooltip ();
88
89         struct ColorScheme {
90                 uint32_t outline;
91                 uint32_t fill;
92                 uint32_t text;
93                 uint32_t background;
94                 uint32_t rule;
95         };
96
97         enum State {
98                 Normal,
99                 Mono,
100                 Inverted
101         };
102
103         bool _dragging;
104
105         static Pango::AttrList panner_font_attributes;
106         static bool have_font;
107
108         static ColorScheme colors[3];
109         static void set_colors ();
110         static bool have_colors;
111         void color_handler ();
112         void bypass_handler ();
113         void pannable_handler ();
114 };
115
116 #endif /* __gtk_ardour_stereo_panner_h__ */