2 Copyright (C) 2000-2004 Paul Davis
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.
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.
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.
22 #include <sigc++/bind.h>
24 #include <pbd/lockmonitor.h>
25 #include <gtkmm2ext/gtk_ui.h>
26 #include <gtkmm2ext/utils.h>
27 #include <gtkmm2ext/stop_signal.h>
29 #include <ardour/audioengine.h>
30 #include <ardour/session.h>
31 #include <ardour/session_route.h>
32 #include <ardour/diskstream.h>
33 #include <ardour/plugin_manager.h>
36 #include "mixer_strip.h"
37 #include "plugin_selector.h"
38 #include "ardour_ui.h"
39 #include "check_mark.h"
42 #include "gui_thread.h"
46 using namespace ARDOUR;
48 using namespace Gtkmm2ext;
51 static const gchar* track_display_titles[] = {
55 static const gchar* snapshot_display_titles[] = {
60 static const gchar* group_list_titles[] = {
66 GdkPixmap* Mixer_UI::check_pixmap = 0;
67 GdkBitmap* Mixer_UI::check_mask = 0;
68 GdkPixmap* Mixer_UI::empty_pixmap = 0;
69 GdkBitmap* Mixer_UI::empty_mask = 0;
72 Mixer_UI::Mixer_UI (AudioEngine& eng)
73 : Gtk::Window (GTK_WINDOW_TOPLEVEL),
74 KeyboardTarget (*this, "mixer"),
76 track_display_list (internationalize (track_display_titles)),
77 group_list (internationalize (group_list_titles)),
78 snapshot_display (internationalize (snapshot_display_titles))
84 check_pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL,
85 gtk_widget_get_colormap (GTK_WIDGET(group_list.gobj())),
86 &check_mask, NULL, (gchar **) check_xpm);
87 empty_pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL,
88 gtk_widget_get_colormap (GTK_WIDGET(group_list.gobj())),
89 &empty_mask, NULL, (gchar **) empty_xpm);
91 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
94 scroller_base.signal_add_event()s (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
95 scroller_base.set_name ("MixerWindow");
96 scroller_base.signal_button_release_event().connect (mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
97 // add as last item of strip packer
98 strip_packer.pack_end (scroller_base, true, true);
100 scroller.add_with_viewport (strip_packer);
101 scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
103 track_display_list.column_titles_active();
104 track_display_list.set_name ("MixerTrackDisplayList");
105 track_display_list.set_shadow_type (Gtk::SHADOW_IN);
106 track_display_list.set_selection_mode (GTK_SELECTION_MULTIPLE);
107 track_display_list.set_reorderable (true);
108 track_display_list.set_size_request (75, -1);
109 track_display_scroller.add (track_display_list);
110 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
112 snapshot_display.column_titles_active();
113 snapshot_display.set_name ("MixerSnapshotDisplayList");
114 snapshot_display.set_shadow_type (Gtk::SHADOW_IN);
115 snapshot_display.set_selection_mode (GTK_SELECTION_SINGLE);
116 snapshot_display.set_reorderable (true);
117 snapshot_display.set_size_request (75, -1);
118 snapshot_display_scroller.add (snapshot_display);
119 snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
121 group_list_button_label.set_text (_("Mix Groups"));
122 group_list_button_label.set_name ("MixerGroupTitleButton");
123 group_list_button.add (group_list_button_label);
124 group_list_button.set_name ("MixerGroupTitleButton");
126 group_list.column_titles_hide();
127 group_list.set_name ("MixerGroupList");
128 group_list.set_shadow_type (Gtk::SHADOW_IN);
129 group_list.set_selection_mode (GTK_SELECTION_MULTIPLE);
130 group_list.set_reorderable (false);
131 group_list.set_size_request (75, -1);
132 group_list.set_column_auto_resize (0, true);
133 group_list_scroller.add (group_list);
134 group_list_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
136 group_list_vbox.pack_start (group_list_button, false, false);
137 group_list_vbox.pack_start (group_list_scroller, true, true);
139 list<string> stupid_list;
141 stupid_list.push_back ("");
142 stupid_list.push_back (_("-all-"));
144 group_list.rows().push_back (stupid_list);
145 group_list.rows().back().set_data (0);
146 group_list.rows().back().select();
147 group_list.cell(0,0).set_pixmap (check_pixmap);
149 track_display_frame.set_name("BaseFrame");
150 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
151 track_display_frame.add(track_display_scroller);
153 group_list_frame.set_name ("BaseFrame");
154 group_list_frame.set_shadow_type (Gtk::SHADOW_IN);
155 group_list_frame.add (group_list_vbox);
157 rhs_pane1.add1 (track_display_frame);
158 rhs_pane1.add2 (rhs_pane2);
160 rhs_pane2.add1 (group_list_frame);
161 rhs_pane2.add2 (snapshot_display_scroller);
163 list_vpacker.pack_start (rhs_pane1, true, true);
165 global_hpacker.pack_start (scroller, true, true);
166 global_hpacker.pack_start (out_packer, false, false);
168 list_hpane.add1(list_vpacker);
169 list_hpane.add2(global_hpacker);
171 rhs_pane1.size_allocate.connect_after (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler),
172 static_cast<Gtk::Paned*> (&rhs_pane1)));
173 rhs_pane2.size_allocate.connect_after (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler),
174 static_cast<Gtk::Paned*> (&rhs_pane2)));
175 list_hpane.size_allocate.connect_after (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler),
176 static_cast<Gtk::Paned*> (&list_hpane)));
179 rhs_pane1.set_data ("collapse-direction", (gpointer) 0);
180 rhs_pane2.set_data ("collapse-direction", (gpointer) 0);
181 list_hpane.set_data ("collapse-direction", (gpointer) 1);
183 rhs_pane1.signal_button_release_event().connect (bind (ptr_fun (pane_handler), static_cast<Paned*>(&rhs_pane1)));
184 rhs_pane2.signal_button_release_event().connect (bind (ptr_fun (pane_handler), static_cast<Paned*>(&rhs_pane2)));
185 list_hpane.signal_button_release_event().connect (bind (ptr_fun (pane_handler), static_cast<Paned*>(&list_hpane)));
187 global_vpacker.pack_start (list_hpane, true, true);
189 add (global_vpacker);
190 set_name ("MixerWindow");
191 set_title (_("ardour: mixer"));
192 set_wmclass (_("ardour_mixer"), "Ardour");
194 delete_event.connect (bind (ptr_fun (just_hide_it),
195 static_cast<Gtk::Window *>(this)));
196 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
198 snapshot_display.select_row.connect (mem_fun(*this, &Mixer_UI::snapshot_display_selected));
200 track_display_list.select_row.connect (mem_fun(*this, &Mixer_UI::track_display_selected));
201 track_display_list.unselect_row.connect (mem_fun(*this, &Mixer_UI::track_display_unselected));
202 track_display_list.row_move.connect (mem_fun(*this, &Mixer_UI::queue_track_display_reordered));
203 track_display_list.click_column.connect (mem_fun(*this, &Mixer_UI::track_column_click));
205 group_list_button.signal_clicked().connect (mem_fun(*this, &Mixer_UI::group_list_button_clicked));
206 group_list.signal_button_press_event().connect (mem_fun(*this, &Mixer_UI::group_list_button_press_event));
207 group_list.select_row.connect (mem_fun(*this, &Mixer_UI::group_selected));
208 group_list.unselect_row.connect (mem_fun(*this, &Mixer_UI::group_unselected));
210 _plugin_selector = new PluginSelector (PluginManager::the_manager());
211 _plugin_selector->signal_delete_event().connect (bind (ptr_fun (just_hide_it),
212 static_cast<Window *> (_plugin_selector)));
214 configure_event.connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
216 _selection.RoutesChanged.connect (mem_fun(*this, &Mixer_UI::follow_strip_selection));
219 Mixer_UI::~Mixer_UI ()
224 Mixer_UI::ensure_float (Window& win)
226 win.set_transient_for (*this);
230 Mixer_UI::show_window ()
234 /* now reset each strips width so the right widgets are shown */
236 CList_Helpers::RowList::iterator i;
238 for (i = track_display_list.rows().begin(); i != track_display_list.rows().end(); ++i) {
239 ms = (MixerStrip *) i->get_data ();
240 ms->set_width (ms->get_width());
245 Mixer_UI::add_strip (Route* route)
247 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_strip), route));
251 if (route->hidden()) {
255 strip = new MixerStrip (*this, *session, *route);
256 strips.push_back (strip);
258 strip->set_width (_strip_width);
261 const gchar* rowdata[1];
262 rowdata[0] = route->name().c_str();
264 track_display_list.freeze ();
265 track_display_list.rows().push_back (rowdata);
266 track_display_list.rows().back().set_data (strip);
267 track_display_list.thaw ();
269 if (strip->marked_for_display() || strip->packed()) {
270 track_display_list.rows().back().select ();
273 route->name_changed.connect (bind (mem_fun(*this, &Mixer_UI::strip_name_changed), strip));
274 strip->GoingAway.connect (bind (mem_fun(*this, &Mixer_UI::remove_strip), strip));
276 strip->signal_button_release_event().connect (bind (mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
278 // if (width() < gdk_screen_width()) {
279 // set_size_request (width() + (_strip_width == Wide ? 75 : 50), height());
284 Mixer_UI::remove_strip (MixerStrip* strip)
286 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::remove_strip), strip));
288 CList_Helpers::RowList::iterator ri;
289 list<MixerStrip *>::iterator i;
291 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
295 for (ri = track_display_list.rows().begin(); ri != track_display_list.rows().end(); ++ri) {
296 if ((MixerStrip *) ri->get_data () == strip) {
297 track_display_list.rows().erase (ri);
304 Mixer_UI::follow_strip_selection ()
306 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
307 (*i)->set_selected (_selection.selected (&(*i)->route()));
312 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
314 if (ev->button == 1) {
316 /* this allows the user to click on the strip to terminate comment
317 editing. XXX it needs improving so that we don't select the strip
321 ARDOUR_UI::instance()->allow_focus (false);
323 if (_selection.selected (&strip->route())) {
324 _selection.remove (&strip->route());
326 if (Keyboard::modifier_state_equals (ev->state, Keyboard::Shift)) {
327 _selection.add (&strip->route());
329 _selection.set (&strip->route());
338 Mixer_UI::connect_to_session (Session* sess)
342 string wintitle = _("ardour: mixer: ");
343 wintitle += session->name();
344 set_title (wintitle);
346 track_display_list.freeze ();
347 track_display_list.clear ();
349 session->foreach_route (this, &Mixer_UI::add_strip);
351 track_display_list.thaw ();
353 session->going_away.connect (mem_fun(*this, &Mixer_UI::disconnect_from_session));
354 session->RouteAdded.connect (mem_fun(*this, &Mixer_UI::add_strip));
355 session->mix_group_added.connect (mem_fun(*this, &Mixer_UI::add_mix_group));
357 session->foreach_mix_group(this, &Mixer_UI::add_mix_group);
359 session->StateSaved.connect (mem_fun(*this, &Mixer_UI::session_state_saved));
360 redisplay_snapshots ();
362 _plugin_selector->set_session (session);
368 Mixer_UI::disconnect_from_session ()
370 ENSURE_GUI_THREAD(mem_fun(*this, &Mixer_UI::disconnect_from_session));
373 set_title (_("ardour: mixer"));
375 hide_all_strips (false);
379 Mixer_UI::hide_all_strips (bool with_select)
382 CList_Helpers::RowList::iterator i;
384 track_display_list.freeze ();
386 for (i = track_display_list.rows().begin(); i != track_display_list.rows().end(); ++i) {
387 ms = (MixerStrip *) i->get_data ();
396 track_display_list.thaw ();
400 Mixer_UI::unselect_all_strips ()
402 hide_all_strips (false);
406 Mixer_UI::select_all_strips ()
408 CList_Helpers::RowList::iterator i;
410 for (i = track_display_list.rows().begin(); i != track_display_list.rows().end(); ++i) {
416 Mixer_UI::select_all_audiotrack_strips ()
419 CList_Helpers::RowList::iterator i;
421 track_display_list.freeze ();
423 for (i = track_display_list.rows().begin(); i != track_display_list.rows().end(); ++i) {
424 ms = (MixerStrip *) i->get_data ();
426 if (ms->is_audio_track()) {
431 track_display_list.thaw ();
435 Mixer_UI::unselect_all_audiotrack_strips ()
438 CList_Helpers::RowList::iterator i;
440 track_display_list.freeze ();
442 for (i = track_display_list.rows().begin(); i != track_display_list.rows().end(); ++i) {
443 ms = (MixerStrip *) i->get_data ();
445 if (ms->is_audio_track()) {
450 track_display_list.thaw ();
454 Mixer_UI::select_all_audiobus_strips ()
457 CList_Helpers::RowList::iterator i;
459 track_display_list.freeze ();
461 for (i = track_display_list.rows().begin(); i != track_display_list.rows().end(); ++i) {
462 ms = (MixerStrip *) i->get_data ();
464 if (!ms->is_audio_track()) {
469 track_display_list.thaw ();
473 Mixer_UI::unselect_all_audiobus_strips ()
476 CList_Helpers::RowList::iterator i;
478 track_display_list.freeze ();
480 for (i = track_display_list.rows().begin(); i != track_display_list.rows().end(); ++i) {
481 ms = (MixerStrip *) i->get_data ();
483 if (!ms->is_audio_track()) {
488 track_display_list.thaw ();
492 Mixer_UI::show_strip (MixerStrip* ms)
496 if (ms->route().master() || ms->route().control()) {
497 out_packer.pack_start (*ms, false, false);
499 strip_packer.pack_start (*ms, false, false);
501 ms->set_packed (true);
508 Mixer_UI::hide_strip (MixerStrip* ms)
511 if (ms->route().master() || ms->route().control()) {
512 out_packer.remove (*ms);
514 strip_packer.remove (*ms);
516 ms->set_packed (false);
521 Mixer_UI::start_updating ()
523 screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (mem_fun(*this, &Mixer_UI::update_strips));
524 fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun(*this, &Mixer_UI::fast_update_strips));
529 Mixer_UI::stop_updating ()
531 screen_update_connection.disconnect();
532 fast_screen_update_connection.disconnect();
537 Mixer_UI::update_strips ()
539 if (is_mapped () && session) {
540 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
547 Mixer_UI::fast_update_strips ()
549 if (is_mapped () && session) {
550 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
551 (*i)->fast_update ();
557 Mixer_UI::snapshot_display_selected (gint row, gint col, GdkEvent* ev)
561 if ((snap_name = (string*) snapshot_display.get_row_data(row)) != 0){
562 if (session->snap_name() == *snap_name){
565 string path = session->path();
566 ARDOUR_UI::instance()->load_session(path, *snap_name);
571 Mixer_UI::track_display_selected (gint row, gint col, GdkEvent* ev)
575 if ((strip = (MixerStrip *) track_display_list.get_row_data (row)) != 0) {
576 strip->set_marked_for_display (true);
579 /* just redraw the whole thing so that we get the right order
580 when we reinsert the strip.
583 track_display_reordered ();
588 Mixer_UI::track_display_unselected (gint row, gint col, GdkEvent* ev)
592 if ((strip = (MixerStrip *) track_display_list.get_row_data (row)) != 0) {
593 strip->set_marked_for_display (false);
599 Mixer_UI::unselect_strip_in_display (MixerStrip *strip)
601 CList_Helpers::RowIterator i;
603 if ((i = track_display_list.rows().find_data (strip)) != track_display_list.rows().end()) {
609 Mixer_UI::select_strip_in_display (MixerStrip *strip)
611 CList_Helpers::RowIterator i;
613 if ((i = track_display_list.rows().find_data (strip)) != track_display_list.rows().end()) {
619 Mixer_UI::queue_track_display_reordered (gint arg1, gint arg2)
621 /* the problem here is that we are called *before* the
622 list has been reordered. so just queue up
623 the actual re-drawer to happen once the re-ordering
627 Main::idle.connect (mem_fun(*this, &Mixer_UI::track_display_reordered));
631 Mixer_UI::track_display_reordered ()
633 CList_Helpers::RowList::iterator i;
636 // hide_all_strips (false);
638 for (order = 0, i = track_display_list.rows().begin(); i != track_display_list.rows().end(); ++i, ++order) {
639 MixerStrip* strip = (MixerStrip *) (*i)->get_data ();
640 if (strip->marked_for_display()) {
641 strip->route().set_order_key (N_("signal"), order);
642 strip_packer.reorder_child (*strip, -1); /* put at end */
650 Mixer_UI::track_column_click (gint col)
652 if (track_menu == 0) {
656 track_menu->popup (0, 0);
660 Mixer_UI::build_track_menu ()
662 using namespace Menu_Helpers;
665 track_menu = new Menu;
666 track_menu->set_name ("ArdourContextMenu");
667 MenuList& items = track_menu->items();
668 track_menu->set_name ("ArdourContextMenu");
670 items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Mixer_UI::select_all_strips)));
671 items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Mixer_UI::unselect_all_strips)));
672 items.push_back (MenuElem (_("Show All AudioTrack MixerStrips"), mem_fun(*this, &Mixer_UI::select_all_audiotrack_strips)));
673 items.push_back (MenuElem (_("Hide All AudioTrack MixerStrips"), mem_fun(*this, &Mixer_UI::unselect_all_audiotrack_strips)));
674 items.push_back (MenuElem (_("Show All AudioBus MixerStrips"), mem_fun(*this, &Mixer_UI::select_all_audiobus_strips)));
675 items.push_back (MenuElem (_("Hide All AudioBus MixerStrips"), mem_fun(*this, &Mixer_UI::unselect_all_audiobus_strips)));
680 Mixer_UI::strip_name_changed (void* src, MixerStrip* mx)
682 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::strip_name_changed), src, mx));
684 CList_Helpers::RowList::iterator i;
686 if ((i = track_display_list.rows().find_data (mx)) == track_display_list.rows().end()) {
687 error << _("track display list item for renamed strip not found!") << endmsg;
691 track_display_list.cell ((*i)->get_row_num(), 0).set_text (mx->route().name());
695 Mixer_UI::new_mix_group ()
697 ArdourPrompter prompter;
700 prompter.set_prompt (_("Name for new mix group"));
701 prompter.done.connect (Main::quit.slot());
703 prompter.show_all ();
707 if (prompter.status != Gtkmm2ext::Prompter::entered) {
711 prompter.get_result (result);
713 if (result.length()) {
714 session->add_mix_group (result);
719 Mixer_UI::group_list_button_clicked ()
727 Mixer_UI::group_list_button_press_event (GdkEventButton* ev)
732 if (group_list.get_selection_info ((int)ev->x, (int)ev->y, &row, &col) == 0) {
738 if (Keyboard::is_edit_event (ev)) {
739 // RouteGroup* group = (RouteGroup *) group_list.row(row).get_data ();
741 // edit_mix_group (group);
743 return stop_signal (group_list, "button_press_event");
746 /* allow regular select to occur */
751 stop_signal (group_list, "button_press_event");
752 if ((group = (RouteGroup *) group_list.row(row).get_data ()) != 0) {
753 group->set_active (!group->is_active (), this);
762 Mixer_UI::group_selected (gint row, gint col, GdkEvent* ev)
764 RouteGroup* group = (RouteGroup *) group_list.row(row).get_data ();
767 group->set_hidden (false, this);
769 /* the master group */
771 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
775 track_display_reordered ();
780 Mixer_UI::group_unselected (gint row, gint col, GdkEvent* ev)
783 RouteGroup* group = (RouteGroup *) group_list.row(row).get_data ();
786 group->set_hidden (true, this);
788 /* the master group */
790 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
797 Mixer_UI::group_flags_changed (void* src, RouteGroup* group)
799 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::group_flags_changed), src, group));
805 CList_Helpers::RowIterator ri = group_list.rows().find_data (group);
807 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
808 if ((*i)->route().mix_group() == group) {
809 if (group->is_hidden ()) {
810 unselect_strip_in_display(*i);
812 select_strip_in_display(*i);
818 if (group->is_active()) {
819 group_list.cell (ri->get_row_num(),0).set_pixmap (check_pixmap, check_mask);
821 group_list.cell (ri->get_row_num(),0).set_pixmap (empty_pixmap, empty_mask);
826 Mixer_UI::add_mix_group (RouteGroup* group)
829 ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_mix_group), group));
833 names.push_back ("");
834 names.push_back (group->name());
836 group_list.rows().push_back (names);
837 group_list.rows().back().set_data (group);
839 /* update display to reflect group flags */
841 group_flags_changed (0, group);
843 group->FlagsChanged.connect (bind (mem_fun(*this, &Mixer_UI::group_flags_changed), group));
847 Mixer_UI::redisplay_snapshots ()
853 vector<string*>* states;
854 if ((states = session->possible_states()) == 0) {
858 snapshot_display.freeze();
859 snapshot_display.rows().clear ();
861 for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
862 string statename = *(*i);
863 const char *rowtext[1];
865 rowtext[0] = statename.c_str();
867 snapshot_display.rows().push_back (rowtext);
868 snapshot_display.rows().back().set_data (new string (statename), deferred_delete<string>);
874 snapshot_display.thaw();
878 Mixer_UI::session_state_saved (string snap_name)
880 ENSURE_GUI_THREAD (bind (mem_fun(*this, &Mixer_UI::session_state_saved), snap_name));
881 redisplay_snapshots ();
885 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
887 using namespace Menu_Helpers;
889 if (Keyboard::is_context_menu_event (ev)) {
890 ARDOUR_UI::instance()->add_route();
898 Mixer_UI::set_strip_width (Width w)
902 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
909 Mixer_UI::set_state (const XMLNode& node)
911 const XMLProperty* prop;
913 int x, y, width, height, xoff, yoff;
915 if ((geometry = find_named_node (node, "geometry")) == 0) {
917 width = default_width;
918 height = default_height;
926 width = atoi(geometry->property("x_size")->value().c_str());
927 height = atoi(geometry->property("y_size")->value().c_str());
928 x = atoi(geometry->property("x_pos")->value().c_str());
929 y = atoi(geometry->property("y_pos")->value().c_str());
930 xoff = atoi(geometry->property("x_off")->value().c_str());
931 yoff = atoi(geometry->property("y_off")->value().c_str());
934 set_default_size(width, height);
935 set_uposition(x, y-yoff);
937 if ((prop = node.property ("narrow-strips"))) {
938 if (prop->value() == "yes") {
939 set_strip_width (Narrow);
941 set_strip_width (Wide);
949 Mixer_UI::get_state (void)
951 XMLNode* node = new XMLNode ("Mixer");
954 Gdk_Window win = get_window();
956 int x, y, xoff, yoff, width, height;
957 win.get_root_origin(x, y);
958 win.get_position(xoff, yoff);
959 win.get_size(width, height);
961 XMLNode* geometry = new XMLNode ("geometry");
963 snprintf(buf, sizeof(buf), "%d", width);
964 geometry->add_property(X_("x_size"), string(buf));
965 snprintf(buf, sizeof(buf), "%d", height);
966 geometry->add_property(X_("y_size"), string(buf));
967 snprintf(buf, sizeof(buf), "%d", x);
968 geometry->add_property(X_("x_pos"), string(buf));
969 snprintf(buf, sizeof(buf), "%d", y);
970 geometry->add_property(X_("y_pos"), string(buf));
971 snprintf(buf, sizeof(buf), "%d", xoff);
972 geometry->add_property(X_("x_off"), string(buf));
973 snprintf(buf, sizeof(buf), "%d", yoff);
974 geometry->add_property(X_("y_off"), string(buf));
976 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&rhs_pane1)->gobj()));
977 geometry->add_property(X_("mixer_rhs_pane1_pos"), string(buf));
978 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&rhs_pane2)->gobj()));
979 geometry->add_property(X_("mixer_rhs_pane2_pos"), string(buf));
980 snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&list_hpane)->gobj()));
981 geometry->add_property(X_("mixer_list_hpane_pos"), string(buf));
983 node->add_child_nocopy (*geometry);
986 node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no");
993 Mixer_UI::pane_allocation_handler (GtkAllocation *alloc, Gtk::Paned* which)
996 XMLProperty* prop = 0;
998 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1001 static int32_t done[3] = { 0, 0, 0 };
1003 if ((geometry = find_named_node (*node, "geometry")) == 0) {
1004 width = default_width;
1005 height = default_height;
1007 width = atoi(geometry->property("x_size")->value());
1008 height = atoi(geometry->property("y_size")->value());
1011 if (which == static_cast<Gtk::Paned*> (&rhs_pane1)) {
1017 if (!geometry || (prop = geometry->property("mixer_rhs_pane1_pos")) == 0) {
1019 snprintf (buf, sizeof(buf), "%d", pos);
1021 pos = atoi (prop->value());
1024 if ((done[0] = GTK_WIDGET(rhs_pane1.gobj())->allocation.height > pos)) {
1025 rhs_pane1.set_position (pos);
1028 } else if (which == static_cast<Gtk::Paned*> (&rhs_pane2)) {
1034 if (!geometry || (prop = geometry->property("mixer_rhs_pane2_pos")) == 0) {
1036 snprintf (buf, sizeof(buf), "%d", pos);
1038 pos = atoi (prop->value());
1041 if ((done[1] = GTK_WIDGET(rhs_pane2.gobj())->allocation.height > pos)) {
1042 rhs_pane2.set_position (pos);
1045 } else if (which == static_cast<Gtk::Paned*> (&list_hpane)) {
1051 if (!geometry || (prop = geometry->property("mixer_list_hpane_pos")) == 0) {
1053 snprintf (buf, sizeof(buf), "%d", pos);
1055 pos = atoi (prop->value());
1058 if ((done[2] = GTK_WIDGET(list_hpane.gobj())->allocation.width > pos)) {
1059 list_hpane.set_position (pos);