X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmixer_ui.cc;h=4c5d60d6c753c27479b2a7efe9df713f6c8ae532;hb=e54413ee46831252286ecfd12775236c439d9d44;hp=ce6ed294a381fbe6652d1b97c3b59b91503b0392;hpb=efd8402502154c53826a9ebc5a4a96f7a38512c7;p=ardour.git diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index ce6ed294a3..4c5d60d6c7 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -107,7 +107,6 @@ Mixer_UI::Mixer_UI () , ignore_reorder (false) , _in_group_rebuild_or_clear (false) , _route_deletion_in_progress (false) - , _following_editor_selection (false) , _maximised (false) , _show_mixer_list (true) , myactions (X_("mixer")) @@ -116,7 +115,7 @@ Mixer_UI::Mixer_UI () load_bindings (); _content.set_data ("ardour-bindings", bindings); - PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_presentation_info, this), gui_context()); + PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context()); scroller.set_can_default (true); // set_default (scroller); @@ -142,6 +141,7 @@ Mixer_UI::Mixer_UI () b->pack_start (*_group_tabs, PACK_SHRINK); b->pack_start (strip_packer); b->show_all (); + b->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false); scroller.add (*b); scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC); @@ -280,32 +280,30 @@ Mixer_UI::Mixer_UI () XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings(); - XMLProperty const * prop; float fract; { LocaleGuard lg; - if (!settings || ((prop = settings->property ("mixer-rhs-pane1-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) { - rhs_pane1.set_divider (0, 0.6f); - } else { - rhs_pane1.set_divider (0, fract); + if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) { + fract = 0.6f; } - if (!settings || ((prop = settings->property ("mixer-rhs-pane2-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) { - rhs_pane2.set_divider (0, 0.7f); - } else { - rhs_pane2.set_divider (0, fract); + rhs_pane1.set_divider (0, fract); + + if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) { + fract = 0.7f; } - if (!settings || ((prop = settings->property ("mixer-list-hpane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) { - list_hpane.set_divider (0, 0.2f); - } else { - list_hpane.set_divider (0, fract); + rhs_pane2.set_divider (0, fract); + + if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) { + fract = 0.2f; } - if (!settings || ((prop = settings->property ("mixer-inner-pane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) { - inner_pane.set_divider (0, 0.8f); - } else { - inner_pane.set_divider (0, atof (prop->value())); + list_hpane.set_divider (0, fract); + + if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) { + fract = 0.8f; } + inner_pane.set_divider (0, fract); } rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down); @@ -375,6 +373,7 @@ Mixer_UI::~Mixer_UI () delete _monitor_section; } delete _plugin_selector; + delete track_menu; } void @@ -383,12 +382,6 @@ Mixer_UI::escape () select_none (); } -void -Mixer_UI::track_editor_selection () -{ - PublicEditor::instance().get_selection().TracksChanged.connect (sigc::mem_fun (*this, &Mixer_UI::follow_editor_selection)); -} - Gtk::Window* Mixer_UI::use_own_window (bool and_fill_it) { @@ -396,14 +389,16 @@ Mixer_UI::use_own_window (bool and_fill_it) Gtk::Window* win = Tabbable::use_own_window (and_fill_it); - if (win && new_window) { win->set_name ("MixerWindow"); ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this); - win->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false); win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win)); win->set_data ("ardour-bindings", bindings); update_title (); + if (!win->get_focus()) { + /* set focus widget to something, anything */ + win->set_focus (scroller); + } } return win; @@ -520,7 +515,6 @@ Mixer_UI::add_stripables (StripableList& slist) MixerStrip* strip; - try { PBD::Unwinder uw (no_track_list_redisplay, true); @@ -597,10 +591,6 @@ Mixer_UI::add_stripables (StripableList& slist) row[stripable_columns.stripable] = route; row[stripable_columns.strip] = strip; - if (nroutes != 0) { - _selection.add (strip); - } - } else { out_packer.pack_start (*strip, false, false); @@ -621,6 +611,9 @@ Mixer_UI::add_stripables (StripableList& slist) track_display.set_model (track_model); + /* catch up on selection state, which we left to the editor to set */ + sync_treeview_from_presentation_info (PropertyChange (Properties::selected)); + if (!from_scratch) { sync_presentation_info_from_treeview (); } @@ -687,6 +680,19 @@ Mixer_UI::remove_strip (MixerStrip* strip) } } +void +Mixer_UI::presentation_info_changed (PropertyChange const & what_changed) +{ + PropertyChange soh; + soh.add (Properties::selected); + soh.add (Properties::order); + soh.add (Properties::hidden); + + if (what_changed.contains (soh)) { + sync_treeview_from_presentation_info (what_changed); + } +} + void Mixer_UI::sync_presentation_info_from_treeview () { @@ -706,11 +712,16 @@ Mixer_UI::sync_presentation_info_from_treeview () bool change = false; uint32_t order = 0; + OrderingKeys sorted; + const size_t cmp_max = rows.size (); + // special case master if it's got PI order 0 lets keep it there if (_session->master_out() && (_session->master_out()->presentation_info().order() == 0)) { order++; } + PresentationInfo::ChangeSuspender cs; + for (ri = rows.begin(); ri != rows.end(); ++ri) { bool visible = (*ri)[stripable_columns.visible]; boost::shared_ptr stripable = (*ri)[stripable_columns.stripable]; @@ -739,22 +750,50 @@ Mixer_UI::sync_presentation_info_from_treeview () } if (order != stripable->presentation_info().order()) { - stripable->set_presentation_order (order, false); + stripable->set_presentation_order (order); change = true; } + sorted.push_back (OrderKeys (order, stripable, cmp_max)); + ++order; } + if (!change) { + // VCA (and Mixbus) special cases according to SortByNewDisplayOrder + uint32_t n = 0; + SortByNewDisplayOrder cmp; + sort (sorted.begin(), sorted.end(), cmp); + for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) { + if (_session->master_out() && (_session->master_out()->presentation_info().order() == n)) { + ++n; + } + if (sr->old_display_order != n) { + change = true; + break; + } + } + if (change) { + n = 0; + for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) { + if (_session->master_out() && (_session->master_out()->presentation_info().order() == n)) { + ++n; + } + if (sr->stripable->presentation_info().order() != n) { + sr->stripable->set_presentation_order (n); + } + } + } + } + if (change) { DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n"); - _session->notify_presentation_info_change (); _session->set_dirty(); } } void -Mixer_UI::sync_treeview_from_presentation_info () +Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed) { if (!_session || _session->deletion_in_progress()) { return; @@ -805,35 +844,25 @@ Mixer_UI::sync_treeview_from_presentation_info () track_model->reorder (neworder); } - redisplay_track_list (); -} - -void -Mixer_UI::follow_editor_selection () -{ - if (_following_editor_selection) { - return; - } - - _following_editor_selection = true; - _selection.block_routes_changed (true); - - TrackSelection& s (PublicEditor::instance().get_selection().tracks); + if (what_changed.contains (Properties::selected)) { - _selection.clear_routes (); + PresentationInfo::ChangeSuspender cs; - for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) { - TimeAxisView* tav = dynamic_cast (*i); - if (tav) { - AxisView* axis = axis_by_stripable (tav->stripable()); - if (axis) { - _selection.add (axis); + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { + boost::shared_ptr stripable = (*i)->stripable(); + if (stripable && stripable->presentation_info().selected()) { + _selection.add (*i); + } else { + _selection.remove (*i); } } + + if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll ()) { + move_stripable_into_view ((*_selection.axes.begin())->stripable()); + } } - _following_editor_selection = false; - _selection.block_routes_changed (false); + redisplay_track_list (); } @@ -849,6 +878,18 @@ Mixer_UI::strip_by_route (boost::shared_ptr r) const return 0; } +MixerStrip* +Mixer_UI::strip_by_stripable (boost::shared_ptr s) const +{ + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { + if ((*i)->stripable() == s) { + return (*i); + } + } + + return 0; +} + AxisView* Mixer_UI::axis_by_stripable (boost::shared_ptr s) const { @@ -884,10 +925,19 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) bool accumulate = false; bool found_another = false; - tmp.push_back (strip); - + OrderingKeys sorted; + const size_t cmp_max = strips.size (); for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - if ((*i) == strip) { + sorted.push_back (OrderKeys (-1, (*i)->stripable(), cmp_max)); + } + SortByNewDisplayOrder cmp; + sort (sorted.begin(), sorted.end(), cmp); + + for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr) { + MixerStrip* ms = strip_by_stripable (sr->stripable); + assert (ms); + + if (ms == strip) { /* hit clicked strip, start accumulating till we hit the first selected strip */ @@ -897,7 +947,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) } else { accumulate = true; } - } else if (_selection.selected (*i)) { + } else if (_selection.selected (ms)) { /* hit selected strip. if currently accumulating others, we're done. if not accumulating others, start doing so. */ @@ -910,17 +960,21 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) } } else { if (accumulate) { - tmp.push_back (*i); + tmp.push_back (ms); } } } + tmp.push_back (strip); + if (found_another) { + PresentationInfo::ChangeSuspender cs; for (vector::iterator i = tmp.begin(); i != tmp.end(); ++i) { _selection.add (*i); } - } else + } else { _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet + } } else { _selection.set (strip); } @@ -1288,6 +1342,7 @@ Mixer_UI::spill_redisplay (boost::shared_ptr vca) AxisView* av = (*i)[stripable_columns.strip]; MixerStrip* strip = dynamic_cast (av); + bool const visible = (*i)[stripable_columns.visible]; if (!strip) { /* we're in the middle of changing a row, don't worry */ @@ -1311,7 +1366,7 @@ Mixer_UI::spill_redisplay (boost::shared_ptr vca) } } - if (slaved) { + if (slaved && visible) { if (strip->packed()) { strip_packer.reorder_child (*strip, -1); /* put at end */ @@ -1337,11 +1392,13 @@ Mixer_UI::redisplay_track_list () return; } - boost::shared_ptr sv = spilled_vca.lock (); - - if (sv) { - spill_redisplay (sv); - return; + boost::shared_ptr ss = spilled_strip.lock (); + if (ss) { + boost::shared_ptr sv = boost::dynamic_pointer_cast (ss); + if (sv) { + spill_redisplay (sv); + return; + } } TreeModel::Children rows = track_model->children(); @@ -1486,24 +1543,17 @@ Mixer_UI::initial_track_display () add_stripables (sl); } - redisplay_track_list (); -} - -void -Mixer_UI::show_track_list_menu () -{ - if (track_menu == 0) { - build_track_menu (); - } - - track_menu->popup (1, gtk_get_current_event_time()); + sync_treeview_from_presentation_info (Properties::order); } bool Mixer_UI::track_display_button_press (GdkEventButton* ev) { if (Keyboard::is_context_menu_event (ev)) { - show_track_list_menu (); + if (track_menu == 0) { + build_track_menu (); + } + track_menu->popup (ev->button, ev->time); return true; } if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) { @@ -1538,11 +1588,13 @@ Mixer_UI::move_stripable_into_view (boost::shared_ptr s) #endif bool found = false; int x0 = 0; + Gtk::Allocation alloc; for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { if ((*i)->route() == s) { int y; found = true; (*i)->translate_coordinates (strip_packer, 0, 0, x0, y); + alloc = (*i)->get_allocation (); break; } } @@ -1551,7 +1603,13 @@ Mixer_UI::move_stripable_into_view (boost::shared_ptr s) } Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); - scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0))); + + if (x0 < adj->get_value()) { + adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0))); + } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) { + int x1 = x0 + alloc.get_width() - adj->get_page_size(); + adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1))); + } } void @@ -1621,13 +1679,17 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev) int celly; if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { - _group_tabs->get_menu(0)->popup (1, ev->time); + if (ev->button == 3) { + _group_tabs->get_menu(0)->popup (ev->button, ev->time); + } return true; } TreeIter iter = group_model->get_iter (path); if (!iter) { - _group_tabs->get_menu(0)->popup (1, ev->time); + if (ev->button == 3) { + _group_tabs->get_menu(0)->popup (ev->button, ev->time); + } return true; } @@ -2005,27 +2067,22 @@ private: int Mixer_UI::set_state (const XMLNode& node, int version) { - XMLProperty const * prop; LocaleGuard lg; + bool yn; Tabbable::set_state (node, version); - if ((prop = node.property ("narrow-strips"))) { - if (string_is_affirmative (prop->value())) { + if (node.get_property ("narrow-strips", yn)) { + if (yn) { set_strip_width (Narrow); } else { set_strip_width (Wide); } } - if ((prop = node.property ("show-mixer"))) { - if (string_is_affirmative (prop->value())) { - _visible = true; - } - } + node.get_property ("show-mixer", _visible); - if ((prop = node.property ("maximised"))) { - bool yn = string_is_affirmative (prop->value()); + if (node.get_property ("maximised", yn)) { Glib::RefPtr act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer")); assert (act); Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); @@ -2035,8 +2092,7 @@ Mixer_UI::set_state (const XMLNode& node, int version) } } - if ((prop = node.property ("show-mixer-list"))) { - bool yn = string_is_affirmative (prop->value()); + if (node.get_property ("show-mixer-list", yn)) { Glib::RefPtr act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList")); assert (act); Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); @@ -2054,11 +2110,11 @@ Mixer_UI::set_state (const XMLNode& node, int version) const XMLNodeList& kids = plugin_order->children("PluginInfo"); XMLNodeConstIterator i; for (i = kids.begin(); i != kids.end(); ++i) { - if ((prop = (*i)->property ("unique-id"))) { - std::string unique_id = prop->value(); + std::string unique_id; + if ((*i)->get_property ("unique-id", unique_id)) { order.push_back (unique_id); - if ((prop = (*i)->property ("expanded"))) { - favorite_ui_state[unique_id] = string_is_affirmative (prop->value()); + if ((*i)->get_property ("expanded", yn)) { + favorite_ui_state[unique_id] = yn; } } } @@ -2073,34 +2129,29 @@ XMLNode& Mixer_UI::get_state () { XMLNode* node = new XMLNode (X_("Mixer")); - char buf[128]; LocaleGuard lg; node->add_child_nocopy (Tabbable::get_state()); - snprintf(buf,sizeof(buf), "%f", rhs_pane1.get_divider()); - node->add_property(X_("mixer-rhs-pane1-pos"), string(buf)); - snprintf(buf,sizeof(buf), "%f", rhs_pane2.get_divider()); - node->add_property(X_("mixer-rhs_pane2-pos"), string(buf)); - snprintf(buf,sizeof(buf), "%f", list_hpane.get_divider()); - node->add_property(X_("mixer-list-hpane-pos"), string(buf)); - snprintf(buf,sizeof(buf), "%f", inner_pane.get_divider()); - node->add_property(X_("mixer-inner-pane-pos"), string(buf)); + node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider()); + node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider()); + node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider()); + node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider()); - node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no"); - node->add_property ("show-mixer", _visible ? "yes" : "no"); - node->add_property ("show-mixer-list", _show_mixer_list ? "yes" : "no"); - node->add_property ("maximised", _maximised ? "yes" : "no"); + node->set_property ("narrow-strips", (_strip_width == Narrow)); + node->set_property ("show-mixer", _visible); + node->set_property ("show-mixer-list", _show_mixer_list); + node->set_property ("maximised", _maximised); store_current_favorite_order (); XMLNode* plugin_order = new XMLNode ("PluginOrder"); - int cnt = 0; + uint32_t cnt = 0; for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) { XMLNode* p = new XMLNode ("PluginInfo"); - p->add_property ("sort", cnt); - p->add_property ("unique-id", (*i)->unique_id); + p->set_property ("sort", cnt); + p->set_property ("unique-id", (*i)->unique_id); if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) { - p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]); + p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]); } plugin_order->add_child_nocopy (*p); } @@ -2812,13 +2863,13 @@ Mixer_UI::do_vca_unassign (boost::shared_ptr vca) } void -Mixer_UI::show_vca_slaves (boost::shared_ptr vca) +Mixer_UI::show_spill (boost::shared_ptr s) { - boost::shared_ptr v = spilled_vca.lock(); - if (v != vca) { - spilled_vca = vca; - show_vca_change (vca); /* EMIT SIGNAL */ - if (vca) { + boost::shared_ptr ss = spilled_strip.lock(); + if (ss != s) { + spilled_strip = s; + show_spill_change (s); /* EMIT SIGNAL */ + if (s) { _group_tabs->hide (); } else { _group_tabs->show (); @@ -2828,9 +2879,15 @@ Mixer_UI::show_vca_slaves (boost::shared_ptr vca) } bool -Mixer_UI::showing_vca_slaves_for (boost::shared_ptr vca) const +Mixer_UI::showing_spill_for (boost::shared_ptr s) const +{ + return s == spilled_strip.lock(); +} + +void +Mixer_UI::show_editor_window () const { - return vca == spilled_vca.lock(); + PublicEditor::instance().make_visible (); } void @@ -2838,6 +2895,8 @@ Mixer_UI::register_actions () { Glib::RefPtr group = myactions.create_action_group (X_("Mixer")); + myactions.register_action (group, "show-editor", _("Show Editor"), sigc::mem_fun (*this, &Mixer_UI::show_editor_window)); + myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action)); myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action)); myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action)); @@ -3032,26 +3091,22 @@ void Mixer_UI::vca_assign (boost::shared_ptr vca) { set_axis_targets_for_operation (); -#if 0 BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->vca_assign (vca); } } -#endif } void Mixer_UI::vca_unassign (boost::shared_ptr vca) { set_axis_targets_for_operation (); -#if 0 BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->vca_unassign (vca); } } -#endif }