add GUI elements to control 2in/2out panning. Probably not perfect. REQUIRES FULL...
[ardour.git] / gtk2_ardour / panner_ui.h
1 /*
2     Copyright (C) 2004 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_gtk_panner_ui_h__
21 #define __ardour_gtk_panner_ui_h__
22
23 #include <vector>
24
25 #include <gtkmm/box.h>
26 #include <gtkmm/adjustment.h>
27 #include <gtkmm/viewport.h>
28 #include <gtkmm/eventbox.h>
29 #include <gtkmm/arrow.h>
30 #include <gtkmm/togglebutton.h>
31 #include <gtkmm/button.h>
32
33 #include <gtkmm2ext/click_box.h>
34 #include <gtkmm2ext/slider_controller.h>
35
36 #include "ardour/session_handle.h"
37
38 #include "enums.h"
39
40 class Panner2d;
41 class PannerBar;
42 class Panner2dWindow;
43
44 namespace ARDOUR {
45         class Session;
46         class Panner;
47         class Delivery;
48         class AutomationControl;
49 }
50
51 namespace Gtkmm2ext {
52         class FastMeter;
53 }
54
55 namespace Gtk {
56         class Menu;
57         class Menuitem;
58 }
59
60 class PannerUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
61 {
62   public:
63         PannerUI (ARDOUR::Session*);
64         ~PannerUI ();
65
66         virtual void set_panner (boost::shared_ptr<ARDOUR::Panner>);
67
68         void panner_changed (void *);
69
70         void update_pan_sensitive ();
71         void update_gain_sensitive ();
72
73         void set_width (Width);
74         void setup_pan ();
75
76         void effective_pan_display ();
77
78         void set_meter_strip_name (std::string name);
79         boost::shared_ptr<PBD::Controllable> get_controllable();
80
81         void set_mono (bool);
82         void on_size_allocate (Gtk::Allocation &);
83         
84         static void setup_slider_pix ();
85
86   private:
87         friend class MixerStrip;
88
89         boost::shared_ptr<ARDOUR::Panner> _panner;
90         PBD::ScopedConnectionList connections;
91         PBD::ScopedConnectionList _pan_control_connections;
92
93         bool ignore_toggle;
94         bool in_pan_update;
95         int _current_nouts;
96         int _current_npans;
97
98         static const int pan_bar_height;
99
100         Panner2d*       twod_panner; ///< 2D panner, or 0
101         Panner2dWindow* big_window;
102
103         Gtk::VBox           pan_bar_packer;
104         Gtk::Adjustment     hAdjustment;
105         Gtk::Adjustment     vAdjustment;
106         Gtk::Viewport       panning_viewport;
107         Gtk::EventBox       panning_up;
108         Gtk::Arrow          panning_up_arrow;
109         Gtk::EventBox       panning_down;
110         Gtk::Arrow          panning_down_arrow;
111         Gtk::VBox           pan_vbox;
112         Gtk::VBox           poswidth_box;
113         Width              _width;
114
115         Gtk::Adjustment _position_adjustment;
116         Gtk::Adjustment _width_adjustment;
117         Gtkmm2ext::BarController* _position_fader;
118         Gtkmm2ext::BarController* _width_fader;
119         static Glib::RefPtr<Gdk::Pixbuf> _poswidth_slider;
120         bool _ignore_width_change;
121         bool _ignore_position_change;
122         void width_adjusted ();
123         void show_width ();
124         void position_adjusted ();
125         void show_position ();
126         
127         Gtk::ToggleButton   panning_link_button;
128         Gtk::Button         panning_link_direction_button;
129         Gtk::HBox           panning_link_box;
130
131         bool panning_link_button_press (GdkEventButton*);
132         bool panning_link_button_release (GdkEventButton*);
133
134         Gtk::Menu* pan_astate_menu;
135         Gtk::Menu* pan_astyle_menu;
136
137         Gtk::Button pan_automation_style_button;
138         Gtk::ToggleButton pan_automation_state_button;
139
140         void panning_link_direction_clicked ();
141
142         std::vector<Gtk::Adjustment*> pan_adjustments;
143         std::vector<PannerBar*> pan_bars;
144
145         void pan_adjustment_changed (uint32_t which);
146         void pan_value_changed (uint32_t which);
147         void update_pan_bars (bool only_if_aplay);
148         void update_pan_linkage ();
149         void update_pan_state ();
150         void build_astate_menu ();
151         void build_astyle_menu ();
152
153         void hide_pans ();
154
155         void panner_moved (int which);
156         void panner_bypass_toggled ();
157
158         gint start_pan_touch (GdkEventButton*);
159         gint end_pan_touch (GdkEventButton*);
160
161         bool pan_button_event (GdkEventButton*, uint32_t which);
162
163         void connect_to_pan_control (uint32_t);
164
165         Gtk::Menu* pan_menu;
166         Gtk::CheckMenuItem* bypass_menu_item;
167         void build_pan_menu (uint32_t which);
168         void pan_mute (uint32_t which);
169         void pan_reset (uint32_t);
170         void pan_reset_all ();
171         void pan_bypass_toggle ();
172
173         void pan_automation_state_changed();
174         void pan_automation_style_changed();
175         gint pan_automation_style_button_event (GdkEventButton *);
176         gint pan_automation_state_button_event (GdkEventButton *);
177         sigc::connection pan_watching;
178
179         std::string astate_string (ARDOUR::AutoState);
180         std::string short_astate_string (ARDOUR::AutoState);
181         std::string _astate_string (ARDOUR::AutoState, bool);
182
183         std::string astyle_string (ARDOUR::AutoStyle);
184         std::string short_astyle_string (ARDOUR::AutoStyle);
185         std::string _astyle_string (ARDOUR::AutoStyle, bool);
186
187         void start_touch (boost::weak_ptr<ARDOUR::AutomationControl>);
188         void stop_touch (boost::weak_ptr<ARDOUR::AutomationControl>);
189
190         void bar_spinner_activate (bool);
191         /** true if any of our PannerBars are currently using a SpinButton to modify value */
192         bool _bar_spinner_active;
193 };
194
195 #endif /* __ardour_gtk_panner_ui_h__ */
196