summaryrefslogtreecommitdiffstats
path: root/src/libs/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-05-19 21:36:34 +0000
committerDavid Robillard <d@drobilla.net>2008-05-19 21:36:34 +0000
commitf9eba59332ee7e45ffbfebcd0ce79e8e0cfd9ec4 (patch)
treefa8a4a74ee4072987ed79ffdcf766730bcdc0790 /src/libs/gui
parentee173c38c5c0a385c46bec12e3f52c57e0e074a0 (diff)
downloadingen-f9eba59332ee7e45ffbfebcd0ce79e8e0cfd9ec4.tar.gz
ingen-f9eba59332ee7e45ffbfebcd0ce79e8e0cfd9ec4.tar.bz2
ingen-f9eba59332ee7e45ffbfebcd0ce79e8e0cfd9ec4.zip
More (but not yet completely) type safe value_changed notification.
git-svn-id: http://svn.drobilla.net/lad/ingen@1216 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/gui')
-rw-r--r--src/libs/gui/ControlGroups.cpp8
-rw-r--r--src/libs/gui/ControlGroups.hpp4
-rw-r--r--src/libs/gui/NodeModule.cpp10
-rw-r--r--src/libs/gui/NodeModule.hpp2
-rw-r--r--src/libs/gui/Port.cpp2
5 files changed, 15 insertions, 11 deletions
diff --git a/src/libs/gui/ControlGroups.cpp b/src/libs/gui/ControlGroups.cpp
index 236f782e..114bb79d 100644
--- a/src/libs/gui/ControlGroups.cpp
+++ b/src/libs/gui/ControlGroups.cpp
@@ -64,7 +64,7 @@ ControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
assert(_port_model);
assert(panel);
- _control_connection = pm->signal_control.connect(sigc::mem_fun(this, &ControlGroup::set_value));
+ _control_connection = pm->signal_value_changed.connect(sigc::mem_fun(this, &ControlGroup::set_value));
}
@@ -130,7 +130,7 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
pm->signal_variable.connect(sigc::mem_fun(this, &SliderControlGroup::port_variable_change));
- _slider->set_range(std::min(min, pm->value()), std::max(max, pm->value()));
+ _slider->set_range(std::min(min, pm->value().get_float()), std::max(max, pm->value().get_float()));
//_value_spinner->set_range(min, max);
set_value(pm->value());
@@ -165,8 +165,10 @@ SliderControlGroup::menu_properties()
void
-SliderControlGroup::set_value(float val)
+SliderControlGroup::set_value(const Atom& atom)
{
+ float val = atom.get_float();
+
if (_port_model->is_integer())
val = lrintf(val);
diff --git a/src/libs/gui/ControlGroups.hpp b/src/libs/gui/ControlGroups.hpp
index 89f26a6b..da604f72 100644
--- a/src/libs/gui/ControlGroups.hpp
+++ b/src/libs/gui/ControlGroups.hpp
@@ -49,7 +49,7 @@ public:
inline const SharedPtr<PortModel> port_model() const { return _port_model; }
protected:
- virtual void set_value(float value) = 0;
+ virtual void set_value(const Atom& value) = 0;
virtual void set_range(float min, float max) {}
ControlPanel* _control_panel;
@@ -80,7 +80,7 @@ private:
bool clicked(GdkEventButton* ev);
- void set_value(float value);
+ void set_value(const Atom& value);
void set_range(float min, float max);
void port_variable_change(const string& key, const Raul::Atom& value);
diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp
index fefe84fb..0e4ce18b 100644
--- a/src/libs/gui/NodeModule.cpp
+++ b/src/libs/gui/NodeModule.cpp
@@ -107,8 +107,10 @@ NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> n
void
-NodeModule::control_change(uint32_t index, float control)
+NodeModule::value_changed(uint32_t index, const Atom& value)
{
+ float control = value.get_float();
+ cout << _node->name() << " control " << index << " = " << control << endl;
if (_plugin_ui) {
SLV2UIInstance inst = _plugin_ui->instance();
const LV2UI_Descriptor* ui_descriptor = slv2_ui_instance_get_descriptor(inst);
@@ -250,8 +252,8 @@ NodeModule::add_port(SharedPtr<PortModel> port, bool resize_to_fit)
Module::add_port(boost::shared_ptr<Port>(
new Port(PtrCast<NodeModule>(shared_from_this()), port)));
- port->signal_control.connect(sigc::bind<0>(
- sigc::mem_fun(this, &NodeModule::control_change), index));
+ port->signal_value_changed.connect(sigc::bind<0>(
+ sigc::mem_fun(this, &NodeModule::value_changed), index));
if (resize_to_fit)
resize();
@@ -320,7 +322,7 @@ NodeModule::initialise_gui_values()
uint32_t index=0;
for (PortModelList::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) {
if ((*p)->type().is_control())
- control_change(index, (*p)->value());
+ value_changed(index, (*p)->value());
++index;
}
}
diff --git a/src/libs/gui/NodeModule.hpp b/src/libs/gui/NodeModule.hpp
index d73b4529..595cb1e1 100644
--- a/src/libs/gui/NodeModule.hpp
+++ b/src/libs/gui/NodeModule.hpp
@@ -77,7 +77,7 @@ protected:
void add_port(SharedPtr<PortModel> port, bool resize=true);
void remove_port(SharedPtr<PortModel> port);
- void control_change(uint32_t index, float control);
+ void value_changed(uint32_t index, const Atom& value);
void embed_gui(bool embed);
void gui_size_request(Gtk::Requisition* req, bool force);
diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp
index 97a06bcd..225ab7ab 100644
--- a/src/libs/gui/Port.cpp
+++ b/src/libs/gui/Port.cpp
@@ -63,7 +63,7 @@ Port::Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm
set_control_max(max);
pm->signal_variable.connect(sigc::mem_fun(this, &Port::variable_change));
- _port_model->signal_control.connect(sigc::mem_fun(this, &Port::control_changed));
+ _port_model->signal_value_changed.connect(sigc::mem_fun(this, &Port::control_changed));
}
_port_model->signal_activity.connect(sigc::mem_fun(this, &Port::activity));