ea54d82def9ae214d73f99d2f301d350250bc29a
[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 class StereoPanner;
44
45 namespace ARDOUR {
46         class Session;
47         class Panner;
48         class Delivery;
49         class AutomationControl;
50 }
51
52 namespace Gtkmm2ext {
53         class FastMeter;
54 }
55
56 namespace Gtk {
57         class Menu;
58         class Menuitem;
59 }
60
61 class PannerUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
62 {
63   public:
64         PannerUI (ARDOUR::Session*);
65         ~PannerUI ();
66
67         virtual void set_panner (boost::shared_ptr<ARDOUR::Panner>);
68
69         void panner_changed (void *);
70
71         void update_pan_sensitive ();
72         void update_gain_sensitive ();
73
74         void set_width (Width);
75         void setup_pan ();
76
77         void effective_pan_display ();
78
79         void set_meter_strip_name (std::string name);
80         boost::shared_ptr<PBD::Controllable> get_controllable();
81
82         void set_mono (bool);
83         void on_size_allocate (Gtk::Allocation &);
84         
85         static void setup_slider_pix ();
86
87   private:
88         friend class MixerStrip;
89
90         boost::shared_ptr<ARDOUR::Panner> _panner;
91         PBD::ScopedConnectionList connections;
92         PBD::ScopedConnectionList _pan_control_connections;
93
94         bool ignore_toggle;
95         bool in_pan_update;
96         int _current_nouts;
97         int _current_npans;
98
99         static const int pan_bar_height;
100
101         Panner2d*       twod_panner; ///< 2D panner, or 0
102         Panner2dWindow* big_window;
103
104         Gtk::VBox           pan_bar_packer;
105         Gtk::Adjustment     hAdjustment;
106         Gtk::Adjustment     vAdjustment;
107         Gtk::Viewport       panning_viewport;
108         Gtk::EventBox       panning_up;
109         Gtk::Arrow          panning_up_arrow;
110         Gtk::EventBox       panning_down;
111         Gtk::Arrow          panning_down_arrow;
112         Gtk::VBox           pan_vbox;
113         Gtk::VBox           poswidth_box;
114         Width              _width;
115
116         StereoPanner*  _stereo_panner;
117         bool _ignore_width_change;
118         bool _ignore_position_change;
119         void width_adjusted ();
120         void show_width ();
121         void position_adjusted ();
122         void show_position ();
123         
124         Gtk::ToggleButton   panning_link_button;
125         Gtk::Button         panning_link_direction_button;
126         Gtk::HBox           panning_link_box;
127
128         bool panning_link_button_press (GdkEventButton*);
129         bool panning_link_button_release (GdkEventButton*);
130
131         Gtk::Menu* pan_astate_menu;
132         Gtk::Menu* pan_astyle_menu;
133
134         Gtk::Button pan_automation_style_button;
135         Gtk::ToggleButton pan_automation_state_button;
136
137         void panning_link_direction_clicked ();
138
139         std::vector<Gtk::Adjustment*> pan_adjustments;
140         std::vector<PannerBar*> pan_bars;
141
142         void pan_adjustment_changed (uint32_t which);
143         void pan_value_changed (uint32_t which);
144         void update_pan_bars (bool only_if_aplay);
145         void update_pan_linkage ();
146         void update_pan_state ();
147         void build_astate_menu ();
148         void build_astyle_menu ();
149
150         void hide_pans ();
151
152         void panner_moved (int which);
153         void panner_bypass_toggled ();
154
155         gint start_pan_touch (GdkEventButton*);
156         gint end_pan_touch (GdkEventButton*);
157
158         bool pan_button_event (GdkEventButton*, uint32_t which);
159
160         void connect_to_pan_control (uint32_t);
161
162         Gtk::Menu* pan_menu;
163         Gtk::CheckMenuItem* bypass_menu_item;
164         void build_pan_menu (uint32_t which);
165         void pan_mute (uint32_t which);
166         void pan_reset (uint32_t);
167         void pan_reset_all ();
168         void pan_bypass_toggle ();
169
170         void pan_automation_state_changed();
171         void pan_automation_style_changed();
172         gint pan_automation_style_button_event (GdkEventButton *);
173         gint pan_automation_state_button_event (GdkEventButton *);
174         sigc::connection pan_watching;
175
176         std::string astate_string (ARDOUR::AutoState);
177         std::string short_astate_string (ARDOUR::AutoState);
178         std::string _astate_string (ARDOUR::AutoState, bool);
179
180         std::string astyle_string (ARDOUR::AutoStyle);
181         std::string short_astyle_string (ARDOUR::AutoStyle);
182         std::string _astyle_string (ARDOUR::AutoStyle, bool);
183
184         void start_touch (boost::weak_ptr<ARDOUR::AutomationControl>);
185         void stop_touch (boost::weak_ptr<ARDOUR::AutomationControl>);
186
187         void bar_spinner_activate (bool);
188         /** true if any of our PannerBars are currently using a SpinButton to modify value */
189         bool _bar_spinner_active;
190 };
191
192 #endif /* __ardour_gtk_panner_ui_h__ */
193