d94ad2048732bb93e5023ee69084c9027d4847fe
[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         static void register_actions();
87
88   protected:
89         void set_stuff_from_route ();
90
91   private:
92         ARDOUR::Route &     _route;
93         ARDOUR::Session &   _session;
94         bool                _owner_is_mixer;
95
96         ARDOUR::Placement   _placement;
97
98         PluginSelector     & _plugin_selector;
99         RouteRedirectSelection  & _rr_selection;
100         
101         struct ModelColumns : public Gtk::TreeModel::ColumnRecord {
102                 ModelColumns () {
103                         add (text);
104                     add (redirect);
105                 }
106             Gtk::TreeModelColumn<std::string> text;
107             Gtk::TreeModelColumn<ARDOUR::Redirect*>   redirect;
108         };
109
110         ModelColumns columns;
111         Glib::RefPtr<Gtk::ListStore> model;
112         
113         void selection_changed ();
114         
115         Gtk::EventBox          redirect_eventbox;
116         Gtk::HBox              redirect_hpacker;
117         Gtkmm2ext::DnDTreeView redirect_display;
118         Gtk::ScrolledWindow    redirect_scroller;
119
120         void object_drop (std::string type, uint32_t cnt, void**);
121
122         Width _width;
123         
124         Gtk::Menu *send_action_menu;
125         void build_send_action_menu ();
126
127         void new_send ();
128         void show_send_controls ();
129
130         Gtk::Menu *redirect_menu;
131         gint redirect_menu_map_handler (GdkEventAny *ev);
132         Gtk::Menu * build_redirect_menu ();
133         void build_redirect_tooltip (Gtk::EventBox&, string);
134         void show_redirect_menu (gint arg);
135
136         void choose_send ();
137         void send_io_finished (IOSelector::Result, ARDOUR::Redirect*, IOSelectorWindow*);
138         void choose_insert ();
139         void choose_plugin ();
140         void insert_plugin_chosen (ARDOUR::Plugin *);
141
142         gint redirect_button (GdkEventButton *);
143         void redirects_changed (void *);
144         void show_redirect_active (ARDOUR::Redirect *, void *);
145         void show_redirect_name (void*, ARDOUR::Redirect *);
146         void add_redirect_to_display (ARDOUR::Redirect *);
147
148         string redirect_name (ARDOUR::Redirect&);
149
150         void remove_redirect_gui (ARDOUR::Redirect *);
151
152         void redirects_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
153         gint compute_redirect_sort_keys ();
154         vector<sigc::connection> redirect_active_connections;
155         vector<sigc::connection> redirect_name_connections;
156         
157         bool redirect_drag_in_progress;
158         void redirect_drag_begin (GdkDragContext*);
159         void redirect_drag_end (GdkDragContext*);
160         void all_redirects_active(bool state);
161
162         void cut_redirects ();
163         void copy_redirects ();
164         void paste_redirects ();
165         void clear_redirects ();
166         void clone_redirects ();
167         void rename_redirects ();
168
169         void for_selected_redirects (void (RedirectBox::*pmf)(ARDOUR::Redirect*));
170         void get_selected_redirects (vector<ARDOUR::Redirect*>&);
171
172         
173         void activate_redirect (ARDOUR::Redirect*);
174         void deactivate_redirect (ARDOUR::Redirect*);
175         void cut_redirect (ARDOUR::Redirect*);
176         void copy_redirect (ARDOUR::Redirect*);
177         void edit_redirect (ARDOUR::Redirect*);
178         void hide_redirect_editor (ARDOUR::Redirect*);
179         void rename_redirect (ARDOUR::Redirect*);
180
181         gint idle_delete_redirect (ARDOUR::Redirect *);
182
183         void wierd_plugin_dialog (ARDOUR::Plugin& p, uint32_t streams, ARDOUR::IO& io);
184
185         static RedirectBox* _current_redirect_box;
186         static bool enter_box (GdkEventCrossing*, RedirectBox*);
187         static bool leave_box (GdkEventCrossing*, RedirectBox*);
188
189         static void rb_choose_plugin ();
190         static void rb_choose_insert ();
191         static void rb_choose_send ();
192         static void rb_clear ();
193         static void rb_cut ();
194         static void rb_copy ();
195         static void rb_paste ();
196         static void rb_rename ();
197         static void rb_select_all ();
198         static void rb_deselect_all ();
199         static void rb_activate ();
200         static void rb_deactivate ();
201         static void rb_activate_all ();
202         static void rb_deactivate_all ();
203         static void rb_edit ();
204 };
205
206 #endif /* __ardour_gtk_redirect_box__ */