merge from 2.0-ongoing @ 3581
[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 "enums.h"
37
38 class Panner2d;
39 class PannerBar;
40
41 namespace ARDOUR {
42         class IO;
43         class Session;
44 }
45 namespace Gtkmm2ext {
46         class FastMeter;
47 }
48
49 namespace Gtk {
50         class Menu;
51         class Menuitem;
52 }
53
54 class PannerUI : public Gtk::HBox
55 {
56   public:
57         PannerUI (boost::shared_ptr<ARDOUR::IO>, ARDOUR::Session&);
58         ~PannerUI ();
59
60         void pan_changed (void *);
61
62         void update_pan_sensitive ();
63         void update_gain_sensitive ();
64
65         void set_width (Width);
66         void setup_pan ();
67
68         void effective_pan_display ();
69
70         void set_meter_strip_name (string name);
71         boost::shared_ptr<PBD::Controllable> get_controllable();
72
73   private:
74         friend class MixerStrip;
75
76         boost::shared_ptr<ARDOUR::IO> _io;
77         ARDOUR::Session& _session;
78
79         bool ignore_toggle;
80         bool in_pan_update;
81
82         static const int pan_bar_height;
83
84         Panner2d*   panner;
85
86         Gtk::VBox           pan_bar_packer;
87         Gtk::Adjustment     hAdjustment;
88         Gtk::Adjustment     vAdjustment;
89         Gtk::Viewport       panning_viewport;
90         Gtk::EventBox       panning_up;
91         Gtk::Arrow          panning_up_arrow;
92         Gtk::EventBox       panning_down;
93         Gtk::Arrow          panning_down_arrow;
94         Gtk::VBox           pan_vbox;
95         Width              _width;
96
97         Gtk::ToggleButton   panning_link_button;
98         Gtk::Button         panning_link_direction_button;
99         Gtk::HBox           panning_link_box;
100
101         bool panning_link_button_press (GdkEventButton*);
102         bool panning_link_button_release (GdkEventButton*);
103
104         Gtk::Menu pan_astate_menu;
105         Gtk::Menu pan_astyle_menu;
106
107         Gtk::Button pan_automation_style_button;
108         Gtk::ToggleButton pan_automation_state_button;
109
110         void panning_link_direction_clicked ();
111
112         vector<Gtk::Adjustment*> pan_adjustments;
113         vector<PannerBar*> pan_bars;
114
115         void pan_adjustment_changed (uint32_t which);
116         void pan_value_changed (uint32_t which);
117         void pan_printer (char* buf, uint32_t, Gtk::Adjustment*);
118         void update_pan_bars (bool only_if_aplay);
119         void update_pan_linkage ();
120         void update_pan_state ();
121
122         void panner_changed ();
123         
124         void hide_pans ();
125
126         void panner_moved (int which);
127         void panner_bypass_toggled ();
128
129         gint start_pan_touch (GdkEventButton*);
130         gint end_pan_touch (GdkEventButton*);
131
132         bool pan_button_event (GdkEventButton*, uint32_t which);
133
134         Gtk::Menu* pan_menu;
135         Gtk::CheckMenuItem* bypass_menu_item;
136         void build_pan_menu (uint32_t which);
137         void pan_mute (uint32_t which);
138         void pan_reset ();
139         void pan_bypass_toggle ();
140
141         void pan_automation_state_changed();
142         void pan_automation_style_changed();
143         gint pan_automation_style_button_event (GdkEventButton *);
144         gint pan_automation_state_button_event (GdkEventButton *);
145         sigc::connection pan_watching;
146
147         std::string astate_string (ARDOUR::AutoState);
148         std::string short_astate_string (ARDOUR::AutoState);
149         std::string _astate_string (ARDOUR::AutoState, bool);
150
151         std::string astyle_string (ARDOUR::AutoStyle);
152         std::string short_astyle_string (ARDOUR::AutoStyle);
153         std::string _astyle_string (ARDOUR::AutoStyle, bool);
154 };
155
156 #endif /* __ardour_gtk_panner_ui_h__ */
157