From 971ba0227ab563bf264cf19c967679796209708d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 8 Dec 2011 02:36:32 +0000 Subject: Clean up port event stuff. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3836 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/PatchWindow.hpp | 5 +++-- src/gui/Port.cpp | 36 +++++++++++++++++++++++++++++------- src/gui/Port.hpp | 3 +++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/gui/PatchWindow.hpp b/src/gui/PatchWindow.hpp index b3f7ad55..fcb0e3f7 100644 --- a/src/gui/PatchWindow.hpp +++ b/src/gui/PatchWindow.hpp @@ -70,6 +70,9 @@ public: void show_port_status(const PortModel* model, const Raul::Atom& value); + void object_entered(const ObjectModel* model); + void object_left(const ObjectModel* model); + protected: void on_show(); void on_hide(); @@ -79,8 +82,6 @@ private: void patch_port_added(SharedPtr port); void patch_port_removed(SharedPtr port); void show_status(const ObjectModel* model); - void object_entered(const ObjectModel* model); - void object_left(const ObjectModel* model); void editable_changed(bool editable); void event_import(); diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 950a1df9..eafc6392 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -150,7 +150,20 @@ Port::value_changed(const Atom& value) bool Port::on_event(GdkEvent* ev) { + PatchWindow* win = NULL; switch (ev->type) { + case GDK_ENTER_NOTIFY: + win = get_patch_window(); + if (win) { + win->object_entered(model().get()); + } + break; + case GDK_LEAVE_NOTIFY: + win = get_patch_window(); + if (win) { + win->object_left(model().get()); + } + break; case GDK_BUTTON_PRESS: if (ev->button.button == 1) _pressed = true; @@ -233,6 +246,17 @@ Port::activity(const Raul::Atom& value) } } +PatchWindow* +Port::get_patch_window() const +{ + SharedPtr patch = PtrCast(model()->parent()); + if (!patch) { + patch = PtrCast(model()->parent()->parent()); + } + + return _app.window_factory()->patch_window(patch); +} + void Port::set_control(float value, bool signal) { @@ -240,13 +264,11 @@ Port::set_control(float value, bool signal) Ingen::Shared::World* const world = _app.world(); _app.engine()->set_property(model()->path(), world->uris()->ingen_value, Atom(value)); - PatchWindow* pw = _app.window_factory()->patch_window( - PtrCast(model()->parent())); - if (!pw) - pw = _app.window_factory()->patch_window( - PtrCast(model()->parent()->parent())); - if (pw) - pw->show_port_status(model().get(), value); + } + + PatchWindow* pw = get_patch_window(); + if (pw) { + pw->show_port_status(model().get(), value); } Ganv::Port::set_control_value(value); diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 3cea7bc5..465fc783 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -34,6 +34,7 @@ using Ingen::Client::PortModel; namespace GUI { class App; +class PatchWindow; /** A Port on an Module. * @@ -71,6 +72,8 @@ private: const std::string& name, bool flip = false); + PatchWindow* get_patch_window() const; + void property_changed(const Raul::URI& key, const Raul::Atom& value); bool on_event(GdkEvent* ev); -- cgit v1.2.1