summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-10-04 01:28:27 +0000
committerDavid Robillard <d@drobilla.net>2007-10-04 01:28:27 +0000
commit2f991988c6b3d91652461fe70447e343fb3aa916 (patch)
treee4cd972696c68e6a4758f6df74401b9147c53e41 /src/libs
parent93197523aaf7b35350a2a26430be7301ad0502b8 (diff)
downloadingen-2f991988c6b3d91652461fe70447e343fb3aa916.tar.gz
ingen-2f991988c6b3d91652461fe70447e343fb3aa916.tar.bz2
ingen-2f991988c6b3d91652461fe70447e343fb3aa916.zip
Fixed port menu (load fancy dynamic menu from Glade).
Renaming of JACK ports. git-svn-id: http://svn.drobilla.net/lad/ingen@820 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/engine/Driver.hpp12
-rw-r--r--src/libs/engine/JackAudioDriver.cpp18
-rw-r--r--src/libs/engine/JackAudioDriver.hpp4
-rw-r--r--src/libs/engine/JackMidiDriver.cpp24
-rw-r--r--src/libs/engine/JackMidiDriver.hpp5
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.cpp23
-rw-r--r--src/libs/engine/events/RenameEvent.cpp47
-rw-r--r--src/libs/gui/NodeMenu.hpp3
-rw-r--r--src/libs/gui/NodeModule.cpp2
-rw-r--r--src/libs/gui/PatchPortModule.cpp14
-rw-r--r--src/libs/gui/PatchPortModule.hpp7
-rw-r--r--src/libs/gui/Port.cpp5
-rw-r--r--src/libs/gui/PortMenu.hpp9
13 files changed, 124 insertions, 49 deletions
diff --git a/src/libs/engine/Driver.hpp b/src/libs/engine/Driver.hpp
index 012b4ab0..13a5a432 100644
--- a/src/libs/engine/Driver.hpp
+++ b/src/libs/engine/Driver.hpp
@@ -22,6 +22,7 @@
#include <boost/utility.hpp>
#include <raul/Path.hpp>
#include "DataType.hpp"
+#include "DuplexPort.hpp"
namespace Ingen {
@@ -43,13 +44,14 @@ public:
/** Set the name of the system port */
virtual void set_name(const std::string& name) = 0;
- bool is_input() { return _is_input; }
+ bool is_input() const { return _patch_port->is_input(); }
+ DuplexPort* patch_port() const { return _patch_port; }
protected:
/** is_input from the perspective outside of ingen */
- DriverPort(bool is_input) : _is_input(is_input) {}
+ DriverPort(DuplexPort* port) : _patch_port(port) {}
- bool _is_input;
+ DuplexPort* _patch_port;
};
@@ -74,13 +76,15 @@ public:
virtual void deactivate() = 0;
virtual bool is_activated() const = 0;
-
+
/** Create a port ready to be inserted with add_input (non realtime).
*
* May return NULL if the Driver can not drive the port for some reason.
*/
virtual DriverPort* create_port(DuplexPort* patch_port) = 0;
+ virtual DriverPort* driver_port(const Raul::Path& path) = 0;
+
virtual void add_port(DriverPort* port) = 0;
virtual DriverPort* remove_port(const Raul::Path& path) = 0;
diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp
index c8a26510..0d4eb878 100644
--- a/src/libs/engine/JackAudioDriver.cpp
+++ b/src/libs/engine/JackAudioDriver.cpp
@@ -48,12 +48,11 @@ namespace Ingen {
//// JackAudioPort ////
JackAudioPort::JackAudioPort(JackAudioDriver* driver, DuplexPort* patch_port)
-: DriverPort(patch_port->is_input()),
+: DriverPort(patch_port),
Raul::ListNode<JackAudioPort*>(this),
_driver(driver),
_jack_port(NULL),
- _jack_buffer(NULL),
- _patch_port(patch_port)
+ _jack_buffer(NULL)
{
assert(patch_port->poly() == 1);
@@ -253,6 +252,19 @@ JackAudioDriver::create_port(DuplexPort* patch_port)
}
+DriverPort*
+JackAudioDriver::driver_port(const Path& path)
+{
+ assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
+
+ for (Raul::List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i)
+ if ((*i)->patch_port()->path() == path)
+ return (*i);
+
+ return NULL;
+}
+
+
/**** Jack Callbacks ****/
diff --git a/src/libs/engine/JackAudioDriver.hpp b/src/libs/engine/JackAudioDriver.hpp
index f2678800..07877e6f 100644
--- a/src/libs/engine/JackAudioDriver.hpp
+++ b/src/libs/engine/JackAudioDriver.hpp
@@ -52,13 +52,11 @@ public:
void prepare_buffer(jack_nframes_t nframes);
jack_port_t* jack_port() const { return _jack_port; }
- DuplexPort* patch_port() const { return _patch_port; }
private:
JackAudioDriver* _driver;
jack_port_t* _jack_port;
jack_sample_t* _jack_buffer; ///< Cached for output ports
- DuplexPort* _patch_port;
};
@@ -91,6 +89,8 @@ public:
void add_port(DriverPort* port);
DriverPort* remove_port(const Raul::Path& path);
+ DriverPort* driver_port(const Raul::Path& path);
+
Patch* root_patch() { return _root_patch; }
void set_root_patch(Patch* patch) { _root_patch = patch; }
diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp
index 730f5d80..b07a4e37 100644
--- a/src/libs/engine/JackMidiDriver.cpp
+++ b/src/libs/engine/JackMidiDriver.cpp
@@ -39,11 +39,10 @@ namespace Ingen {
//// JackMidiPort ////
JackMidiPort::JackMidiPort(JackMidiDriver* driver, DuplexPort* patch_port)
-: DriverPort(patch_port->is_input()),
+: DriverPort(patch_port),
Raul::ListNode<JackMidiPort*>(this),
_driver(driver),
- _jack_port(NULL),
- _patch_port(patch_port)
+ _jack_port(NULL)
{
assert(patch_port->poly() == 1);
@@ -240,6 +239,25 @@ JackMidiDriver::remove_port(const Path& path)
return NULL;
}
+
+DriverPort*
+JackMidiDriver::driver_port(const Path& path)
+{
+ assert(ThreadManager::current_thread_id() == THREAD_PROCESS);
+
+ // FIXME: duplex?
+
+ for (Raul::List<JackMidiPort*>::iterator i = _in_ports.begin(); i != _in_ports.end(); ++i)
+ if ((*i)->patch_port()->path() == path)
+ return (*i);
+
+ for (Raul::List<JackMidiPort*>::iterator i = _out_ports.begin(); i != _out_ports.end(); ++i)
+ if ((*i)->patch_port()->path() == path)
+ return (*i);
+
+ return NULL;
+}
+
} // namespace Ingen
diff --git a/src/libs/engine/JackMidiDriver.hpp b/src/libs/engine/JackMidiDriver.hpp
index ce83266f..5d7ae493 100644
--- a/src/libs/engine/JackMidiDriver.hpp
+++ b/src/libs/engine/JackMidiDriver.hpp
@@ -46,13 +46,10 @@ public:
void post_process(ProcessContext& context);
void set_name(const std::string& name) { jack_port_set_name(_jack_port, name.c_str()); };
-
- DuplexPort* patch_port() const { return _patch_port; }
private:
JackMidiDriver* _driver;
jack_port_t* _jack_port;
- DuplexPort* _patch_port;
};
@@ -85,6 +82,8 @@ public:
void add_port(DriverPort* port);
DriverPort* remove_port(const Raul::Path& path);
+
+ DriverPort* driver_port(const Raul::Path& path);
jack_client_t* jack_client() { return _client; }
diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp
index b1f76dd6..26f31549 100644
--- a/src/libs/engine/events/DisconnectNodeEvent.cpp
+++ b/src/libs/engine/events/DisconnectNodeEvent.cpp
@@ -15,26 +15,23 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "DisconnectNodeEvent.hpp"
-#include <iostream>
-#include <raul/List.hpp>
#include <raul/Array.hpp>
+#include <raul/List.hpp>
#include <raul/Maid.hpp>
-#include "Responder.hpp"
-#include "Engine.hpp"
-#include "Node.hpp"
+#include <raul/Path.hpp>
+#include "ClientBroadcaster.hpp"
#include "Connection.hpp"
+#include "DisconnectNodeEvent.hpp"
#include "DisconnectionEvent.hpp"
-#include "Port.hpp"
+#include "Engine.hpp"
#include "InputPort.hpp"
+#include "Node.hpp"
+#include "ObjectStore.hpp"
#include "OutputPort.hpp"
#include "Patch.hpp"
-#include "ClientBroadcaster.hpp"
+#include "Port.hpp"
+#include "Responder.hpp"
#include "util.hpp"
-#include "ObjectStore.hpp"
-#include <raul/Path.hpp>
-
-using std::cerr; using std::endl;
namespace Ingen {
@@ -75,8 +72,6 @@ DisconnectNodeEvent::pre_process()
{
typedef Raul::List<Connection*>::const_iterator ConnectionListIterator;
- // cerr << "Preparing disconnection event...\n";
-
if (_lookup) {
_patch = _engine.object_store()->find_patch(_node_path.parent());
diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp
index 1ec3b0d1..9e5ef543 100644
--- a/src/libs/engine/events/RenameEvent.cpp
+++ b/src/libs/engine/events/RenameEvent.cpp
@@ -15,15 +15,17 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <raul/Path.hpp>
+#include "ClientBroadcaster.hpp"
+#include "Engine.hpp"
+#include "Node.hpp"
+#include "ObjectStore.hpp"
+#include "Patch.hpp"
#include "RenameEvent.hpp"
#include "Responder.hpp"
-#include "Patch.hpp"
-#include "Node.hpp"
#include "Tree.hpp"
-#include "Engine.hpp"
-#include "ClientBroadcaster.hpp"
-#include <raul/Path.hpp>
-#include "ObjectStore.hpp"
+#include "AudioDriver.hpp"
+#include "MidiDriver.hpp"
using namespace std;
@@ -34,7 +36,7 @@ RenameEvent::RenameEvent(Engine& engine, SharedPtr<Responder> responder, SampleC
: QueuedEvent(engine, responder, timestamp),
_old_path(path),
_name(name),
- _new_path(_old_path.parent().base() + name),
+ _new_path("/"),
_parent_patch(NULL),
_store_iterator(engine.object_store()->objects().end()),
_error(NO_ERROR)
@@ -55,19 +57,27 @@ RenameEvent::~RenameEvent()
void
RenameEvent::pre_process()
{
- if (_name.find("/") != string::npos) {
+ if ((!Raul::Path::is_valid_name(_name)) || _name.find("/") != string::npos) {
_error = INVALID_NAME;
QueuedEvent::pre_process();
return;
}
+ _new_path = _old_path.parent().base() + _name;
+
_store_iterator = _engine.object_store()->find(_old_path);
if (_store_iterator == _engine.object_store()->objects().end()) {
_error = OBJECT_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
-
+
+ if (_engine.object_store()->find_object(_new_path)) {
+ _error = OBJECT_EXISTS;
+ QueuedEvent::pre_process();
+ return;
+ }
+
Table<Path,GraphObject*> removed = _engine.object_store()->remove(_store_iterator);
assert(removed.size() > 0);
@@ -81,7 +91,6 @@ RenameEvent::pre_process()
else
child_new_path = _new_path.base() + child_old_path.substr(_old_path.length()+1);
- cerr << "Renamed " << child_old_path << " -> " << child_new_path << endl;
i->second->set_path(child_new_path);
i->first = child_new_path;
}
@@ -95,8 +104,24 @@ RenameEvent::pre_process()
void
RenameEvent::execute(ProcessContext& context)
{
- //cout << "Executing rename event...";
QueuedEvent::execute(context);
+
+ Port* port = dynamic_cast<Port*>(_store_iterator->second);
+ if (port && port->parent()->parent() == NULL) {
+ DriverPort* driver_port = NULL;
+
+ if (port->type() == DataType::FLOAT)
+ driver_port = _engine.audio_driver()->driver_port(_new_path);
+ else if (port->type() == DataType::MIDI)
+ driver_port = _engine.midi_driver()->driver_port(_new_path);
+
+ if (driver_port) {
+ cerr << "DRIVER PORT :)!" << endl;
+ driver_port->set_name(_new_path);
+ } else {
+ cerr << "NO DRIVER PORT :(" << endl;
+ }
+ }
}
diff --git a/src/libs/gui/NodeMenu.hpp b/src/libs/gui/NodeMenu.hpp
index f0d30f4c..715cf6b9 100644
--- a/src/libs/gui/NodeMenu.hpp
+++ b/src/libs/gui/NodeMenu.hpp
@@ -35,7 +35,8 @@ class NodeControlWindow;
class NodePropertiesWindow;
class PatchCanvas;
-/** Controller for a Node.
+
+/** Menu for a Node.
*
* \ingroup GUI
*/
diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp
index d3bb9de3..ed05c859 100644
--- a/src/libs/gui/NodeModule.cpp
+++ b/src/libs/gui/NodeModule.cpp
@@ -208,7 +208,7 @@ void
NodeModule::gui_size_request(Gtk::Requisition* r)
{
if (r->width + 4 > _width)
- set_width(r->width + 4);
+ set_minimum_width(r->width + 4);
_gui_item->property_width() = _width - 4;
_gui_item->property_height() = r->height;
diff --git a/src/libs/gui/PatchPortModule.cpp b/src/libs/gui/PatchPortModule.cpp
index 863fc55e..f686079d 100644
--- a/src/libs/gui/PatchPortModule.cpp
+++ b/src/libs/gui/PatchPortModule.cpp
@@ -15,8 +15,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "PatchPortModule.hpp"
#include <cassert>
+#include "PatchPortModule.hpp"
#include "interface/EngineInterface.hpp"
#include "client/PatchModel.hpp"
#include "client/NodeModel.hpp"
@@ -27,6 +27,7 @@
#include "RenameWindow.hpp"
#include "PatchWindow.hpp"
#include "WindowFactory.hpp"
+#include "PortMenu.hpp"
namespace Ingen {
namespace GUI {
@@ -85,6 +86,17 @@ PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortMod
void
+PatchPortModule::create_menu()
+{
+ Glib::RefPtr<Gnome::Glade::Xml> xml = GladeFactory::new_glade_reference();
+ xml->get_widget_derived("object_menu", _menu);
+ _menu->init(_port);
+
+ set_menu(_menu);
+}
+
+
+void
PatchPortModule::store_location()
{
const float x = static_cast<float>(property_x());
diff --git a/src/libs/gui/PatchPortModule.hpp b/src/libs/gui/PatchPortModule.hpp
index 7a420a44..8f3a3fc6 100644
--- a/src/libs/gui/PatchPortModule.hpp
+++ b/src/libs/gui/PatchPortModule.hpp
@@ -38,6 +38,7 @@ namespace GUI {
class PatchCanvas;
class Port;
+class PortMenu;
/** A "module" to represent a patch's port on it's own canvas.
@@ -62,9 +63,11 @@ protected:
PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> port);
void metadata_update(const string& key, const Raul::Atom& value);
+ void create_menu();
- SharedPtr<PortModel> _port;
- boost::shared_ptr<Port> _patch_port; ///< Port on this 'anonymous' module
+ SharedPtr<PortModel> _port;
+ PortMenu* _menu;
+ SharedPtr<Port> _patch_port; ///< Port on this 'anonymous' module
};
diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp
index 228e4598..ccd9652c 100644
--- a/src/libs/gui/Port.cpp
+++ b/src/libs/gui/Port.cpp
@@ -18,6 +18,7 @@
#include <cassert>
#include <iostream>
#include "interface/EngineInterface.hpp"
+#include "flowcanvas/Module.hpp"
#include "client/PatchModel.hpp"
#include "client/PortModel.hpp"
#include "client/ControlModel.hpp"
@@ -44,6 +45,9 @@ Port::Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm
{
assert(module);
assert(_port_model);
+
+ delete _menu;
+ _menu = NULL;
_port_model->signal_renamed.connect(sigc::mem_fun(this, &Port::renamed));
@@ -83,6 +87,7 @@ void
Port::renamed()
{
set_name(_port_model->path().name());
+ module().lock()->resize();
}
diff --git a/src/libs/gui/PortMenu.hpp b/src/libs/gui/PortMenu.hpp
index aa520ebc..e1079f0d 100644
--- a/src/libs/gui/PortMenu.hpp
+++ b/src/libs/gui/PortMenu.hpp
@@ -15,8 +15,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef NODEMENU_H
-#define NODEMENU_H
+#ifndef PORTMENU_H
+#define PORTMENU_H
#include <string>
#include <gtkmm.h>
@@ -35,7 +35,8 @@ class PortControlWindow;
class PortPropertiesWindow;
class PatchCanvas;
-/** Controller for a Port.
+
+/** Menu for a Port.
*
* \ingroup GUI
*/
@@ -51,4 +52,4 @@ public:
} // namespace GUI
} // namespace Ingen
-#endif // NODEMENU_H
+#endif // PORTMENU_H