some C++-ification of GnomeCanvasBlah
[ardour.git] / gtk2_ardour / redirect_box.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     $Id$
19 */
20
21 #ifndef __ardour_gtk_redirect_box__
22 #define __ardour_gtk_redirect_box__
23
24 #include <vector>
25
26 #include <cmath>
27 #include <gtkmm/box.h>
28 #include <gtkmm/eventbox.h>
29 #include <gtkmm/menu.h>
30 #include <gtkmm/scrolledwindow.h>
31 #include <gtkmm2ext/dndtreeview.h>
32 #include <gtkmm2ext/auto_spin.h>
33 #include <gtkmm2ext/click_box.h>
34 #include <gtkmm2ext/dndtreeview.h>
35
36 #include <ardour/types.h>
37 #include <ardour/ardour.h>
38 #include <ardour/io.h>
39 #include <ardour/insert.h>
40 #include <ardour/stateful.h>
41 #include <ardour/redirect.h>
42
43 #include <pbd/fastlog.h>
44
45 #include "route_ui.h"
46 #include "io_selector.h"
47 #include "enums.h"
48
49 class MotionController;
50 class PluginSelector;
51 class RouteRedirectSelection;
52
53 namespace ARDOUR {
54         class Route;
55         class Send;
56         class Insert;
57         class Session;
58         class PortInsert;
59         class Connection;
60         class Plugin;
61 }
62
63
64 class RedirectBox : public Gtk::HBox
65 {
66   public:
67         RedirectBox (ARDOUR::Placement, ARDOUR::Session&, ARDOUR::Route &, PluginSelector &, RouteRedirectSelection &, bool owner_is_mixer = false);
68         ~RedirectBox ();
69
70         void set_width (Width);
71
72         void set_title (const std::string & title);
73         void set_title_shown (bool flag);
74         
75         void update();
76
77         void select_all_redirects ();
78         void deselect_all_redirects ();
79         void select_all_plugins ();
80         void select_all_inserts ();
81         void select_all_sends ();
82         
83         sigc::signal<void,ARDOUR::Redirect *> RedirectSelected;
84         sigc::signal<void,ARDOUR::Redirect *> RedirectUnselected;
85         
86   protected:
87         void set_stuff_from_route ();
88
89   private:
90         ARDOUR::Route &     _route;
91         ARDOUR::Session &   _session;
92         bool                _owner_is_mixer;
93
94         ARDOUR::Placement   _placement;
95
96         PluginSelector     & _plugin_selector;
97         RouteRedirectSelection  & _rr_selection;
98         
99         struct ModelColumns : public Gtk::TreeModel::ColumnRecord {
100                 ModelColumns () {
101                         add (text);
102                     add (redirect);
103                 }
104             Gtk::TreeModelColumn<std::string> text;
105             Gtk::TreeModelColumn<ARDOUR::Redirect*>   redirect;
106         };
107
108         ModelColumns columns;
109         Glib::RefPtr<Gtk::ListStore> model;
110         Glib::RefPtr<Gtk::TreeSelection> selection;
111         
112         Gtk::EventBox          redirect_eventbox;
113         Gtk::HBox              redirect_hpacker;
114         Gtkmm2ext::DnDTreeView redirect_display;
115         Gtk::ScrolledWindow    redirect_scroller;
116
117         void object_drop (std::string type, uint32_t cnt, void**);
118
119         Width _width;
120         
121         sigc::connection newplug_connection;
122         
123         Gtk::Menu *send_action_menu;
124         void build_send_action_menu ();
125
126         void new_send ();
127         void show_send_controls ();
128
129         Glib::RefPtr<Gtk::UIManager> popup_ui_mgr;
130         Glib::RefPtr<Gtk::ActionGroup> popup_act_grp;
131         Gtk::Menu *redirect_menu;
132         vector<Glib::RefPtr<Gtk::Action> > selection_dependent_items;
133         gint redirect_menu_map_handler (GdkEventAny *ev);
134         Gtk::Menu * build_redirect_menu ();
135         void build_redirect_tooltip (Gtk::EventBox&, string);
136         void show_redirect_menu (gint arg);
137
138         void choose_send ();
139         void send_io_finished (IOSelector::Result, ARDOUR::Redirect*, IOSelectorWindow*);
140         void choose_insert ();
141         void choose_plugin ();
142         void insert_plugin_chosen (ARDOUR::Plugin *);
143
144         gint redirect_button (GdkEventButton *);
145         void redirects_changed (void *);
146         void show_redirect_active (ARDOUR::Redirect *, void *);
147         void show_redirect_name (void*, ARDOUR::Redirect *);
148         void add_redirect_to_display (ARDOUR::Redirect *);
149
150         void show_plugin_selector ();
151
152
153         string redirect_name (ARDOUR::Redirect&);
154
155
156         void remove_redirect_gui (ARDOUR::Redirect *);
157
158         void disconnect_newplug();
159
160         void redirects_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
161         gint compute_redirect_sort_keys ();
162         vector<sigc::connection> redirect_active_connections;
163         vector<sigc::connection> redirect_name_connections;
164         
165         bool redirect_drag_in_progress;
166         void redirect_drag_begin (GdkDragContext*);
167         void redirect_drag_end (GdkDragContext*);
168         void all_redirects_active(bool state);
169
170         void cut_redirects ();
171         void copy_redirects ();
172         void paste_redirects ();
173         void clear_redirects ();
174         void clone_redirects ();
175         void rename_redirects ();
176
177         void for_selected_redirects (void (RedirectBox::*pmf)(ARDOUR::Redirect*));
178         void get_selected_redirects (vector<ARDOUR::Redirect*>&);
179
180         
181         void activate_redirect (ARDOUR::Redirect*);
182         void deactivate_redirect (ARDOUR::Redirect*);
183         void cut_redirect (ARDOUR::Redirect*);
184         void copy_redirect (ARDOUR::Redirect*);
185         void edit_redirect (ARDOUR::Redirect*);
186         void hide_redirect_editor (ARDOUR::Redirect*);
187         void rename_redirect (ARDOUR::Redirect*);
188
189         gint idle_delete_redirect (ARDOUR::Redirect *);
190
191         void wierd_plugin_dialog (ARDOUR::Plugin& p, uint32_t streams, ARDOUR::IO& io);
192
193 };
194
195 #endif /* __ardour_gtk_redirect_box__ */