summaryrefslogtreecommitdiffstats
path: root/src/libs/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/gui')
-rw-r--r--src/libs/gui/ControlGroups.cpp4
-rw-r--r--src/libs/gui/Port.cpp47
-rw-r--r--src/libs/gui/Port.hpp5
-rw-r--r--src/libs/gui/PortPropertiesWindow.cpp2
4 files changed, 32 insertions, 26 deletions
diff --git a/src/libs/gui/ControlGroups.cpp b/src/libs/gui/ControlGroups.cpp
index b6c62435..d82fca13 100644
--- a/src/libs/gui/ControlGroups.cpp
+++ b/src/libs/gui/ControlGroups.cpp
@@ -119,7 +119,7 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
if (parent)
- parent->port_value_range(_port_model->path().name(), min, max);
+ parent->port_value_range(_port_model, min, max);
if (pm->is_integer() || pm->is_toggle()) {
_slider->set_increments(1, 10);
@@ -128,7 +128,7 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
_slider->set_increments(0, 0);
}
- _slider->set_range(min, max);
+ _slider->set_range(std::min(min, pm->value()), std::max(max, pm->value()));
//_value_spinner->set_range(min, max);
set_value(pm->value());
diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp
index 49a1a7c6..455f9e8c 100644
--- a/src/libs/gui/Port.cpp
+++ b/src/libs/gui/Port.cpp
@@ -48,14 +48,24 @@ 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));
if (pm->is_control()) {
show_control();
+
+ 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, min, max);
+
+ set_control_min(min);
+ set_control_max(max);
+
+ pm->metadata_update_sig.connect(sigc::mem_fun(this, &Port::metadata_update));
_port_model->control_change_sig.connect(sigc::mem_fun(this, &Port::control_changed));
}
+
+ control_changed(_port_model->value());
}
@@ -76,33 +86,26 @@ 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));
+ FlowCanvas::Port::set_control(value);
}
void
-Port::set_control(float value)
+Port::set_control(float value, bool signal)
{
- if (_port_model->is_control()) {
- //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);
+ if (signal)
+ App::instance().engine()->set_port_value(_port_model->path(), value);
+ FlowCanvas::Port::set_control(value);
+}
- App::instance().engine()->set_port_value(_port_model->path(),
- min + (value * (max-min)));
- FlowCanvas::Port::set_control(value);
+void
+Port::metadata_update(const string& key, const Atom& value)
+{
+ if ( (key == "ingen:minimum") && value.type() == Atom::FLOAT) {
+ set_control_min(value.get_float());
+ } else if ( (key == "ingen:maximum") && value.type() == Atom::FLOAT) {
+ set_control_max(value.get_float());
}
}
diff --git a/src/libs/gui/Port.hpp b/src/libs/gui/Port.hpp
index f7eed2f7..5925860d 100644
--- a/src/libs/gui/Port.hpp
+++ b/src/libs/gui/Port.hpp
@@ -22,6 +22,7 @@
#include <string>
#include <flowcanvas/Port.hpp>
#include <raul/SharedPtr.hpp>
+#include <raul/Atom.hpp>
namespace Ingen { namespace Client { class PortModel; } }
using Ingen::Client::PortModel;
@@ -43,10 +44,12 @@ public:
SharedPtr<PortModel> model() const { return _port_model; }
- virtual void set_control(float value);
+ virtual void set_control(float value, bool signal);
void control_changed(float value);
private:
+
+ void metadata_update(const string& key, const Raul::Atom& value);
void on_menu_destroy();
void renamed();
diff --git a/src/libs/gui/PortPropertiesWindow.cpp b/src/libs/gui/PortPropertiesWindow.cpp
index c975d289..3d69e648 100644
--- a/src/libs/gui/PortPropertiesWindow.cpp
+++ b/src/libs/gui/PortPropertiesWindow.cpp
@@ -65,7 +65,7 @@ PortPropertiesWindow::init(ControlGroup* control, SharedPtr<PortModel> pm)
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);
+ parent->port_value_range(_port_model, min, max);
_initial_min = min;
_initial_max = max;