X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmixer_ui.cc;h=c3aa14d6e2d5272707fa69ea41674b5f6fcf1f9f;hb=57d2555d3e7857c44daedd1d51f777d0c50b27c4;hp=644a51f880426e85864676d79988ed3288d6c51f;hpb=4aa84f0513c6cd47561e5bb1d5ec436426fee581;p=ardour.git diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 644a51f880..c3aa14d6e2 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -68,6 +68,9 @@ using PBD::atoi; Mixer_UI::Mixer_UI () : Window (Gtk::WINDOW_TOPLEVEL) { + /* allow this window to become the key focus window */ + set_flags (CAN_FOCUS); + _strip_width = Config->get_default_narrow_ms() ? Narrow : Wide; track_menu = 0; _monitor_section = 0; @@ -80,6 +83,7 @@ Mixer_UI::Mixer_UI () Route::SyncOrderKeys.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::sync_order_keys, this, _1), gui_context()); + scroller_base.set_flags (Gtk::CAN_FOCUS); scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); scroller_base.set_name ("MixerWindow"); scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release)); @@ -186,21 +190,15 @@ Mixer_UI::Mixer_UI () add (global_vpacker); set_name ("MixerWindow"); - WindowTitle title(Glib::get_application_name()); - title += _("Mixer"); - set_title (title.get_string()); + update_title (); set_wmclass (X_("ardour_mixer"), PROGRAM_NAME); - add_accel_group (ActionManager::ui_manager->get_accel_group()); - signal_delete_event().connect (sigc::mem_fun (*this, &Mixer_UI::hide_window)); add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK); signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler)); - _selection.RoutesChanged.connect (sigc::mem_fun(*this, &Mixer_UI::follow_strip_selection)); - route_group_display_button_box->show(); route_group_add_button->show(); route_group_remove_button->show(); @@ -232,7 +230,7 @@ Mixer_UI::Mixer_UI () MonitorSection::setup_knob_images (); #ifndef DEFER_PLUGIN_SELECTOR_LOAD - _plugin_selector = new PluginSelector (PluginManager::the_manager ()); + _plugin_selector = new PluginSelector (PluginManager::instance ()); #endif } @@ -265,8 +263,14 @@ Mixer_UI::show_window () for (ri = rows.begin(); ri != rows.end(); ++ri) { ms = (*ri)[track_columns.strip]; ms->set_width_enum (ms->get_width_enum (), ms->width_owner()); + /* Fix visibility of mixer strip stuff */ + ms->parameter_changed (X_("mixer-strip-visibility")); } } + + /* force focus into main area */ + scroller_base.grab_focus (); + _visible = true; } @@ -361,8 +365,6 @@ Mixer_UI::remove_strip (MixerStrip* strip) ENSURE_GUI_THREAD (*this, &Mixer_UI::remove_strip, strip); - cerr << "Mixer UI removing strip for " << strip << endl; - TreeModel::Children rows = track_model->children(); TreeModel::Children::iterator ri; list::iterator i; @@ -429,31 +431,76 @@ Mixer_UI::sync_order_keys (string const & src) } } -void -Mixer_UI::follow_strip_selection () +MixerStrip* +Mixer_UI::strip_by_route (boost::shared_ptr r) { for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - (*i)->set_selected (_selection.selected ((*i)->route())); + if ((*i)->route() == r) { + return (*i); + } } + + return 0; } bool Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) { if (ev->button == 1) { - - /* this allows the user to click on the strip to terminate comment - 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()); + if (_selection.selected (strip)) { + /* primary-click: toggle selection state of strip */ + if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + _selection.remove (strip); + } } else { - if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { - _selection.add (strip->route()); + if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + _selection.add (strip); + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) { + + if (!_selection.selected(strip)) { + + /* extend selection */ + + vector tmp; + bool accumulate = false; + + tmp.push_back (strip); + + for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + if ((*i) == strip) { + /* hit clicked strip, start accumulating till we hit the first + selected strip + */ + if (accumulate) { + /* done */ + break; + } else { + accumulate = true; + } + } else if (_selection.selected (*i)) { + /* hit selected strip. if currently accumulating others, + we're done. if not accumulating others, start doing so. + */ + if (accumulate) { + /* done */ + break; + } else { + accumulate = true; + } + } else { + if (accumulate) { + tmp.push_back (*i); + } + } + } + + for (vector::iterator i = tmp.begin(); i != tmp.end(); ++i) { + _selection.add (*i); + } + } + } else { - _selection.set (strip->route()); + _selection.set (strip); } } } @@ -479,11 +526,7 @@ Mixer_UI::set_session (Session* sess) XMLNode* node = ARDOUR_UI::instance()->mixer_settings(); set_state (*node); - WindowTitle title(_session->name()); - title += _("Mixer"); - title += Glib::get_application_name(); - - set_title (title.get_string()); + update_title (); initial_track_display (); @@ -492,6 +535,8 @@ Mixer_UI::set_session (Session* sess) _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context()); _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context()); _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), ui_bind (&Mixer_UI::parameter_changed, this, _1), gui_context()); + _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context()); + _session->StateSaved.connect (_session_connections, invalidator (*this), ui_bind (&Mixer_UI::update_title, this), gui_context()); Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&Mixer_UI::parameter_changed, this, _1), gui_context ()); @@ -526,13 +571,12 @@ Mixer_UI::session_going_away () strips.clear (); - WindowTitle title(Glib::get_application_name()); - title += _("Mixer"); - set_title (title.get_string()); - stop_updating (); SessionHandlePtr::session_going_away (); + + _session = 0; + update_title (); } void @@ -1530,29 +1574,40 @@ Mixer_UI::scroll_right () bool Mixer_UI::on_key_press_event (GdkEventKey* ev) { - switch (ev->keyval) { - case GDK_Left: - scroll_left (); - return true; + /* focus widget gets first shot, then bindings, otherwise + forward to main window + */ - case GDK_Right: - scroll_right (); + if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { return true; - - default: - break; } - - return key_press_focus_accelerator_handler (*this, ev); + + KeyboardKey k (ev->state, ev->keyval); + + if (bindings.activate (k, Bindings::Press)) { + return true; + } + + return forward_key_press (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); -} + if (gtk_window_propagate_key_event (GTK_WINDOW(gobj()), ev)) { + return true; + } + + KeyboardKey k (ev->state, ev->keyval); + + if (bindings.activate (k, Bindings::Release)) { + return true; + } + + /* don't forward releases */ + return true; +} bool Mixer_UI::on_scroll_event (GdkEventScroll* ev) @@ -1613,7 +1668,7 @@ Mixer_UI::plugin_selector() { #ifdef DEFER_PLUGIN_SELECTOR_LOAD if (!_plugin_selector) - _plugin_selector = new PluginSelector (PluginManager::the_manager ()); + _plugin_selector = new PluginSelector (PluginManager::instance()); #endif return _plugin_selector; @@ -1677,3 +1732,71 @@ Mixer_UI::new_track_or_bus () ARDOUR_UI::instance()->add_route (this); } + +void +Mixer_UI::update_title () +{ + if (_session) { + string n; + + if (_session->snap_name() != _session->name()) { + n = _session->snap_name (); + } else { + n = _session->name (); + } + + if (_session->dirty ()) { + n = "*" + n; + } + + WindowTitle title (n); + title += _("Mixer"); + title += Glib::get_application_name (); + set_title (title.get_string()); + + } else { + + WindowTitle title (X_("Mixer")); + title += Glib::get_application_name (); + set_title (title.get_string()); + } +} + +MixerStrip* +Mixer_UI::strip_by_x (int x) +{ + for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + int x1, x2, y; + + (*i)->translate_coordinates (*this, 0, 0, x1, y); + x2 = x1 + (*i)->get_width(); + + if (x >= x1 && x <= x2) { + return (*i); + } + } + + return 0; +} + +void +Mixer_UI::set_route_targets_for_operation () +{ + _route_targets.clear (); + + if (!_selection.empty()) { + _route_targets = _selection.routes; + return; + } + + /* try to get mixer strip at mouse */ + + int x, y; + get_pointer (x, y); + + MixerStrip* ms = strip_by_x (x); + + if (ms) { + _route_targets.insert (ms); + } +}