do something to make MIDI bindings accessible in any EditingContext

This commit is contained in:
Paul Davis 2024-01-31 18:08:44 -07:00
parent 23a672b45d
commit 7836418ebf
11 changed files with 248 additions and 106 deletions

View File

@ -274,7 +274,7 @@ ARDOUR_UI::key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey
Gtkmm2ext::Bindings* focus_bindings = get_bindings_from_widget_hierarchy (&focus);
if (focus_bindings) {
DEBUG_TRACE (DEBUG::Accelerators, string_compose ("\tusing widget (%3) bindings %1 @ %2 for this event\n", focus_bindings->name(), focus_bindings, gtk_widget_get_name (focus)));
DEBUG_TRACE (DEBUG::Accelerators, string_compose ("\t(nomod) using widget (%3) bindings %1 @ %2 for this event\n", focus_bindings->name(), focus_bindings, gtk_widget_get_name (focus)));
if (focus_bindings->activate (k, Bindings::Press)) {
return true;
}
@ -290,7 +290,7 @@ ARDOUR_UI::key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey
*/
if (top_level_bindings) {
DEBUG_TRACE (DEBUG::Accelerators, string_compose ("\tusing top level bindings %1 @ %2 for this event\n", top_level_bindings->name(), top_level_bindings));
DEBUG_TRACE (DEBUG::Accelerators, string_compose ("\t(nomod) using top level bindings %1 @ %2 for this event\n", top_level_bindings->name(), top_level_bindings));
}
if (top_level_bindings && top_level_bindings->activate (k, Bindings::Press)) {

View File

@ -58,6 +58,9 @@ using std::string;
sigc::signal<void> EditingContext::DropDownKeys;
Gtkmm2ext::Bindings* EditingContext::button_bindings = nullptr;
Glib::RefPtr<Gtk::ActionGroup> EditingContext::_midi_actions;
std::queue<EditingContext*> EditingContext::ec_stack;
std::vector<std::string> EditingContext::grid_type_strings;
static const gchar *_grid_type_strings[] = {
N_("No Grid"),
@ -125,7 +128,9 @@ EditingContext::EditingContext ()
}
}
grid_type_strings = I18N (_grid_type_strings);
if (grid_type_strings.empty()) {
grid_type_strings = I18N (_grid_type_strings);
}
}
EditingContext::~EditingContext()
@ -155,131 +160,143 @@ EditingContext::set_selected_midi_region_view (MidiRegionView& mrv)
void
EditingContext::register_midi_actions (Bindings* midi_bindings)
{
if (_midi_actions) {
return;
}
_midi_actions = ActionManager::create_action_group (midi_bindings, X_("Notes"));
/* two versions to allow same action for Delete and Backspace */
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));
ActionManager::register_action (_midi_actions, X_("clear-selection"), _("Clear Note Selection"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::clear_note_selection));
ActionManager::register_action (_midi_actions, X_("invert-selection"), _("Invert Note Selection"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::invert_selection));
ActionManager::register_action (_midi_actions, X_("extend-selection"), _("Extend Note Selection"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::extend_selection));
ActionManager::register_action (_midi_actions, X_("duplicate-selection"), _("Duplicate Note Selection"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::duplicate_selection));
/* Lengthen */
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));
ActionManager::register_action (_midi_actions, X_("move-starts-earlier-fine"), _("Move Note Start Earlier (fine)"), sigc::bind (sigc::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::move_note_ends_later));
/* Shorten */
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));
ActionManager::register_action (_midi_actions, X_("move-starts-later-fine"), _("Move Note Start Later (fine)"), sigc::bind (sigc::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::select_next_note));
ActionManager::register_action (_midi_actions, X_("alt-select-next"), _("Select Next (alternate)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::select_next_note));
ActionManager::register_action (_midi_actions, X_("select-previous"), _("Select Previous"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::select_previous_note));
ActionManager::register_action (_midi_actions, X_("alt-select-previous"), _("Select Previous (alternate)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::add_select_previous_note));
ActionManager::register_action (_midi_actions, X_("select-next"), _("Select Next"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::select_next_note));
ActionManager::register_action (_midi_actions, X_("alt-select-next"), _("Select Next (alternate)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::select_next_note));
ActionManager::register_action (_midi_actions, X_("select-previous"), _("Select Previous"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::select_previous_note));
ActionManager::register_action (_midi_actions, X_("alt-select-previous"), _("Select Previous (alternate)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::select_previous_note));
ActionManager::register_action (_midi_actions, X_("add-select-next"), _("Add Next to Selection"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::add_select_next_note));
ActionManager::register_action (_midi_actions, X_("alt-add-select-next"), _("Add Next to Selection (alternate)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::add_select_next_note));
ActionManager::register_action (_midi_actions, X_("add-select-previous"), _("Add Previous to Selection"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::add_select_previous_note));
ActionManager::register_action (_midi_actions, X_("alt-add-select-previous"), _("Add Previous to Selection (alternate)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::add_select_previous_note));
ActionManager::register_action (_midi_actions, X_("increase-velocity"), _("Increase Velocity"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::increase_note_velocity));
ActionManager::register_action (_midi_actions, X_("increase-velocity-fine"), _("Increase Velocity (fine)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::increase_note_velocity_fine_smush_together));
ActionManager::register_action (_midi_actions, X_("increase-velocity"), _("Increase Velocity"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::increase_note_velocity));
ActionManager::register_action (_midi_actions, X_("increase-velocity-fine"), _("Increase Velocity (fine)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::increase_note_velocity_fine));
ActionManager::register_action (_midi_actions, X_("increase-velocity-smush"), _("Increase Velocity (allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::increase_note_velocity_smush));
ActionManager::register_action (_midi_actions, X_("increase-velocity-together"), _("Increase Velocity (non-relative)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::increase_note_velocity_together));
ActionManager::register_action (_midi_actions, X_("increase-velocity-fine-smush"), _("Increase Velocity (fine, allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::increase_note_velocity_fine_smush));
ActionManager::register_action (_midi_actions, X_("increase-velocity-fine-together"), _("Increase Velocity (fine, non-relative)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::increase_note_velocity_fine_together));
ActionManager::register_action (_midi_actions, X_("increase-velocity-smush-together"), _("Increase Velocity (maintain ratios, allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::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::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::increase_note_velocity_fine_smush_together));
ActionManager::register_action (_midi_actions, X_("decrease-velocity"), _("Decrease Velocity"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::decrease_note_velocity));
ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine"), _("Decrease Velocity (fine)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::decrease_note_velocity_fine_smush_together));
ActionManager::register_action (_midi_actions, X_("decrease-velocity"), _("Decrease Velocity"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::decrease_note_velocity));
ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine"), _("Decrease Velocity (fine)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::decrease_note_velocity_fine));
ActionManager::register_action (_midi_actions, X_("decrease-velocity-smush"), _("Decrease Velocity (allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::decrease_note_velocity_smush));
ActionManager::register_action (_midi_actions, X_("decrease-velocity-together"), _("Decrease Velocity (non-relative)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::decrease_note_velocity_together));
ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine-smush"), _("Decrease Velocity (fine, allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::decrease_note_velocity_fine_smush));
ActionManager::register_action (_midi_actions, X_("decrease-velocity-fine-together"), _("Decrease Velocity (fine, non-relative)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::decrease_note_velocity_fine_together));
ActionManager::register_action (_midi_actions, X_("decrease-velocity-smush-together"), _("Decrease Velocity (maintain ratios, allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::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::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::decrease_note_velocity_fine_smush_together));
ActionManager::register_action (_midi_actions, X_("transpose-up-octave"), _("Transpose Up (octave)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::transpose_up_octave_smush));
ActionManager::register_action (_midi_actions, X_("transpose-up-octave"), _("Transpose Up (octave)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::transpose_up_octave));
ActionManager::register_action (_midi_actions, X_("transpose-up-octave-smush"), _("Transpose Up (octave, allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::transpose_up_octave_smush));
ActionManager::register_action (_midi_actions, X_("transpose-up-semitone"), _("Transpose Up (semitone)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::transpose_up_tone));
ActionManager::register_action (_midi_actions, X_("transpose-up-semitone-smush"), _("Transpose Up (semitone, allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::transpose_up_octave_smush));
ActionManager::register_action (_midi_actions, X_("transpose-down-octave"), _("Transpose Down (octave)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::transpose_down_octave_smush));
ActionManager::register_action (_midi_actions, X_("transpose-down-octave"), _("Transpose Down (octave)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::transpose_down_octave));
ActionManager::register_action (_midi_actions, X_("transpose-down-octave-smush"), _("Transpose Down (octave, allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::transpose_down_octave_smush));
ActionManager::register_action (_midi_actions, X_("transpose-down-semitone"), _("Transpose Down (semitone)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::transpose_down_tone));
ActionManager::register_action (_midi_actions, X_("transpose-down-semitone-smush"), _("Transpose Down (semitone, allow mush)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::transpose_down_octave_smush));
ActionManager::register_action (_midi_actions, X_("nudge-later"), _("Nudge Notes Later (grid)"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::nudge_notes_earlier_fine));
ActionManager::register_action (_midi_actions, X_("nudge-later"), _("Nudge Notes Later (grid)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::nudge_notes_later));
ActionManager::register_action (_midi_actions, X_("nudge-later-fine"), _("Nudge Notes Later (1/4 grid)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::nudge_notes_later_fine));
ActionManager::register_action (_midi_actions, X_("nudge-earlier"), _("Nudge Notes Earlier (grid)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::nudge_notes_earlier));
ActionManager::register_action (_midi_actions, X_("nudge-earlier-fine"), _("Nudge Notes Earlier (1/4 grid)"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::nudge_notes_earlier_fine));
ActionManager::register_action (_midi_actions, X_("split-notes-grid"), _("Split Selected Notes on grid boundaries"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::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), &MidiRegionView::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), &MidiRegionView::split_notes_less));
ActionManager::register_action (_midi_actions, X_("join-notes"), _("Join Selected Notes"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::join_notes));
ActionManager::register_action (_midi_actions, X_("split-notes-grid"), _("Split Selected Notes on grid boundaries"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::split_notes_grid));
ActionManager::register_action (_midi_actions, X_("split-notes-more"), _("Split Selected Notes into more pieces"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::split_notes_more));
ActionManager::register_action (_midi_actions, X_("split-notes-less"), _("Split Selected Notes into less pieces"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::split_notes_less));
ActionManager::register_action (_midi_actions, X_("join-notes"), _("Join Selected Notes"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::join_notes));
ActionManager::register_action (_midi_actions, X_("edit-channels"), _("Edit Note Channels"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::channel_edit));
ActionManager::register_action (_midi_actions, X_("edit-velocities"), _("Edit Note Velocities"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action), &MidiRegionView::velocity_edit));
ActionManager::register_action (_midi_actions, X_("edit-channels"), _("Edit Note Channels"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::channel_edit));
ActionManager::register_action (_midi_actions, X_("edit-velocities"), _("Edit Note Velocities"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action), &MidiRegionView::velocity_edit));
ActionManager::register_action (_midi_actions, X_("quantize-selected-notes"), _("Quantize Selected Notes"), sigc::bind (sigc::mem_fun (*this, &EditingContext::midi_action ), &MidiRegionView::quantize_selected_notes));
ActionManager::register_action (_midi_actions, X_("quantize-selected-notes"), _("Quantize Selected Notes"), sigc::bind (sigc::ptr_fun (&EditingContext::_midi_action ), &MidiRegionView::quantize_selected_notes));
Glib::RefPtr<ActionGroup> length_actions = ActionManager::create_action_group (midi_bindings, 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(), (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)));
ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-thirtyseconds"), grid_type_strings[(int)GridTypeBeatDiv32].c_str(), (sigc::bind (sigc::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&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::ptr_fun (&EditingContext::_draw_length_chosen), Editing::GridTypeBar)));
ActionManager::register_radio_action (length_actions, draw_length_group, X_("draw-length-auto"), _("Auto"), (sigc::bind (sigc::ptr_fun (&EditingContext::_draw_length_chosen), DRAW_LEN_AUTO)));
Glib::RefPtr<ActionGroup> velocity_actions = ActionManager::create_action_group (midi_bindings, _("Draw Velocity"));
RadioAction::Group draw_velocity_group;
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)));
ActionManager::register_radio_action (velocity_actions, draw_velocity_group, X_("draw-velocity-auto"), _("Auto"), (sigc::bind (sigc::ptr_fun(&EditingContext::_draw_velocity_chosen), DRAW_VEL_AUTO)));
for (int i = 1; i <= 127; i++) {
char buf[64];
sprintf(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, (sigc::bind (sigc::mem_fun(*this, &EditingContext::draw_velocity_chosen), i)));
ActionManager::register_radio_action (velocity_actions, draw_velocity_group, buf, vel, (sigc::bind (sigc::ptr_fun(&EditingContext::_draw_velocity_chosen), i)));
}
Glib::RefPtr<ActionGroup> channel_actions = ActionManager::create_action_group (midi_bindings, _("Draw Channel"));
RadioAction::Group draw_channel_group;
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)));
ActionManager::register_radio_action (channel_actions, draw_channel_group, X_("draw-channel-auto"), _("Auto"), (sigc::bind (sigc::ptr_fun(&EditingContext::_draw_channel_chosen), DRAW_CHAN_AUTO)));
for (int i = 0; i <= 15; i++) {
char buf[64];
sprintf(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, (sigc::bind (sigc::mem_fun(*this, &EditingContext::draw_channel_chosen), i)));
ActionManager::register_radio_action (channel_actions, draw_channel_group, buf, ch, (sigc::bind (sigc::ptr_fun(&EditingContext::_draw_channel_chosen), i)));
}
ActionManager::set_sensitive (_midi_actions, false);
}
void
EditingContext::_midi_action (void (MidiView::*method)())
{
if (current_editing_context()) {
current_editing_context()->midi_action (method);
}
}
void
EditingContext::midi_action (void (MidiView::*method)())
{
@ -553,6 +570,14 @@ EditingContext::grid_type_chosen (GridType type)
}
}
void
EditingContext::_draw_length_chosen (GridType type)
{
if (current_editing_context()) {
current_editing_context()->draw_length_chosen (type);
}
}
void
EditingContext::draw_length_chosen (GridType type)
{
@ -568,6 +593,14 @@ EditingContext::draw_length_chosen (GridType type)
}
}
void
EditingContext::_draw_velocity_chosen (int v)
{
if (current_editing_context()) {
current_editing_context()->draw_velocity_action (v);
}
}
void
EditingContext::draw_velocity_chosen (int v)
{
@ -583,6 +616,14 @@ EditingContext::draw_velocity_chosen (int v)
}
}
void
EditingContext::_draw_channel_chosen (int c)
{
if (current_editing_context()) {
current_editing_context()->draw_channel_chosen (c);
}
}
void
EditingContext::draw_channel_chosen (int c)
{
@ -1916,3 +1957,24 @@ EditingContext::apply_midi_note_edit_op (MidiOperator& op, const RegionSelection
}
}
EditingContext*
EditingContext::current_editing_context()
{
if (!ec_stack.empty()) {
return ec_stack.front ();
}
return nullptr;
}
void
EditingContext::push_editing_context (EditingContext* ec)
{
ec_stack.push (ec);
}
void
EditingContext::pop_editing_context ()
{
ec_stack.pop ();
}

View File

@ -33,6 +33,8 @@
#ifndef __ardour_midi_editing_context_h__
#define __ardour_midi_editing_context_h__
#include <queue>
#include "pbd/signals.h"
#include "temporal/timeline.h"
@ -312,6 +314,7 @@ public:
ARDOUR::Quantize* get_quantize_op ();
void apply_midi_note_edit_op (ARDOUR::MidiOperator& op, const RegionSelection& rs);
void midi_action (void (MidiView::*method)());
static void _midi_action (void (MidiView::*method)());
std::vector<MidiView*> filter_to_unique_midi_region_views (RegionSelection const & ms) const;
void quantize_region ();
@ -319,7 +322,7 @@ public:
void legatize_region (bool shrink_only);
void transpose_region ();
void register_midi_actions (Gtkmm2ext::Bindings*);
static void register_midi_actions (Gtkmm2ext::Bindings*);
ArdourCanvas::Rectangle* rubberband_rect;
@ -331,7 +334,7 @@ public:
bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
protected:
Glib::RefPtr<Gtk::ActionGroup> _midi_actions;
static Glib::RefPtr<Gtk::ActionGroup> _midi_actions;
/* Cursor stuff. Do not use directly, use via CursorContext. */
friend class CursorContext;
@ -345,7 +348,7 @@ public:
Editing::GridType internal_grid_type;
Editing::SnapMode internal_snap_mode;
std::vector<std::string> grid_type_strings;
static std::vector<std::string> grid_type_strings;
Glib::RefPtr<Gtk::RadioAction> grid_type_action (Editing::GridType);
Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
@ -377,12 +380,15 @@ public:
void draw_length_selection_done (Editing::GridType);
void draw_length_chosen (Editing::GridType);
static void _draw_length_chosen (Editing::GridType);
void draw_velocity_selection_done (int);
void draw_velocity_chosen (int);
static void _draw_velocity_chosen (int);
void draw_channel_selection_done (int);
void draw_channel_chosen (int);
static void _draw_channel_chosen (int);
DragManager* _drags;
@ -494,6 +500,13 @@ public:
void legatize_regions (const RegionSelection& rs, bool shrink_only);
void transform_regions (const RegionSelection& rs);
void transpose_regions (const RegionSelection& rs);
static EditingContext* current_editing_context();
static void push_editing_context (EditingContext*);
static void pop_editing_context ();
private:
static std::queue<EditingContext*> ec_stack;
};

View File

@ -826,6 +826,8 @@ Editor::Editor ()
UIConfiguration::instance().map_parameters (pc);
setup_fade_images ();
push_editing_context (this);
}
Editor::~Editor()

View File

@ -25,6 +25,9 @@
#include "canvas/scroll_group.h"
#include "canvas/rectangle.h"
#include "gtkmm2ext/actions.h"
#include "ardour_ui.h"
#include "editor_cursors.h"
#include "editor_drag.h"
#include "keyboard.h"
@ -69,7 +72,7 @@ MidiCueEditor::build_canvas ()
_canvas_viewport = new ArdourCanvas::GtkCanvasViewport (horizontal_adjustment, vertical_adjustment);
_canvas = _canvas_viewport->canvas ();
_canvas->set_background_color (0xff00000a); // UIConfiguration::instance().color ("arrange base"));
_canvas->set_background_color (UIConfiguration::instance().color ("arrange base"));
dynamic_cast<ArdourCanvas::GtkCanvas*>(_canvas)->use_nsglview (UIConfiguration::instance().get_nsgl_view_mode () == NSGLHiRes);
/* scroll group for items that should not automatically scroll
@ -88,34 +91,68 @@ MidiCueEditor::build_canvas ()
hv_scroll_group = hsg = new ArdourCanvas::ScrollGroup (_canvas->root(),
ArdourCanvas::ScrollGroup::ScrollSensitivity (ArdourCanvas::ScrollGroup::ScrollsVertically|
ArdourCanvas::ScrollGroup::ScrollsHorizontally));
CANVAS_DEBUG_NAME (hv_scroll_group, "canvas hv scroll");
CANVAS_DEBUG_NAME (hv_scroll_group, "cue canvas hv scroll");
_canvas->add_scroller (*hsg);
cursor_scroll_group = cg = new ArdourCanvas::ScrollGroup (_canvas->root(), ArdourCanvas::ScrollGroup::ScrollsHorizontally);
CANVAS_DEBUG_NAME (cursor_scroll_group, "canvas cursor scroll");
CANVAS_DEBUG_NAME (cursor_scroll_group, "cue canvas cursor scroll");
_canvas->add_scroller (*cg);
/*a group to hold global rects like punch/loop indicators */
global_rect_group = new ArdourCanvas::Container (hv_scroll_group);
CANVAS_DEBUG_NAME (global_rect_group, "global rect group");
CANVAS_DEBUG_NAME (global_rect_group, "cue global rect group");
transport_loop_range_rect = new ArdourCanvas::Rectangle (global_rect_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, ArdourCanvas::COORD_MAX));
CANVAS_DEBUG_NAME (transport_loop_range_rect, "loop rect");
CANVAS_DEBUG_NAME (transport_loop_range_rect, "cue loop rect");
transport_loop_range_rect->hide();
/*a group to hold time (measure) lines */
time_line_group = new ArdourCanvas::Container (h_scroll_group);
CANVAS_DEBUG_NAME (time_line_group, "time line group");
CANVAS_DEBUG_NAME (time_line_group, "cue time line group");
// used as rubberband rect
rubberband_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
rubberband_rect->hide();
rubberband_rect->set_outline_color (UIConfiguration::instance().color ("rubber band rect"));
rubberband_rect->set_fill_color (UIConfiguration::instance().color_mod ("rubber band rect", "selection rect"));
CANVAS_DEBUG_NAME (rubberband_rect, X_("midi cue rubberband rect"));
CANVAS_DEBUG_NAME (rubberband_rect, X_("cue rubberband rect"));
bg = new CueMidiBackground (hv_scroll_group);
_canvas_viewport->signal_size_allocate().connect (sigc::mem_fun(*this, &MidiCueEditor::canvas_allocate));
_canvas->set_name ("MidiCueCanvas");
_canvas->add_events (Gdk::POINTER_MOTION_HINT_MASK | Gdk::SCROLL_MASK | Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
_canvas->signal_enter_notify_event().connect (sigc::mem_fun(*this, &MidiCueEditor::canvas_enter_leave), false);
_canvas->signal_leave_notify_event().connect (sigc::mem_fun(*this, &MidiCueEditor::canvas_enter_leave), false);
_canvas->set_can_focus ();
Bindings* midi_bindings = Bindings::get_bindings (X_("MIDI"));
_canvas->set_data (X_("ardour-bindings"), midi_bindings);
}
bool
MidiCueEditor::canvas_enter_leave (GdkEventCrossing* ev)
{
switch (ev->type) {
case GDK_ENTER_NOTIFY:
if (ev->detail != GDK_NOTIFY_INFERIOR) {
_canvas_viewport->canvas()->grab_focus ();
ActionManager::set_sensitive (_midi_actions, true);
EditingContext::push_editing_context (this);
std::cerr << "GRAB FOCUS\n";
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->detail != GDK_NOTIFY_INFERIOR) {
ActionManager::set_sensitive (_midi_actions, false);
ARDOUR_UI::instance()->reset_focus (_canvas_viewport);
EditingContext::pop_editing_context ();
std::cerr << "DROP FOCUS\n";
}
default:
break;
}
return false;
}
void
@ -210,9 +247,9 @@ MidiCueEditor::apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, Midi
}
bool
MidiCueEditor::canvas_note_event (GdkEvent* event, ArdourCanvas::Item*)
MidiCueEditor::canvas_note_event (GdkEvent* event, ArdourCanvas::Item* item)
{
return false;
return typed_event (item, event, NoteItem);
}
Gtk::Widget&
@ -275,7 +312,7 @@ MidiCueEditor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event,
}
return true;
return false;
}
bool
@ -300,7 +337,7 @@ MidiCueEditor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event
}
}
return true;
return false;
}
bool
@ -312,11 +349,14 @@ MidiCueEditor::button_press_handler_2 (ArdourCanvas::Item*, GdkEvent*, ItemType)
bool
MidiCueEditor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
{
std::cerr << "hey\n";
if (Keyboard::is_context_menu_event (&event->button)) {
switch (item_type) {
case NoteItem:
if (internal_editing()) {
popup_note_context_menu (item, event);
return true;
}
break;
default:
@ -324,7 +364,7 @@ MidiCueEditor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event
}
}
return true;
return false;
}
bool
@ -364,8 +404,20 @@ MidiCueEditor::leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType)
}
bool
MidiCueEditor::key_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType)
MidiCueEditor::key_press_handler (ArdourCanvas::Item*, GdkEvent* ev, ItemType)
{
switch (ev->key.keyval) {
case GDK_d:
set_mouse_mode (Editing::MouseDraw);
std::cerr << "draw\n";
break;
case GDK_e:
set_mouse_mode (Editing::MouseContent);
std::cerr << "content/edit\n";
break;
}
return true;
}

View File

@ -100,7 +100,7 @@ class MidiCueEditor : public CueEditor
Gtk::Adjustment vertical_adjustment;
Gtk::Adjustment horizontal_adjustment;
ArdourCanvas::GtkCanvasViewport* _canvas_viewport;
ArdourCanvas::Canvas* _canvas;
ArdourCanvas::GtkCanvas* _canvas;
ArdourCanvas::Container* tempo_group;
@ -134,6 +134,8 @@ class MidiCueEditor : public CueEditor
Editing::MouseMode mouse_mode;
RegionSelection region_selection();
bool canvas_enter_leave (GdkEventCrossing* ev);
};

View File

@ -244,14 +244,14 @@ MidiView::canvas_group_event (GdkEvent* ev)
case GDK_ENTER_NOTIFY:
_last_event_x = ev->crossing.x;
_last_event_y = ev->crossing.y;
enter_notify(&ev->crossing);
enter_notify (&ev->crossing);
// set entered_regionview (among other things)
return true;
case GDK_LEAVE_NOTIFY:
_last_event_x = ev->crossing.x;
_last_event_y = ev->crossing.y;
leave_notify(&ev->crossing);
leave_notify (&ev->crossing);
// reset entered_regionview (among other things)
return true;
@ -384,9 +384,9 @@ MidiView::button_press (GdkEventButton* ev)
if (m == MouseDraw || (m == MouseContent && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier()))) {
if (_midi_context.note_mode() == Percussive) {
_editing_context.drags()->set (new HitCreateDrag (_editing_context, _note_group->parent(), this), (GdkEvent *) ev);
_editing_context.drags()->set (new HitCreateDrag (_editing_context, drag_group(), this), (GdkEvent *) ev);
} else {
_editing_context.drags()->set (new NoteCreateDrag (_editing_context, _note_group->parent(), this), (GdkEvent *) ev);
_editing_context.drags()->set (new NoteCreateDrag (_editing_context, drag_group(), this), (GdkEvent *) ev);
}
_mouse_state = AddDragging;
@ -408,6 +408,8 @@ MidiView::button_press (GdkEventButton* ev)
bool
MidiView::button_release (GdkEventButton* ev)
{
std::cerr << "ho1\n";
double event_x, event_y;
if (ev->button != 1) {
@ -424,7 +426,7 @@ MidiView::button_release (GdkEventButton* ev)
switch (_mouse_state) {
case Pressed: // Clicked
std::cerr << "P\n";
switch (_editing_context.current_mouse_mode()) {
case MouseRange:
/* no motion occurred - simple click */
@ -448,9 +450,11 @@ MidiView::button_release (GdkEventButton* ev)
break;
case AddDragging:
std::cerr << "AD\n";
/* Don't a ghost note when we added a note - wait until motion to avoid visual confusion.
we don't want one when we were drag-selecting either. */
case SelectRectDragging:
std::cerr << "SRD\n";
_editing_context.drags()->end_grab ((GdkEvent *) ev);
_mouse_state = None;
break;

View File

@ -757,6 +757,8 @@ SlotPropertyWindow::SlotPropertyWindow (TriggerReference tref)
_midi_editor = new MidiCueEditor;
std::cerr << "here\n";
table->attach(*_trig_box, col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++;
table->attach(_midi_editor->viewport(), col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++;
}

View File

@ -154,6 +154,8 @@ TriggerPage::TriggerPage ()
table->attach (_midi_trig_box, col, col + 1, 0, 1, Gtk::FILL, Gtk::SHRINK);
++col;
std::cerr << "there\n";
col = 3;
table->attach (_midi_editor->viewport(), col, col + 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
++col;

View File

@ -526,6 +526,7 @@ GtkCanvas::re_enter ()
DEBUG_TRACE (PBD::DEBUG::CanvasEnterLeave, "re-enter canvas by request\n");
_current_item = 0;
pick_current_item (0);
PBD::stacktrace (std::cerr, 20);
}
/** Construct a GtkCanvas */
@ -1381,7 +1382,7 @@ void
GtkCanvas::ungrab ()
{
/* XXX: should this be doing gdk_pointer_ungrab? */
_grabbed_item = 0;
_grabbed_item = nullptr;
}
/** Set keyboard focus on an item, so that all keyboard events are sent to that item until the focus

View File

@ -118,9 +118,11 @@ ActionManager::set_sensitive (Glib::RefPtr<ActionGroup> group, bool yn)
GtkActionGroup* grp = group->gobj();
for (GList* acts = gtk_action_group_list_actions (grp); acts; acts = g_list_next (acts)) {
GtkAction* action = (GtkAction*) acts->data;
gtk_action_set_sensitive (action, yn);
if (grp) {
for (GList* acts = gtk_action_group_list_actions (grp); acts; acts = g_list_next (acts)) {
GtkAction* action = (GtkAction*) acts->data;
gtk_action_set_sensitive (action, yn);
}
}
}