summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-09-08 19:37:48 +0200
committerRobin Gareus <robin@gareus.org>2017-09-08 23:35:00 +0200
commitc3e8cdb418008d05a927b442eb9291a1cd6f7111 (patch)
tree0ebbc1834b1cfe93620c5ac862e5d91045c1c8c6 /gtk2_ardour
parentb7227415ad70a2fd35344f783dcbdc9104d23c36 (diff)
PatchChange Dialog: update title & refresh midnam on change
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/midi_time_axis.cc19
-rw-r--r--gtk2_ardour/midi_time_axis.h1
-rw-r--r--gtk2_ardour/patch_change_widget.cc25
-rw-r--r--gtk2_ardour/patch_change_widget.h7
4 files changed, 45 insertions, 7 deletions
diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc
index 9e4d0ed5b1..3627074bc8 100644
--- a/gtk2_ardour/midi_time_axis.cc
+++ b/gtk2_ardour/midi_time_axis.cc
@@ -425,7 +425,7 @@ MidiTimeAxisView::update_patch_selector ()
boost::bind (&MidiTimeAxisView::drop_instrument_ref, this),
gui_context());
pi->plugin()->UpdateMidnam.connect (midnam_connection, invalidator (*this),
- boost::bind (&Plugin::read_midnam, pi->plugin ()),
+ boost::bind (&MidiTimeAxisView::reread_midnam, this),
gui_context());
pluginprovided = true;
@@ -446,6 +446,17 @@ MidiTimeAxisView::update_patch_selector ()
}
void
+MidiTimeAxisView::reread_midnam ()
+{
+ boost::shared_ptr<Processor> the_instrument (_route->the_instrument());
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(the_instrument);
+ pi->plugin ()->read_midnam();
+
+ if (_patch_change_dialog) {
+ _patch_change_dialog->refresh ();
+ }
+}
+void
MidiTimeAxisView::model_changed(const std::string& model)
{
set_gui_property (X_("midnam-model-name"), model);
@@ -486,6 +497,10 @@ MidiTimeAxisView::model_changed(const std::string& model)
delete controller_menu;
controller_menu = 0;
build_automation_action_menu(false);
+
+ if (_patch_change_dialog) {
+ _patch_change_dialog->refresh ();
+ }
}
void
@@ -1093,7 +1108,7 @@ MidiTimeAxisView::send_patch_change ()
return;
}
- PatchChangeGridDialog* d = new PatchChangeGridDialog (string_compose (_("Select Patch for '%1'"), _route->name ()), _route);
+ PatchChangeGridDialog* d = new PatchChangeGridDialog (_route);
_patch_change_dialog = d;
d->present ();
}
diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h
index 72167204ed..faa0e723e8 100644
--- a/gtk2_ardour/midi_time_axis.h
+++ b/gtk2_ardour/midi_time_axis.h
@@ -122,6 +122,7 @@ private:
void setup_midnam_patches ();
void update_patch_selector ();
void drop_instrument_ref ();
+ void reread_midnam ();
PBD::ScopedConnectionList midnam_connection;
void start_scroomer_update ();
diff --git a/gtk2_ardour/patch_change_widget.cc b/gtk2_ardour/patch_change_widget.cc
index 521ad60313..0d167eb576 100644
--- a/gtk2_ardour/patch_change_widget.cc
+++ b/gtk2_ardour/patch_change_widget.cc
@@ -19,7 +19,6 @@
#include <bitset>
#include <gtkmm/frame.h>
-#include <boost/algorithm/string.hpp>
#include "pbd/unwind.h"
@@ -142,6 +141,14 @@ PatchChangeWidget::~PatchChangeWidget ()
}
void
+PatchChangeWidget::refresh ()
+{
+ if (is_visible ()) {
+ on_show ();
+ }
+}
+
+void
PatchChangeWidget::on_show ()
{
Gtk::VBox::on_show ();
@@ -237,7 +244,7 @@ PatchChangeWidget::refill_program_list ()
if (_current_patch_bank) {
const MIDI::Name::PatchNameList& patches = _current_patch_bank->patch_name_list ();
for (MIDI::Name::PatchNameList::const_iterator i = patches.begin(); i != patches.end(); ++i) {
- std::string n = (*i)->name ();
+ const std::string n = (*i)->name ();
MIDI::Name::PatchPrimaryKey const& key = (*i)->patch_primary_key ();
const uint8_t pgm = key.program();
@@ -477,10 +484,20 @@ PatchChangeWidget::program (uint8_t chn) const
/* ***************************************************************************/
-PatchChangeGridDialog::PatchChangeGridDialog (std::string const& title, boost::shared_ptr<ARDOUR::Route> r)
- : ArdourDialog (title, false, false)
+PatchChangeGridDialog::PatchChangeGridDialog (boost::shared_ptr<ARDOUR::Route> r)
+ : ArdourDialog (string_compose (_("Select Patch for '%1"), r->name()), false, false)
, w (r)
{
+ r->PropertyChanged.connect (_route_connection, invalidator (*this), boost::bind (&PatchChangeGridDialog::route_property_changed, this, _1, boost::weak_ptr<Route>(r)), gui_context());
get_vbox()->add (w);
w.show ();
}
+
+void
+PatchChangeGridDialog::route_property_changed (const PBD::PropertyChange& what_changed, boost::weak_ptr<Route> wr)
+{
+ boost::shared_ptr<ARDOUR::Route> r = wr.lock ();
+ if (r && what_changed.contains (ARDOUR::Properties::name)) {
+ set_title (string_compose (_("Select Patch for '%1"), r->name()));
+ }
+}
diff --git a/gtk2_ardour/patch_change_widget.h b/gtk2_ardour/patch_change_widget.h
index f3f7898508..81e73bda44 100644
--- a/gtk2_ardour/patch_change_widget.h
+++ b/gtk2_ardour/patch_change_widget.h
@@ -39,6 +39,8 @@ public:
PatchChangeWidget (boost::shared_ptr<ARDOUR::Route>);
~PatchChangeWidget ();
+ void refresh ();
+
protected:
int bank (uint8_t) const;
uint8_t program (uint8_t) const;
@@ -105,11 +107,14 @@ private:
class PatchChangeGridDialog : public ArdourDialog
{
public:
- PatchChangeGridDialog (std::string const&, boost::shared_ptr<ARDOUR::Route>);
+ PatchChangeGridDialog (boost::shared_ptr<ARDOUR::Route>);
void on_hide () { w.hide (); ArdourDialog::on_hide (); }
void on_show () { w.show (); ArdourDialog::on_show (); }
+ void refresh () { w.refresh (); }
private:
+ void route_property_changed (const PBD::PropertyChange&, boost::weak_ptr<ARDOUR::Route>);
+ PBD::ScopedConnection _route_connection;
PatchChangeWidget w;
};