From 08a6a9058d114a3208f5304799e2c84576e52f90 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 17 Mar 2011 06:32:50 +0000 Subject: Show plugin/port documentation in side pane when selected. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3103 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/PluginModel.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++ src/client/PluginModel.hpp | 3 +++ src/gui/NodeModule.cpp | 15 ++++++++++++- src/gui/PatchCanvas.cpp | 12 +++++++++++ src/gui/PatchCanvas.hpp | 1 + src/gui/PatchWindow.cpp | 1 + src/gui/PatchWindow.hpp | 4 ++++ src/gui/Port.cpp | 24 +++++++++++++++++++++ src/gui/Port.hpp | 2 ++ src/gui/WindowFactory.cpp | 10 +++++++++ src/gui/WindowFactory.hpp | 1 + src/gui/ingen_gui.glade | 39 ++++++++++++++++++++++++++++------ 12 files changed, 157 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 8e826368..aa8e2e1d 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -243,6 +243,59 @@ PluginModel::get_lv2_icon_path(SLV2Plugin plugin) } #endif +std::string +PluginModel::documentation() const +{ + std::string doc; + #ifdef HAVE_SLV2 + if (!_slv2_plugin) + return doc; + + //SLV2Value lv2_documentation = slv2_value_new_uri( + // _slv2_world, SLV2_NAMESPACE_LV2 "documentation"); + SLV2Value rdfs_comment = slv2_value_new_uri( + _slv2_world, "http://www.w3.org/2000/01/rdf-schema#comment"); + + SLV2Values vals = slv2_plugin_get_value(_slv2_plugin, + rdfs_comment); + SLV2Value val = slv2_values_get_first(vals); + if (slv2_value_is_string(val)) { + doc += slv2_value_as_string(val); + } + slv2_value_free(rdfs_comment); + slv2_values_free(vals); + #endif + return doc; +} + +std::string +PluginModel::port_documentation(uint32_t index) const +{ + std::string doc; + #ifdef HAVE_SLV2 + if (!_slv2_plugin) + return doc; + + SLV2Port port = slv2_plugin_get_port_by_index(_slv2_plugin, index); + + //SLV2Value lv2_documentation = slv2_value_new_uri( + // _slv2_world, SLV2_NAMESPACE_LV2 "documentation"); + SLV2Value rdfs_comment = slv2_value_new_uri( + _slv2_world, "http://www.w3.org/2000/01/rdf-schema#comment"); + + SLV2Values vals = slv2_port_get_value(_slv2_plugin, + port, + rdfs_comment); + SLV2Value val = slv2_values_get_first(vals); + if (slv2_value_is_string(val)) { + doc += slv2_value_as_string(val); + } + slv2_value_free(rdfs_comment); + slv2_values_free(vals); + #endif + return doc; +} + } // namespace Client } // namespace Ingen diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp index 3f647a7c..006c53d9 100644 --- a/src/client/PluginModel.hpp +++ b/src/client/PluginModel.hpp @@ -86,6 +86,9 @@ public: static std::string get_lv2_icon_path(SLV2Plugin plugin); #endif + std::string documentation() const; + std::string port_documentation(uint32_t index) const; + static void set_rdf_world(Sord::World& world) { _rdf_world = &world; } diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index ea4c8079..d7523083 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -439,9 +439,22 @@ NodeModule::property_changed(const URI& key, const Atom& value) void NodeModule::set_selected(bool b) { - const LV2URIMap& uris = App::instance().uris(); + const App& app = App::instance(); + const LV2URIMap& uris = app.uris(); if (b != selected()) { Module::set_selected(b); + if (b) { + PatchWindow* win = app.window_factory()->parent_patch_window(node()); + if (win) { + const std::string& doc = node()->plugin_model()->documentation(); + if (!doc.empty()) { + win->doc_textview()->get_buffer()->set_text(doc); + win->doc_textview()->show(); + } else { + win->doc_textview()->hide(); + } + } + } if (App::instance().signal()) App::instance().engine()->set_property(_node->path(), uris.ingen_selected, b); } diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index beb2da23..d3d8c5c4 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -606,6 +606,18 @@ PatchCanvas::canvas_event(GdkEvent* event) return (ret ? true : Canvas::canvas_event(event)); } +void +PatchCanvas::clear_selection() +{ + const App& app = App::instance(); + PatchWindow* win = app.window_factory()->patch_window(_patch); + if (win) { + win->doc_textview()->hide(); + } + + FlowCanvas::Canvas::clear_selection(); +} + #define FOREACH_ITEM(iter, coll) \ for (list >::iterator (iter) = coll.begin(); \ (iter) != coll.end(); ++(iter)) diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index aa27c9e1..702f90bb 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -77,6 +77,7 @@ public: void get_new_module_location(double& x, double& y); + void clear_selection(); void destroy_selection(); void copy_selection(); void paste(); diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index adbfc933..c64d72b9 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -95,6 +95,7 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("patch_view_messages_window_menuitem", _menu_view_messages_window); xml->get_widget("patch_view_patch_tree_window_menuitem", _menu_view_patch_tree_window); xml->get_widget("patch_help_about_menuitem", _menu_help_about); + xml->get_widget("patch_documentation_textview", _doc_textview); _menu_view_control_window->property_sensitive() = false; string engine_name = App::instance().engine()->uri().str(); diff --git a/src/gui/PatchWindow.hpp b/src/gui/PatchWindow.hpp index aafb9d2c..096343bd 100644 --- a/src/gui/PatchWindow.hpp +++ b/src/gui/PatchWindow.hpp @@ -57,6 +57,8 @@ public: PatchWindow(BaseObjectType* cobject, const Glib::RefPtr& glade_xml); ~PatchWindow(); + Gtk::TextView* doc_textview() { return _doc_textview; } + void set_patch_from_path(const Raul::Path& path, SharedPtr view); void set_patch(SharedPtr pc, SharedPtr view); @@ -151,6 +153,8 @@ private: BreadCrumbs* _breadcrumbs; Gtk::Statusbar* _status_bar; + Gtk::TextView* _doc_textview; + sigc::connection _entered_connection; sigc::connection _left_connection; diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 4102a52c..949e459d 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -253,6 +253,30 @@ Port::dash() return _dash; } +void +Port::set_selected(bool b) +{ + if (b != selected()) { + FlowCanvas::Port::set_selected(b); + SharedPtr pm = _port_model.lock(); + if (pm && b) { + const App& app = App::instance(); + SharedPtr node = PtrCast(pm->parent()); + PatchWindow* win = app.window_factory()->parent_patch_window(node); + if (win) { + const std::string& doc = node->plugin_model()->port_documentation( + pm->index()); + if (!doc.empty()) { + win->doc_textview()->get_buffer()->set_text(doc); + win->doc_textview()->show(); + } else { + win->doc_textview()->hide(); + } + } + } + } +} + } // namespace GUI } // namespace Ingen diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 49409510..ba2f2f99 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -58,6 +58,8 @@ public: void value_changed(const Raul::Atom& value); void activity(); + void set_selected(bool b); + ArtVpathDash* dash(); private: diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp index 99c596dd..6c48d11d 100644 --- a/src/gui/WindowFactory.cpp +++ b/src/gui/WindowFactory.cpp @@ -116,6 +116,16 @@ WindowFactory::patch_window(SharedPtr patch) } +PatchWindow* +WindowFactory::parent_patch_window(SharedPtr node) +{ + if (!node) + return NULL; + + return patch_window(PtrCast(node->parent())); +} + + NodeControlWindow* WindowFactory::control_window(SharedPtr node) { diff --git a/src/gui/WindowFactory.hpp b/src/gui/WindowFactory.hpp index 113cfc3d..a00ffc1e 100644 --- a/src/gui/WindowFactory.hpp +++ b/src/gui/WindowFactory.hpp @@ -62,6 +62,7 @@ public: size_t num_open_patch_windows(); PatchWindow* patch_window(SharedPtr patch); + PatchWindow* parent_patch_window(SharedPtr node); NodeControlWindow* control_window(SharedPtr node); void present_patch(SharedPtr model, diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade index 15e38061..0a38bbb2 100644 --- a/src/gui/ingen_gui.glade +++ b/src/gui/ingen_gui.glade @@ -9,6 +9,7 @@ True + vertical True @@ -335,8 +336,8 @@ - True gtk-fullscreen + True True True @@ -460,19 +461,43 @@ - + True True - automatic - automatic - + True - none + True + automatic + automatic - + + True + queue + none + + + + + + True + False + + + + + True + True + False + word + False + + + False + True + -- cgit v1.2.1