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