id_t becomes a fully-fledged object, UUID's used for IDs, generic MIDI now owns bindi...
[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 <pbd/stateful.h>
37
38 #include <ardour/types.h>
39 #include <ardour/ardour.h>
40 #include <ardour/io.h>
41 #include <ardour/insert.h>
42 #include <ardour/redirect.h>
43
44 #include <pbd/fastlog.h>
45
46 #include "route_ui.h"
47 #include "io_selector.h"
48 #include "enums.h"
49
50 class MotionController;
51 class PluginSelector;
52 class RouteRedirectSelection;
53
54 namespace ARDOUR {
55         class Route;
56         class Send;
57         class Insert;
58         class Session;
59         class PortInsert;
60         class Connection;
61         class Plugin;
62 }
63
64
65 class RedirectBox : public Gtk::HBox
66 {
67   public:
68         RedirectBox (ARDOUR::Placement, ARDOUR::Session&, ARDOUR::Route &, PluginSelector &, RouteRedirectSelection &, bool owner_is_mixer = false);
69         ~RedirectBox ();
70
71         void set_width (Width);
72
73         void update();
74
75         void select_all_redirects ();
76         void deselect_all_redirects ();
77         void select_all_plugins ();
78         void select_all_inserts ();
79         void select_all_sends ();
80         
81         sigc::signal<void,ARDOUR::Redirect *> RedirectSelected;
82         sigc::signal<void,ARDOUR::Redirect *> RedirectUnselected;
83         
84         static void register_actions();
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                     add (color);
104             }
105             Gtk::TreeModelColumn<std::string>       text;
106             Gtk::TreeModelColumn<ARDOUR::Redirect*> redirect;
107             Gtk::TreeModelColumn<Gdk::Color>        color;
108         };
109
110         ModelColumns columns;
111         Glib::RefPtr<Gtk::ListStore> model;
112         
113         void selection_changed ();
114
115         static bool get_colors;
116         static Gdk::Color* active_redirect_color;
117         static Gdk::Color* inactive_redirect_color;
118         
119         Gtk::EventBox          redirect_eventbox;
120         Gtk::HBox              redirect_hpacker;
121         Gtkmm2ext::DnDTreeView redirect_display;
122         Gtk::ScrolledWindow    redirect_scroller;
123
124         void object_drop (std::string type, uint32_t cnt, void**);
125
126         Width _width;
127         
128         Gtk::Menu *send_action_menu;
129         void build_send_action_menu ();
130
131         void new_send ();
132         void show_send_controls ();
133
134         Gtk::Menu *redirect_menu;
135         gint redirect_menu_map_handler (GdkEventAny *ev);
136         Gtk::Menu * build_redirect_menu ();
137         void build_redirect_tooltip (Gtk::EventBox&, string);
138         void show_redirect_menu (gint arg);
139
140         void choose_send ();
141         void send_io_finished (IOSelector::Result, ARDOUR::Redirect*, IOSelectorWindow*);
142         void choose_insert ();
143         void choose_plugin ();
144         void insert_plugin_chosen (ARDOUR::Plugin *);
145
146         bool no_redirect_redisplay;
147         bool ignore_delete;
148
149         bool redirect_button_press_event (GdkEventButton *);
150         void redisplay_redirects (void* src);
151         void show_redirect_active (ARDOUR::Redirect *, void *);
152         void show_redirect_name (void*, ARDOUR::Redirect *);
153         void add_redirect_to_display (ARDOUR::Redirect *);
154         void row_deleted (const Gtk::TreeModel::Path& path);
155
156         string redirect_name (ARDOUR::Redirect&);
157
158         void remove_redirect_gui (ARDOUR::Redirect *);
159
160         void redirects_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
161         void 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         static Glib::RefPtr<Gtk::Action> paste_action;
181         void paste_redirect_list (std::list<ARDOUR::Redirect*>& redirects);
182         
183         void activate_redirect (ARDOUR::Redirect*);
184         void deactivate_redirect (ARDOUR::Redirect*);
185         void cut_redirect (ARDOUR::Redirect*);
186         void copy_redirect (ARDOUR::Redirect*);
187         void edit_redirect (ARDOUR::Redirect*);
188         void hide_redirect_editor (ARDOUR::Redirect*);
189         void rename_redirect (ARDOUR::Redirect*);
190
191         gint idle_delete_redirect (ARDOUR::Redirect *);
192
193         void wierd_plugin_dialog (ARDOUR::Plugin& p, uint32_t streams, ARDOUR::IO& io);
194
195         static RedirectBox* _current_redirect_box;
196         static bool enter_box (GdkEventCrossing*, RedirectBox*);
197         static bool leave_box (GdkEventCrossing*, RedirectBox*);
198
199         static void rb_choose_plugin ();
200         static void rb_choose_insert ();
201         static void rb_choose_send ();
202         static void rb_clear ();
203         static void rb_cut ();
204         static void rb_copy ();
205         static void rb_paste ();
206         static void rb_rename ();
207         static void rb_select_all ();
208         static void rb_deselect_all ();
209         static void rb_activate ();
210         static void rb_deactivate ();
211         static void rb_activate_all ();
212         static void rb_deactivate_all ();
213         static void rb_edit ();
214 };
215
216 #endif /* __ardour_gtk_redirect_box__ */