X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmidi_time_axis.cc;h=ffff6a96981a7b0e2aea69c6a7eaba673c1b0f43;hb=c2afd958ba915fa324ec7ee4b86267a5b5581849;hp=4e4b54197730830c375a2d8dbcec15df2d11a362;hpb=9773cfa92645f8caf8aa524a5e7f45bb4d4d1b24;p=ardour.git diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 4e4b541977..ffff6a9698 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -25,6 +25,9 @@ #include +#include +#include + #include "pbd/error.h" #include "pbd/ffs.h" #include "pbd/stl_delete.h" @@ -35,10 +38,10 @@ #include "pbd/stateful_diff_command.h" #include "gtkmm2ext/gtk_ui.h" -#include "gtkmm2ext/selector.h" -#include "gtkmm2ext/bindable_button.h" #include "gtkmm2ext/utils.h" +#include "widgets/tooltips.h" + #include "ardour/event_type_map.h" #include "ardour/midi_patch_manager.h" #include "ardour/midi_playlist.h" @@ -61,7 +64,6 @@ #include "ardour/track.h" #include "ardour/types.h" -#include "ardour_button.h" #include "automation_line.h" #include "automation_time_axis.h" #include "editor.h" @@ -74,17 +76,16 @@ #include "midi_streamview.h" #include "midi_region_view.h" #include "midi_time_axis.h" +#include "patch_change_dialog.h" #include "piano_roll_header.h" #include "playlist_selector.h" #include "plugin_selector.h" #include "plugin_ui.h" #include "point_selection.h" -#include "prompter.h" #include "region_view.h" #include "rgb_macros.h" #include "selection.h" #include "step_editor.h" -#include "tooltips.h" #include "utils.h" #include "note_base.h" @@ -93,7 +94,6 @@ #include "pbd/i18n.h" using namespace ARDOUR; -using namespace ARDOUR_UI_UTILS; using namespace PBD; using namespace Gtk; using namespace Gtkmm2ext; @@ -153,7 +153,7 @@ MidiTimeAxisView::set_route (boost::shared_ptr rt) */ RouteTimeAxisView::set_route (rt); - _view->apply_color (gdk_color_to_rgba (color()), StreamView::RegionColor); + _view->apply_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (color()), StreamView::RegionColor); subplugin_menu.set_name ("ArdourContextMenu"); @@ -163,8 +163,6 @@ MidiTimeAxisView::set_route (boost::shared_ptr rt) true); } - midi_view()->NoteRangeChanged.connect ( - sigc::mem_fun (*this, &MidiTimeAxisView::note_range_changed)); _view->ContentsHeightChanged.connect ( sigc::mem_fun (*this, &MidiTimeAxisView::contents_height_changed)); @@ -207,11 +205,12 @@ MidiTimeAxisView::set_route (boost::shared_ptr rt) _piano_roll_header->ToggleNoteSelection.connect ( sigc::mem_fun (*this, &MidiTimeAxisView::toggle_note_selection)); - /* Suspend updates of the StreamView during scroomer drags to speed things up */ + /* Update StreamView during scroomer drags.*/ + _range_scroomer->DragStarting.connect ( - sigc::mem_fun (*midi_view(), &MidiStreamView::suspend_updates)); + sigc::mem_fun (*this, &MidiTimeAxisView::start_scroomer_update)); _range_scroomer->DragFinishing.connect ( - sigc::mem_fun (*midi_view(), &MidiStreamView::resume_updates)); + sigc::mem_fun (*this, &MidiTimeAxisView::stop_scroomer_update)); /* Put the scroomer and the keyboard in a VBox with a padding label so that they can be reduced in height for stacked-view @@ -242,26 +241,6 @@ MidiTimeAxisView::set_route (boost::shared_ptr rt) _view->RegionViewAdded.connect ( sigc::mem_fun(*this, &MidiTimeAxisView::region_view_added)); - midi_track()->playback_filter().ChannelModeChanged.connect ( - *this, invalidator (*this), - boost::bind (&MidiTimeAxisView::playback_channel_mode_changed, this), - gui_context()); - midi_track()->playback_filter().ChannelMaskChanged.connect ( - *this, invalidator (*this), - boost::bind (&MidiTimeAxisView::playback_channel_mode_changed, this), - gui_context()); - midi_track()->capture_filter().ChannelModeChanged.connect ( - *this, invalidator (*this), - boost::bind (&MidiTimeAxisView::capture_channel_mode_changed, this), - gui_context()); - midi_track()->capture_filter().ChannelMaskChanged.connect ( - *this, invalidator (*this), - boost::bind (&MidiTimeAxisView::capture_channel_mode_changed, this), - gui_context()); - - playback_channel_mode_changed (); - capture_channel_mode_changed (); - if (!_editor.have_idled()) { /* first idle will do what we need */ } else { @@ -281,8 +260,8 @@ MidiTimeAxisView::set_route (boost::shared_ptr rt) } } - set_tooltip (_midnam_model_selector, _("External MIDI Device")); - set_tooltip (_midnam_custom_device_mode_selector, _("External Device Mode")); + ArdourWidgets::set_tooltip (_midnam_model_selector, _("External MIDI Device")); + ArdourWidgets::set_tooltip (_midnam_custom_device_mode_selector, _("External Device Mode")); _midi_controls_box.pack_start (_midnam_model_selector, false, false, 2); _midi_controls_box.pack_start (_midnam_custom_device_mode_selector, false, false, 2); @@ -290,25 +269,6 @@ MidiTimeAxisView::set_route (boost::shared_ptr rt) _midi_controls_box.set_homogeneous(false); _midi_controls_box.set_border_width (2); - _channel_status_box.set_homogeneous (false); - _channel_status_box.set_spacing (4); - - ArdourButton *channel_selector_button = manage (new ArdourButton(_("Chns"))); - channel_selector_button->set_name ("route button"); - set_tooltip (channel_selector_button, _("Click to edit channel settings")); - - // Insert expanding space labels to get full width justification - _channel_status_box.pack_start (_playback_channel_status, false, false, 2); - _channel_status_box.pack_start (*Gtk::manage(new Gtk::Label(" ")), true, true); - _channel_status_box.pack_start (_capture_channel_status, false, false, 2); - _channel_status_box.pack_start (*Gtk::manage(new Gtk::Label(" ")), true, true); - _channel_status_box.pack_end (*channel_selector_button, false, false); - _channel_status_box.show_all (); - - channel_selector_button->signal_clicked.connect (sigc::mem_fun (*this, &MidiTimeAxisView::toggle_channel_selector)); - - _midi_controls_box.pack_start (_channel_status_box, false, false, 10); - MIDI::Name::MidiPatchManager::instance().PatchesChanged.connect (*this, invalidator (*this), boost::bind (&MidiTimeAxisView::setup_midnam_patches, this), gui_context()); @@ -353,7 +313,7 @@ MidiTimeAxisView::set_route (boost::shared_ptr rt) *i, route_id, has_parameter, parameter); if (p && route_id == _route->id () && has_parameter) { const std::string& visible = gui_object_state().get_string (*i, X_("visible")); - create_automation_child (parameter, string_is_affirmative (visible)); + create_automation_child (parameter, string_to (visible)); } } } @@ -431,6 +391,18 @@ MidiTimeAxisView::drop_instrument_ref () { midnam_connection.drop_connections (); } +void +MidiTimeAxisView::start_scroomer_update () +{ + _note_range_changed_connection.disconnect(); + _note_range_changed_connection = midi_view()->NoteRangeChanged.connect ( + sigc::mem_fun (*this, &MidiTimeAxisView::note_range_changed)); +} +void +MidiTimeAxisView::stop_scroomer_update () +{ + _note_range_changed_connection.disconnect(); +} void MidiTimeAxisView::update_patch_selector () @@ -587,6 +559,9 @@ MidiTimeAxisView::append_extra_display_menu_items () items.push_back (MenuElem (_("Channel Selector"), sigc::mem_fun(*this, &MidiTimeAxisView::toggle_channel_selector))); + items.push_back (MenuElem (_("Select Patch..."), + sigc::mem_fun(*this, &MidiTimeAxisView::send_patch_change))); + color_mode_menu = build_color_mode_menu(); if (color_mode_menu) { items.push_back (MenuElem (_("Color Mode"), *color_mode_menu)); @@ -1102,6 +1077,36 @@ MidiTimeAxisView::build_color_mode_menu() return mode_menu; } +void +MidiTimeAxisView::send_patch_change () +{ + if (!_route) { + return; + } + + Evoral::PatchChange empty (Evoral::Beats(), 0, 0, 0); + PatchChangeDialog d (0, 0, empty, _route->instrument_info(), Gtk::Stock::OK); + + if (d.run() == RESPONSE_CANCEL) { + return; + } + Evoral::PatchChange p (d.patch ()); + + uint8_t chn = p.channel(); + + boost::shared_ptr bank_msb = _route->automation_control(Evoral::Parameter (MidiCCAutomation, chn, MIDI_CTL_MSB_BANK), true); + boost::shared_ptr bank_lsb = _route->automation_control(Evoral::Parameter (MidiCCAutomation, chn, MIDI_CTL_LSB_BANK), true); + boost::shared_ptr program = _route->automation_control(Evoral::Parameter (MidiPgmChangeAutomation, chn), true); + + if (!bank_msb || ! bank_lsb || !program) { + return; + } + + bank_msb->set_value (p.bank_msb (), Controllable::NoGroup); + bank_lsb->set_value (p.bank_lsb (), Controllable::NoGroup); + program->set_value (p.program () , Controllable::NoGroup); +} + void MidiTimeAxisView::set_note_mode(NoteMode mode, bool apply_to_selection) { @@ -1161,13 +1166,6 @@ MidiTimeAxisView::set_note_range (MidiStreamView::VisibleNoteRange range, bool a void MidiTimeAxisView::update_range() { - MidiGhostRegion* mgr; - - for (list::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { - if ((mgr = dynamic_cast(*i)) != 0) { - mgr->update_range(); - } - } } void @@ -1326,6 +1324,10 @@ MidiTimeAxisView::create_automation_child (const Evoral::Parameter& param, bool } add_automation_child (param, track, show); + if (selected ()) { + reshow_selection (_editor.get_selection().time); + } + break; case PanWidthAutomation: @@ -1575,9 +1577,11 @@ MidiTimeAxisView::automation_child_menu_item (Evoral::Parameter param) } boost::shared_ptr -MidiTimeAxisView::add_region (framepos_t pos, framecnt_t length, bool commit, const int32_t sub_num) +MidiTimeAxisView::add_region (framepos_t f, framecnt_t length, bool commit) { Editor* real_editor = dynamic_cast (&_editor); + MusicFrame pos (f, 0); + if (commit) { real_editor->begin_reversible_command (Operations::create_region); } @@ -1594,8 +1598,8 @@ MidiTimeAxisView::add_region (framepos_t pos, framecnt_t length, bool commit, co boost::shared_ptr region = (RegionFactory::create (src, plist)); /* sets beat position */ - region->set_position (pos, sub_num); - playlist()->add_region (region, pos, 1.0, false, sub_num); + region->set_position (pos.frame, pos.division); + playlist()->add_region (region, pos.frame, 1.0, false, pos.division); _session->add_command (new StatefulDiffCommand (playlist())); if (commit) { @@ -1669,42 +1673,6 @@ MidiTimeAxisView::contents_height_changed () _range_scroomer->queue_resize (); } -void -MidiTimeAxisView::playback_channel_mode_changed () -{ - /* Invalidate the controller automation menu */ - delete controller_menu; - controller_menu = 0; - /* Update the button text */ - switch (midi_track()->get_playback_channel_mode()) { - case AllChannels: - _playback_channel_status.set_markup (string_compose ("%1: %2", _("Play"), _("all"))); - break; - case FilterChannels: - _playback_channel_status.set_markup (string_compose ("%1: %2", _("Play"), _("some"))); - break; - case ForceChannel: - _playback_channel_status.set_markup (string_compose ("%1: %2>%3", _("Play"), _("all"), PBD::ffs (midi_track()->get_playback_channel_mask()))); - break; - } -} - -void -MidiTimeAxisView::capture_channel_mode_changed () -{ - switch (midi_track()->get_capture_channel_mode()) { - case AllChannels: - _capture_channel_status.set_markup (string_compose ("%1: %2", _("Rec"), _("all"))); - break; - case FilterChannels: - _capture_channel_status.set_markup (string_compose ("%1: %2", _("Rec"), _("some"))); - break; - case ForceChannel: - _capture_channel_status.set_markup (string_compose ("%1: %2>%3", _("Rec"), _("all"), PBD::ffs (midi_track()->get_capture_channel_mask()))); - break; - } -} - bool MidiTimeAxisView::paste (framepos_t pos, const Selection& selection, PasteContext& ctx, const int32_t sub_num) {