summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/NodeModel.cpp29
-rw-r--r--src/libs/client/NodeModel.hpp2
-rw-r--r--src/libs/client/PortModel.cpp3
-rw-r--r--src/libs/gui/ControlGroups.cpp36
-rw-r--r--src/libs/gui/Port.cpp36
-rw-r--r--src/libs/gui/Port.hpp1
-rw-r--r--src/libs/gui/PortPropertiesWindow.cpp33
7 files changed, 67 insertions, 73 deletions
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
index 4e3a0a11..76faa158 100644
--- a/src/libs/client/NodeModel.cpp
+++ b/src/libs/client/NodeModel.cpp
@@ -15,6 +15,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "../../../config/config.h"
+
#include "NodeModel.hpp"
#include "PatchModel.hpp"
#include <cassert>
@@ -146,5 +148,32 @@ NodeModel::remove_program(int bank, int program)
}
+void
+NodeModel::port_value_range(const string& name, float& min, float& max)
+{
+ // FIXME: cache these values
+ const Atom& min_atom = get_metadata("ingen:minimum");
+ const Atom& max_atom = get_metadata("ingen:maximum");
+ if (min_atom.type() == Atom::FLOAT)
+ min = min_atom.get_float();
+ if (max_atom.type() == Atom::FLOAT)
+ max = max_atom.get_float();
+
+#ifdef HAVE_SLV2
+ if (plugin() && plugin()->type() == PluginModel::LV2) {
+ min = slv2_port_get_minimum_value(
+ plugin()->slv2_plugin(),
+ slv2_plugin_get_port_by_symbol(plugin()->slv2_plugin(),
+ name.c_str()));
+ max = slv2_port_get_maximum_value(
+ plugin()->slv2_plugin(),
+ slv2_plugin_get_port_by_symbol(plugin()->slv2_plugin(),
+ name.c_str()));
+ }
+#endif
+}
+
+
+
} // namespace Client
} // namespace Ingen
diff --git a/src/libs/client/NodeModel.hpp b/src/libs/client/NodeModel.hpp
index fcaacd0e..05a92d7c 100644
--- a/src/libs/client/NodeModel.hpp
+++ b/src/libs/client/NodeModel.hpp
@@ -58,6 +58,8 @@ public:
const PortModelList& ports() const { return _ports; }
virtual bool polyphonic() const { return _polyphonic; }
+ void port_value_range(const string& name, float& min, float& max);
+
// Signals
sigc::signal<void, SharedPtr<PortModel> > new_port_sig;
sigc::signal<void, SharedPtr<PortModel> > removed_port_sig;
diff --git a/src/libs/client/PortModel.cpp b/src/libs/client/PortModel.cpp
index af80e250..ed59c8ca 100644
--- a/src/libs/client/PortModel.cpp
+++ b/src/libs/client/PortModel.cpp
@@ -16,6 +16,7 @@
*/
#include "PortModel.hpp"
+#include "NodeModel.hpp"
namespace Ingen {
namespace Client {
@@ -44,7 +45,5 @@ PortModel::is_toggle() const
return (hint && hint > 0);
}
-
-
} // namespace Client
} // namespace Ingen
diff --git a/src/libs/gui/ControlGroups.cpp b/src/libs/gui/ControlGroups.cpp
index b22f0a2d..b6c62435 100644
--- a/src/libs/gui/ControlGroups.cpp
+++ b/src/libs/gui/ControlGroups.cpp
@@ -115,39 +115,11 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
_value_spinner->signal_value_changed().connect(
sigc::mem_fun(*this, &SliderControlGroup::update_value_from_spinner));
- // FIXME: code duplication w/ PortPropertiesWindow.cpp
- float min = 0.0f;
- float max = 1.0f;
-
- const Atom& min_atom = pm->get_metadata("ingen:minimum");
- const Atom& max_atom = pm->get_metadata("ingen:maximum");
- if (min_atom.type() == Atom::FLOAT && max_atom.type() == Atom::FLOAT) {
- min = min_atom.get_float();
- max = max_atom.get_float();
- }
+ float min = 0.0f, max = 1.0f;
- const SharedPtr<NodeModel> parent = PtrCast<NodeModel>(pm->parent());
-#ifdef HAVE_SLV2
- if (parent && parent->plugin() && parent->plugin()->type() == PluginModel::LV2) {
- min = slv2_port_get_minimum_value(
- parent->plugin()->slv2_plugin(),
- slv2_plugin_get_port_by_symbol(parent->plugin()->slv2_plugin(),
- pm->path().name().c_str()));
- max = slv2_port_get_maximum_value(
- parent->plugin()->slv2_plugin(),
- slv2_plugin_get_port_by_symbol(parent->plugin()->slv2_plugin(),
- pm->path().name().c_str()));
- }
-#endif
-
- if (min > pm->value())
- min = pm->value();
-
- if (max < pm->value())
- max = pm->value();
-
- if (max <= min)
- max = min + 1.0f;
+ boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
+ if (parent)
+ parent->port_value_range(_port_model->path().name(), min, max);
if (pm->is_integer() || pm->is_toggle()) {
_slider->set_increments(1, 10);
diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp
index aa63af14..38cb42a6 100644
--- a/src/libs/gui/Port.cpp
+++ b/src/libs/gui/Port.cpp
@@ -48,7 +48,11 @@ Port::Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm
_menu.items().push_back(Gtk::Menu_Helpers::MenuElem("Destroy",
sigc::mem_fun(this, &Port::on_menu_destroy)));
+ control_changed(_port_model->value());
+
_port_model->renamed_sig.connect(sigc::mem_fun(this, &Port::renamed));
+
+ _port_model->control_change_sig.connect(sigc::mem_fun(this, &Port::control_changed));
}
@@ -67,22 +71,34 @@ Port::renamed()
void
+Port::control_changed(float value)
+{
+ float min = 0.0f, max = 1.0f;
+ boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
+ if (parent)
+ parent->port_value_range(_port_model->path().name(), min, max);
+
+ /*cerr << "Control changed: " << value << endl;
+ cerr << "Min: " << min << endl;
+ cerr << "Max: " << max << endl;*/
+
+ FlowCanvas::Port::set_control((value - min) / (max - min));
+}
+
+
+void
Port::set_control(float value)
{
if (_port_model->is_control()) {
- float min = 0.0f;
- float max = 1.0f;
-
- const Atom& min_atom = _port_model->get_metadata("ingen:minimum");
- const Atom& max_atom = _port_model->get_metadata("ingen:maximum");
- if (min_atom.type() == Atom::FLOAT && max_atom.type() == Atom::FLOAT) {
- min = min_atom.get_float();
- max = max_atom.get_float();
- }
+ //cerr << "Set control: " << value << endl;
+ float min = 0.0f, max = 1.0f;
+ boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
+ if (parent)
+ parent->port_value_range(_port_model->path().name(), min, max);
App::instance().engine()->set_port_value(_port_model->path(),
min + (value * (max-min)));
-
+
FlowCanvas::Port::set_control(value);
}
}
diff --git a/src/libs/gui/Port.hpp b/src/libs/gui/Port.hpp
index d91c963a..f7eed2f7 100644
--- a/src/libs/gui/Port.hpp
+++ b/src/libs/gui/Port.hpp
@@ -44,6 +44,7 @@ public:
SharedPtr<PortModel> model() const { return _port_model; }
virtual void set_control(float value);
+ void control_changed(float value);
private:
diff --git a/src/libs/gui/PortPropertiesWindow.cpp b/src/libs/gui/PortPropertiesWindow.cpp
index 3ca1b2c3..c975d289 100644
--- a/src/libs/gui/PortPropertiesWindow.cpp
+++ b/src/libs/gui/PortPropertiesWindow.cpp
@@ -60,37 +60,12 @@ PortPropertiesWindow::init(ControlGroup* control, SharedPtr<PortModel> pm)
_port_model = pm;
_control = control;
-
set_title(pm->path() + " Properties");
- // FIXME: code duplication w/ ControlGroups.cpp
- float min = 0.0f;
- float max = 1.0f;
-
- const Atom& min_atom = pm->get_metadata("ingen:minimum");
- const Atom& max_atom = pm->get_metadata("ingen:maximum");
- if (min_atom.type() == Atom::FLOAT && max_atom.type() == Atom::FLOAT) {
- min = min_atom.get_float();
- max = max_atom.get_float();
- }
-
- const SharedPtr<NodeModel> parent = PtrCast<NodeModel>(pm->parent());
-
-#ifdef HAVE_SLV2
- if (parent && parent->plugin() && parent->plugin()->type() == PluginModel::LV2) {
- min = slv2_port_get_minimum_value(
- parent->plugin()->slv2_plugin(),
- slv2_plugin_get_port_by_symbol(parent->plugin()->slv2_plugin(),
- pm->path().name().c_str()));
- max = slv2_port_get_maximum_value(
- parent->plugin()->slv2_plugin(),
- slv2_plugin_get_port_by_symbol(parent->plugin()->slv2_plugin(),
- pm->path().name().c_str()));
- }
-#endif
-
- if (max <= min)
- max = min + 1.0f;
+ float min = 0.0f, max = 1.0f;
+ boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
+ if (parent)
+ parent->port_value_range(_port_model->path().name(), min, max);
_initial_min = min;
_initial_max = max;