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.
21 #include "gtk2ardour-config.h"
26 #include <sigc++/bind.h>
28 #include <gtkmm/accelmap.h>
30 #include "pbd/convert.h"
31 #include "pbd/stacktrace.h"
32 #include <glibmm/thread.h>
34 #include <gtkmm2ext/gtk_ui.h>
35 #include <gtkmm2ext/utils.h>
36 #include <gtkmm2ext/tearoff.h>
37 #include <gtkmm2ext/window_title.h>
39 #include "ardour/audio_track.h"
40 #include "ardour/plugin_manager.h"
41 #include "ardour/route_group.h"
42 #include "ardour/session.h"
43 #include "ardour/session_route.h"
47 #include "mixer_strip.h"
48 #include "monitor_section.h"
49 #include "plugin_selector.h"
50 #include "ardour_ui.h"
54 #include "gui_thread.h"
55 #include "mixer_group_tabs.h"
59 using namespace ARDOUR
;
63 using namespace Gtkmm2ext
;
69 : Window (Gtk::WINDOW_TOPLEVEL
)
71 _strip_width
= Config
->get_default_narrow_ms() ? Narrow
: Wide
;
74 no_track_list_redisplay
= false;
75 in_group_row_change
= false;
77 strip_redisplay_does_not_reset_order_keys
= false;
78 strip_redisplay_does_not_sync_order_keys
= false;
81 Route::SyncOrderKeys
.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::sync_order_keys
, this, _1
), gui_context());
83 scroller_base
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
);
84 scroller_base
.set_name ("MixerWindow");
85 scroller_base
.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release
));
86 // add as last item of strip packer
87 strip_packer
.pack_end (scroller_base
, true, true);
89 _group_tabs
= new MixerGroupTabs (this);
90 VBox
* b
= manage (new VBox
);
91 b
->pack_start (*_group_tabs
, PACK_SHRINK
);
92 b
->pack_start (strip_packer
);
96 scroller
.set_policy (Gtk::POLICY_ALWAYS
, Gtk::POLICY_AUTOMATIC
);
98 setup_track_display ();
100 group_model
= ListStore::create (group_columns
);
101 group_display
.set_model (group_model
);
102 group_display
.append_column (_("Group"), group_columns
.text
);
103 group_display
.append_column (_("Show"), group_columns
.visible
);
104 group_display
.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
105 group_display
.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
106 group_display
.get_column (0)->set_expand(true);
107 group_display
.get_column (1)->set_expand(false);
108 group_display
.set_name ("MixerGroupList");
109 group_display
.get_selection()->set_mode (Gtk::SELECTION_SINGLE
);
110 group_display
.set_reorderable (true);
111 group_display
.set_headers_visible (true);
112 group_display
.set_rules_hint (true);
114 /* name is directly editable */
116 CellRendererText
* name_cell
= dynamic_cast<CellRendererText
*>(group_display
.get_column_cell_renderer (0));
117 name_cell
->property_editable() = true;
118 name_cell
->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit
));
120 /* use checkbox for the active column */
122 CellRendererToggle
* active_cell
= dynamic_cast<CellRendererToggle
*>(group_display
.get_column_cell_renderer (1));
123 active_cell
->property_activatable() = true;
124 active_cell
->property_radio() = false;
126 group_model
->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change
));
128 group_display
.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press
), false);
130 group_display_scroller
.add (group_display
);
131 group_display_scroller
.set_policy (Gtk::POLICY_NEVER
, Gtk::POLICY_AUTOMATIC
);
133 HBox
* route_group_display_button_box
= manage (new HBox());
135 Button
* route_group_add_button
= manage (new Button ());
136 Button
* route_group_remove_button
= manage (new Button ());
140 w
= manage (new Image (Stock::ADD
, ICON_SIZE_BUTTON
));
142 route_group_add_button
->add (*w
);
144 w
= manage (new Image (Stock::REMOVE
, ICON_SIZE_BUTTON
));
146 route_group_remove_button
->add (*w
);
148 route_group_display_button_box
->set_homogeneous (true);
150 route_group_add_button
->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group
));
151 route_group_remove_button
->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group
));
153 route_group_display_button_box
->add (*route_group_add_button
);
154 route_group_display_button_box
->add (*route_group_remove_button
);
156 group_display_vbox
.pack_start (group_display_scroller
, true, true);
157 group_display_vbox
.pack_start (*route_group_display_button_box
, false, false);
159 group_display_frame
.set_name ("BaseFrame");
160 group_display_frame
.set_shadow_type (Gtk::SHADOW_IN
);
161 group_display_frame
.add (group_display_vbox
);
163 rhs_pane1
.pack1 (track_display_frame
);
164 rhs_pane1
.pack2 (group_display_frame
);
166 list_vpacker
.pack_start (rhs_pane1
, true, true);
168 global_hpacker
.pack_start (scroller
, true, true);
170 /* current gtk-quartz has dirty updates on borders like this one */
171 global_hpacker
.pack_start (out_packer
, false, false, 0);
173 global_hpacker
.pack_start (out_packer
, false, false, 12);
175 list_hpane
.add1(list_vpacker
);
176 list_hpane
.add2(global_hpacker
);
178 rhs_pane1
.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::pane_allocation_handler
),
179 static_cast<Gtk::Paned
*> (&rhs_pane1
)));
180 list_hpane
.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::pane_allocation_handler
),
181 static_cast<Gtk::Paned
*> (&list_hpane
)));
183 global_vpacker
.pack_start (list_hpane
, true, true);
185 add (global_vpacker
);
186 set_name ("MixerWindow");
188 WindowTitle
title(Glib::get_application_name());
190 set_title (title
.get_string());
192 set_wmclass (X_("ardour_mixer"), PROGRAM_NAME
);
194 add_accel_group (ActionManager::ui_manager
->get_accel_group());
196 signal_delete_event().connect (sigc::mem_fun (*this, &Mixer_UI::hide_window
));
197 add_events (Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
);
199 signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler
));
201 _selection
.RoutesChanged
.connect (sigc::mem_fun(*this, &Mixer_UI::follow_strip_selection
));
203 route_group_display_button_box
->show();
204 route_group_add_button
->show();
205 route_group_remove_button
->show();
207 global_hpacker
.show();
208 global_vpacker
.show();
210 scroller_base
.show();
211 scroller_hpacker
.show();
212 mixer_scroller_vpacker
.show();
214 group_display_button_label
.show();
215 group_display_button
.show();
216 group_display_scroller
.show();
217 group_display_vbox
.show();
218 group_display_frame
.show();
223 group_display
.show();
225 auto_rebinding
= FALSE
;
227 MixerStrip::CatchDeletion
.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::remove_strip
, this, _1
), gui_context());
229 MonitorSection::setup_knob_images ();
231 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
232 _plugin_selector
= new PluginSelector (PluginManager::the_manager ());
236 Mixer_UI::~Mixer_UI ()
241 Mixer_UI::ensure_float (Window
& win
)
243 win
.set_transient_for (*this);
247 Mixer_UI::show_window ()
251 set_window_pos_and_size ();
253 /* now reset each strips width so the right widgets are shown */
256 TreeModel::Children rows
= track_model
->children();
257 TreeModel::Children::iterator ri
;
259 for (ri
= rows
.begin(); ri
!= rows
.end(); ++ri
) {
260 ms
= (*ri
)[track_columns
.strip
];
261 ms
->set_width_enum (ms
->get_width_enum (), ms
->width_owner());
268 Mixer_UI::hide_window (GdkEventAny
*ev
)
270 get_window_pos_and_size ();
273 return just_hide_it(ev
, static_cast<Gtk::Window
*>(this));
278 Mixer_UI::add_strip (RouteList
& routes
)
280 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_strip
, routes
)
284 no_track_list_redisplay
= true;
285 strip_redisplay_does_not_sync_order_keys
= true;
287 for (RouteList::iterator x
= routes
.begin(); x
!= routes
.end(); ++x
) {
288 boost::shared_ptr
<Route
> route
= (*x
);
290 if (route
->is_hidden()) {
294 if (route
->is_monitor()) {
295 if (!_monitor_section
) {
296 _monitor_section
= new MonitorSection (_session
);
297 out_packer
.pack_end (_monitor_section
->tearoff(), false, false);
299 _monitor_section
->set_session (_session
);
302 _monitor_section
->tearoff().show_all ();
304 XMLNode
* mnode
= ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
306 _monitor_section
->tearoff().set_state (*mnode
);
309 /* no regular strip shown for control out */
314 strip
= new MixerStrip (*this, _session
, route
);
315 strips
.push_back (strip
);
317 Config
->get_default_narrow_ms() ? _strip_width
= Narrow
: _strip_width
= Wide
;
319 if (strip
->width_owner() != strip
) {
320 strip
->set_width_enum (_strip_width
, this);
325 TreeModel::Row row
= *(track_model
->append());
326 row
[track_columns
.text
] = route
->name();
327 row
[track_columns
.visible
] = strip
->marked_for_display();
328 row
[track_columns
.route
] = route
;
329 row
[track_columns
.strip
] = strip
;
331 if (route
->order_key (N_("signal")) == -1) {
332 route
->set_order_key (N_("signal"), track_model
->children().size()-1);
335 route
->PropertyChanged
.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::strip_property_changed
, this, _1
, strip
), gui_context());
337 strip
->WidthChanged
.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed
));
338 strip
->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event
), strip
));
341 no_track_list_redisplay
= false;
343 redisplay_track_list ();
345 strip_redisplay_does_not_sync_order_keys
= false;
349 Mixer_UI::remove_strip (MixerStrip
* strip
)
351 if (_session
&& _session
->deletion_in_progress()) {
352 /* its all being taken care of */
356 ENSURE_GUI_THREAD (*this, &Mixer_UI::remove_strip
, strip
);
358 cerr
<< "Mixer UI removing strip for " << strip
<< endl
;
360 TreeModel::Children rows
= track_model
->children();
361 TreeModel::Children::iterator ri
;
362 list
<MixerStrip
*>::iterator i
;
364 if ((i
= find (strips
.begin(), strips
.end(), strip
)) != strips
.end()) {
368 strip_redisplay_does_not_sync_order_keys
= true;
370 for (ri
= rows
.begin(); ri
!= rows
.end(); ++ri
) {
371 if ((*ri
)[track_columns
.strip
] == strip
) {
372 track_model
->erase (ri
);
377 strip_redisplay_does_not_sync_order_keys
= false;
381 Mixer_UI::sync_order_keys (string
const & src
)
383 TreeModel::Children rows
= track_model
->children();
384 TreeModel::Children::iterator ri
;
386 if (src
== N_("signal") || !_session
|| (_session
->state_of_the_state() & (Session::Loading
|Session::Deletion
)) || rows
.empty()) {
390 std::map
<int,int> keys
;
392 bool changed
= false;
395 for (ri
= rows
.begin(); ri
!= rows
.end(); ++ri
, ++order
) {
396 boost::shared_ptr
<Route
> route
= (*ri
)[track_columns
.route
];
397 unsigned int old_key
= order
;
398 unsigned int new_key
= route
->order_key (N_("signal"));
400 keys
[new_key
] = old_key
;
402 if (new_key
!= old_key
) {
407 if (keys
.size() != rows
.size()) {
408 PBD::stacktrace (cerr
, 20);
410 assert(keys
.size() == rows
.size());
412 // Remove any gaps in keys caused by automation children tracks
413 vector
<int> neworder
;
414 for (std::map
<int,int>::const_iterator i
= keys
.begin(); i
!= keys
.end(); ++i
) {
415 neworder
.push_back(i
->second
);
417 assert(neworder
.size() == rows
.size());
420 strip_redisplay_does_not_reset_order_keys
= true;
421 track_model
->reorder (neworder
);
422 strip_redisplay_does_not_reset_order_keys
= false;
427 Mixer_UI::follow_strip_selection ()
429 for (list
<MixerStrip
*>::iterator i
= strips
.begin(); i
!= strips
.end(); ++i
) {
430 (*i
)->set_selected (_selection
.selected ((*i
)->route()));
435 Mixer_UI::strip_button_release_event (GdkEventButton
*ev
, MixerStrip
*strip
)
437 if (ev
->button
== 1) {
439 /* this allows the user to click on the strip to terminate comment
440 editing. XXX it needs improving so that we don't select the strip
444 if (_selection
.selected (strip
->route())) {
445 _selection
.remove (strip
->route());
447 if (Keyboard::modifier_state_equals (ev
->state
, Keyboard::TertiaryModifier
)) {
448 _selection
.add (strip
->route());
450 _selection
.set (strip
->route());
459 Mixer_UI::set_session (Session
* sess
)
461 SessionHandlePtr::set_session (sess
);
463 if (_plugin_selector
) {
464 _plugin_selector
->set_session (_session
);
467 _group_tabs
->set_session (sess
);
473 XMLNode
* node
= ARDOUR_UI::instance()->mixer_settings();
476 WindowTitle
title(_session
->name());
478 title
+= Glib::get_application_name();
480 set_title (title
.get_string());
482 initial_track_display ();
484 _session
->RouteAdded
.connect (_session_connections
, invalidator (*this), ui_bind (&Mixer_UI::add_strip
, this, _1
), gui_context());
485 _session
->route_group_added
.connect (_session_connections
, invalidator (*this), ui_bind (&Mixer_UI::add_route_group
, this, _1
), gui_context());
486 _session
->route_group_removed
.connect (_session_connections
, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed
, this), gui_context());
487 _session
->config
.ParameterChanged
.connect (_session_connections
, invalidator (*this), ui_bind (&Mixer_UI::parameter_changed
, this, _1
), gui_context());
489 Config
->ParameterChanged
.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::parameter_changed
, this, _1
), gui_context ());
491 route_groups_changed ();
501 Mixer_UI::session_going_away ()
503 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away
)
505 group_model
->clear ();
507 track_model
->clear ();
509 for (list
<MixerStrip
*>::iterator i
= strips
.begin(); i
!= strips
.end(); ++i
) {
513 if (_monitor_section
) {
514 _monitor_section
->tearoff().hide_visible ();
519 WindowTitle
title(Glib::get_application_name());
521 set_title (title
.get_string());
525 SessionHandlePtr::session_going_away ();
529 Mixer_UI::show_strip (MixerStrip
* ms
)
531 TreeModel::Children rows
= track_model
->children();
532 TreeModel::Children::iterator i
;
534 for (i
= rows
.begin(); i
!= rows
.end(); ++i
) {
536 MixerStrip
* strip
= (*i
)[track_columns
.strip
];
538 (*i
)[track_columns
.visible
] = true;
545 Mixer_UI::hide_strip (MixerStrip
* ms
)
547 TreeModel::Children rows
= track_model
->children();
548 TreeModel::Children::iterator i
;
550 for (i
= rows
.begin(); i
!= rows
.end(); ++i
) {
552 MixerStrip
* strip
= (*i
)[track_columns
.strip
];
554 (*i
)[track_columns
.visible
] = false;
561 Mixer_UI::start_updating ()
563 fast_screen_update_connection
= ARDOUR_UI::instance()->SuperRapidScreenUpdate
.connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips
));
568 Mixer_UI::stop_updating ()
570 fast_screen_update_connection
.disconnect();
575 Mixer_UI::fast_update_strips ()
577 if (is_mapped () && _session
) {
578 for (list
<MixerStrip
*>::iterator i
= strips
.begin(); i
!= strips
.end(); ++i
) {
579 (*i
)->fast_update ();
585 Mixer_UI::set_all_strips_visibility (bool yn
)
587 TreeModel::Children rows
= track_model
->children();
588 TreeModel::Children::iterator i
;
590 no_track_list_redisplay
= true;
592 for (i
= rows
.begin(); i
!= rows
.end(); ++i
) {
594 TreeModel::Row row
= (*i
);
595 MixerStrip
* strip
= row
[track_columns
.strip
];
601 if (strip
->route()->is_master() || strip
->route()->is_monitor()) {
605 (*i
)[track_columns
.visible
] = yn
;
608 no_track_list_redisplay
= false;
609 redisplay_track_list ();
614 Mixer_UI::set_all_audio_visibility (int tracks
, bool yn
)
616 TreeModel::Children rows
= track_model
->children();
617 TreeModel::Children::iterator i
;
619 no_track_list_redisplay
= true;
621 for (i
= rows
.begin(); i
!= rows
.end(); ++i
) {
622 TreeModel::Row row
= (*i
);
623 MixerStrip
* strip
= row
[track_columns
.strip
];
629 if (strip
->route()->is_master() || strip
->route()->is_monitor()) {
633 boost::shared_ptr
<AudioTrack
> at
= strip
->audio_track();
637 (*i
)[track_columns
.visible
] = yn
;
641 if (at
) { /* track */
642 (*i
)[track_columns
.visible
] = yn
;
648 (*i
)[track_columns
.visible
] = yn
;
654 no_track_list_redisplay
= false;
655 redisplay_track_list ();
659 Mixer_UI::hide_all_routes ()
661 set_all_strips_visibility (false);
665 Mixer_UI::show_all_routes ()
667 set_all_strips_visibility (true);
671 Mixer_UI::show_all_audiobus ()
673 set_all_audio_visibility (2, true);
676 Mixer_UI::hide_all_audiobus ()
678 set_all_audio_visibility (2, false);
682 Mixer_UI::show_all_audiotracks()
684 set_all_audio_visibility (1, true);
687 Mixer_UI::hide_all_audiotracks ()
689 set_all_audio_visibility (1, false);
693 Mixer_UI::track_list_reorder (const TreeModel::Path
&, const TreeModel::iterator
&, int* /*new_order*/)
695 strip_redisplay_does_not_sync_order_keys
= true;
696 _session
->set_remote_control_ids();
697 redisplay_track_list ();
698 strip_redisplay_does_not_sync_order_keys
= false;
702 Mixer_UI::track_list_change (const Gtk::TreeModel::Path
&, const Gtk::TreeModel::iterator
&)
704 // never reset order keys because of a property change
705 strip_redisplay_does_not_reset_order_keys
= true;
706 _session
->set_remote_control_ids();
707 redisplay_track_list ();
708 strip_redisplay_does_not_reset_order_keys
= false;
712 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path
&)
714 /* this could require an order sync */
715 if (_session
&& !_session
->deletion_in_progress()) {
716 _session
->set_remote_control_ids();
717 redisplay_track_list ();
722 Mixer_UI::redisplay_track_list ()
724 TreeModel::Children rows
= track_model
->children();
725 TreeModel::Children::iterator i
;
728 if (no_track_list_redisplay
) {
732 for (order
= 0, i
= rows
.begin(); i
!= rows
.end(); ++i
, ++order
) {
733 MixerStrip
* strip
= (*i
)[track_columns
.strip
];
736 /* we're in the middle of changing a row, don't worry */
740 bool visible
= (*i
)[track_columns
.visible
];
743 strip
->set_marked_for_display (true);
744 strip
->route()->set_order_key (N_("signal"), order
);
746 if (!strip_redisplay_does_not_reset_order_keys
) {
747 strip
->route()->set_order_key (N_("signal"), order
);
750 if (strip
->packed()) {
752 if (strip
->route()->is_master() || strip
->route()->is_monitor()) {
753 out_packer
.reorder_child (*strip
, -1);
755 strip_packer
.reorder_child (*strip
, -1); /* put at end */
760 if (strip
->route()->is_master() || strip
->route()->is_monitor()) {
761 out_packer
.pack_start (*strip
, false, false);
763 strip_packer
.pack_start (*strip
, false, false);
765 strip
->set_packed (true);
771 strip
->set_marked_for_display (false);
773 if (strip
->route()->is_master() || strip
->route()->is_monitor()) {
774 /* do nothing, these cannot be hidden */
776 if (strip
->packed()) {
777 strip_packer
.remove (*strip
);
778 strip
->set_packed (false);
784 if (!strip_redisplay_does_not_reset_order_keys
&& !strip_redisplay_does_not_sync_order_keys
) {
785 _session
->sync_order_keys (N_("signal"));
788 // Resigc::bind all of the midi controls automatically
791 auto_rebind_midi_controls ();
793 _group_tabs
->set_dirty ();
797 Mixer_UI::strip_width_changed ()
799 _group_tabs
->set_dirty ();
802 TreeModel::Children rows
= track_model
->children();
803 TreeModel::Children::iterator i
;
806 for (order
= 0, i
= rows
.begin(); i
!= rows
.end(); ++i
, ++order
) {
807 MixerStrip
* strip
= (*i
)[track_columns
.strip
];
813 bool visible
= (*i
)[track_columns
.visible
];
824 Mixer_UI::set_auto_rebinding( bool val
)
828 auto_rebinding
= TRUE
;
829 Session::AutoBindingOff();
833 auto_rebinding
= FALSE
;
834 Session::AutoBindingOn();
839 Mixer_UI::toggle_auto_rebinding()
843 set_auto_rebinding( FALSE
);
848 set_auto_rebinding( TRUE
);
851 auto_rebind_midi_controls();
855 Mixer_UI::auto_rebind_midi_controls ()
857 TreeModel::Children rows
= track_model
->children();
858 TreeModel::Children::iterator i
;
861 // Create bindings for all visible strips and remove those that are not visible
862 pos
= 1; // 0 is reserved for the master strip
863 for (i
= rows
.begin(); i
!= rows
.end(); ++i
) {
864 MixerStrip
* strip
= (*i
)[track_columns
.strip
];
866 if ( (*i
)[track_columns
.visible
] == true ) { // add bindings for
867 // make the actual binding
868 //cout<<"Auto Binding: Visible Strip Found: "<<strip->name()<<endl;
870 int controlValue
= pos
;
871 if( strip
->route()->is_master() ) {
878 PBD::Controllable::CreateBinding ( strip
->solo_button
->get_controllable().get(), controlValue
, 0);
879 PBD::Controllable::CreateBinding ( strip
->mute_button
->get_controllable().get(), controlValue
, 1);
881 if( strip
->is_audio_track() ) {
882 PBD::Controllable::CreateBinding ( strip
->rec_enable_button
->get_controllable().get(), controlValue
, 2);
885 PBD::Controllable::CreateBinding ( strip
->gpm
.get_controllable().get(), controlValue
, 3);
886 PBD::Controllable::CreateBinding ( strip
->panners
.get_controllable().get(), controlValue
, 4);
889 else { // Remove any existing binding
890 PBD::Controllable::DeleteBinding ( strip
->solo_button
->get_controllable().get() );
891 PBD::Controllable::DeleteBinding ( strip
->mute_button
->get_controllable().get() );
893 if( strip
->is_audio_track() ) {
894 PBD::Controllable::DeleteBinding ( strip
->rec_enable_button
->get_controllable().get() );
897 PBD::Controllable::DeleteBinding ( strip
->gpm
.get_controllable().get() );
898 PBD::Controllable::DeleteBinding ( strip
->panners
.get_controllable().get() ); // This only takes the first panner if there are multiples...
905 struct SignalOrderRouteSorter
{
906 bool operator() (boost::shared_ptr
<Route
> a
, boost::shared_ptr
<Route
> b
) {
907 /* use of ">" forces the correct sort order */
908 return a
->order_key (N_("signal")) < b
->order_key (N_("signal"));
913 Mixer_UI::initial_track_display ()
915 boost::shared_ptr
<RouteList
> routes
= _session
->get_routes();
916 RouteList
copy (*routes
);
917 SignalOrderRouteSorter sorter
;
921 no_track_list_redisplay
= true;
923 track_model
->clear ();
927 no_track_list_redisplay
= false;
929 redisplay_track_list ();
933 Mixer_UI::show_track_list_menu ()
935 if (track_menu
== 0) {
939 track_menu
->popup (1, gtk_get_current_event_time());
943 Mixer_UI::track_display_button_press (GdkEventButton
* ev
)
945 if (Keyboard::is_context_menu_event (ev
)) {
946 show_track_list_menu ();
951 TreeModel::Path path
;
952 TreeViewColumn
* column
;
956 if (!track_display
.get_path_at_pos ((int)ev
->x
, (int)ev
->y
, path
, column
, cellx
, celly
)) {
960 switch (GPOINTER_TO_UINT (column
->get_data (X_("colnum")))) {
962 /* allow normal processing to occur */
965 case 1: /* visibility */
967 if ((iter
= track_model
->get_iter (path
))) {
968 MixerStrip
* strip
= (*iter
)[track_columns
.strip
];
971 if (!strip
->route()->is_master() && !strip
->route()->is_monitor()) {
972 bool visible
= (*iter
)[track_columns
.visible
];
973 (*iter
)[track_columns
.visible
] = !visible
;
976 track_display
.queue_draw();
991 Mixer_UI::build_track_menu ()
993 using namespace Menu_Helpers
;
996 track_menu
= new Menu
;
997 track_menu
->set_name ("ArdourContextMenu");
998 MenuList
& items
= track_menu
->items();
1000 items
.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes
)));
1001 items
.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes
)));
1002 items
.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks
)));
1003 items
.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks
)));
1004 items
.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus
)));
1005 items
.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus
)));
1010 Mixer_UI::strip_property_changed (const PropertyChange
& what_changed
, MixerStrip
* mx
)
1012 if (!what_changed
.contains (ARDOUR::Properties::name
)) {
1016 ENSURE_GUI_THREAD (*this, &Mixer_UI::strip_name_changed
, what_changed
, mx
)
1018 TreeModel::Children rows
= track_model
->children();
1019 TreeModel::Children::iterator i
;
1021 for (i
= rows
.begin(); i
!= rows
.end(); ++i
) {
1022 if ((*i
)[track_columns
.strip
] == mx
) {
1023 (*i
)[track_columns
.text
] = mx
->route()->name();
1028 error
<< _("track display list item for renamed strip not found!") << endmsg
;
1032 Mixer_UI::group_display_button_press (GdkEventButton
* ev
)
1034 TreeModel::Path path
;
1035 TreeViewColumn
* column
;
1039 if (!group_display
.get_path_at_pos ((int)ev
->x
, (int)ev
->y
, path
, column
, cellx
, celly
)) {
1043 TreeIter iter
= group_model
->get_iter (path
);
1048 RouteGroup
* group
= (*iter
)[group_columns
.group
];
1050 if (Keyboard::is_context_menu_event (ev
)) {
1051 _group_tabs
->get_menu(group
)->popup (1, ev
->time
);
1055 switch (GPOINTER_TO_UINT (column
->get_data (X_("colnum")))) {
1057 if (Keyboard::is_edit_event (ev
)) {
1059 // edit_route_group (group);
1061 group_display
.queue_draw();
1070 bool visible
= (*iter
)[group_columns
.visible
];
1071 (*iter
)[group_columns
.visible
] = !visible
;
1073 group_display
.queue_draw();
1086 Mixer_UI::activate_all_route_groups ()
1088 _session
->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation
), true));
1092 Mixer_UI::disable_all_route_groups ()
1094 _session
->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation
), false));
1098 Mixer_UI::route_groups_changed ()
1100 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed
)
1102 /* just rebuild the while thing */
1104 group_model
->clear ();
1108 row
= *(group_model
->append());
1109 row
[group_columns
.visible
] = true;
1110 row
[group_columns
.text
] = (_("-all-"));
1111 row
[group_columns
.group
] = 0;
1114 _session
->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group
));
1116 _group_tabs
->set_dirty ();
1120 Mixer_UI::new_route_group ()
1124 _group_tabs
->run_new_group_dialog (rl
);
1128 Mixer_UI::remove_selected_route_group ()
1130 Glib::RefPtr
<TreeSelection
> selection
= group_display
.get_selection();
1131 TreeView::Selection::ListHandle_Path rows
= selection
->get_selected_rows ();
1137 TreeView::Selection::ListHandle_Path::iterator i
= rows
.begin();
1140 /* selection mode is single, so rows.begin() is it */
1142 if ((iter
= group_model
->get_iter (*i
))) {
1144 RouteGroup
* rg
= (*iter
)[group_columns
.group
];
1147 _session
->remove_route_group (*rg
);
1153 Mixer_UI::route_group_property_changed (RouteGroup
* group
, const PropertyChange
& change
)
1155 if (in_group_row_change
) {
1159 /* force an update of any mixer strips that are using this group,
1160 otherwise mix group names don't change in mixer strips
1163 for (list
<MixerStrip
*>::iterator i
= strips
.begin(); i
!= strips
.end(); ++i
) {
1164 if ((*i
)->route_group() == group
) {
1165 (*i
)->route_group_changed();
1169 TreeModel::iterator i
;
1170 TreeModel::Children rows
= group_model
->children();
1171 Glib::RefPtr
<TreeSelection
> selection
= group_display
.get_selection();
1173 in_group_row_change
= true;
1175 for (i
= rows
.begin(); i
!= rows
.end(); ++i
) {
1176 if ((*i
)[group_columns
.group
] == group
) {
1177 (*i
)[group_columns
.visible
] = !group
->is_hidden ();
1178 (*i
)[group_columns
.text
] = group
->name ();
1183 in_group_row_change
= false;
1185 if (change
.contains (Properties::name
)) {
1186 _group_tabs
->set_dirty ();
1191 Mixer_UI::route_group_name_edit (const std::string
& path
, const std::string
& new_text
)
1196 if ((iter
= group_model
->get_iter (path
))) {
1198 if ((group
= (*iter
)[group_columns
.group
]) == 0) {
1202 if (new_text
!= group
->name()) {
1203 group
->set_name (new_text
);
1209 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path
&, const Gtk::TreeModel::iterator
& iter
)
1213 if (in_group_row_change
) {
1217 if ((group
= (*iter
)[group_columns
.group
]) == 0) {
1221 if ((*iter
)[group_columns
.visible
]) {
1222 for (list
<MixerStrip
*>::iterator i
= strips
.begin(); i
!= strips
.end(); ++i
) {
1223 if ((*i
)->route_group() == group
) {
1228 for (list
<MixerStrip
*>::iterator i
= strips
.begin(); i
!= strips
.end(); ++i
) {
1229 if ((*i
)->route_group() == group
) {
1235 std::string name
= (*iter
)[group_columns
.text
];
1237 if (name
!= group
->name()) {
1238 group
->set_name (name
);
1244 Mixer_UI::add_route_group (RouteGroup
* group
)
1246 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group
, group
)
1249 in_group_row_change
= true;
1251 TreeModel::Row row
= *(group_model
->append());
1252 row
[group_columns
.visible
] = true;
1253 row
[group_columns
.group
] = group
;
1254 if (!group
->name().empty()) {
1255 row
[group_columns
.text
] = group
->name();
1257 row
[group_columns
.text
] = _("unnamed");
1261 group
->PropertyChanged
.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::route_group_property_changed
, this, group
, _1
), gui_context());
1264 TreeViewColumn
* col
= group_display
.get_column (0);
1265 CellRendererText
* name_cell
= dynamic_cast<CellRendererText
*>(group_display
.get_column_cell_renderer (0));
1266 group_display
.set_cursor (group_model
->get_path (row
), *col
, *name_cell
, true);
1269 _group_tabs
->set_dirty ();
1271 in_group_row_change
= false;
1275 Mixer_UI::strip_scroller_button_release (GdkEventButton
* ev
)
1277 using namespace Menu_Helpers
;
1279 if (Keyboard::is_context_menu_event (ev
)) {
1280 ARDOUR_UI::instance()->add_route (this);
1288 Mixer_UI::set_strip_width (Width w
)
1292 for (list
<MixerStrip
*>::iterator i
= strips
.begin(); i
!= strips
.end(); ++i
) {
1293 (*i
)->set_width_enum (w
, this);
1298 Mixer_UI::set_window_pos_and_size ()
1300 resize (m_width
, m_height
);
1301 move (m_root_x
, m_root_y
);
1305 Mixer_UI::get_window_pos_and_size ()
1307 get_position(m_root_x
, m_root_y
);
1308 get_size(m_width
, m_height
);
1312 Mixer_UI::set_state (const XMLNode
& node
)
1314 const XMLProperty
* prop
;
1317 m_width
= default_width
;
1318 m_height
= default_height
;
1322 if ((geometry
= find_named_node (node
, "geometry")) != 0) {
1326 if ((prop
= geometry
->property("x_size")) == 0) {
1327 prop
= geometry
->property ("x-size");
1330 m_width
= atoi(prop
->value());
1332 if ((prop
= geometry
->property("y_size")) == 0) {
1333 prop
= geometry
->property ("y-size");
1336 m_height
= atoi(prop
->value());
1339 if ((prop
= geometry
->property ("x_pos")) == 0) {
1340 prop
= geometry
->property ("x-pos");
1343 m_root_x
= atoi (prop
->value());
1346 if ((prop
= geometry
->property ("y_pos")) == 0) {
1347 prop
= geometry
->property ("y-pos");
1350 m_root_y
= atoi (prop
->value());
1354 set_window_pos_and_size ();
1356 if ((prop
= node
.property ("narrow-strips"))) {
1357 if (string_is_affirmative (prop
->value())) {
1358 set_strip_width (Narrow
);
1360 set_strip_width (Wide
);
1364 if ((prop
= node
.property ("show-mixer"))) {
1365 if (string_is_affirmative (prop
->value())) {
1374 Mixer_UI::get_state (void)
1376 XMLNode
* node
= new XMLNode ("Mixer");
1378 if (is_realized()) {
1379 Glib::RefPtr
<Gdk::Window
> win
= get_window();
1381 get_window_pos_and_size ();
1383 XMLNode
* geometry
= new XMLNode ("geometry");
1385 snprintf(buf
, sizeof(buf
), "%d", m_width
);
1386 geometry
->add_property(X_("x_size"), string(buf
));
1387 snprintf(buf
, sizeof(buf
), "%d", m_height
);
1388 geometry
->add_property(X_("y_size"), string(buf
));
1389 snprintf(buf
, sizeof(buf
), "%d", m_root_x
);
1390 geometry
->add_property(X_("x_pos"), string(buf
));
1391 snprintf(buf
, sizeof(buf
), "%d", m_root_y
);
1392 geometry
->add_property(X_("y_pos"), string(buf
));
1394 // written only for compatibility, they are not used.
1395 snprintf(buf
, sizeof(buf
), "%d", 0);
1396 geometry
->add_property(X_("x_off"), string(buf
));
1397 snprintf(buf
, sizeof(buf
), "%d", 0);
1398 geometry
->add_property(X_("y_off"), string(buf
));
1400 snprintf(buf
,sizeof(buf
), "%d",gtk_paned_get_position (static_cast<Paned
*>(&rhs_pane1
)->gobj()));
1401 geometry
->add_property(X_("mixer_rhs_pane1_pos"), string(buf
));
1402 snprintf(buf
,sizeof(buf
), "%d",gtk_paned_get_position (static_cast<Paned
*>(&list_hpane
)->gobj()));
1403 geometry
->add_property(X_("mixer_list_hpane_pos"), string(buf
));
1405 node
->add_child_nocopy (*geometry
);
1408 node
->add_property ("narrow-strips", _strip_width
== Narrow
? "yes" : "no");
1410 node
->add_property ("show-mixer", _visible
? "yes" : "no");
1417 Mixer_UI::pane_allocation_handler (Allocation
&, Gtk::Paned
* which
)
1420 XMLProperty
* prop
= 0;
1422 XMLNode
* node
= ARDOUR_UI::instance()->mixer_settings();
1425 static int32_t done
[3] = { 0, 0, 0 };
1427 width
= default_width
;
1428 height
= default_height
;
1430 if ((geometry
= find_named_node (*node
, "geometry")) != 0) {
1433 if ((prop
= geometry
->property ("x_size")) == 0) {
1434 prop
= geometry
->property ("x-size");
1437 width
= atoi (prop
->value());
1439 if ((prop
= geometry
->property ("y_size")) == 0) {
1440 prop
= geometry
->property ("y-size");
1443 height
= atoi (prop
->value());
1447 if (which
== static_cast<Gtk::Paned
*> (&rhs_pane1
)) {
1453 if (!geometry
|| (prop
= geometry
->property("mixer-rhs-pane1-pos")) == 0) {
1455 snprintf (buf
, sizeof(buf
), "%d", pos
);
1457 pos
= atoi (prop
->value());
1460 if ((done
[0] = GTK_WIDGET(rhs_pane1
.gobj())->allocation
.height
> pos
)) {
1461 rhs_pane1
.set_position (pos
);
1464 } else if (which
== static_cast<Gtk::Paned
*> (&list_hpane
)) {
1470 if (!geometry
|| (prop
= geometry
->property("mixer-list-hpane-pos")) == 0) {
1472 snprintf (buf
, sizeof(buf
), "%d", pos
);
1474 pos
= atoi (prop
->value());
1477 if ((done
[2] = GTK_WIDGET(list_hpane
.gobj())->allocation
.width
> pos
)) {
1478 list_hpane
.set_position (pos
);
1483 Mixer_UI::scroll_left ()
1485 Adjustment
* adj
= scroller
.get_hscrollbar()->get_adjustment();
1486 /* stupid GTK: can't rely on clamping across versions */
1487 scroller
.get_hscrollbar()->set_value (max (adj
->get_lower(), adj
->get_value() - adj
->get_step_increment()));
1491 Mixer_UI::scroll_right ()
1493 Adjustment
* adj
= scroller
.get_hscrollbar()->get_adjustment();
1494 /* stupid GTK: can't rely on clamping across versions */
1495 scroller
.get_hscrollbar()->set_value (min (adj
->get_upper(), adj
->get_value() + adj
->get_step_increment()));
1499 Mixer_UI::on_key_press_event (GdkEventKey
* ev
)
1501 switch (ev
->keyval
) {
1514 return key_press_focus_accelerator_handler (*this, ev
);
1518 Mixer_UI::on_key_release_event (GdkEventKey
* ev
)
1520 return Gtk::Window::on_key_release_event (ev
);
1521 // return key_press_focus_accelerator_handler (*this, ev);
1526 Mixer_UI::on_scroll_event (GdkEventScroll
* ev
)
1528 switch (ev
->direction
) {
1529 case GDK_SCROLL_LEFT
:
1533 if (ev
->state
& Keyboard::TertiaryModifier
) {
1539 case GDK_SCROLL_RIGHT
:
1543 case GDK_SCROLL_DOWN
:
1544 if (ev
->state
& Keyboard::TertiaryModifier
) {
1556 Mixer_UI::parameter_changed (string
const & p
)
1558 if (p
== "show-group-tabs") {
1559 bool const s
= _session
->config
.get_show_group_tabs ();
1561 _group_tabs
->show ();
1563 _group_tabs
->hide ();
1565 } else if (p
== "default-narrow_ms") {
1566 bool const s
= Config
->get_default_narrow_ms ();
1567 for (list
<MixerStrip
*>::iterator i
= strips
.begin(); i
!= strips
.end(); ++i
) {
1568 (*i
)->set_width_enum (s
? Narrow
: Wide
, this);
1574 Mixer_UI::set_route_group_activation (RouteGroup
* g
, bool a
)
1576 g
->set_active (a
, this);
1580 Mixer_UI::plugin_selector()
1582 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
1583 if (!_plugin_selector
)
1584 _plugin_selector
= new PluginSelector (PluginManager::the_manager ());
1587 return _plugin_selector
;
1591 Mixer_UI::setup_track_display ()
1593 track_model
= ListStore::create (track_columns
);
1594 track_display
.set_model (track_model
);
1595 track_display
.append_column (_("Strips"), track_columns
.text
);
1596 track_display
.append_column (_("Show"), track_columns
.visible
);
1597 track_display
.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
1598 track_display
.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
1599 track_display
.get_column (0)->set_expand(true);
1600 track_display
.get_column (1)->set_expand(false);
1601 track_display
.set_name (X_("MixerTrackDisplayList"));
1602 track_display
.get_selection()->set_mode (Gtk::SELECTION_NONE
);
1603 track_display
.set_reorderable (true);
1604 track_display
.set_headers_visible (true);
1606 track_model
->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete
));
1607 track_model
->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_change
));
1608 track_model
->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder
));
1610 CellRendererToggle
* track_list_visible_cell
= dynamic_cast<CellRendererToggle
*>(track_display
.get_column_cell_renderer (1));
1611 track_list_visible_cell
->property_activatable() = true;
1612 track_list_visible_cell
->property_radio() = false;
1614 track_display
.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press
), false);
1616 track_display_scroller
.add (track_display
);
1617 track_display_scroller
.set_policy (Gtk::POLICY_NEVER
, Gtk::POLICY_AUTOMATIC
);
1619 VBox
* v
= manage (new VBox
);
1621 v
->pack_start (track_display_scroller
, true, true);
1623 Button
* b
= manage (new Button
);
1625 Widget
* w
= manage (new Image (Stock::ADD
, ICON_SIZE_BUTTON
));
1629 b
->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus
));
1631 v
->pack_start (*b
, false, false);
1633 track_display_frame
.set_name("BaseFrame");
1634 track_display_frame
.set_shadow_type (Gtk::SHADOW_IN
);
1635 track_display_frame
.add (*v
);
1637 track_display_scroller
.show();
1638 track_display_frame
.show();
1639 track_display
.show();
1643 Mixer_UI::new_track_or_bus ()
1645 ARDOUR_UI::instance()->add_route (this);