summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-12-17 20:18:11 -0500
committerDavid Robillard <d@drobilla.net>2014-12-17 20:18:11 -0500
commit5f6630034919bde73ffa603e7420c8af2c3c16f7 (patch)
treecd5b4d36e528d426087b20db465f24d5588ab5bd /gtk2_ardour
parentd2cafbe95a5784b7c306c24b0008379a41a909f7 (diff)
Support stepping bank by shift+scroll/arrow.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/midi_region_view.cc9
-rw-r--r--gtk2_ardour/midi_region_view.h7
-rw-r--r--gtk2_ardour/patch_change.cc41
-rw-r--r--gtk2_ardour/patch_change.h37
4 files changed, 49 insertions, 45 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 11534dd035..6b6d40f93c 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -1984,11 +1984,14 @@ MidiRegionView::delete_patch_change (PatchChange* pc)
}
void
-MidiRegionView::step_patch (PatchChange& patch, int dbank, int dprog)
+MidiRegionView::step_patch (PatchChange& patch, bool bank, int delta)
{
MIDI::Name::PatchPrimaryKey key = patch_change_to_patch_key(patch.patch());
- key.set_bank(key.bank() + dbank);
- key.set_program(key.program() + dprog);
+ if (bank) {
+ key.set_bank(key.bank() + delta);
+ } else {
+ key.set_program(key.program() + delta);
+ }
change_patch_change(patch, key);
}
diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h
index a07a46825f..7280ba6e4e 100644
--- a/gtk2_ardour/midi_region_view.h
+++ b/gtk2_ardour/midi_region_view.h
@@ -153,8 +153,11 @@ public:
void delete_sysex (SysEx*);
- /** Change a patch to the next or previous bank/program. */
- void step_patch (PatchChange& patch, int dbank, int dprog);
+ /** Change a patch to the next or previous bank/program.
+ * @param bank If true, step bank, otherwise, step program.
+ * @param delta Amount to adjust number.
+ */
+ void step_patch (PatchChange& patch, bool bank, int delta);
/** Displays all patch change events in the region as flags on the canvas.
*/
diff --git a/gtk2_ardour/patch_change.cc b/gtk2_ardour/patch_change.cc
index 844a129b1d..925a0f3b23 100644
--- a/gtk2_ardour/patch_change.cc
+++ b/gtk2_ardour/patch_change.cc
@@ -31,25 +31,25 @@
#include "canvas/debug.h"
#include "ardour_ui.h"
-#include "midi_region_view.h"
-#include "patch_change.h"
#include "editor.h"
#include "editor_drag.h"
+#include "midi_region_view.h"
+#include "patch_change.h"
using namespace MIDI::Name;
using namespace std;
+using Gtkmm2ext::Keyboard;
/** @param x x position in pixels.
*/
-PatchChange::PatchChange(
- MidiRegionView& region,
- ArdourCanvas::Container* parent,
- const string& text,
- double height,
- double x,
- double y,
- ARDOUR::InstrumentInfo& info,
- ARDOUR::MidiModel::PatchChangePtr patch)
+PatchChange::PatchChange(MidiRegionView& region,
+ ArdourCanvas::Container* parent,
+ const string& text,
+ double height,
+ double x,
+ double y,
+ ARDOUR::InstrumentInfo& info,
+ ARDOUR::MidiModel::PatchChangePtr patch)
: _region (region)
, _info (info)
, _patch (patch)
@@ -60,8 +60,7 @@ PatchChange::PatchChange(
height,
ARDOUR_UI::config()->color ("midi patch change outline"),
ARDOUR_UI::config()->color_mod ("midi patch change fill", "midi patch change fill"),
- ArdourCanvas::Duple (x, y)
- );
+ ArdourCanvas::Duple (x, y));
CANVAS_DEBUG_NAME (_flag, text);
@@ -199,13 +198,15 @@ PatchChange::event_handler (GdkEvent* ev)
case GDK_Up:
case GDK_KP_Up:
case GDK_uparrow:
- _region.step_patch (*this, 0, -1);
- break;
+ _region.step_patch(
+ *this, Keyboard::modifier_state_contains(ev->key.state, Keyboard::TertiaryModifier), 1);
+ return true;
case GDK_Down:
case GDK_KP_Down:
case GDK_downarrow:
- _region.step_patch (*this, 0, 1);
- break;
+ _region.step_patch(
+ *this, Keyboard::modifier_state_contains(ev->key.state, Keyboard::TertiaryModifier), -1);
+ return true;
default:
break;
}
@@ -213,10 +214,12 @@ PatchChange::event_handler (GdkEvent* ev)
case GDK_SCROLL:
if (ev->scroll.direction == GDK_SCROLL_UP) {
- _region.step_patch (*this, 0, -1);
+ _region.step_patch(
+ *this, Keyboard::modifier_state_contains(ev->scroll.state, Keyboard::TertiaryModifier), 1);
return true;
} else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
- _region.step_patch (*this, 0, 1);
+ _region.step_patch(
+ *this, Keyboard::modifier_state_contains(ev->scroll.state, Keyboard::TertiaryModifier), -1);
return true;
}
break;
diff --git a/gtk2_ardour/patch_change.h b/gtk2_ardour/patch_change.h
index a087c2a090..a734daf797 100644
--- a/gtk2_ardour/patch_change.h
+++ b/gtk2_ardour/patch_change.h
@@ -33,45 +33,40 @@ namespace MIDI {
class PatchChange
{
public:
- PatchChange(
- MidiRegionView& region,
- ArdourCanvas::Container* parent,
- const std::string& text,
- double height,
- double x,
- double y,
- ARDOUR::InstrumentInfo& info,
- ARDOUR::MidiModel::PatchChangePtr patch
- );
+ PatchChange(MidiRegionView& region,
+ ArdourCanvas::Container* parent,
+ const std::string& text,
+ double height,
+ double x,
+ double y,
+ ARDOUR::InstrumentInfo& info,
+ ARDOUR::MidiModel::PatchChangePtr patch);
~PatchChange();
- ARDOUR::MidiModel::PatchChangePtr patch () const { return _patch; }
-
void initialize_popup_menus();
void on_patch_menu_selected(const MIDI::Name::PatchPrimaryKey& key);
- ArdourCanvas::Item* canvas_item () const {
- return _flag;
- }
void move (ArdourCanvas::Duple);
void set_height (ArdourCanvas::Distance);
void hide ();
void show ();
- ArdourCanvas::Item& item() const { return *_flag; }
+ ARDOUR::MidiModel::PatchChangePtr patch() const { return _patch; }
+ ArdourCanvas::Item* canvas_item() const { return _flag; }
+ ArdourCanvas::Item& item() const { return *_flag; }
private:
bool event_handler (GdkEvent *);
- MidiRegionView& _region;
- ARDOUR::InstrumentInfo& _info;
+ MidiRegionView& _region;
+ ARDOUR::InstrumentInfo& _info;
ARDOUR::MidiModel::PatchChangePtr _patch;
- Gtk::Menu _popup;
- bool _popup_initialized;
- ArdourCanvas::Flag* _flag;
+ Gtk::Menu _popup;
+ bool _popup_initialized;
+ ArdourCanvas::Flag* _flag;
};
#endif /* __PATCH_CHANGE_H__ */