X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmixer_ui.cc;h=0d3f42c1d5e2fb24f462bb55087bb09371fd7023;hb=c4ac43749048c4c0e0ab3656d39384112a628742;hp=9c9e76d5df8a6fb809a6b66f672e58e5f23e548e;hpb=e0aaed6d65f160c328cb8b56d7c6552ee15d65e2;p=ardour.git diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 9c9e76d5df..0d3f42c1d5 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2004 Paul Davis + Copyright (C) 2000-2004 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -46,6 +47,7 @@ #include "utils.h" #include "actions.h" #include "gui_thread.h" +#include "mixer_group_tabs.h" #include "i18n.h" @@ -61,11 +63,12 @@ using PBD::atoi; Mixer_UI::Mixer_UI () : Window (Gtk::WINDOW_TOPLEVEL) + , _plugin_selector (0) { session = 0; _strip_width = Config->get_default_narrow_ms() ? Narrow : Wide; track_menu = 0; - mix_group_context_menu = 0; + route_group_context_menu = 0; no_track_list_redisplay = false; in_group_row_change = false; _visible = false; @@ -75,13 +78,19 @@ Mixer_UI::Mixer_UI () Route::SyncOrderKeys.connect (mem_fun (*this, &Mixer_UI::sync_order_keys)); - scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); - scroller_base.set_name ("MixerWindow"); - scroller_base.signal_button_release_event().connect (mem_fun(*this, &Mixer_UI::strip_scroller_button_release)); + scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); + scroller_base.set_name ("MixerWindow"); + scroller_base.signal_button_release_event().connect (mem_fun(*this, &Mixer_UI::strip_scroller_button_release)); // add as last item of strip packer strip_packer.pack_end (scroller_base, true, true); - scroller.add (strip_packer); + _group_tabs = new MixerGroupTabs (this); + VBox* b = manage (new VBox); + b->pack_start (*_group_tabs, PACK_SHRINK); + b->pack_start (strip_packer); + b->show_all (); + + scroller.add (*b); scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC); track_model = ListStore::create (track_columns); @@ -113,14 +122,11 @@ Mixer_UI::Mixer_UI () group_model = ListStore::create (group_columns); group_display.set_model (group_model); group_display.append_column (_("Group"), group_columns.text); - group_display.append_column (_("Active"), group_columns.active); group_display.append_column (_("Show"), group_columns.visible); group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0)); group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1)); - group_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2)); group_display.get_column (0)->set_expand(true); group_display.get_column (1)->set_expand(false); - group_display.get_column (2)->set_expand(false); group_display.set_name ("MixerGroupList"); group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE); group_display.set_reorderable (true); @@ -131,7 +137,7 @@ Mixer_UI::Mixer_UI () CellRendererText* name_cell = dynamic_cast(group_display.get_column_cell_renderer (0)); name_cell->property_editable() = true; - name_cell->signal_edited().connect (mem_fun (*this, &Mixer_UI::mix_group_name_edit)); + name_cell->signal_edited().connect (mem_fun (*this, &Mixer_UI::route_group_name_edit)); /* use checkbox for the active column */ @@ -139,44 +145,38 @@ Mixer_UI::Mixer_UI () active_cell->property_activatable() = true; active_cell->property_radio() = false; - /* use checkbox for the visible column */ - - active_cell = dynamic_cast(group_display.get_column_cell_renderer (2)); - active_cell->property_activatable() = true; - active_cell->property_radio() = false; - - group_model->signal_row_changed().connect (mem_fun (*this, &Mixer_UI::mix_group_row_change)); + group_model->signal_row_changed().connect (mem_fun (*this, &Mixer_UI::route_group_row_change)); group_display.signal_button_press_event().connect (mem_fun (*this, &Mixer_UI::group_display_button_press), false); group_display_scroller.add (group_display); group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); - HBox* mix_group_display_button_box = manage (new HBox()); + HBox* route_group_display_button_box = manage (new HBox()); - Button* mix_group_add_button = manage (new Button ()); - Button* mix_group_remove_button = manage (new Button ()); + Button* route_group_add_button = manage (new Button ()); + Button* route_group_remove_button = manage (new Button ()); Widget* w; w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON)); w->show(); - mix_group_add_button->add (*w); + route_group_add_button->add (*w); w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON)); w->show(); - mix_group_remove_button->add (*w); + route_group_remove_button->add (*w); - mix_group_display_button_box->set_homogeneous (true); + route_group_display_button_box->set_homogeneous (true); - mix_group_add_button->signal_clicked().connect (mem_fun (*this, &Mixer_UI::new_mix_group)); - mix_group_remove_button->signal_clicked().connect (mem_fun (*this, &Mixer_UI::remove_selected_mix_group)); + route_group_add_button->signal_clicked().connect (mem_fun (*this, &Mixer_UI::new_route_group)); + route_group_remove_button->signal_clicked().connect (mem_fun (*this, &Mixer_UI::remove_selected_route_group)); - mix_group_display_button_box->add (*mix_group_remove_button); - mix_group_display_button_box->add (*mix_group_add_button); + route_group_display_button_box->add (*route_group_remove_button); + route_group_display_button_box->add (*route_group_add_button); group_display_vbox.pack_start (group_display_scroller, true, true); - group_display_vbox.pack_start (*mix_group_display_button_box, false, false); + group_display_vbox.pack_start (*route_group_display_button_box, false, false); track_display_frame.set_name("BaseFrame"); track_display_frame.set_shadow_type (Gtk::SHADOW_IN); @@ -201,16 +201,16 @@ Mixer_UI::Mixer_UI () list_hpane.add1(list_vpacker); list_hpane.add2(global_hpacker); - rhs_pane1.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), + rhs_pane1.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), static_cast (&rhs_pane1))); - list_hpane.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), + list_hpane.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), static_cast (&list_hpane))); - + global_vpacker.pack_start (list_hpane, true, true); add (global_vpacker); set_name ("MixerWindow"); - + WindowTitle title(Glib::get_application_name()); title += _("Mixer"); set_title (title.get_string()); @@ -222,15 +222,13 @@ Mixer_UI::Mixer_UI () signal_delete_event().connect (mem_fun (*this, &Mixer_UI::hide_window)); add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK); - _plugin_selector = new PluginSelector (PluginManager::the_manager()); - signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler)); _selection.RoutesChanged.connect (mem_fun(*this, &Mixer_UI::follow_strip_selection)); - mix_group_display_button_box->show(); - mix_group_add_button->show(); - mix_group_remove_button->show(); + route_group_display_button_box->show(); + route_group_add_button->show(); + route_group_remove_button->show(); global_hpacker.show(); global_vpacker.show(); @@ -275,13 +273,13 @@ Mixer_UI::show_window () /* now reset each strips width so the right widgets are shown */ MixerStrip* ms; - + TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator ri; - + for (ri = rows.begin(); ri != rows.end(); ++ri) { ms = (*ri)[track_columns.strip]; - ms->set_width (ms->get_width(), ms->width_owner()); + ms->set_width_enum (ms->get_width_enum (), ms->width_owner()); } } _visible = true; @@ -301,7 +299,7 @@ void Mixer_UI::add_strip (RouteList& routes) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_strip), routes)); - + MixerStrip* strip; no_track_list_redisplay = true; @@ -313,20 +311,18 @@ Mixer_UI::add_strip (RouteList& routes) if (route->is_hidden()) { return; } - + strip = new MixerStrip (*this, *session, route); strips.push_back (strip); - - Config->get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide; Config->get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide; if (strip->width_owner() != strip) { - strip->set_width (_strip_width, this); + strip->set_width_enum (_strip_width, this); } show_strip (strip); - + TreeModel::Row row = *(track_model->append()); row[track_columns.text] = route->name(); row[track_columns.visible] = strip->marked_for_display(); @@ -336,20 +332,18 @@ Mixer_UI::add_strip (RouteList& routes) if (route->order_key (N_("signal")) == -1) { route->set_order_key (N_("signal"), track_model->children().size()-1); } - + route->NameChanged.connect (bind (mem_fun(*this, &Mixer_UI::strip_name_changed), strip)); strip->GoingAway.connect (bind (mem_fun(*this, &Mixer_UI::remove_strip), strip)); -#ifdef GTKOSX - strip->WidthChanged.connect (mem_fun(*this, &Mixer_UI::queue_draw_all_strips)); -#endif + strip->WidthChanged.connect (mem_fun(*this, &Mixer_UI::strip_width_changed)); strip->signal_button_release_event().connect (bind (mem_fun(*this, &Mixer_UI::strip_button_release_event), strip)); } no_track_list_redisplay = false; redisplay_track_list (); - + strip_redisplay_does_not_sync_order_keys = false; } @@ -378,48 +372,40 @@ Mixer_UI::remove_strip (MixerStrip* strip) strip_redisplay_does_not_sync_order_keys = false; } -const char* -Mixer_UI::get_order_key() -{ - return X_("signal"); -#if 0 - if (Config->get_sync_all_route_ordering()) { - return X_("editor"); - } else { - return X_("signal"); - } -#endif -} - void -Mixer_UI::sync_order_keys (const char *src) +Mixer_UI::sync_order_keys (string const & src) { - vector neworder; TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator ri; - if ((strcmp (src, get_order_key()) == 0) || !session || (session->state_of_the_state() & Session::Loading) || rows.empty()) { + if (src == N_("signal") || !session || (session->state_of_the_state() & Session::Loading) || rows.empty()) { return; } - for (ri = rows.begin(); ri != rows.end(); ++ri) { - neworder.push_back (0); - } + std::map keys; bool changed = false; - int order; - for (order = 0, ri = rows.begin(); ri != rows.end(); ++ri, ++order) { + unsigned order = 0; + for (ri = rows.begin(); ri != rows.end(); ++ri, ++order) { boost::shared_ptr route = (*ri)[track_columns.route]; - int old_key = order; - int new_key = route->order_key (get_order_key()); + unsigned int old_key = order; + unsigned int new_key = route->order_key (N_("signal")); - neworder[new_key] = old_key; + keys[new_key] = old_key; if (new_key != old_key) { changed = true; } } + assert(keys.size() == rows.size()); + + // Remove any gaps in keys caused by automation children tracks + vector neworder; + for (std::map::const_iterator i = keys.begin(); i != keys.end(); ++i) { + neworder.push_back(i->second); + } + assert(neworder.size() == rows.size()); if (changed) { strip_redisplay_does_not_reset_order_keys = true; @@ -445,7 +431,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) editing. XXX it needs improving so that we don't select the strip at the same time. */ - + if (_selection.selected (strip->route())) { _selection.remove (strip->route()); } else { @@ -463,7 +449,6 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) void Mixer_UI::connect_to_session (Session* sess) { - session = sess; XMLNode* node = ARDOUR_UI::instance()->mixer_settings(); @@ -479,17 +464,21 @@ Mixer_UI::connect_to_session (Session* sess) session->GoingAway.connect (mem_fun(*this, &Mixer_UI::disconnect_from_session)); session->RouteAdded.connect (mem_fun(*this, &Mixer_UI::add_strip)); - session->mix_group_added.connect (mem_fun(*this, &Mixer_UI::add_mix_group)); - session->mix_group_removed.connect (mem_fun(*this, &Mixer_UI::mix_groups_changed)); + session->route_group_added.connect (mem_fun(*this, &Mixer_UI::add_route_group)); + session->route_group_removed.connect (mem_fun(*this, &Mixer_UI::route_groups_changed)); + session->config.ParameterChanged.connect (mem_fun (*this, &Mixer_UI::parameter_changed)); + + route_groups_changed (); - mix_groups_changed (); - - _plugin_selector->set_session (session); + if (_plugin_selector) + _plugin_selector->set_session (session); if (_visible) { show_window(); } + _group_tabs->connect_to_session (sess); + start_updating (); } @@ -497,14 +486,14 @@ void Mixer_UI::disconnect_from_session () { ENSURE_GUI_THREAD(mem_fun(*this, &Mixer_UI::disconnect_from_session)); - + group_model->clear (); _selection.clear (); WindowTitle title(Glib::get_application_name()); title += _("Mixer"); set_title (title.get_string()); - + stop_updating (); } @@ -513,9 +502,9 @@ Mixer_UI::show_strip (MixerStrip* ms) { TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; - + for (i = rows.begin(); i != rows.end(); ++i) { - + MixerStrip* strip = (*i)[track_columns.strip]; if (strip == ms) { (*i)[track_columns.visible] = true; @@ -529,9 +518,9 @@ Mixer_UI::hide_strip (MixerStrip* ms) { TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; - + for (i = rows.begin(); i != rows.end(); ++i) { - + MixerStrip* strip = (*i)[track_columns.strip]; if (strip == ms) { (*i)[track_columns.visible] = false; @@ -576,11 +565,11 @@ Mixer_UI::set_all_strips_visibility (bool yn) TreeModel::Row row = (*i); MixerStrip* strip = row[track_columns.strip]; - + if (strip == 0) { continue; } - + if (strip->route()->is_master() || strip->route()->is_control()) { continue; } @@ -594,9 +583,9 @@ Mixer_UI::set_all_strips_visibility (bool yn) void -Mixer_UI::set_all_audio_visibility (int tracks, bool yn) +Mixer_UI::set_all_audio_visibility (int tracks, bool yn) { - TreeModel::Children rows = track_model->children(); + TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; no_track_list_redisplay = true; @@ -619,13 +608,13 @@ Mixer_UI::set_all_audio_visibility (int tracks, bool yn) case 0: (*i)[track_columns.visible] = yn; break; - + case 1: if (at) { /* track */ (*i)[track_columns.visible] = yn; } break; - + case 2: if (!at) { /* bus */ (*i)[track_columns.visible] = yn; @@ -673,7 +662,7 @@ Mixer_UI::hide_all_audiotracks () } void -Mixer_UI::track_list_reorder (const TreeModel::Path& path, const TreeModel::iterator& iter, int* new_order) +Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/) { strip_redisplay_does_not_sync_order_keys = true; session->set_remote_control_ids(); @@ -682,17 +671,17 @@ Mixer_UI::track_list_reorder (const TreeModel::Path& path, const TreeModel::iter } void -Mixer_UI::track_list_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter) +Mixer_UI::track_list_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) { // never reset order keys because of a property change - strip_redisplay_does_not_reset_order_keys = true; + strip_redisplay_does_not_reset_order_keys = true; session->set_remote_control_ids(); redisplay_track_list (); strip_redisplay_does_not_reset_order_keys = false; } void -Mixer_UI::track_list_delete (const Gtk::TreeModel::Path& path) +Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&) { /* this could require an order sync */ session->set_remote_control_ids(); @@ -725,8 +714,8 @@ Mixer_UI::redisplay_track_list () strip->route()->set_order_key (N_("signal"), order); if (!strip_redisplay_does_not_reset_order_keys) { - strip->route()->set_order_key (get_order_key(), order); - } + strip->route()->set_order_key (N_("signal"), order); + } if (strip->packed()) { @@ -749,6 +738,8 @@ Mixer_UI::redisplay_track_list () } else { + strip->set_marked_for_display (false); + if (strip->route()->is_master() || strip->route()->is_control()) { /* do nothing, these cannot be hidden */ } else { @@ -759,21 +750,25 @@ Mixer_UI::redisplay_track_list () } } } - + if (!strip_redisplay_does_not_reset_order_keys && !strip_redisplay_does_not_sync_order_keys) { - session->sync_order_keys (get_order_key()); + session->sync_order_keys (N_("signal")); } // Rebind all of the midi controls automatically - + if (auto_rebinding) auto_rebind_midi_controls (); + + _group_tabs->set_dirty (); } -#ifdef GTKOSX void -Mixer_UI::queue_draw_all_strips () +Mixer_UI::strip_width_changed () { + _group_tabs->set_dirty (); + +#ifdef GTKOSX TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; long order; @@ -786,14 +781,15 @@ Mixer_UI::queue_draw_all_strips () } bool visible = (*i)[track_columns.visible]; - + if (visible) { strip->queue_draw(); } } -} #endif +} + void Mixer_UI::set_auto_rebinding( bool val ) { @@ -809,14 +805,14 @@ Mixer_UI::set_auto_rebinding( bool val ) } } -void -Mixer_UI::toggle_auto_rebinding() +void +Mixer_UI::toggle_auto_rebinding() { if (auto_rebinding) { set_auto_rebinding( FALSE ); } - + else { set_auto_rebinding( TRUE ); @@ -825,8 +821,8 @@ Mixer_UI::toggle_auto_rebinding() auto_rebind_midi_controls(); } -void -Mixer_UI::auto_rebind_midi_controls () +void +Mixer_UI::auto_rebind_midi_controls () { TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; @@ -836,7 +832,7 @@ Mixer_UI::auto_rebind_midi_controls () pos = 1; // 0 is reserved for the master strip for (i = rows.begin(); i != rows.end(); ++i) { MixerStrip* strip = (*i)[track_columns.strip]; - + if ( (*i)[track_columns.visible] == true ) { // add bindings for // make the actual binding //cout<<"Auto Binding: Visible Strip Found: "<name()< a, boost::shared_ptr b) { /* use of ">" forces the correct sort order */ - return a->order_key (Mixer_UI::get_order_key()) < b->order_key (Mixer_UI::get_order_key()); + return a->order_key (N_("signal")) < b->order_key (N_("signal")); } }; @@ -891,7 +887,7 @@ Mixer_UI::initial_track_display () SignalOrderRouteSorter sorter; copy.sort (sorter); - + no_track_list_redisplay = true; track_model->clear (); @@ -926,7 +922,7 @@ Mixer_UI::track_display_button_press (GdkEventButton* ev) TreeViewColumn* column; int cellx; int celly; - + if (!track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { return false; } @@ -970,7 +966,7 @@ Mixer_UI::build_track_menu () track_menu = new Menu; track_menu->set_name ("ArdourContextMenu"); MenuList& items = track_menu->items(); - + items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Mixer_UI::show_all_routes))); items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Mixer_UI::hide_all_routes))); items.push_back (MenuElem (_("Show All Audio Tracks"), mem_fun(*this, &Mixer_UI::show_all_audiotracks))); @@ -984,45 +980,45 @@ void Mixer_UI::strip_name_changed (MixerStrip* mx) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::strip_name_changed), mx)); - + TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator i; - + for (i = rows.begin(); i != rows.end(); ++i) { if ((*i)[track_columns.strip] == mx) { (*i)[track_columns.text] = mx->route()->name(); return; } - } + } error << _("track display list item for renamed strip not found!") << endmsg; } void -Mixer_UI::build_mix_group_context_menu () +Mixer_UI::build_route_group_context_menu () { using namespace Gtk::Menu_Helpers; - mix_group_context_menu = new Menu; - mix_group_context_menu->set_name ("ArdourContextMenu"); - MenuList& items = mix_group_context_menu->items(); + route_group_context_menu = new Menu; + route_group_context_menu->set_name ("ArdourContextMenu"); + MenuList& items = route_group_context_menu->items(); - items.push_back (MenuElem (_("Activate All"), mem_fun(*this, &Mixer_UI::activate_all_mix_groups))); - items.push_back (MenuElem (_("Disable All"), mem_fun(*this, &Mixer_UI::disable_all_mix_groups))); + items.push_back (MenuElem (_("Activate All"), mem_fun(*this, &Mixer_UI::activate_all_route_groups))); + items.push_back (MenuElem (_("Disable All"), mem_fun(*this, &Mixer_UI::disable_all_route_groups))); items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Add group"), mem_fun(*this, &Mixer_UI::new_mix_group))); - + items.push_back (MenuElem (_("Add group"), mem_fun(*this, &Mixer_UI::new_route_group))); + } bool Mixer_UI::group_display_button_press (GdkEventButton* ev) { if (Keyboard::is_context_menu_event (ev)) { - if (mix_group_context_menu == 0) { - build_mix_group_context_menu (); + if (route_group_context_menu == 0) { + build_route_group_context_menu (); } - mix_group_context_menu->popup (1, ev->time); + route_group_context_menu->popup (1, ev->time); return true; } @@ -1043,29 +1039,18 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev) if (Keyboard::is_edit_event (ev)) { if ((iter = group_model->get_iter (path))) { if ((group = (*iter)[group_columns.group]) != 0) { - // edit_mix_group (group); + // edit_route_group (group); #ifdef GTKOSX group_display.queue_draw(); #endif return true; } } - - } - break; - case 1: - if ((iter = group_model->get_iter (path))) { - bool active = (*iter)[group_columns.active]; - (*iter)[group_columns.active] = !active; -#ifdef GTKOSX - group_display.queue_draw(); -#endif - return true; } break; - - case 2: + + case 1: if ((iter = group_model->get_iter (path))) { bool visible = (*iter)[group_columns.visible]; (*iter)[group_columns.visible] = !visible; @@ -1079,32 +1064,26 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev) default: break; } - + return false; } void -Mixer_UI::activate_all_mix_groups () +Mixer_UI::activate_all_route_groups () { - Gtk::TreeModel::Children children = group_model->children(); - for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) { - (*iter)[group_columns.active] = true; - } + session->foreach_route_group (bind (mem_fun (*this, &Mixer_UI::set_route_group_activation), true)); } void -Mixer_UI::disable_all_mix_groups () +Mixer_UI::disable_all_route_groups () { - Gtk::TreeModel::Children children = group_model->children(); - for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) { - (*iter)[group_columns.active] = false; - } + session->foreach_route_group (bind (mem_fun (*this, &Mixer_UI::set_route_group_activation), false)); } void -Mixer_UI::mix_groups_changed () +Mixer_UI::route_groups_changed () { - ENSURE_GUI_THREAD (mem_fun (*this, &Mixer_UI::mix_groups_changed)); + ENSURE_GUI_THREAD (mem_fun (*this, &Mixer_UI::route_groups_changed)); /* just rebuild the while thing */ @@ -1113,23 +1092,22 @@ Mixer_UI::mix_groups_changed () { TreeModel::Row row; row = *(group_model->append()); - row[group_columns.active] = false; row[group_columns.visible] = true; row[group_columns.text] = (_("-all-")); row[group_columns.group] = 0; } - session->foreach_mix_group (mem_fun (*this, &Mixer_UI::add_mix_group)); + session->foreach_route_group (mem_fun (*this, &Mixer_UI::add_route_group)); } void -Mixer_UI::new_mix_group () +Mixer_UI::new_route_group () { - session->add_mix_group (""); + session->add_route_group (new RouteGroup (*session, "", RouteGroup::Active, (RouteGroup::Property) (RouteGroup::Gain |RouteGroup::Mute | RouteGroup::Solo))); } void -Mixer_UI::remove_selected_mix_group () +Mixer_UI::remove_selected_route_group () { Glib::RefPtr selection = group_display.get_selection(); TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows (); @@ -1140,7 +1118,7 @@ Mixer_UI::remove_selected_mix_group () TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); TreeIter iter; - + /* selection mode is single, so rows.begin() is it */ if ((iter = group_model->get_iter (*i))) { @@ -1148,7 +1126,7 @@ Mixer_UI::remove_selected_mix_group () RouteGroup* rg = (*iter)[group_columns.group]; if (rg) { - session->remove_mix_group (*rg); + session->remove_route_group (*rg); } } } @@ -1163,53 +1141,54 @@ Mixer_UI::group_flags_changed (void* src, RouteGroup* group) ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::group_flags_changed), src, group)); /* force an update of any mixer strips that are using this group, - otherwise mix group names don't change in mixer strips + otherwise mix group names don't change in mixer strips */ for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - if ((*i)->mix_group() == group) { - (*i)->mix_group_changed(0); + if ((*i)->route_group() == group) { + (*i)->route_group_changed(0); } } - + TreeModel::iterator i; TreeModel::Children rows = group_model->children(); Glib::RefPtr selection = group_display.get_selection(); in_group_row_change = true; - + for (i = rows.begin(); i != rows.end(); ++i) { if ((*i)[group_columns.group] == group) { (*i)[group_columns.visible] = !group->is_hidden (); - (*i)[group_columns.active] = group->is_active (); (*i)[group_columns.text] = group->name (); break; } } in_group_row_change = false; + + _group_tabs->set_dirty (); } void -Mixer_UI::mix_group_name_edit (const Glib::ustring& path, const Glib::ustring& new_text) +Mixer_UI::route_group_name_edit (const Glib::ustring& path, const Glib::ustring& new_text) { RouteGroup* group; TreeIter iter; if ((iter = group_model->get_iter (path))) { - + if ((group = (*iter)[group_columns.group]) == 0) { return; } - + if (new_text != group->name()) { group->set_name (new_text); } } } -void -Mixer_UI::mix_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter) +void +Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter) { RouteGroup* group; @@ -1223,20 +1202,17 @@ Mixer_UI::mix_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::Tree if ((*iter)[group_columns.visible]) { for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - if ((*i)->mix_group() == group) { + if ((*i)->route_group() == group) { show_strip (*i); } } } else { for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - if ((*i)->mix_group() == group) { + if ((*i)->route_group() == group) { hide_strip (*i); } } - } - - bool active = (*iter)[group_columns.active]; - group->set_active (active, this); + } Glib::ustring name = (*iter)[group_columns.text]; @@ -1247,16 +1223,14 @@ Mixer_UI::mix_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::Tree } void -Mixer_UI::add_mix_group (RouteGroup* group) - +Mixer_UI::add_route_group (RouteGroup* group) { - ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_mix_group), group)); + ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_route_group), group)); bool focus = false; in_group_row_change = true; TreeModel::Row row = *(group_model->append()); - row[group_columns.active] = group->is_active(); row[group_columns.visible] = true; row[group_columns.group] = group; if (!group->name().empty()) { @@ -1267,7 +1241,7 @@ Mixer_UI::add_mix_group (RouteGroup* group) } group->FlagsChanged.connect (bind (mem_fun(*this, &Mixer_UI::group_flags_changed), group)); - + if (focus) { TreeViewColumn* col = group_display.get_column (0); CellRendererText* name_cell = dynamic_cast(group_display.get_column_cell_renderer (0)); @@ -1296,7 +1270,7 @@ Mixer_UI::set_strip_width (Width w) _strip_width = w; for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - (*i)->set_width (w, this); + (*i)->set_width_enum (w, this); } } @@ -1319,12 +1293,12 @@ Mixer_UI::set_state (const XMLNode& node) { const XMLProperty* prop; XMLNode* geometry; - + m_width = default_width; m_height = default_height; m_root_x = 1; m_root_y = 1; - + if ((geometry = find_named_node (node, "geometry")) != 0) { XMLProperty* prop; @@ -1347,7 +1321,7 @@ Mixer_UI::set_state (const XMLNode& node) } if (prop) { m_root_x = atoi (prop->value()); - + } if ((prop = geometry->property ("y_pos")) == 0) { prop = geometry->property ("y-pos"); @@ -1360,7 +1334,7 @@ Mixer_UI::set_state (const XMLNode& node) set_window_pos_and_size (); if ((prop = node.property ("narrow-strips"))) { - if (prop->value() == "yes") { + if (string_is_affirmative (prop->value())) { set_strip_width (Narrow); } else { set_strip_width (Wide); @@ -1368,7 +1342,7 @@ Mixer_UI::set_state (const XMLNode& node) } if ((prop = node.property ("show-mixer"))) { - if (prop->value() == "yes") { + if (string_is_affirmative (prop->value())) { _visible = true; } } @@ -1383,7 +1357,7 @@ Mixer_UI::get_state (void) if (is_realized()) { Glib::RefPtr win = get_window(); - + get_window_pos_and_size (); XMLNode* geometry = new XMLNode ("geometry"); @@ -1396,7 +1370,7 @@ Mixer_UI::get_state (void) geometry->add_property(X_("x_pos"), string(buf)); snprintf(buf, sizeof(buf), "%d", m_root_y); geometry->add_property(X_("y_pos"), string(buf)); - + // written only for compatibility, they are not used. snprintf(buf, sizeof(buf), "%d", 0); geometry->add_property(X_("x_off"), string(buf)); @@ -1419,8 +1393,8 @@ Mixer_UI::get_state (void) } -void -Mixer_UI::pane_allocation_handler (Allocation& alloc, Gtk::Paned* which) +void +Mixer_UI::pane_allocation_handler (Allocation&, Gtk::Paned* which) { int pos; XMLProperty* prop = 0; @@ -1485,9 +1459,104 @@ Mixer_UI::pane_allocation_handler (Allocation& alloc, Gtk::Paned* which) } } } +void +Mixer_UI::scroll_left () +{ + Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); + /* stupid GTK: can't rely on clamping across versions */ + scroller.get_hscrollbar()->set_value (max (adj->get_lower(), adj->get_value() - adj->get_step_increment())); +} + +void +Mixer_UI::scroll_right () +{ + Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); + /* stupid GTK: can't rely on clamping across versions */ + scroller.get_hscrollbar()->set_value (min (adj->get_upper(), adj->get_value() + adj->get_step_increment())); +} bool Mixer_UI::on_key_press_event (GdkEventKey* ev) { + switch (ev->keyval) { + case GDK_Left: + scroll_left (); + return true; + + case GDK_Right: + scroll_right (); + return true; + + default: + break; + } + return key_press_focus_accelerator_handler (*this, ev); } + +bool +Mixer_UI::on_key_release_event (GdkEventKey* ev) +{ + return Gtk::Window::on_key_release_event (ev); + // return key_press_focus_accelerator_handler (*this, ev); +} + + +bool +Mixer_UI::on_scroll_event (GdkEventScroll* ev) +{ + switch (ev->direction) { + case GDK_SCROLL_LEFT: + scroll_left (); + return true; + case GDK_SCROLL_UP: + if (ev->state & Keyboard::TertiaryModifier) { + scroll_left (); + return true; + } + return false; + + case GDK_SCROLL_RIGHT: + scroll_right (); + return true; + + case GDK_SCROLL_DOWN: + if (ev->state & Keyboard::TertiaryModifier) { + scroll_right (); + return true; + } + return false; + } + + return false; +} + + +void +Mixer_UI::parameter_changed (string const & p) +{ + if (p == "show-group-tabs") { + bool const s = session->config.get_show_group_tabs (); + if (s) { + _group_tabs->show (); + } else { + _group_tabs->hide (); + } + } +} + +void +Mixer_UI::set_route_group_activation (RouteGroup* g, bool a) +{ + g->set_active (a, this); +} + +PluginSelector* +Mixer_UI::plugin_selector() +{ + if (!_plugin_selector) { + _plugin_selector = new PluginSelector (PluginManager::the_manager()); + _plugin_selector->set_session (session); + } + return _plugin_selector; +}