13
0

Support stepping bank by shift+scroll/arrow.

This commit is contained in:
David Robillard 2014-12-17 20:18:11 -05:00
parent d2cafbe95a
commit 5f66300349
4 changed files with 49 additions and 45 deletions

View File

@ -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);
}

View File

@ -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.
*/

View File

@ -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;

View File

@ -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__ */