From 83d2adfd67f20e8b2bb2d29e095bf011cde59fba Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 12 Mar 2025 12:36:05 -0600 Subject: [PATCH] remove current_editing_context concept All bindings, actions and members of an EditingContext are now per-EditingContext, and have no impact on others (other than cursors). --- gtk2_ardour/ardour_ui_dialogs.cc | 2 - gtk2_ardour/editing_context.cc | 308 +++++++++++-------------------- gtk2_ardour/editing_context.h | 48 ++--- gtk2_ardour/editor.cc | 11 -- gtk2_ardour/editor.h | 2 - gtk2_ardour/editor_mouse.cc | 4 - gtk2_ardour/pianoroll.cc | 13 -- gtk2_ardour/pianoroll.h | 1 - 8 files changed, 131 insertions(+), 258 deletions(-) diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index 16c9c26866..8461b7b3df 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -654,8 +654,6 @@ ARDOUR_UI::tabs_switch (GtkNotebookPage*, guint page) trigger_page_visibility_button.set_active_state (Gtkmm2ext::Off); } - EditingContext::switch_editing_context (editor); - } else if (mixer && (page == (guint) _tabs.page_num (mixer->contents()))) { mixer->tab_btn_box ().add (tabbables_table); diff --git a/gtk2_ardour/editing_context.cc b/gtk2_ardour/editing_context.cc index 229f8235dc..7d8eff7d42 100644 --- a/gtk2_ardour/editing_context.cc +++ b/gtk2_ardour/editing_context.cc @@ -68,10 +68,8 @@ using std::string; sigc::signal EditingContext::DropDownKeys; Gtkmm2ext::Bindings* EditingContext::button_bindings = nullptr; -Glib::RefPtr EditingContext::_midi_actions; std::vector EditingContext::grid_type_strings; MouseCursors* EditingContext::_cursors = nullptr; -EditingContext* EditingContext::_current_editing_context = nullptr; static const gchar *_grid_type_strings[] = { N_("No Grid"), @@ -109,18 +107,6 @@ static const gchar *_zoom_focus_strings[] = { 0 }; -Editing::GridType EditingContext::_draw_length (GridTypeNone); -int EditingContext::_draw_velocity (DRAW_VEL_AUTO); -int EditingContext::_draw_channel (DRAW_CHAN_AUTO); -sigc::signal EditingContext::DrawLengthChanged; -sigc::signal EditingContext::DrawVelocityChanged; -sigc::signal EditingContext::DrawChannelChanged; - -Glib::RefPtr EditingContext::undo_action; -Glib::RefPtr EditingContext::redo_action; -Glib::RefPtr EditingContext::alternate_redo_action; -Glib::RefPtr EditingContext::alternate_alternate_redo_action; - EditingContext::EditingContext (std::string const & name) : rubberband_rect (0) , _name (name) @@ -131,6 +117,9 @@ EditingContext::EditingContext (std::string const & name) , internal_snap_mode (SnapOff) , _grid_type (GridTypeBeat) , _snap_mode (SnapOff) + , _draw_length (GridTypeNone) + , _draw_velocity (DRAW_VEL_AUTO) + , _draw_channel (DRAW_CHAN_AUTO) , _timeline_origin (0.) , play_note_selection_button (ArdourButton::default_elements) , follow_playhead_button (_("F"), ArdourButton::Text, true) @@ -341,132 +330,126 @@ EditingContext::register_common_actions (Bindings* common_bindings) void EditingContext::register_midi_actions (Bindings* midi_bindings) { - /* These actions are all singletons, defined globally for all EditingContexts */ - - if (_midi_actions) { - return; - } - - _midi_actions = ActionManager::create_action_group (midi_bindings, X_("Notes")); + _midi_actions = ActionManager::create_action_group (midi_bindings, _name + X_("Notes")); /* two versions to allow same action for Delete and Backspace */ - ActionManager::register_action (_midi_actions, X_("clear-selection"), _("Clear Note Selection"), []() { current_editing_context()->midi_action (&MidiRegionView::clear_note_selection); }); - ActionManager::register_action (_midi_actions, X_("invert-selection"), _("Invert Note Selection"), []() { current_editing_context()->midi_action (&MidiRegionView::invert_selection); }); - ActionManager::register_action (_midi_actions, X_("extend-selection"), _("Extend Note Selection"), []() { current_editing_context()->midi_action (&MidiRegionView::extend_selection); }); - ActionManager::register_action (_midi_actions, X_("duplicate-selection"), _("Duplicate Note Selection"), []() { current_editing_context()->midi_action (&MidiRegionView::duplicate_selection); }); + ActionManager::register_action (_midi_actions, X_("clear-selection"), _("Clear Note Selection"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::clear_note_selection)); + ActionManager::register_action (_midi_actions, X_("invert-selection"), _("Invert Note Selection"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::invert_selection)); + ActionManager::register_action (_midi_actions, X_("extend-selection"), _("Extend Note Selection"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::extend_selection)); + ActionManager::register_action (_midi_actions, X_("duplicate-selection"), _("Duplicate Note Selection"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::duplicate_selection)); /* Lengthen */ - ActionManager::register_action (_midi_actions, X_("move-starts-earlier-fine"), _("Move Note Start Earlier (fine)"), []() { current_editing_context()->midi_action (&MidiRegionView::move_note_starts_earlier_fine); }); - ActionManager::register_action (_midi_actions, X_("move-starts-earlier"), _("Move Note Start Earlier"), []() { current_editing_context()->midi_action (&MidiRegionView::move_note_starts_earlier); }); - ActionManager::register_action (_midi_actions, X_("move-ends-later-fine"), _("Move Note Ends Later (fine)"), []() { current_editing_context()->midi_action (&MidiRegionView::move_note_ends_later_fine); }); - ActionManager::register_action (_midi_actions, X_("move-ends-later"), _("Move Note Ends Later"), []() { current_editing_context()->midi_action (&MidiRegionView::move_note_ends_later); }); + ActionManager::register_action (_midi_actions, X_("move-starts-earlier-fine"), _("Move Note Start Earlier (fine)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::move_note_starts_earlier_fine)); + ActionManager::register_action (_midi_actions, X_("move-starts-earlier"), _("Move Note Start Earlier"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::move_note_starts_earlier)); + ActionManager::register_action (_midi_actions, X_("move-ends-later-fine"), _("Move Note Ends Later (fine)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::move_note_ends_later_fine)); + ActionManager::register_action (_midi_actions, X_("move-ends-later"), _("Move Note Ends Later"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::move_note_ends_later)); /* Shorten */ - ActionManager::register_action (_midi_actions, X_("move-starts-later-fine"), _("Move Note Start Later (fine)"), []() { current_editing_context()->midi_action (&MidiRegionView::move_note_starts_later_fine); }); - ActionManager::register_action (_midi_actions, X_("move-starts-later"), _("Move Note Start Later"), []() { current_editing_context()->midi_action (&MidiRegionView::move_note_starts_later); }); - ActionManager::register_action (_midi_actions, X_("move-ends-earlier-fine"), _("Move Note Ends Earlier (fine)"), []() { current_editing_context()->midi_action (&MidiRegionView::move_note_ends_earlier_fine); }); - ActionManager::register_action (_midi_actions, X_("move-ends-earlier"), _("Move Note Ends Earlier"), []() { current_editing_context()->midi_action (&MidiRegionView::move_note_ends_earlier); }); + ActionManager::register_action (_midi_actions, X_("move-starts-later-fine"), _("Move Note Start Later (fine)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::move_note_starts_later_fine)); + ActionManager::register_action (_midi_actions, X_("move-starts-later"), _("Move Note Start Later"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::move_note_starts_later)); + ActionManager::register_action (_midi_actions, X_("move-ends-earlier-fine"), _("Move Note Ends Earlier (fine)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::move_note_ends_earlier_fine)); + ActionManager::register_action (_midi_actions, X_("move-ends-earlier"), _("Move Note Ends Earlier"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::move_note_ends_earlier)); /* Alt versions allow bindings for both Tab and ISO_Left_Tab, if desired */ - ActionManager::register_action (_midi_actions, X_("select-next"), _("Select Next"), []() { current_editing_context()->midi_action (&MidiView::select_next_note); }); - ActionManager::register_action (_midi_actions, X_("alt-select-next"), _("Select Next (alternate)"), []() { current_editing_context()->midi_action (&MidiView::select_next_note); }); - ActionManager::register_action (_midi_actions, X_("select-previous"), _("Select Previous"), []() { current_editing_context()->midi_action (&MidiView::select_previous_note); }); - ActionManager::register_action (_midi_actions, X_("alt-select-previous"), _("Select Previous (alternate)"), []() { current_editing_context()->midi_action (&MidiView::select_previous_note); }); - ActionManager::register_action (_midi_actions, X_("add-select-next"), _("Add Next to Selection"), []() { current_editing_context()->midi_action (&MidiView::add_select_next_note); }); - ActionManager::register_action (_midi_actions, X_("alt-add-select-next"), _("Add Next to Selection (alternate)"), []() { current_editing_context()->midi_action (&MidiView::add_select_next_note); }); - ActionManager::register_action (_midi_actions, X_("add-select-previous"), _("Add Previous to Selection"), []() { current_editing_context()->midi_action (&MidiView::add_select_previous_note); }); - ActionManager::register_action (_midi_actions, X_("alt-add-select-previous"), _("Add Previous to Selection (alternate)"), []() { current_editing_context()->midi_action (&MidiView::add_select_previous_note); }); + ActionManager::register_action (_midi_actions, X_("select-next"), _("Select Next"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::select_next_note)); + ActionManager::register_action (_midi_actions, X_("alt-select-next"), _("Select Next (alternate)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::select_next_note)); + ActionManager::register_action (_midi_actions, X_("select-previous"), _("Select Previous"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::select_previous_note)); + ActionManager::register_action (_midi_actions, X_("alt-select-previous"), _("Select Previous (alternate)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::select_previous_note)); + ActionManager::register_action (_midi_actions, X_("add-select-next"), _("Add Next to Selection"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::add_select_next_note)); + ActionManager::register_action (_midi_actions, X_("alt-add-select-next"), _("Add Next to Selection (alternate)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::add_select_next_note)); + ActionManager::register_action (_midi_actions, X_("add-select-previous"), _("Add Previous to Selection"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::add_select_previous_note)); + ActionManager::register_action (_midi_actions, X_("alt-add-select-previous"), _("Add Previous to Selection (alternate)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::add_select_previous_note)); - ActionManager::register_action (_midi_actions, X_("increase-velocity"), _("Increase Velocity"), []() { current_editing_context()->midi_action (&MidiView::increase_note_velocity); }); - ActionManager::register_action (_midi_actions, X_("increase-velocity-fine"), _("Increase Velocity (fine)"), []() { current_editing_context()->midi_action (&MidiView::increase_note_velocity_fine); }); - ActionManager::register_action (_midi_actions, X_("increase-velocity-smush"), _("Increase Velocity (allow mush)"), []() { current_editing_context()->midi_action (&MidiView::increase_note_velocity_smush); }); - ActionManager::register_action (_midi_actions, X_("increase-velocity-together"), _("Increase Velocity (non-relative)"), []() { current_editing_context()->midi_action (&MidiView::increase_note_velocity_together); }); - ActionManager::register_action (_midi_actions, X_("increase-velocity-fine-smush"), _("Increase Velocity (fine, allow mush)"), []() { current_editing_context()->midi_action (&MidiView::increase_note_velocity_fine_smush); }); - ActionManager::register_action (_midi_actions, X_("increase-velocity-fine-together"), _("Increase Velocity (fine, non-relative)"), []() { current_editing_context()->midi_action (&MidiView::increase_note_velocity_fine_together); }); - ActionManager::register_action (_midi_actions, X_("increase-velocity-smush-together"), _("Increase Velocity (maintain ratios, allow mush)"), []() { current_editing_context()->midi_action (&MidiView::increase_note_velocity_smush_together); }); - ActionManager::register_action (_midi_actions, X_("increase-velocity-fine-smush-together"), _("Increase Velocity (fine, allow mush, non-relative)"), []() { current_editing_context()->midi_action (&MidiView::increase_note_velocity_fine_smush_together); }); + ActionManager::register_action (_midi_actions, X_("increase-velocity"), _("Increase Velocity"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::increase_note_velocity)); + ActionManager::register_action (_midi_actions, X_("increase-velocity-fine"), _("Increase Velocity (fine)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::increase_note_velocity_fine)); + ActionManager::register_action (_midi_actions, X_("increase-velocity-smush"), _("Increase Velocity (allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::increase_note_velocity_smush)); + ActionManager::register_action (_midi_actions, X_("increase-velocity-together"), _("Increase Velocity (non-relative)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::increase_note_velocity_together)); + ActionManager::register_action (_midi_actions, X_("increase-velocity-fine-smush"), _("Increase Velocity (fine, allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::increase_note_velocity_fine_smush)); + ActionManager::register_action (_midi_actions, X_("increase-velocity-fine-together"), _("Increase Velocity (fine, non-relative)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::increase_note_velocity_fine_together)); + ActionManager::register_action (_midi_actions, X_("increase-velocity-smush-together"), _("Increase Velocity (maintain ratios, allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::increase_note_velocity_smush_together)); + ActionManager::register_action (_midi_actions, X_("increase-velocity-fine-smush-together"), _("Increase Velocity (fine, allow mush, non-relative)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::increase_note_velocity_fine_smush_together)); - ActionManager::register_action (_midi_actions, X_("decrease-velocity"), _("Decrease Velocity"), []() { current_editing_context()->midi_action (&MidiView::decrease_note_velocity); }); - ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine"), _("Decrease Velocity (fine)"), []() { current_editing_context()->midi_action (&MidiView::decrease_note_velocity_fine); }); - ActionManager::register_action (_midi_actions, X_("decrease-velocity-smush"), _("Decrease Velocity (allow mush)"), []() { current_editing_context()->midi_action (&MidiView::decrease_note_velocity_smush); }); - ActionManager::register_action (_midi_actions, X_("decrease-velocity-together"), _("Decrease Velocity (non-relative)"), []() { current_editing_context()->midi_action (&MidiView::decrease_note_velocity_together); }); - ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine-smush"), _("Decrease Velocity (fine, allow mush)"), []() { current_editing_context()->midi_action (&MidiView::decrease_note_velocity_fine_smush); }); - ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine-together"), _("Decrease Velocity (fine, non-relative)"), []() { current_editing_context()->midi_action (&MidiView::decrease_note_velocity_fine_together); }); - ActionManager::register_action (_midi_actions, X_("decrease-velocity-smush-together"), _("Decrease Velocity (maintain ratios, allow mush)"), []() { current_editing_context()->midi_action (&MidiView::decrease_note_velocity_smush_together); }); - ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine-smush-together"), _("Decrease Velocity (fine, allow mush, non-relative)"), []() { current_editing_context()->midi_action (&MidiView::decrease_note_velocity_fine_smush_together); }); + ActionManager::register_action (_midi_actions, X_("decrease-velocity"), _("Decrease Velocity"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::decrease_note_velocity)); + ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine"), _("Decrease Velocity (fine)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::decrease_note_velocity_fine)); + ActionManager::register_action (_midi_actions, X_("decrease-velocity-smush"), _("Decrease Velocity (allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::decrease_note_velocity_smush)); + ActionManager::register_action (_midi_actions, X_("decrease-velocity-together"), _("Decrease Velocity (non-relative)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::decrease_note_velocity_together)); + ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine-smush"), _("Decrease Velocity (fine, allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::decrease_note_velocity_fine_smush)); + ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine-together"), _("Decrease Velocity (fine, non-relative)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::decrease_note_velocity_fine_together)); + ActionManager::register_action (_midi_actions, X_("decrease-velocity-smush-together"), _("Decrease Velocity (maintain ratios, allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::decrease_note_velocity_smush_together)); + ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine-smush-together"), _("Decrease Velocity (fine, allow mush, non-relative)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::decrease_note_velocity_fine_smush_together)); - ActionManager::register_action (_midi_actions, X_("transpose-up-octave"), _("Transpose Up (octave)"), []() { current_editing_context()->midi_action (&MidiView::transpose_up_octave); }); - ActionManager::register_action (_midi_actions, X_("transpose-up-octave-smush"), _("Transpose Up (octave, allow mush)"), []() { current_editing_context()->midi_action (&MidiView::transpose_up_octave_smush); }); - ActionManager::register_action (_midi_actions, X_("transpose-up-semitone"), _("Transpose Up (semitone)"), []() { current_editing_context()->midi_action (&MidiView::transpose_up_tone); }); - ActionManager::register_action (_midi_actions, X_("transpose-up-semitone-smush"), _("Transpose Up (semitone, allow mush)"), []() { current_editing_context()->midi_action (&MidiView::transpose_up_octave_smush); }); + ActionManager::register_action (_midi_actions, X_("transpose-up-octave"), _("Transpose Up (octave)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::transpose_up_octave)); + ActionManager::register_action (_midi_actions, X_("transpose-up-octave-smush"), _("Transpose Up (octave, allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::transpose_up_octave_smush)); + ActionManager::register_action (_midi_actions, X_("transpose-up-semitone"), _("Transpose Up (semitone)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::transpose_up_tone)); + ActionManager::register_action (_midi_actions, X_("transpose-up-semitone-smush"), _("Transpose Up (semitone, allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::transpose_up_octave_smush)); - ActionManager::register_action (_midi_actions, X_("transpose-down-octave"), _("Transpose Down (octave)"), []() { current_editing_context()->midi_action (&MidiView::transpose_down_octave); }); - ActionManager::register_action (_midi_actions, X_("transpose-down-octave-smush"), _("Transpose Down (octave, allow mush)"), []() { current_editing_context()->midi_action (&MidiView::transpose_down_octave_smush); }); - ActionManager::register_action (_midi_actions, X_("transpose-down-semitone"), _("Transpose Down (semitone)"), []() { current_editing_context()->midi_action (&MidiView::transpose_down_tone); }); - ActionManager::register_action (_midi_actions, X_("transpose-down-semitone-smush"), _("Transpose Down (semitone, allow mush)"), []() { current_editing_context()->midi_action (&MidiView::transpose_down_octave_smush); }); + ActionManager::register_action (_midi_actions, X_("transpose-down-octave"), _("Transpose Down (octave)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::transpose_down_octave)); + ActionManager::register_action (_midi_actions, X_("transpose-down-octave-smush"), _("Transpose Down (octave, allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::transpose_down_octave_smush)); + ActionManager::register_action (_midi_actions, X_("transpose-down-semitone"), _("Transpose Down (semitone)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::transpose_down_tone)); + ActionManager::register_action (_midi_actions, X_("transpose-down-semitone-smush"), _("Transpose Down (semitone, allow mush)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::transpose_down_octave_smush)); - ActionManager::register_action (_midi_actions, X_("nudge-later"), _("Nudge Notes Later (grid)"), []() { current_editing_context()->midi_action (&MidiView::nudge_notes_later); }); - ActionManager::register_action (_midi_actions, X_("nudge-later-fine"), _("Nudge Notes Later (1/4 grid)"), []() { current_editing_context()->midi_action (&MidiView::nudge_notes_later_fine); }); - ActionManager::register_action (_midi_actions, X_("nudge-earlier"), _("Nudge Notes Earlier (grid)"), []() { current_editing_context()->midi_action (&MidiView::nudge_notes_earlier); }); - ActionManager::register_action (_midi_actions, X_("nudge-earlier-fine"), _("Nudge Notes Earlier (1/4 grid)"), []() { current_editing_context()->midi_action (&MidiView::nudge_notes_earlier_fine); }); + ActionManager::register_action (_midi_actions, X_("nudge-later"), _("Nudge Notes Later (grid)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::nudge_notes_later)); + ActionManager::register_action (_midi_actions, X_("nudge-later-fine"), _("Nudge Notes Later (1/4 grid)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::nudge_notes_later_fine)); + ActionManager::register_action (_midi_actions, X_("nudge-earlier"), _("Nudge Notes Earlier (grid)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::nudge_notes_earlier)); + ActionManager::register_action (_midi_actions, X_("nudge-earlier-fine"), _("Nudge Notes Earlier (1/4 grid)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::nudge_notes_earlier_fine)); - ActionManager::register_action (_midi_actions, X_("split-notes-grid"), _("Split Selected Notes on grid boundaries"), []() { current_editing_context()->midi_action (&MidiView::split_notes_grid); }); - ActionManager::register_action (_midi_actions, X_("split-notes-more"), _("Split Selected Notes into more pieces"), []() { current_editing_context()->midi_action (&MidiView::split_notes_more); }); - ActionManager::register_action (_midi_actions, X_("split-notes-less"), _("Split Selected Notes into less pieces"), []() { current_editing_context()->midi_action (&MidiView::split_notes_less); }); - ActionManager::register_action (_midi_actions, X_("join-notes"), _("Join Selected Notes"), []() { current_editing_context()->midi_action (&MidiView::join_notes); }); + ActionManager::register_action (_midi_actions, X_("split-notes-grid"), _("Split Selected Notes on grid boundaries"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::split_notes_grid)); + ActionManager::register_action (_midi_actions, X_("split-notes-more"), _("Split Selected Notes into more pieces"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::split_notes_more)); + ActionManager::register_action (_midi_actions, X_("split-notes-less"), _("Split Selected Notes into less pieces"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::split_notes_less)); + ActionManager::register_action (_midi_actions, X_("join-notes"), _("Join Selected Notes"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::join_notes)); - ActionManager::register_action (_midi_actions, X_("edit-channels"), _("Edit Note Channels"), []() { current_editing_context()->midi_action (&MidiView::channel_edit); }); - ActionManager::register_action (_midi_actions, X_("edit-velocities"), _("Edit Note Velocities"), []() { current_editing_context()->midi_action (&MidiView::velocity_edit); }); + ActionManager::register_action (_midi_actions, X_("edit-channels"), _("Edit Note Channels"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::channel_edit)); + ActionManager::register_action (_midi_actions, X_("edit-velocities"), _("Edit Note Velocities"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::velocity_edit)); - ActionManager::register_action (_midi_actions, X_("quantize-selected-notes"), _("Quantize Selected Notes"), []() { current_editing_context()->midi_action ( &MidiView::quantize_selected_notes); }); + ActionManager::register_action (_midi_actions, X_("quantize-selected-notes"), _("Quantize Selected Notes"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiView::quantize_selected_notes)); - Glib::RefPtr length_actions = ActionManager::create_action_group (midi_bindings, X_("DrawLength")); + Glib::RefPtr length_actions = ActionManager::create_action_group (midi_bindings, _name + X_("DrawLength")); RadioAction::Group draw_length_group; - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-thirtyseconds"), grid_type_strings[(int)GridTypeBeatDiv32].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv32); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-twentyeighths"), grid_type_strings[(int)GridTypeBeatDiv28].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv28); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-twentyfourths"), grid_type_strings[(int)GridTypeBeatDiv24].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv24); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-twentieths"), grid_type_strings[(int)GridTypeBeatDiv20].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv20); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-asixteenthbeat"), grid_type_strings[(int)GridTypeBeatDiv16].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv16); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-fourteenths"), grid_type_strings[(int)GridTypeBeatDiv14].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv14); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-twelfths"), grid_type_strings[(int)GridTypeBeatDiv12].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv12); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-tenths"), grid_type_strings[(int)GridTypeBeatDiv10].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv10); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-eighths"), grid_type_strings[(int)GridTypeBeatDiv8].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv8); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-sevenths"), grid_type_strings[(int)GridTypeBeatDiv7].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv7); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-sixths"), grid_type_strings[(int)GridTypeBeatDiv6].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv6); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-fifths"), grid_type_strings[(int)GridTypeBeatDiv5].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv5); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-quarters"), grid_type_strings[(int)GridTypeBeatDiv4].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv4); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-thirds"), grid_type_strings[(int)GridTypeBeatDiv3].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv3); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-halves"), grid_type_strings[(int)GridTypeBeatDiv2].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeatDiv2); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-beat"), grid_type_strings[(int)GridTypeBeat].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBeat); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-bar"), grid_type_strings[(int)GridTypeBar].c_str(), []() { EditingContext::draw_length_action_method (Editing::GridTypeBar); }); - ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-auto"), _("Auto"), []() { EditingContext::draw_length_action_method (DRAW_LEN_AUTO); }); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-thirtyseconds"), grid_type_strings[(int)GridTypeBeatDiv32].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv32)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-twentyeighths"), grid_type_strings[(int)GridTypeBeatDiv28].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv28)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-twentyfourths"), grid_type_strings[(int)GridTypeBeatDiv24].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv24)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-twentieths"), grid_type_strings[(int)GridTypeBeatDiv20].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv20)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-asixteenthbeat"), grid_type_strings[(int)GridTypeBeatDiv16].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv16)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-fourteenths"), grid_type_strings[(int)GridTypeBeatDiv14].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv14)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-twelfths"), grid_type_strings[(int)GridTypeBeatDiv12].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv12)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-tenths"), grid_type_strings[(int)GridTypeBeatDiv10].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv10)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-eighths"), grid_type_strings[(int)GridTypeBeatDiv8].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv8)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-sevenths"), grid_type_strings[(int)GridTypeBeatDiv7].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv7)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-sixths"), grid_type_strings[(int)GridTypeBeatDiv6].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv6)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-fifths"), grid_type_strings[(int)GridTypeBeatDiv5].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv5)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-quarters"), grid_type_strings[(int)GridTypeBeatDiv4].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv4)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-thirds"), grid_type_strings[(int)GridTypeBeatDiv3].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv3)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-halves"), grid_type_strings[(int)GridTypeBeatDiv2].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeatDiv2)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-beat"), grid_type_strings[(int)GridTypeBeat].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBeat)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-bar"), grid_type_strings[(int)GridTypeBar].c_str(), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), Editing::GridTypeBar)); + ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-auto"), _("Auto"), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), DRAW_LEN_AUTO)); - Glib::RefPtr velocity_actions = ActionManager::create_action_group (midi_bindings, _("Draw Velocity")); + Glib::RefPtr velocity_actions = ActionManager::create_action_group (midi_bindings, _name + X_("DrawVelocity")); RadioAction::Group draw_velocity_group; - ActionManager::register_radio_action (velocity_actions, draw_velocity_group, X_("draw-velocity-auto"), _("Auto"), []() { EditingContext::draw_velocity_action_method (DRAW_VEL_AUTO); }); + ActionManager::register_radio_action (velocity_actions, draw_velocity_group, X_("draw-velocity-auto"), _("Auto"), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), DRAW_VEL_AUTO)); for (int i = 1; i <= 127; i++) { char buf[64]; snprintf(buf, sizeof (buf), X_("draw-velocity-%d"), i); char vel[64]; sprintf(vel, _("Velocity %d"), i); - ActionManager::register_radio_action (velocity_actions, draw_velocity_group, buf, vel, [i]() { EditingContext::draw_velocity_action_method (i); }); + ActionManager::register_radio_action (velocity_actions, draw_velocity_group, buf, vel, sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), i)); } - Glib::RefPtr channel_actions = ActionManager::create_action_group (midi_bindings, _("Draw Channel")); + Glib::RefPtr channel_actions = ActionManager::create_action_group (midi_bindings, _name + X_("DrawChannel")); RadioAction::Group draw_channel_group; - ActionManager::register_radio_action (channel_actions, draw_channel_group, X_("draw-channel-auto"), _("Auto"), []() { EditingContext::draw_channel_action_method (DRAW_CHAN_AUTO); }); + ActionManager::register_radio_action (channel_actions, draw_channel_group, X_("draw-channel-auto"), _("Auto"), sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_channel_chosen), DRAW_CHAN_AUTO)); for (int i = 0; i <= 15; i++) { char buf[64]; snprintf(buf, sizeof (buf), X_("draw-channel-%d"), i+1); char ch[64]; sprintf(ch, X_("Channel %d"), i+1); - ActionManager::register_radio_action (channel_actions, draw_channel_group, buf, ch, [i]() { EditingContext::draw_channel_action_method (i); }); + ActionManager::register_radio_action (channel_actions, draw_channel_group, buf, ch, sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_channel_chosen), i)); } ActionManager::set_sensitive (_midi_actions, false); @@ -713,22 +696,6 @@ EditingContext::grid_type_chosen (GridType type) } } -void -EditingContext::draw_length_action_method (GridType type) -{ - /* this is driven by a toggle on a radio group, and so is invoked twice, - once for the item that became inactive and once for the one that became - active. - */ - - RefPtr ract = draw_length_action (type); - - if (ract && ract->get_active()) { - /* It doesn't really matter which EditingContext executes this */ - current_editing_context()->set_draw_length_to (type); - } -} - void EditingContext::draw_length_chosen (GridType type) { @@ -741,25 +708,7 @@ EditingContext::draw_length_chosen (GridType type) if (ract && ract->get_active()) { /* It doesn't really matter which EditingContext executes this */ - current_editing_context()->set_draw_length_to (type); - } else { - ract->set_active(); - } -} - -void -EditingContext::draw_velocity_action_method (int v) -{ - /* this is driven by a toggle on a radio group, and so is invoked twice, - once for the item that became inactive and once for the one that became - active. - */ - - RefPtr ract = draw_velocity_action (v); - - if (ract && ract->get_active()) { - /* It doesn't really matter which EditingContext executes this */ - current_editing_context()->set_draw_velocity_to (v); + set_draw_length_to (type); } } @@ -775,25 +724,7 @@ EditingContext::draw_velocity_chosen (int v) if (ract && ract->get_active()) { /* It doesn't really matter which EditingContext executes this */ - current_editing_context()->set_draw_velocity_to (v); - } else { - ract->set_active(); - } -} - -void -EditingContext::draw_channel_action_method (int c) -{ - /* this is driven by a toggle on a radio group, and so is invoked twice, - once for the item that became inactive and once for the one that became - active. - */ - - RefPtr ract = draw_channel_action (c); - - if (ract && ract->get_active()) { - /* It doesn't really matter which EditingContext executes this */ - current_editing_context()->set_draw_channel_to (c); + set_draw_velocity_to (v); } } @@ -809,9 +740,7 @@ EditingContext::draw_channel_chosen (int c) if (ract && ract->get_active()) { /* It doesn't really matter which EditingContext executes this */ - current_editing_context()->set_draw_channel_to (c); - } else { - ract->set_active(); + set_draw_channel_to (c); } } @@ -1111,7 +1040,7 @@ EditingContext::draw_velocity_action (int v) action = buf; } - act = ActionManager::get_action (_("Draw Velocity"), action); + act = ActionManager::get_action ((_name + X_("DrawVelocity")).c_str(), action); if (act) { RefPtr ract = RefPtr::cast_dynamic(act); return ract; @@ -1135,7 +1064,7 @@ EditingContext::draw_channel_action (int c) action = buf; } - act = ActionManager::get_action (_("Draw Channel"), action); + act = ActionManager::get_action ((_name + X_("DrawChannel")).c_str(), action); if (act) { RefPtr ract = RefPtr::cast_dynamic(act); return ract; @@ -1214,7 +1143,7 @@ EditingContext::draw_length_action (GridType type) abort(); /*NOTREACHED*/ } - act = ActionManager::get_action (X_("DrawLength"), action); + act = ActionManager::get_action ((_name + X_("DrawLength")).c_str(), action); if (act) { RefPtr ract = RefPtr::cast_dynamic(act); @@ -1290,13 +1219,13 @@ EditingContext::build_draw_midi_menus () using namespace Menu_Helpers; /* Note-Length when drawing */ - draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeat], []() { EditingContext::draw_length_chosen ((GridType) GridTypeBeat); })); - draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv2], []() { EditingContext::draw_length_chosen ((GridType) GridTypeBeatDiv2); })); - draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv4], []() { EditingContext::draw_length_chosen ((GridType) GridTypeBeatDiv4); })); - draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv8], []() { EditingContext::draw_length_chosen ((GridType) GridTypeBeatDiv8); })); - draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv16],[]() { EditingContext::draw_length_chosen ((GridType) GridTypeBeatDiv16); })); - draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv32],[]() { EditingContext::draw_length_chosen ((GridType) GridTypeBeatDiv32); })); - draw_length_selector.AddMenuElem (MenuElem (_("Auto"),[]() { EditingContext::draw_length_chosen ((GridType) DRAW_LEN_AUTO); })); + draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeat], sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), (GridType) GridTypeBeat))); + draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv2], sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), (GridType) GridTypeBeatDiv2))); + draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv4], sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), (GridType) GridTypeBeatDiv4))); + draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv8], sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), (GridType) GridTypeBeatDiv8))); + draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv16],sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), (GridType) GridTypeBeatDiv16))); + draw_length_selector.AddMenuElem (MenuElem (grid_type_strings[(int)GridTypeBeatDiv32],sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), (GridType) GridTypeBeatDiv32))); + draw_length_selector.AddMenuElem (MenuElem (_("Auto"),sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_length_chosen), (GridType) DRAW_LEN_AUTO))); { std::vector draw_grid_type_strings = {grid_type_strings.begin() + GridTypeBeat, grid_type_strings.begin() + GridTypeBeatDiv32 + 1}; @@ -1306,21 +1235,21 @@ EditingContext::build_draw_midi_menus () /* Note-Velocity when drawing */ - draw_velocity_selector.AddMenuElem (MenuElem ("8", []() { EditingContext::draw_velocity_chosen (8); })); - draw_velocity_selector.AddMenuElem (MenuElem ("32", []() { EditingContext::draw_velocity_chosen (32); })); - draw_velocity_selector.AddMenuElem (MenuElem ("64", []() { EditingContext::draw_velocity_chosen (64); })); - draw_velocity_selector.AddMenuElem (MenuElem ("82", []() { EditingContext::draw_velocity_chosen (82); })); - draw_velocity_selector.AddMenuElem (MenuElem ("100", []() { EditingContext::draw_velocity_chosen (100); })); - draw_velocity_selector.AddMenuElem (MenuElem ("127", []() { EditingContext::draw_velocity_chosen (127); })); - draw_velocity_selector.AddMenuElem (MenuElem (_("Auto"),[]() { EditingContext::draw_velocity_chosen (DRAW_VEL_AUTO); })); + draw_velocity_selector.AddMenuElem (MenuElem ("8", sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), 8))); + draw_velocity_selector.AddMenuElem (MenuElem ("32", sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), 32))); + draw_velocity_selector.AddMenuElem (MenuElem ("64", sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), 64))); + draw_velocity_selector.AddMenuElem (MenuElem ("82", sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), 82))); + draw_velocity_selector.AddMenuElem (MenuElem ("100", sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), 100))); + draw_velocity_selector.AddMenuElem (MenuElem ("127", sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), 127))); + draw_velocity_selector.AddMenuElem (MenuElem (_("Auto"),sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_velocity_chosen), DRAW_VEL_AUTO))); /* Note-Channel when drawing */ for (int i = 0; i<= 15; i++) { char buf[64]; sprintf(buf, "%d", i+1); - draw_channel_selector.AddMenuElem (MenuElem (buf, [i]() { EditingContext::draw_channel_chosen (i); })); + draw_channel_selector.AddMenuElem (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_channel_chosen), i))); } - draw_channel_selector.AddMenuElem (MenuElem (_("Auto"),[]() { EditingContext::draw_channel_chosen (DRAW_CHAN_AUTO); })); + draw_channel_selector.AddMenuElem (MenuElem (_("Auto"),sigc::bind (sigc::mem_fun (*this, &EditingContext::draw_channel_chosen), DRAW_CHAN_AUTO))); } bool @@ -2087,19 +2016,6 @@ EditingContext::apply_midi_note_edit_op (MidiOperator& op, const RegionSelection } } -EditingContext* -EditingContext::current_editing_context() -{ - return _current_editing_context; -} - -void -EditingContext::switch_editing_context (EditingContext* ec) -{ - assert (ec); - _current_editing_context = ec; -} - double EditingContext::horizontal_position () const { @@ -3288,15 +3204,15 @@ EditingContext::load_shared_bindings () * the keys may overlap. */ - Bindings* midi_bindings = Bindings::get_bindings (X_("MIDI")); - register_midi_actions (midi_bindings); - - Bindings* b = Bindings::get_bindings (X_("Editing")); - - /* Copy the Editing bindings, which will make them refer to actions + /* Copy each set of shared bindings but give them a new name, which will make them refer to actions * named after this EditingContext (ie. unique to this EC) */ + Bindings* m = Bindings::get_bindings (X_("MIDI")); + Bindings* midi_bindings = new Bindings (_name, *m); + register_midi_actions (midi_bindings); + + Bindings* b = Bindings::get_bindings (X_("Editing")); Bindings* shared_bindings = new Bindings (_name, *b); register_common_actions (shared_bindings); diff --git a/gtk2_ardour/editing_context.h b/gtk2_ardour/editing_context.h index b413af19f1..6ffe3474f1 100644 --- a/gtk2_ardour/editing_context.h +++ b/gtk2_ardour/editing_context.h @@ -407,7 +407,7 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider void legatize_region (bool shrink_only); void transpose_region (); - static void register_midi_actions (Gtkmm2ext::Bindings*); + void register_midi_actions (Gtkmm2ext::Bindings*); void register_common_actions (Gtkmm2ext::Bindings*); ArdourCanvas::Rectangle* rubberband_rect; @@ -451,10 +451,7 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider void redo (uint32_t n = 1) { do_redo (n); } virtual void history_changed() = 0; - static void update_undo_redo_actions (PBD::UndoHistory const &); - - static EditingContext* current_editing_context(); - static void switch_editing_context(EditingContext*); + void update_undo_redo_actions (PBD::UndoHistory const &); virtual void set_canvas_cursor (Gdk::Cursor*); @@ -484,7 +481,7 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider std::string _name; bool within_track_canvas; - static Glib::RefPtr _midi_actions; + Glib::RefPtr _midi_actions; Glib::RefPtr _common_actions; void load_shared_bindings (); @@ -499,28 +496,24 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider Glib::RefPtr grid_type_action (Editing::GridType); Glib::RefPtr snap_mode_action (Editing::SnapMode); - static Glib::RefPtr draw_length_action (Editing::GridType); - static Glib::RefPtr draw_velocity_action (int); - static Glib::RefPtr draw_channel_action (int); + Glib::RefPtr draw_length_action (Editing::GridType); + Glib::RefPtr draw_velocity_action (int); + Glib::RefPtr draw_channel_action (int); Editing::GridType _grid_type; Editing::SnapMode _snap_mode; - static Editing::GridType _draw_length; - static int _draw_velocity; - static int _draw_channel; + Editing::GridType _draw_length; + int _draw_velocity; + int _draw_channel; - static void draw_channel_chosen (int); - static void draw_velocity_chosen (int); - static void draw_length_chosen (Editing::GridType); + void draw_channel_chosen (int); + void draw_velocity_chosen (int); + void draw_length_chosen (Editing::GridType); - static void draw_channel_action_method (int); - static void draw_velocity_action_method (int); - static void draw_length_action_method (Editing::GridType); - - static sigc::signal DrawLengthChanged; - static sigc::signal DrawVelocityChanged; - static sigc::signal DrawChannelChanged; + sigc::signal DrawLengthChanged; + sigc::signal DrawVelocityChanged; + sigc::signal DrawChannelChanged; void draw_length_changed (); void draw_velocity_changed (); @@ -791,17 +784,14 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider virtual void do_undo (uint32_t n) = 0; virtual void do_redo (uint32_t n) = 0; - static Glib::RefPtr undo_action; - static Glib::RefPtr redo_action; - static Glib::RefPtr alternate_redo_action; - static Glib::RefPtr alternate_alternate_redo_action; + Glib::RefPtr undo_action; + Glib::RefPtr redo_action; + Glib::RefPtr alternate_redo_action; + Glib::RefPtr alternate_alternate_redo_action; /* protected helper functions to help with registering actions */ static Glib::RefPtr reg_sens (Glib::RefPtr group, char const* name, char const* label, sigc::slot slot); static void toggle_reg_sens (Glib::RefPtr group, char const* name, char const* label, sigc::slot slot); static void radio_reg_sens (Glib::RefPtr action_group, Gtk::RadioAction::Group& radio_group, char const* name, char const* label, sigc::slot slot); - - static EditingContext* _current_editing_context; - }; diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 3e83455f5f..1a945651e0 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -717,17 +717,6 @@ Editor::Editor () UIConfiguration::instance().map_parameters (pc); setup_fade_images (); - - switch_editing_context (this); - content_main_top.signal_enter_notify_event().connect (sigc::mem_fun (*this, &Editor::enter), false); - content_main.signal_enter_notify_event().connect (sigc::mem_fun (*this, &Editor::enter), false); -} - -bool -Editor::enter (GdkEventCrossing*) -{ - switch_editing_context (this); - return false; } Editor::~Editor() diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index c39aac7d88..a1c9836332 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2294,8 +2294,6 @@ private: PBD::Signal VisibleMarkersChanged; PBD::Signal VisibleRangesChanged; - bool enter (GdkEventCrossing*); - friend class RegionMoveDrag; friend class TrimDrag; friend class MappingTwistDrag; diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index a8ed23a485..ee933287b7 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2245,10 +2245,6 @@ Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event) void Editor::escape () { - if (this != current_editing_context()) { - return; - } - if (_drags->active ()) { _drags->abort (); } else if (_session) { diff --git a/gtk2_ardour/pianoroll.cc b/gtk2_ardour/pianoroll.cc index 18be15060f..76719b80e4 100644 --- a/gtk2_ardour/pianoroll.cc +++ b/gtk2_ardour/pianoroll.cc @@ -90,11 +90,7 @@ Pianoroll::Pianoroll (std::string const & name) load_bindings (); register_actions (); - /* this is weird because it will use an action that uses current_editing_context */ - EditingContext* ec = current_editing_context (); - switch_editing_context (this); set_mouse_mode (Editing::MouseContent, true); - switch_editing_context (ec); } Pianoroll::~Pianoroll () @@ -104,13 +100,6 @@ Pianoroll::~Pianoroll () ActionManager::drop_action_group (snap_actions); } -bool -Pianoroll::enter (GdkEventCrossing*) -{ - switch_editing_context (this); - return false; -} - void Pianoroll::load_bindings () { @@ -428,7 +417,6 @@ Pianoroll::build_upper_toolbar () _toolbox.pack_start (*_toolbar_outer, false, false); _contents.add (_toolbox); - _contents.signal_enter_notify_event().connect (sigc::mem_fun (*this, &Pianoroll::enter), false); _contents.signal_unmap().connect ([this]() {_canvas_viewport->unmap ();}, false); _contents.signal_map().connect ([this]() {_canvas_viewport->map ();}, false); } @@ -631,7 +619,6 @@ Pianoroll::canvas_enter_leave (GdkEventCrossing* ev) _canvas_viewport->canvas()->grab_focus (); ActionManager::set_sensitive (_midi_actions, true); within_track_canvas = true; - EditingContext::switch_editing_context (this); } break; case GDK_LEAVE_NOTIFY: diff --git a/gtk2_ardour/pianoroll.h b/gtk2_ardour/pianoroll.h index 28ba337365..6b629e55c5 100644 --- a/gtk2_ardour/pianoroll.h +++ b/gtk2_ardour/pianoroll.h @@ -287,7 +287,6 @@ class Pianoroll : public CueEditor std::pair max_zoom_extent() const; void point_selection_changed (); - bool enter (GdkEventCrossing*); bool zoom_in_allocate;