ripping, tearing, shredding
[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         
111         void selection_changed ();
112         
113         Gtk::EventBox          redirect_eventbox;
114         Gtk::HBox              redirect_hpacker;
115         Gtkmm2ext::DnDTreeView redirect_display;
116         Gtk::ScrolledWindow    redirect_scroller;
117
118         void object_drop (std::string type, uint32_t cnt, void**);
119
120         Width _width;
121         
122         Gtk::Menu *send_action_menu;
123         void build_send_action_menu ();
124
125         void new_send ();
126         void show_send_controls ();
127
128         Glib::RefPtr<Gtk::UIManager> popup_ui_mgr;
129         Glib::RefPtr<Gtk::ActionGroup> popup_act_grp;
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 };
186
187 #endif /* __ardour_gtk_redirect_box__ */