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