diff options
author | David Robillard <d@drobilla.net> | 2009-12-31 18:27:20 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-12-31 18:27:20 +0000 |
commit | 3dded8a655b6cad1925f160cb1012b8334e00c3e (patch) | |
tree | 5d743f58c6494ea7e5ed4010f9016c7d3c3f7665 /src/gui/Port.cpp | |
parent | c11b1bd6fe15f281c5e6b1ab2109590c17e739e9 (diff) | |
download | ingen-3dded8a655b6cad1925f160cb1012b8334e00c3e.tar.gz ingen-3dded8a655b6cad1925f160cb1012b8334e00c3e.tar.bz2 ingen-3dded8a655b6cad1925f160cb1012b8334e00c3e.zip |
Various fixes related to port values and metadata (fix ticket #459 among other things).
Fix jitterey behaviour of port controls (on module) while dragging.
Update value in status bar while dragging port slider (on module).
Update plugin data (e.g. port control range) if the plugin is sent to the
client after nodes that are instances of it (i.e. more robust plugin state
tracking via merging like with objects).
Correctly save and restore port values (ticket #459).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2327 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui/Port.cpp')
-rw-r--r-- | src/gui/Port.cpp | 71 |
1 files changed, 57 insertions, 14 deletions
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index ba4e0482..91e64f3a 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -21,11 +21,13 @@ #include "flowcanvas/Module.hpp" #include "client/PatchModel.hpp" #include "client/PortModel.hpp" -#include "Configuration.hpp" #include "App.hpp" +#include "Configuration.hpp" +#include "GladeFactory.hpp" +#include "PatchWindow.hpp" #include "Port.hpp" #include "PortMenu.hpp" -#include "GladeFactory.hpp" +#include "WindowFactory.hpp" using namespace Ingen::Client; using namespace std; @@ -48,6 +50,7 @@ Port::Port( flip ? (!pm->is_input()) : pm->is_input(), App::instance().configuration()->get_port_color(pm.get())) , _port_model(pm) + , _pressed(false) , _flipped(flip) { assert(module); @@ -65,21 +68,14 @@ Port::Port( if (pm->type().is_control()) { set_toggled(pm->is_toggle()); show_control(); - - float min = 0.0f, max = 1.0f; - boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(pm->parent()); - if (parent) - parent->port_value_range(pm, min, max); - - set_control_min(min); - set_control_max(max); - pm->signal_property.connect(sigc::mem_fun(this, &Port::property_changed)); pm->signal_value_changed.connect(sigc::mem_fun(this, &Port::value_changed)); } pm->signal_activity.connect(sigc::mem_fun(this, &Port::activity)); + update_metadata(); + value_changed(pm->value()); } @@ -91,6 +87,24 @@ Port::~Port() void +Port::update_metadata() +{ + SharedPtr<PortModel> pm = _port_model.lock(); + if (pm && pm->type().is_control()) { + boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(pm->parent()); + if (parent) { + float min = 0.0f; + float max = 1.0f; + parent->port_value_range(pm, min, max); + set_control_min(min); + set_control_max(max); + } + } +} + + + +void Port::create_menu() { PortMenu* menu = NULL; @@ -112,13 +126,32 @@ Port::moved() void Port::value_changed(const Atom& value) { - if (value.type() == Atom::FLOAT) + if (_pressed) + return; + else if (value.type() == Atom::FLOAT) FlowCanvas::Port::set_control(value.get_float()); else cerr << "WARNING: Unknown port value type " << (unsigned)value.type() << endl; } +bool +Port::on_event(GdkEvent* ev) +{ + switch (ev->type) { + case GDK_BUTTON_PRESS: + _pressed = true; + break; + case GDK_BUTTON_RELEASE: + _pressed = false; + default: + break; + } + + return false; +} + + void Port::activity() { @@ -132,6 +165,14 @@ Port::set_control(float value, bool signal) if (signal) { if (model()->type() == PortType::CONTROL) { App::instance().engine()->set_port_value(model()->path(), Atom(value)); + PatchWindow* pw = App::instance().window_factory()->patch_window( + PtrCast<PatchModel>(model()->parent())); + if (!pw) + pw = App::instance().window_factory()->patch_window( + PtrCast<PatchModel>(model()->parent()->parent())); + if (pw) + pw->show_port_status(model().get(), value); + } else if (model()->type() == PortType::EVENTS) { App::instance().engine()->set_port_value(model()->path(), Atom("<http://example.org/ev#BangEvent>", 0, NULL)); @@ -146,9 +187,11 @@ void Port::property_changed(const URI& key, const Atom& value) { if (value.type() == Atom::FLOAT) { - if ((key.str() == "lv2:minimum")) + if (key.str() == "ingen:value") + set_control(value.get_float(), false); + else if (key.str() == "lv2:minimum") set_control_min(value.get_float()); - else if ((key.str() == "lv2:maximum")) + else if (key.str() == "lv2:maximum") set_control_max(value.get_float()); } else if (value.type() == Atom::BOOL) { if ((key.str() == "lv2:toggled")) |