Fixed Patchage dynamic reconnection.
git-svn-id: http://svn.drobilla.net/lad@166 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
parent
d3639f2abe
commit
4fccf65944
|
@ -41,14 +41,14 @@ CXXFLAGS="$CXXFLAGS -pipe -fmessage-length=139 -fdiagnostics-show-location=every
|
||||||
CFLAGS="$CFLAGS -pipe -fmessage-length=139 -fdiagnostics-show-location=every-line"
|
CFLAGS="$CFLAGS -pipe -fmessage-length=139 -fdiagnostics-show-location=every-line"
|
||||||
|
|
||||||
# Boost shared_ptr debugging
|
# Boost shared_ptr debugging
|
||||||
pointer_debug="no"
|
#pointer_debug="no"
|
||||||
AC_ARG_ENABLE(pointer_debug,
|
#AC_ARG_ENABLE(pointer_debug,
|
||||||
[AS_HELP_STRING(--enable-pointer-debug, [Enable smart pointer debugging (no)])],
|
# [AS_HELP_STRING(--enable-pointer-debug, [Enable smart pointer debugging (no)])],
|
||||||
[pointer_debug="$enableval"])
|
# [pointer_debug="$enableval"])
|
||||||
if test "$pointer_debug" = "yes"; then
|
#if test "$pointer_debug" = "yes"; then
|
||||||
CFLAGS+=" -DBOOST_SP_ENABLE_DEBUG_HOOKS"
|
# CFLAGS+=" -DBOOST_SP_ENABLE_DEBUG_HOOKS"
|
||||||
CXXFLAGS+=" -DBOOST_SP_ENABLE_DEBUG_HOOKS"
|
# CXXFLAGS+=" -DBOOST_SP_ENABLE_DEBUG_HOOKS"
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
PKG_CHECK_MODULES(GTKMM, gtkmm-2.4)
|
PKG_CHECK_MODULES(GTKMM, gtkmm-2.4)
|
||||||
PKG_CHECK_MODULES(GNOMECANVASMM, libgnomecanvasmm-2.6)
|
PKG_CHECK_MODULES(GNOMECANVASMM, libgnomecanvasmm-2.6)
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
inline boost::shared_ptr<Port> get_port(const string& name) const;
|
inline boost::shared_ptr<Port> get_port(const string& name) const;
|
||||||
|
|
||||||
void add_port(boost::shared_ptr<Port> port);
|
void add_port(boost::shared_ptr<Port> port);
|
||||||
|
void remove_port(boost::shared_ptr<Port> port);
|
||||||
boost::shared_ptr<Port> remove_port(const string& name);
|
boost::shared_ptr<Port> remove_port(const string& name);
|
||||||
boost::shared_ptr<Port> port_at(double x, double y);
|
boost::shared_ptr<Port> port_at(double x, double y);
|
||||||
|
|
||||||
|
@ -82,8 +83,6 @@ public:
|
||||||
int base_color() const { return 0x1F2A3CFF; }
|
int base_color() const { return 0x1F2A3CFF; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void remove_port(boost::shared_ptr<Port> port);
|
|
||||||
|
|
||||||
bool module_event(GdkEvent* event);
|
bool module_event(GdkEvent* event);
|
||||||
|
|
||||||
bool is_within(const Gnome::Canvas::Rect& rect);
|
bool is_within(const Gnome::Canvas::Rect& rect);
|
||||||
|
|
|
@ -412,8 +412,8 @@ FlowCanvas::are_connected(boost::shared_ptr<const Port> port1, boost::shared_ptr
|
||||||
ConnectionList::const_iterator c;
|
ConnectionList::const_iterator c;
|
||||||
|
|
||||||
for (c = m_connections.begin(); c != m_connections.end(); ++c) {
|
for (c = m_connections.begin(); c != m_connections.end(); ++c) {
|
||||||
boost::shared_ptr<Port> src = (*c)->source().lock();
|
const boost::shared_ptr<Port> src = (*c)->source().lock();
|
||||||
boost::shared_ptr<Port> dst = (*c)->dest().lock();
|
const boost::shared_ptr<Port> dst = (*c)->dest().lock();
|
||||||
if (!src || !dst)
|
if (!src || !dst)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -432,8 +432,8 @@ FlowCanvas::get_connection(boost::shared_ptr<Port> port1, boost::shared_ptr<Port
|
||||||
assert(port2);
|
assert(port2);
|
||||||
|
|
||||||
for (ConnectionList::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
|
for (ConnectionList::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
|
||||||
boost::shared_ptr<Port> src = (*i)->source().lock();
|
const boost::shared_ptr<Port> src = (*i)->source().lock();
|
||||||
boost::shared_ptr<Port> dst = (*i)->dest().lock();
|
const boost::shared_ptr<Port> dst = (*i)->dest().lock();
|
||||||
if (!src || !dst)
|
if (!src || !dst)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -482,8 +482,8 @@ FlowCanvas::add_connection(boost::shared_ptr<Port> port1, boost::shared_ptr<Port
|
||||||
bool
|
bool
|
||||||
FlowCanvas::add_connection(boost::shared_ptr<Connection> c)
|
FlowCanvas::add_connection(boost::shared_ptr<Connection> c)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Port> src = c->source().lock();
|
const boost::shared_ptr<Port> src = c->source().lock();
|
||||||
boost::shared_ptr<Port> dst = c->dest().lock();
|
const boost::shared_ptr<Port> dst = c->dest().lock();
|
||||||
|
|
||||||
if (src && dst) {
|
if (src && dst) {
|
||||||
src->add_connection(c);
|
src->add_connection(c);
|
||||||
|
@ -505,10 +505,16 @@ FlowCanvas::remove_connection(boost::shared_ptr<Connection> connection)
|
||||||
ConnectionList::iterator i = find(m_connections.begin(), m_connections.end(), connection);
|
ConnectionList::iterator i = find(m_connections.begin(), m_connections.end(), connection);
|
||||||
|
|
||||||
if (i != m_connections.end()) {
|
if (i != m_connections.end()) {
|
||||||
boost::shared_ptr<Connection> c = *i;
|
const boost::shared_ptr<Connection> c = *i;
|
||||||
|
|
||||||
|
const boost::shared_ptr<Port> src = c->source().lock();
|
||||||
|
const boost::shared_ptr<Port> dst = c->dest().lock();
|
||||||
|
|
||||||
c->source().lock()->remove_connection(c);
|
if (src)
|
||||||
c->dest().lock()->remove_connection(c);
|
src->remove_connection(c);
|
||||||
|
|
||||||
|
if (dst)
|
||||||
|
dst->remove_connection(c);
|
||||||
|
|
||||||
m_connections.erase(i);
|
m_connections.erase(i);
|
||||||
}
|
}
|
||||||
|
@ -532,8 +538,12 @@ FlowCanvas::destroy_all_flagged_connections()
|
||||||
if ((*c)->flagged()) {
|
if ((*c)->flagged()) {
|
||||||
ConnectionList::iterator next = c;
|
ConnectionList::iterator next = c;
|
||||||
++next;
|
++next;
|
||||||
(*c)->source().lock()->remove_connection(*c);
|
const boost::shared_ptr<Port> src = (*c)->source().lock();
|
||||||
(*c)->dest().lock()->remove_connection(*c);
|
const boost::shared_ptr<Port> dst = (*c)->dest().lock();
|
||||||
|
if (src)
|
||||||
|
src->remove_connection(*c);
|
||||||
|
if (dst)
|
||||||
|
dst->remove_connection(*c);
|
||||||
m_connections.erase(c);
|
m_connections.erase(c);
|
||||||
c = next;
|
c = next;
|
||||||
} else {
|
} else {
|
||||||
|
@ -551,8 +561,12 @@ FlowCanvas::destroy_all_connections()
|
||||||
m_remove_objects = false;
|
m_remove_objects = false;
|
||||||
|
|
||||||
for (ConnectionList::iterator c = m_connections.begin(); c != m_connections.end(); ++c) {
|
for (ConnectionList::iterator c = m_connections.begin(); c != m_connections.end(); ++c) {
|
||||||
(*c)->source().lock()->remove_connection(*c);
|
const boost::shared_ptr<Port> src = (*c)->source().lock();
|
||||||
(*c)->dest().lock()->remove_connection(*c);
|
const boost::shared_ptr<Port> dst = (*c)->dest().lock();
|
||||||
|
if (src)
|
||||||
|
src->remove_connection(*c);
|
||||||
|
if (dst)
|
||||||
|
dst->remove_connection(*c);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connections.clear();
|
m_connections.clear();
|
||||||
|
@ -898,18 +912,20 @@ FlowCanvas::connection_drag_handler(GdkEvent* event)
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
boost::shared_ptr<Module> m = p->module().lock();
|
boost::shared_ptr<Module> m = p->module().lock();
|
||||||
if (p != m_selected_port) {
|
if (m) {
|
||||||
if (snapped_port)
|
if (p != m_selected_port) {
|
||||||
snapped_port->set_highlighted(false);
|
if (snapped_port)
|
||||||
p->set_highlighted(true);
|
snapped_port->set_highlighted(false);
|
||||||
snapped_port = p;
|
p->set_highlighted(true);
|
||||||
|
snapped_port = p;
|
||||||
|
}
|
||||||
|
drag_module->property_x() = m->property_x().get_value();
|
||||||
|
drag_module->m_module_box.property_x2() = m->m_module_box.property_x2().get_value();
|
||||||
|
drag_module->property_y() = m->property_y().get_value();
|
||||||
|
drag_module->m_module_box.property_y2() = m->m_module_box.property_y2().get_value();
|
||||||
|
drag_port->property_x() = p->property_x().get_value();
|
||||||
|
drag_port->property_y() = p->property_y().get_value();
|
||||||
}
|
}
|
||||||
drag_module->property_x() = m->property_x().get_value();
|
|
||||||
drag_module->m_module_box.property_x2() = m->m_module_box.property_x2().get_value();
|
|
||||||
drag_module->property_y() = m->property_y().get_value();
|
|
||||||
drag_module->m_module_box.property_y2() = m->m_module_box.property_y2().get_value();
|
|
||||||
drag_port->property_x() = p->property_x().get_value();
|
|
||||||
drag_port->property_y() = p->property_y().get_value();
|
|
||||||
} else { // off the port now, unsnap
|
} else { // off the port now, unsnap
|
||||||
if (snapped_port)
|
if (snapped_port)
|
||||||
snapped_port->set_highlighted(false);
|
snapped_port->set_highlighted(false);
|
||||||
|
@ -939,18 +955,20 @@ FlowCanvas::connection_drag_handler(GdkEvent* event)
|
||||||
|
|
||||||
if (p && p->is_input() != m_connect_port->is_input()) {
|
if (p && p->is_input() != m_connect_port->is_input()) {
|
||||||
boost::shared_ptr<Module> m = p->module().lock();
|
boost::shared_ptr<Module> m = p->module().lock();
|
||||||
p->set_highlighted(true);
|
if (m) {
|
||||||
snapped_port = p;
|
p->set_highlighted(true);
|
||||||
snapped = true;
|
snapped_port = p;
|
||||||
// Make drag module and port exactly the same size/loc as the snapped
|
snapped = true;
|
||||||
drag_module->move_to(m->property_x().get_value(), m->property_y().get_value());
|
// Make drag module and port exactly the same size/loc as the snapped
|
||||||
drag_module->set_width(m->width());
|
drag_module->move_to(m->property_x().get_value(), m->property_y().get_value());
|
||||||
drag_module->set_height(m->height());
|
drag_module->set_width(m->width());
|
||||||
drag_port->property_x() = p->property_x().get_value();
|
drag_module->set_height(m->height());
|
||||||
drag_port->property_y() = p->property_y().get_value();
|
drag_port->property_x() = p->property_x().get_value();
|
||||||
// Make the drag port as wide as the snapped port so the connection coords are the same
|
drag_port->property_y() = p->property_y().get_value();
|
||||||
drag_port->m_rect.property_x2() = p->m_rect.property_x2().get_value();
|
// Make the drag port as wide as the snapped port so the connection coords are the same
|
||||||
drag_port->m_rect.property_y2() = p->m_rect.property_y2().get_value();
|
drag_port->m_rect.property_x2() = p->m_rect.property_x2().get_value();
|
||||||
|
drag_port->m_rect.property_y2() = p->m_rect.property_y2().get_value();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
drag_module->property_x() = x;
|
drag_module->property_x() = x;
|
||||||
drag_module->property_y() = y - 7; // FIXME: s#7#cursor_height/2#
|
drag_module->property_y() = y - 7; // FIXME: s#7#cursor_height/2#
|
||||||
|
|
|
@ -98,6 +98,16 @@ if test "$strict" = "yes"; then
|
||||||
CXXFLAGS="$CXXFLAGS -ansi -Wall -Wextra -Wno-unused-parameter -Wconversion -Winit-self -Woverloaded-virtual -Wsign-promo"
|
CXXFLAGS="$CXXFLAGS -ansi -Wall -Wextra -Wno-unused-parameter -Wconversion -Winit-self -Woverloaded-virtual -Wsign-promo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Boost shared_ptr debugging
|
||||||
|
pointer_debug="no"
|
||||||
|
AC_ARG_ENABLE(pointer_debug,
|
||||||
|
[AS_HELP_STRING(--enable-pointer-debug, [Enable smart pointer debugging (no)])],
|
||||||
|
[pointer_debug="$enableval"])
|
||||||
|
if test "$pointer_debug" = "yes"; then
|
||||||
|
CFLAGS+=" -DBOOST_SP_ENABLE_DEBUG_HOOKS"
|
||||||
|
CXXFLAGS+=" -DBOOST_SP_ENABLE_DEBUG_HOOKS"
|
||||||
|
fi
|
||||||
|
|
||||||
# Bolt on a few specific flags to CXXFLAGS that should always be used
|
# Bolt on a few specific flags to CXXFLAGS that should always be used
|
||||||
CXXFLAGS="$CXXFLAGS -pipe -Wall -fmessage-length=139 -fdiagnostics-show-location=every-line"
|
CXXFLAGS="$CXXFLAGS -pipe -Wall -fmessage-length=139 -fdiagnostics-show-location=every-line"
|
||||||
CFLAGS="$CFLAGS -pipe -Wall -fmessage-length=139 -fdiagnostics-show-location=every-line"
|
CFLAGS="$CFLAGS -pipe -Wall -fmessage-length=139 -fdiagnostics-show-location=every-line"
|
||||||
|
|
|
@ -73,7 +73,7 @@ AlsaDriver::attach(bool /*launch_daemon*/)
|
||||||
void
|
void
|
||||||
AlsaDriver::detach()
|
AlsaDriver::detach()
|
||||||
{
|
{
|
||||||
if (m_seq != NULL) {
|
if (m_seq) {
|
||||||
pthread_cancel(m_refresh_thread);
|
pthread_cancel(m_refresh_thread);
|
||||||
pthread_join(m_refresh_thread, NULL);
|
pthread_join(m_refresh_thread, NULL);
|
||||||
snd_seq_close(m_seq);
|
snd_seq_close(m_seq);
|
||||||
|
|
|
@ -75,12 +75,12 @@ JackDriver::attach(bool launch_daemon)
|
||||||
void
|
void
|
||||||
JackDriver::detach()
|
JackDriver::detach()
|
||||||
{
|
{
|
||||||
if (m_client != NULL) {
|
if (m_client) {
|
||||||
jack_deactivate(m_client);
|
jack_deactivate(m_client);
|
||||||
jack_client_close(m_client);
|
jack_client_close(m_client);
|
||||||
m_client = NULL;
|
m_client = NULL;
|
||||||
signal_detached.emit();
|
|
||||||
destroy_all_ports();
|
destroy_all_ports();
|
||||||
|
signal_detached.emit();
|
||||||
m_app->status_message("[JACK] Detached");
|
m_app->status_message("[JACK] Detached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,12 +97,12 @@ JackDriver::destroy_all_ports()
|
||||||
for (PortVector::iterator p = ports.begin(); p != ports.end(); ++p) {
|
for (PortVector::iterator p = ports.begin(); p != ports.end(); ++p) {
|
||||||
boost::shared_ptr<PatchagePort> port = boost::dynamic_pointer_cast<PatchagePort>(*p);
|
boost::shared_ptr<PatchagePort> port = boost::dynamic_pointer_cast<PatchagePort>(*p);
|
||||||
if (port && port->type() == JACK_AUDIO || port->type() == JACK_MIDI) {
|
if (port && port->type() == JACK_AUDIO || port->type() == JACK_MIDI) {
|
||||||
port.reset();
|
m->second->remove_port(port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->second->ports().empty())
|
if (m->second->ports().empty())
|
||||||
m->second.reset();
|
m_app->canvas()->remove_module(m->second->name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,8 +144,8 @@ JackDriver::refresh()
|
||||||
if (m_client == NULL) {
|
if (m_client == NULL) {
|
||||||
// Shutdown
|
// Shutdown
|
||||||
if (m_is_dirty) {
|
if (m_is_dirty) {
|
||||||
signal_detached.emit();
|
|
||||||
destroy_all_ports();
|
destroy_all_ports();
|
||||||
|
signal_detached.emit();
|
||||||
}
|
}
|
||||||
m_is_dirty = false;
|
m_is_dirty = false;
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
|
|
|
@ -67,7 +67,6 @@ LashDriver::attach(bool launch_daemon)
|
||||||
void
|
void
|
||||||
LashDriver::detach()
|
LashDriver::detach()
|
||||||
{
|
{
|
||||||
// FIXME: send some notification that we're gone??
|
|
||||||
m_client = NULL;
|
m_client = NULL;
|
||||||
m_app->status_message("[LASH] Detached");
|
m_app->status_message("[LASH] Detached");
|
||||||
signal_detached.emit();
|
signal_detached.emit();
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include "LashDriver.h"
|
#include "LashDriver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// FIXME: include to avoid undefined reference to boost SP debug hooks stuff
|
||||||
|
#include <raul/SharedPtr.h>
|
||||||
|
|
||||||
Patchage::Patchage(int argc, char** argv)
|
Patchage::Patchage(int argc, char** argv)
|
||||||
:
|
:
|
||||||
|
@ -47,6 +49,8 @@ Patchage::Patchage(int argc, char** argv)
|
||||||
m_state_manager = new StateManager();
|
m_state_manager = new StateManager();
|
||||||
m_canvas = boost::shared_ptr<PatchageFlowCanvas>(new PatchageFlowCanvas(this, 1600*2, 1200*2));
|
m_canvas = boost::shared_ptr<PatchageFlowCanvas>(new PatchageFlowCanvas(this, 1600*2, 1200*2));
|
||||||
m_jack_driver = new JackDriver(this);
|
m_jack_driver = new JackDriver(this);
|
||||||
|
m_jack_driver->signal_detached.connect(sigc::mem_fun(this, &Patchage::queue_refresh));
|
||||||
|
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
m_alsa_driver = new AlsaDriver(this);
|
m_alsa_driver = new AlsaDriver(this);
|
||||||
#endif
|
#endif
|
||||||
|
@ -108,6 +112,7 @@ Patchage::Patchage(int argc, char** argv)
|
||||||
xml->get_widget("zoom_normal_but", m_zoom_normal_button);
|
xml->get_widget("zoom_normal_but", m_zoom_normal_button);
|
||||||
|
|
||||||
update_state();
|
update_state();
|
||||||
|
m_main_paned->set_position(m_main_paned->get_height() - 20);
|
||||||
|
|
||||||
m_canvas_scrolledwindow->add(*m_canvas);
|
m_canvas_scrolledwindow->add(*m_canvas);
|
||||||
//m_canvas_scrolledwindow->signal_event().connect(sigc::mem_fun(m_canvas, &FlowCanvas::scroll_event_handler));
|
//m_canvas_scrolledwindow->signal_event().connect(sigc::mem_fun(m_canvas, &FlowCanvas::scroll_event_handler));
|
||||||
|
@ -142,7 +147,6 @@ Patchage::Patchage(int argc, char** argv)
|
||||||
m_menu_help_about->signal_activate().connect( sigc::mem_fun(this, &Patchage::menu_help_about));
|
m_menu_help_about->signal_activate().connect( sigc::mem_fun(this, &Patchage::menu_help_about));
|
||||||
|
|
||||||
attach_menu_items();
|
attach_menu_items();
|
||||||
m_main_paned->set_position(m_main_paned->get_height() - 20);
|
|
||||||
|
|
||||||
m_canvas->show();
|
m_canvas->show();
|
||||||
}
|
}
|
||||||
|
@ -231,15 +235,16 @@ Patchage::update_state()
|
||||||
for (ModuleMap::iterator i = m_canvas->modules().begin(); i != m_canvas->modules().end(); ++i)
|
for (ModuleMap::iterator i = m_canvas->modules().begin(); i != m_canvas->modules().end(); ++i)
|
||||||
(*i).second->load_location();
|
(*i).second->load_location();
|
||||||
|
|
||||||
cerr << "[Patchage] Resizing window: (" << m_state_manager->get_window_size().x
|
//cerr << "[Patchage] Resizing window: (" << m_state_manager->get_window_size().x
|
||||||
<< "," << m_state_manager->get_window_size().y << ")" << endl;
|
// << "," << m_state_manager->get_window_size().y << ")" << endl;
|
||||||
|
|
||||||
m_main_window->resize(
|
m_main_window->resize(
|
||||||
static_cast<int>(m_state_manager->get_window_size().x),
|
static_cast<int>(m_state_manager->get_window_size().x),
|
||||||
static_cast<int>(m_state_manager->get_window_size().y));
|
static_cast<int>(m_state_manager->get_window_size().y));
|
||||||
|
|
||||||
cerr << "[Patchage] Moving window: (" << m_state_manager->get_window_location().x
|
//cerr << "[Patchage] Moving window: (" << m_state_manager->get_window_location().x
|
||||||
<< "," << m_state_manager->get_window_location().y << ")" << endl;
|
// << "," << m_state_manager->get_window_location().y << ")" << endl;
|
||||||
|
|
||||||
m_main_window->move(
|
m_main_window->move(
|
||||||
static_cast<int>(m_state_manager->get_window_location().x),
|
static_cast<int>(m_state_manager->get_window_location().x),
|
||||||
static_cast<int>(m_state_manager->get_window_location().y));
|
static_cast<int>(m_state_manager->get_window_location().y));
|
||||||
|
|
|
@ -51,6 +51,11 @@ namespace boost {
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#ifdef BOOST_AC_USE_PTHREADS
|
||||||
|
#error "Boost is using mutex locking for pointer reference counting."
|
||||||
|
#error "This is VERY slow. Please report your platform."
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SharedPtr boost::shared_ptr
|
#define SharedPtr boost::shared_ptr
|
||||||
#define PtrCast boost::dynamic_pointer_cast
|
#define PtrCast boost::dynamic_pointer_cast
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue