new hellenic translation, plus new names in about dialog
[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 */
19
20 #ifndef __ardour_gtk_redirect_box__
21 #define __ardour_gtk_redirect_box__
22
23 #include <vector>
24
25 #include <cmath>
26 #include <gtkmm/box.h>
27 #include <gtkmm/eventbox.h>
28 #include <gtkmm/menu.h>
29 #include <gtkmm/scrolledwindow.h>
30 #include <gtkmm2ext/dndtreeview.h>
31 #include <gtkmm2ext/auto_spin.h>
32 #include <gtkmm2ext/click_box.h>
33 #include <gtkmm2ext/dndtreeview.h>
34
35 #include <pbd/stateful.h>
36
37 #include <ardour/types.h>
38 #include <ardour/ardour.h>
39 #include <ardour/io.h>
40 #include <ardour/insert.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 PluginUIWindow;
52 class RouteRedirectSelection;
53
54 namespace ARDOUR {
55         class Connection;
56         class Insert;
57         class Plugin;
58         class PluginInsert;
59         class PortInsert;
60         class Route;
61         class Send;
62         class Session;
63 }
64
65 class RedirectBox : public Gtk::HBox
66 {
67   public:
68         RedirectBox (ARDOUR::Placement, ARDOUR::Session&, 
69                      boost::shared_ptr<ARDOUR::Route>, PluginSelector &, RouteRedirectSelection &, bool owner_is_mixer = false);
70         ~RedirectBox ();
71
72         void set_width (Width);
73
74         void update();
75
76         void select_all_redirects ();
77         void deselect_all_redirects ();
78         void select_all_plugins ();
79         void select_all_inserts ();
80         void select_all_sends ();
81         
82         sigc::signal<void,boost::shared_ptr<ARDOUR::Redirect> > RedirectSelected;
83         sigc::signal<void,boost::shared_ptr<ARDOUR::Redirect> > RedirectUnselected;
84         
85         static void register_actions();
86
87   protected:
88         void set_stuff_from_route ();
89
90   private:
91         boost::shared_ptr<ARDOUR::Route>  _route;
92         ARDOUR::Session &   _session;
93         bool                _owner_is_mixer;
94
95         ARDOUR::Placement   _placement;
96
97         PluginSelector     & _plugin_selector;
98         RouteRedirectSelection  & _rr_selection;
99
100         void route_going_away ();
101
102         struct ModelColumns : public Gtk::TreeModel::ColumnRecord {
103             ModelColumns () {
104                     add (text);
105                     add (redirect);
106                     add (color);
107             }
108             Gtk::TreeModelColumn<std::string>       text;
109             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Redirect> > redirect;
110             Gtk::TreeModelColumn<Gdk::Color>        color;
111         };
112
113         ModelColumns columns;
114         Glib::RefPtr<Gtk::ListStore> model;
115         
116         void selection_changed ();
117
118         static bool get_colors;
119         static Gdk::Color* active_redirect_color;
120         static Gdk::Color* inactive_redirect_color;
121         
122         Gtk::EventBox          redirect_eventbox;
123         Gtk::HBox              redirect_hpacker;
124         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Redirect> > redirect_display;
125         Gtk::ScrolledWindow    redirect_scroller;
126
127         void object_drop (std::string type, uint32_t cnt, const boost::shared_ptr<ARDOUR::Redirect>*);
128
129         Width _width;
130         
131         Gtk::Menu *send_action_menu;
132         void build_send_action_menu ();
133
134         void new_send ();
135         void show_send_controls ();
136
137         Gtk::Menu *redirect_menu;
138         gint redirect_menu_map_handler (GdkEventAny *ev);
139         Gtk::Menu * build_redirect_menu ();
140         void build_redirect_tooltip (Gtk::EventBox&, string);
141         void show_redirect_menu (gint arg);
142
143         void choose_send ();
144         void send_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Redirect>, IOSelectorWindow*);
145         void choose_insert ();
146         void choose_plugin ();
147         void insert_plugin_chosen (boost::shared_ptr<ARDOUR::Plugin>);
148
149         bool no_redirect_redisplay;
150         bool ignore_delete;
151
152         bool redirect_button_press_event (GdkEventButton *);
153         bool redirect_button_release_event (GdkEventButton *);
154         void redisplay_redirects (void* src);
155         void add_redirect_to_display (boost::shared_ptr<ARDOUR::Redirect>);
156         void row_deleted (const Gtk::TreeModel::Path& path);
157         void show_redirect_active_r (ARDOUR::Redirect*, void *, boost::weak_ptr<ARDOUR::Redirect>);
158         void show_redirect_active (boost::weak_ptr<ARDOUR::Redirect>);
159         void show_redirect_name (void* src, boost::weak_ptr<ARDOUR::Redirect>);
160         string redirect_name (boost::weak_ptr<ARDOUR::Redirect>);
161
162         void remove_redirect_gui (boost::shared_ptr<ARDOUR::Redirect>);
163
164         void redirects_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
165         void compute_redirect_sort_keys ();
166         vector<sigc::connection> redirect_active_connections;
167         vector<sigc::connection> redirect_name_connections;
168         
169         bool redirect_drag_in_progress;
170         void redirect_drag_begin (GdkDragContext*);
171         void redirect_drag_end (GdkDragContext*);
172         void all_redirects_active(bool state);
173
174         void cut_redirects ();
175         void copy_redirects ();
176         void paste_redirects ();
177         void delete_redirects ();
178         void clear_redirects ();
179         void clone_redirects ();
180         void rename_redirects ();
181
182         void for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<ARDOUR::Redirect>));
183         void get_selected_redirects (vector<boost::shared_ptr<ARDOUR::Redirect> >&);
184
185         static Glib::RefPtr<Gtk::Action> paste_action;
186         void paste_redirect_list (std::list<boost::shared_ptr<ARDOUR::Redirect> >& redirects);
187         
188         void activate_redirect (boost::shared_ptr<ARDOUR::Redirect>);
189         void deactivate_redirect (boost::shared_ptr<ARDOUR::Redirect>);
190         void cut_redirect (boost::shared_ptr<ARDOUR::Redirect>);
191         void copy_redirect (boost::shared_ptr<ARDOUR::Redirect>);
192         void edit_redirect (boost::shared_ptr<ARDOUR::Redirect>);
193         void hide_redirect_editor (boost::shared_ptr<ARDOUR::Redirect>);
194         void rename_redirect (boost::shared_ptr<ARDOUR::Redirect>);
195
196         gint idle_delete_redirect (boost::weak_ptr<ARDOUR::Redirect>);
197
198         void weird_plugin_dialog (ARDOUR::Plugin& p, uint32_t streams, boost::shared_ptr<ARDOUR::IO> io);
199
200         static RedirectBox* _current_redirect_box;
201         static bool enter_box (GdkEventCrossing*, RedirectBox*);
202         static bool leave_box (GdkEventCrossing*, RedirectBox*);
203
204         static void rb_choose_plugin ();
205         static void rb_choose_insert ();
206         static void rb_choose_send ();
207         static void rb_clear ();
208         static void rb_cut ();
209         static void rb_copy ();
210         static void rb_paste ();
211         static void rb_delete ();
212         static void rb_rename ();
213         static void rb_select_all ();
214         static void rb_deselect_all ();
215         static void rb_activate ();
216         static void rb_deactivate ();
217         static void rb_activate_all ();
218         static void rb_deactivate_all ();
219         static void rb_edit ();
220         
221         void route_name_changed (void* src, PluginUIWindow* plugin_ui, boost::weak_ptr<ARDOUR::PluginInsert> pi);
222         std::string generate_redirect_title (boost::shared_ptr<ARDOUR::PluginInsert> pi);
223 };
224
225 #endif /* __ardour_gtk_redirect_box__ */