Modify Stateful to allow undo to be done using differences in state.
[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 }
49 namespace Gtkmm2ext {
50         class FastMeter;
51 }
52
53 namespace Gtk {
54         class Menu;
55         class Menuitem;
56 }
57
58 class PannerUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
59 {
60   public:
61         PannerUI (ARDOUR::Session*);
62         ~PannerUI ();
63
64         virtual void set_panner (boost::shared_ptr<ARDOUR::Panner>);
65
66         void pan_changed (void *);
67
68         void update_pan_sensitive ();
69         void update_gain_sensitive ();
70
71         void set_width (Width);
72         void setup_pan ();
73
74         void effective_pan_display ();
75
76         void set_meter_strip_name (std::string name);
77         boost::shared_ptr<PBD::Controllable> get_controllable();
78
79         void set_mono (bool);
80
81   private:
82         friend class MixerStrip;
83
84         boost::shared_ptr<ARDOUR::Panner> _panner;
85         PBD::ScopedConnectionList connections;
86
87         bool ignore_toggle;
88         bool in_pan_update;
89         int _current_nouts;
90         int _current_npans;
91
92         static const int pan_bar_height;
93
94         Panner2d*       panner; ///< 2D panner, or 0
95         Panner2dWindow* big_window;
96
97         Gtk::VBox           pan_bar_packer;
98         Gtk::Adjustment     hAdjustment;
99         Gtk::Adjustment     vAdjustment;
100         Gtk::Viewport       panning_viewport;
101         Gtk::EventBox       panning_up;
102         Gtk::Arrow          panning_up_arrow;
103         Gtk::EventBox       panning_down;
104         Gtk::Arrow          panning_down_arrow;
105         Gtk::VBox           pan_vbox;
106         Width              _width;
107
108         Gtk::ToggleButton   panning_link_button;
109         Gtk::Button         panning_link_direction_button;
110         Gtk::HBox           panning_link_box;
111
112         bool panning_link_button_press (GdkEventButton*);
113         bool panning_link_button_release (GdkEventButton*);
114
115         Gtk::Menu* pan_astate_menu;
116         Gtk::Menu* pan_astyle_menu;
117
118         Gtk::Button pan_automation_style_button;
119         Gtk::ToggleButton pan_automation_state_button;
120
121         void panning_link_direction_clicked ();
122
123         std::vector<Gtk::Adjustment*> pan_adjustments;
124         std::vector<PannerBar*> pan_bars;
125
126         void pan_adjustment_changed (uint32_t which);
127         void pan_value_changed (uint32_t which);
128         void update_pan_bars (bool only_if_aplay);
129         void update_pan_linkage ();
130         void update_pan_state ();
131         void build_astate_menu ();
132         void build_astyle_menu ();
133
134         void panner_changed ();
135
136         void hide_pans ();
137
138         void panner_moved (int which);
139         void panner_bypass_toggled ();
140
141         gint start_pan_touch (GdkEventButton*);
142         gint end_pan_touch (GdkEventButton*);
143
144         bool pan_button_event (GdkEventButton*, uint32_t which);
145
146         Gtk::Menu* pan_menu;
147         Gtk::CheckMenuItem* bypass_menu_item;
148         void build_pan_menu (uint32_t which);
149         void pan_mute (uint32_t which);
150         void pan_reset (uint32_t);
151         void pan_reset_all ();
152         void pan_bypass_toggle ();
153
154         void pan_automation_state_changed();
155         void pan_automation_style_changed();
156         gint pan_automation_style_button_event (GdkEventButton *);
157         gint pan_automation_state_button_event (GdkEventButton *);
158         sigc::connection pan_watching;
159
160         std::string astate_string (ARDOUR::AutoState);
161         std::string short_astate_string (ARDOUR::AutoState);
162         std::string _astate_string (ARDOUR::AutoState, bool);
163
164         std::string astyle_string (ARDOUR::AutoStyle);
165         std::string short_astyle_string (ARDOUR::AutoStyle);
166         std::string _astyle_string (ARDOUR::AutoStyle, bool);
167 };
168
169 #endif /* __ardour_gtk_panner_ui_h__ */
170