mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
NO-OP: whitespace
This commit is contained in:
parent
4e005540c6
commit
a6d1890168
1 changed files with 114 additions and 129 deletions
|
|
@ -44,37 +44,36 @@ using Gtkmm2ext::Keyboard;
|
||||||
|
|
||||||
/** @param x x position in pixels.
|
/** @param x x position in pixels.
|
||||||
*/
|
*/
|
||||||
PatchChange::PatchChange(MidiRegionView& region,
|
PatchChange::PatchChange (MidiRegionView& region,
|
||||||
ArdourCanvas::Container* parent,
|
ArdourCanvas::Container* parent,
|
||||||
double height,
|
double height,
|
||||||
double x,
|
double x,
|
||||||
double y,
|
double y,
|
||||||
ARDOUR::InstrumentInfo& info,
|
ARDOUR::InstrumentInfo& info,
|
||||||
ARDOUR::MidiModel::PatchChangePtr patch,
|
ARDOUR::MidiModel::PatchChangePtr patch,
|
||||||
Gtkmm2ext::Color outline_color,
|
Gtkmm2ext::Color outline_color,
|
||||||
Gtkmm2ext::Color fill_color)
|
Gtkmm2ext::Color fill_color)
|
||||||
: _region (region)
|
: _region (region)
|
||||||
, _info (info)
|
, _info (info)
|
||||||
, _patch (patch)
|
, _patch (patch)
|
||||||
, _popup_initialized(false)
|
, _popup_initialized (false)
|
||||||
{
|
{
|
||||||
_flag = new ArdourCanvas::Flag (
|
_flag = new ArdourCanvas::Flag (parent,
|
||||||
parent,
|
height,
|
||||||
height,
|
outline_color,
|
||||||
outline_color,
|
fill_color,
|
||||||
fill_color,
|
ArdourCanvas::Duple (x, y),
|
||||||
ArdourCanvas::Duple (x, y),
|
true);
|
||||||
true);
|
|
||||||
|
|
||||||
CANVAS_DEBUG_NAME (_flag, _info.get_patch_name (_patch->bank (), _patch->program (), _patch->channel ()));
|
CANVAS_DEBUG_NAME (_flag, _info.get_patch_name (_patch->bank (), _patch->program (), _patch->channel ()));
|
||||||
|
|
||||||
_flag->Event.connect (sigc::mem_fun (*this, &PatchChange::event_handler));
|
_flag->Event.connect (sigc::mem_fun (*this, &PatchChange::event_handler));
|
||||||
_flag->set_font_description (UIConfiguration::instance().get_SmallFont());
|
_flag->set_font_description (UIConfiguration::instance ().get_SmallFont ());
|
||||||
|
|
||||||
update_name ();
|
update_name ();
|
||||||
}
|
}
|
||||||
|
|
||||||
PatchChange::~PatchChange()
|
PatchChange::~PatchChange ()
|
||||||
{
|
{
|
||||||
delete _flag;
|
delete _flag;
|
||||||
}
|
}
|
||||||
|
|
@ -86,73 +85,66 @@ PatchChange::update_name ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PatchChange::initialize_popup_menus()
|
PatchChange::initialize_popup_menus ()
|
||||||
{
|
{
|
||||||
using namespace MIDI::Name;
|
using namespace MIDI::Name;
|
||||||
|
|
||||||
boost::shared_ptr<ChannelNameSet> channel_name_set = _info.get_patches (_patch->channel());
|
boost::shared_ptr<ChannelNameSet> channel_name_set = _info.get_patches (_patch->channel ());
|
||||||
|
|
||||||
if (!channel_name_set || channel_name_set->patch_banks().size () == 0) {
|
if (!channel_name_set || channel_name_set->patch_banks ().size () == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChannelNameSet::PatchBanks& patch_banks = channel_name_set->patch_banks();
|
const ChannelNameSet::PatchBanks& patch_banks = channel_name_set->patch_banks ();
|
||||||
|
|
||||||
if (patch_banks.size() > 1) {
|
|
||||||
|
|
||||||
|
if (patch_banks.size () > 1) {
|
||||||
// fill popup menu:
|
// fill popup menu:
|
||||||
Gtk::Menu::MenuList& patch_bank_menus = _popup.items();
|
Gtk::Menu::MenuList& patch_bank_menus = _popup.items ();
|
||||||
|
|
||||||
for (ChannelNameSet::PatchBanks::const_iterator bank = patch_banks.begin();
|
for (ChannelNameSet::PatchBanks::const_iterator bank = patch_banks.begin (); bank != patch_banks.end (); ++bank) {
|
||||||
bank != patch_banks.end();
|
Glib::RefPtr<Glib::Regex> underscores = Glib::Regex::create ("_");
|
||||||
++bank) {
|
std::string const& replacement (" ");
|
||||||
Glib::RefPtr<Glib::Regex> underscores = Glib::Regex::create("_");
|
|
||||||
std::string replacement(" ");
|
|
||||||
|
|
||||||
Gtk::Menu& patch_bank_menu = *manage(new Gtk::Menu());
|
Gtk::Menu& patch_bank_menu = *manage (new Gtk::Menu ());
|
||||||
|
|
||||||
const PatchNameList& patches = (*bank)->patch_name_list();
|
const PatchNameList& patches = (*bank)->patch_name_list ();
|
||||||
Gtk::Menu::MenuList& patch_menus = patch_bank_menu.items();
|
Gtk::Menu::MenuList& patch_menus = patch_bank_menu.items ();
|
||||||
|
|
||||||
for (PatchNameList::const_iterator patch = patches.begin();
|
for (PatchNameList::const_iterator patch = patches.begin (); patch != patches.end (); ++patch) {
|
||||||
patch != patches.end();
|
|
||||||
++patch) {
|
|
||||||
std::string name = underscores->replace((*patch)->name().c_str(), -1, 0, replacement);
|
|
||||||
|
|
||||||
patch_menus.push_back(
|
std::string name = underscores->replace ((*patch)->name ().c_str (), -1, 0, replacement);
|
||||||
Gtk::Menu_Helpers::MenuElem(
|
|
||||||
name,
|
patch_menus.push_back (
|
||||||
sigc::bind(
|
Gtk::Menu_Helpers::MenuElem (
|
||||||
sigc::mem_fun(*this, &PatchChange::on_patch_menu_selected),
|
name,
|
||||||
(*patch)->patch_primary_key())) );
|
sigc::bind (sigc::mem_fun (*this, &PatchChange::on_patch_menu_selected), (*patch)->patch_primary_key ())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string name = underscores->replace ((*bank)->name ().c_str (), -1, 0, replacement);
|
||||||
|
|
||||||
std::string name = underscores->replace((*bank)->name().c_str(), -1, 0, replacement);
|
patch_bank_menus.push_back (
|
||||||
|
Gtk::Menu_Helpers::MenuElem (
|
||||||
patch_bank_menus.push_back(
|
name,
|
||||||
Gtk::Menu_Helpers::MenuElem(
|
patch_bank_menu));
|
||||||
name,
|
|
||||||
patch_bank_menu) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* only one patch bank, so make it the initial menu */
|
/* only one patch bank, so make it the initial menu */
|
||||||
|
|
||||||
const PatchNameList& patches = patch_banks.front()->patch_name_list();
|
const PatchNameList& patches = patch_banks.front ()->patch_name_list ();
|
||||||
Gtk::Menu::MenuList& patch_menus = _popup.items();
|
Gtk::Menu::MenuList& patch_menus = _popup.items ();
|
||||||
|
|
||||||
for (PatchNameList::const_iterator patch = patches.begin();
|
for (PatchNameList::const_iterator patch = patches.begin ();
|
||||||
patch != patches.end();
|
patch != patches.end ();
|
||||||
++patch) {
|
++patch) {
|
||||||
patch_menus.push_back (Gtkmm2ext::MenuElemNoMnemonic ((*patch)->name(),
|
patch_menus.push_back (Gtkmm2ext::MenuElemNoMnemonic ((*patch)->name (),
|
||||||
sigc::bind (sigc::mem_fun(*this, &PatchChange::on_patch_menu_selected), (*patch)->patch_primary_key())));
|
sigc::bind (sigc::mem_fun (*this, &PatchChange::on_patch_menu_selected), (*patch)->patch_primary_key ())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PatchChange::on_patch_menu_selected(const PatchPrimaryKey& key)
|
PatchChange::on_patch_menu_selected (const PatchPrimaryKey& key)
|
||||||
{
|
{
|
||||||
_region.change_patch_change (*this, key);
|
_region.change_patch_change (*this, key);
|
||||||
}
|
}
|
||||||
|
|
@ -161,93 +153,86 @@ bool
|
||||||
PatchChange::event_handler (GdkEvent* ev)
|
PatchChange::event_handler (GdkEvent* ev)
|
||||||
{
|
{
|
||||||
/* XXX: icky dcast */
|
/* XXX: icky dcast */
|
||||||
Editor* e = dynamic_cast<Editor*> (&_region.get_time_axis_view().editor());
|
Editor* e = dynamic_cast<Editor*> (&_region.get_time_axis_view ().editor ());
|
||||||
|
|
||||||
if (!e->internal_editing()) {
|
if (!e->internal_editing ()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ev->type) {
|
switch (ev->type) {
|
||||||
case GDK_BUTTON_PRESS:
|
case GDK_BUTTON_PRESS:
|
||||||
if (e->current_mouse_mode() == Editing::MouseContent) {
|
if (e->current_mouse_mode () == Editing::MouseContent) {
|
||||||
|
if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
|
||||||
|
_region.delete_patch_change (this);
|
||||||
|
return true;
|
||||||
|
|
||||||
if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
|
} else if (Gtkmm2ext::Keyboard::is_edit_event (&ev->button)) {
|
||||||
|
_region.edit_patch_change (this);
|
||||||
|
return true;
|
||||||
|
|
||||||
_region.delete_patch_change (this);
|
} else if (ev->button.button == 1) {
|
||||||
return true;
|
e->drags ()->set (new PatchChangeDrag (e, this, &_region), ev);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (Gtkmm2ext::Keyboard::is_edit_event (&ev->button)) {
|
if (Gtkmm2ext::Keyboard::is_context_menu_event (&ev->button)) {
|
||||||
|
if (!_popup_initialized) {
|
||||||
_region.edit_patch_change (this);
|
initialize_popup_menus ();
|
||||||
return true;
|
_popup_initialized = true;
|
||||||
|
}
|
||||||
} else if (ev->button.button == 1) {
|
_popup.popup (ev->button.button, ev->button.time);
|
||||||
e->drags()->set (new PatchChangeDrag (e, this, &_region), ev);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
if (Gtkmm2ext::Keyboard::is_context_menu_event (&ev->button)) {
|
case GDK_KEY_PRESS:
|
||||||
if (!_popup_initialized) {
|
switch (ev->key.keyval) {
|
||||||
initialize_popup_menus();
|
case GDK_Up:
|
||||||
_popup_initialized = true;
|
case GDK_KP_Up:
|
||||||
|
case GDK_uparrow:
|
||||||
|
_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, Keyboard::modifier_state_contains (ev->key.state, Keyboard::TertiaryModifier), -1);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
_popup.popup(ev->button.button, ev->button.time);
|
break;
|
||||||
return true;
|
|
||||||
}
|
case GDK_KEY_RELEASE:
|
||||||
break;
|
switch (ev->key.keyval) {
|
||||||
|
case GDK_BackSpace:
|
||||||
|
case GDK_Delete:
|
||||||
|
_region.delete_patch_change (this);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GDK_SCROLL:
|
||||||
|
if (ev->scroll.direction == GDK_SCROLL_UP) {
|
||||||
|
_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, Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::TertiaryModifier), -1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GDK_ENTER_NOTIFY:
|
||||||
|
_region.patch_entered (this);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GDK_LEAVE_NOTIFY:
|
||||||
|
_region.patch_left (this);
|
||||||
|
break;
|
||||||
|
|
||||||
case GDK_KEY_PRESS:
|
|
||||||
switch (ev->key.keyval) {
|
|
||||||
case GDK_Up:
|
|
||||||
case GDK_KP_Up:
|
|
||||||
case GDK_uparrow:
|
|
||||||
_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, Keyboard::modifier_state_contains(ev->key.state, Keyboard::TertiaryModifier), -1);
|
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_KEY_RELEASE:
|
|
||||||
switch (ev->key.keyval) {
|
|
||||||
case GDK_BackSpace:
|
|
||||||
case GDK_Delete:
|
|
||||||
_region.delete_patch_change (this);
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_SCROLL:
|
|
||||||
if (ev->scroll.direction == GDK_SCROLL_UP) {
|
|
||||||
_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, Keyboard::modifier_state_contains(ev->scroll.state, Keyboard::TertiaryModifier), -1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_ENTER_NOTIFY:
|
|
||||||
_region.patch_entered (this);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_LEAVE_NOTIFY:
|
|
||||||
_region.patch_left (this);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue