From 2fb2442dd31dc6f5e434011bedd552823bd82fd3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 27 Jul 2011 19:11:39 +0000 Subject: [PATCH] Primary-(scroll|up|down) on patch/bank change event changes bank number; change format of verbose cursor when inside patch/bank change git-svn-id: svn://localhost/ardour2/branches/3.0@9939 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/canvas_patch_change.cc | 27 ++++++++++++++++---- gtk2_ardour/midi_region_view.cc | 41 +++++++++++++++++++++++++++++- gtk2_ardour/midi_region_view.h | 3 +++ 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/canvas_patch_change.cc b/gtk2_ardour/canvas_patch_change.cc index 53bddbef40..7f7413e39e 100644 --- a/gtk2_ardour/canvas_patch_change.cc +++ b/gtk2_ardour/canvas_patch_change.cc @@ -23,6 +23,7 @@ #include "gtkmm2ext/keyboard.h" #include "ardour/midi_patch_manager.h" + #include "ardour_ui.h" #include "midi_region_view.h" #include "canvas_patch_change.h" @@ -31,6 +32,7 @@ using namespace Gnome::Canvas; using namespace MIDI::Name; +using namespace Gtkmm2ext; using namespace std; /** @param x x position in pixels. @@ -118,7 +120,6 @@ CanvasPatchChange::initialize_popup_menus() void CanvasPatchChange::on_patch_menu_selected(const PatchPrimaryKey& key) { - cerr << " got patch program number " << key.program_number << endl; _region.change_patch_change (*this, key); } @@ -166,12 +167,20 @@ CanvasPatchChange::on_event (GdkEvent* ev) case GDK_Up: case GDK_KP_Up: case GDK_uparrow: - _region.previous_patch (*this); + if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) { + _region.previous_bank (*this); + } else { + _region.previous_patch (*this); + } break; case GDK_Down: case GDK_KP_Down: case GDK_downarrow: - _region.next_patch (*this); + if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) { + _region.next_bank (*this); + } else { + _region.next_patch (*this); + } break; default: break; @@ -180,10 +189,18 @@ CanvasPatchChange::on_event (GdkEvent* ev) case GDK_SCROLL: if (ev->scroll.direction == GDK_SCROLL_UP) { - _region.previous_patch (*this); + if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) { + _region.previous_bank (*this); + } else { + _region.previous_patch (*this); + } return true; } else if (ev->scroll.direction == GDK_SCROLL_DOWN) { - _region.next_patch (*this); + if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) { + _region.next_bank (*this); + } else { + _region.next_patch (*this); + } return true; } break; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index ea5d2f0510..2d7cccb628 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1841,6 +1841,44 @@ MidiRegionView::next_patch (CanvasPatchChange& patch) } } +void +MidiRegionView::previous_bank (CanvasPatchChange& patch) +{ + if (patch.patch()->program() < 127) { + MIDI::Name::PatchPrimaryKey key; + get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key); + if (key.lsb > 0) { + key.lsb--; + change_patch_change (patch, key); + } else { + if (key.msb > 0) { + key.lsb = 127; + key.msb--; + change_patch_change (patch, key); + } + } + } +} + +void +MidiRegionView::next_bank (CanvasPatchChange& patch) +{ + if (patch.patch()->program() > 0) { + MIDI::Name::PatchPrimaryKey key; + get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key); + if (key.lsb < 127) { + key.lsb++; + change_patch_change (patch, key); + } else { + if (key.msb < 127) { + key.lsb = 0; + key.msb++; + change_patch_change (patch, key); + } + } + } +} + void MidiRegionView::maybe_remove_deleted_note_from_selection (CanvasNoteEvent* cne) { @@ -2917,7 +2955,8 @@ void MidiRegionView::patch_entered (ArdourCanvas::CanvasPatchChange* ev) { ostringstream s; - s << ((int) ev->patch()->program() + 1) << ":" << (ev->patch()->bank() + 1); + /* XXX should get patch name if we can */ + s << _("Bank:") << (ev->patch()->bank() + 1) << '\n' << _("Program:") << ((int) ev->patch()->program() + 1); show_verbose_cursor (s.str(), 10, 20); } diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 6dfcd08e0b..418cf215b3 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -154,6 +154,9 @@ public: */ void next_patch (ArdourCanvas::CanvasPatchChange &); + void previous_bank (ArdourCanvas::CanvasPatchChange &); + void next_bank (ArdourCanvas::CanvasPatchChange &); + /** Displays all patch change events in the region as flags on the canvas. */ void display_patch_changes();