From a47220df59c076eaa717710dc2ffc6614bee268c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 1 Oct 2007 05:27:41 +0000 Subject: Blink MIDI ports on message transmission. git-svn-id: http://svn.drobilla.net/lad/ingen@794 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/gui/App.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- src/libs/gui/App.hpp | 9 +++++++++ src/libs/gui/NodeModule.cpp | 2 +- src/libs/gui/Port.cpp | 9 +++++++++ src/libs/gui/Port.hpp | 1 + 5 files changed, 59 insertions(+), 4 deletions(-) (limited to 'src/libs/gui') diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp index feeae181..dc3db30d 100644 --- a/src/libs/gui/App.cpp +++ b/src/libs/gui/App.cpp @@ -47,11 +47,12 @@ #ifdef HAVE_SLV2 #include #endif -using std::cerr; using std::cout; using std::endl; -using std::string; -namespace Ingen { namespace Client { class PluginModel; } } + +using namespace std; using namespace Ingen::Client; +namespace Ingen { namespace Client { class PluginModel; } } + namespace Ingen { namespace GUI { @@ -145,6 +146,9 @@ App::attach(SharedPtr engine, SharedPtr cli _loader = SharedPtr(new ThreadedLoader(engine)); _patch_tree_window->init(*_store); + + Glib::signal_timeout().connect(sigc::mem_fun(this, &App::animate_callback), + 100, G_PRIORITY_DEFAULT_IDLE); } @@ -172,6 +176,38 @@ App::error_message(const string& str) } +void +App::port_activity(Port* port) +{ + std::pair inserted = _activity_ports.insert(make_pair(port, false)); + if (inserted.second) + inserted.first->second = false; + + port->set_highlighted(true, false, true, false); +} + + +bool +App::animate_callback() +{ + for (ActivityPorts::iterator i = _activity_ports.begin(); i != _activity_ports.end() ; ) { + ActivityPorts::iterator next = i; + ++next; + + if ((*i).second) { // saw it last time, unhighlight and pop + (*i).first->set_highlighted(false, false, true, false); + _activity_ports.erase(i); + } else { + (*i).second = true; + } + + i = next; + } + + return true; +} + + /* bool App::idle_callback() diff --git a/src/libs/gui/App.hpp b/src/libs/gui/App.hpp index 298fc44e..7629cd0e 100644 --- a/src/libs/gui/App.hpp +++ b/src/libs/gui/App.hpp @@ -61,6 +61,7 @@ class ConnectWindow; class Configuration; class ThreadedLoader; class WindowFactory; +class Port; /** Singleton master class most everything is contained within. @@ -84,6 +85,8 @@ public: void quit(); + void port_activity(Port* port); + ConnectWindow* connect_window() const { return _connect_window; } Gtk::AboutDialog* about_dialog() const { return _about_dialog; } MessagesWindow* messages_dialog() const { return _messages_window; } @@ -108,6 +111,8 @@ public: protected: App(Ingen::Shared::World* world); + bool animate_callback(); + static App* _instance; SharedPtr _engine; @@ -125,6 +130,10 @@ protected: Ingen::Shared::World* _world; + /// + typedef std::map ActivityPorts; + ActivityPorts _activity_ports; + /** Used to avoid feedback loops with (eg) process checkbutton * FIXME: Maybe this should be globally implemented at the Controller level, * disable all command sending while handling events to avoid feedback diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index 39df7151..4ac973f9 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -187,7 +187,7 @@ NodeModule::embed_gui(bool embed) _gui = NULL; } - slv2_ui_instance_free(_slv2_ui); + //slv2_ui_instance_free(_slv2_ui); // FIXME: leak _slv2_ui = NULL; _ports_y_offset = 0; diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp index a75d9cee..228e4598 100644 --- a/src/libs/gui/Port.cpp +++ b/src/libs/gui/Port.cpp @@ -61,6 +61,8 @@ Port::Port(boost::shared_ptr module, SharedPtr pm pm->signal_metadata.connect(sigc::mem_fun(this, &Port::metadata_update)); _port_model->signal_control.connect(sigc::mem_fun(this, &Port::control_changed)); } + + _port_model->signal_activity.connect(sigc::mem_fun(this, &Port::activity)); control_changed(_port_model->value()); } @@ -90,6 +92,13 @@ Port::control_changed(float value) FlowCanvas::Port::set_control(value); } + +void +Port::activity() +{ + App::instance().port_activity(this); +} + void Port::set_control(float value, bool signal) diff --git a/src/libs/gui/Port.hpp b/src/libs/gui/Port.hpp index 5e7b6bbe..e381c59b 100644 --- a/src/libs/gui/Port.hpp +++ b/src/libs/gui/Port.hpp @@ -48,6 +48,7 @@ public: virtual void set_control(float value, bool signal); void control_changed(float value); + void activity(); private: -- cgit v1.2.1