diff options
author | David Robillard <d@drobilla.net> | 2012-03-12 00:24:11 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-12 00:24:11 +0000 |
commit | 89272aef042d57d7be9dd50e8157849d192f13b1 (patch) | |
tree | e18e819092018c63e476aa26f0fb9790c8bfdad3 /src | |
parent | 4c299323440923891b9c583a354116000eb143cc (diff) | |
download | ingen-89272aef042d57d7be9dd50e8157849d192f13b1.tar.gz ingen-89272aef042d57d7be9dd50e8157849d192f13b1.tar.bz2 ingen-89272aef042d57d7be9dd50e8157849d192f13b1.zip |
Make port controls actually do something.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4051 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/Port.cpp | 68 | ||||
-rw-r--r-- | src/gui/Port.hpp | 5 |
2 files changed, 36 insertions, 37 deletions
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index eafc6392..06d79c11 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -82,8 +82,6 @@ Port::Port(App& app, //_rect.property_dash() = dash; set_border_width(1.0); - pm->signal_moved().connect(sigc::mem_fun(this, &Port::moved)); - if (app.can_control(pm.get())) { set_control_is_toggle(pm->is_toggle()); show_control(); @@ -94,9 +92,11 @@ Port::Port(App& app, } pm->signal_activity().connect(sigc::mem_fun(this, &Port::activity)); + pm->signal_moved().connect(sigc::mem_fun(this, &Port::moved)); - update_metadata(); + signal_value_changed.connect(sigc::mem_fun(this, &Port::on_value_changed)); + update_metadata(); value_changed(pm->value()); } @@ -139,12 +139,33 @@ Port::moved() } void -Port::value_changed(const Atom& value) +Port::on_value_changed(const Glib::VariantBase& value) { - if (_pressed) + if (!value.is_of_type(Glib::VARIANT_TYPE_DOUBLE)) { + Raul::warn << "TODO: Non-float port value changed." << std::endl; return; - else if (value.type() == Atom::FLOAT) + } + + const Glib::Variant<double>& fvalue = Glib::VariantBase::cast_dynamic + < Glib::Variant<double> >(value); + const float fval = fvalue.get(); + Ingen::Shared::World* const world = _app.world(); + _app.engine()->set_property(model()->path(), + world->uris()->ingen_value, + Atom(fval)); + + PatchWindow* pw = get_patch_window(); + if (pw) { + pw->show_port_status(model().get(), fval); + } +} + +void +Port::value_changed(const Atom& value) +{ + if (!_pressed && value.type() == Atom::FLOAT) { Ganv::Port::set_control_value(value.get_float()); + } } bool @@ -165,12 +186,16 @@ Port::on_event(GdkEvent* ev) } break; case GDK_BUTTON_PRESS: - if (ev->button.button == 1) + if (ev->button.button == 1) { _pressed = true; + } else if (ev->button.button == 3) { + return show_menu(&ev->button); + } break; case GDK_BUTTON_RELEASE: - if (ev->button.button == 1) + if (ev->button.button == 1) { _pressed = false; + } default: break; } @@ -178,14 +203,6 @@ Port::on_event(GdkEvent* ev) return Ganv::Port::on_event(ev); } -bool -Port::on_click(GdkEventButton* ev) -{ - if (ev->button == 3) { - return show_menu(ev); - } - return false; -} /* Peak colour stuff */ @@ -258,30 +275,13 @@ Port::get_patch_window() const } void -Port::set_control(float value, bool signal) -{ - if (signal) { - Ingen::Shared::World* const world = _app.world(); - _app.engine()->set_property(model()->path(), - world->uris()->ingen_value, Atom(value)); - } - - PatchWindow* pw = get_patch_window(); - if (pw) { - pw->show_port_status(model().get(), value); - } - - Ganv::Port::set_control_value(value); -} - -void Port::property_changed(const URI& key, const Atom& value) { const URIs& uris = _app.uris(); if (value.type() == Atom::FLOAT) { float val = value.get_float(); if (key == uris.ingen_value && !_pressed) { - set_control(val, false); + Ganv::Port::set_control_value(val); } else if (key == uris.lv2_minimum) { if (model()->port_property(uris.lv2_sampleRate)) { val *= _app.sample_rate(); diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 465fc783..7eef8c56 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -57,7 +57,6 @@ public: bool show_menu(GdkEventButton* ev); void update_metadata(); - virtual void set_control(float value, bool signal); void value_changed(const Raul::Atom& value); void activity(const Raul::Atom& value); @@ -75,10 +74,10 @@ private: PatchWindow* get_patch_window() const; void property_changed(const Raul::URI& key, const Raul::Atom& value); + void moved(); + void on_value_changed(const Glib::VariantBase& value); bool on_event(GdkEvent* ev); - bool on_click(GdkEventButton* ev); - void moved(); //static ArtVpathDash* _dash; |