Set tooltips on generic UI controls for LV2 plugin controls with documentation (rdfs...
authorDavid Robillard <d@drobilla.net>
Fri, 20 Apr 2012 01:24:07 +0000 (01:24 +0000)
committerDavid Robillard <d@drobilla.net>
Fri, 20 Apr 2012 01:24:07 +0000 (01:24 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12042 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/generic_pluginui.cc
libs/ardour/ardour/lv2_plugin.h
libs/ardour/ardour/plugin.h
libs/ardour/lv2_plugin.cc

index 3f8d0f63c95c19874c3bea146e866acfbf821f78..6306c051e56f2d2b31e3088f657e584cc2d0c843 100644 (file)
@@ -264,6 +264,11 @@ GenericPluginUI::build ()
                                continue;
                        }
 
+                       const std::string param_docs = plugin->get_parameter_docs(i);
+                       if (param_docs != "") {
+                               ARDOUR_UI::instance()->set_tip(cui, param_docs.c_str());
+                       }
+
                        if (cui->controller || cui->clickbox || cui->combo) {
                                // Get all of the controls into a list, so that
                                // we can lay them out a bit more nicely later.
index 51d88a672de2e1b47d3481a91fbd87b233a80d14..b72b7d605b106288ebf08d036b41a0bf41151cea 100644 (file)
@@ -50,14 +50,15 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        const char* name () const;
        const char* maker () const;
 
-       uint32_t   num_ports () const;
-       uint32_t   parameter_count () const;
-       float      default_value (uint32_t port);
-       framecnt_t signal_latency () const;
-       void       set_parameter (uint32_t port, float val);
-       float      get_parameter (uint32_t port) const;
-       int        get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
-       uint32_t   nth_parameter (uint32_t port, bool& ok) const;
+       uint32_t    num_ports () const;
+       uint32_t    parameter_count () const;
+       float       default_value (uint32_t port);
+       framecnt_t  signal_latency () const;
+       void        set_parameter (uint32_t port, float val);
+       float       get_parameter (uint32_t port) const;
+       std::string get_parameter_docs(uint32_t which) const;
+       int         get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
+       uint32_t    nth_parameter (uint32_t port, bool& ok) const;
 
        const void* extension_data (const char* uri) const;
 
index d73fef2f53301482db6d634783f15f2a62ced218..bade84341bc81d2a9ff87ba1cdc728242b1d79f2 100644 (file)
@@ -118,6 +118,7 @@ class Plugin : public PBD::StatefulDestructible, public Latent
        virtual uint32_t parameter_count () const = 0;
        virtual float default_value (uint32_t port) = 0;
        virtual float get_parameter(uint32_t which) const = 0;
+       virtual std::string get_parameter_docs(uint32_t which) const { return ""; }
 
        virtual int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const = 0;
        virtual uint32_t nth_parameter (uint32_t which, bool& ok) const = 0;
index dc312a099bfad68ec619340b87931d21fdd4b837..bd628e46bdc0551841f88fa739229f355385c70c 100644 (file)
@@ -108,6 +108,7 @@ public:
        LilvNode* lv2_sampleRate;
        LilvNode* lv2_toggled;
        LilvNode* midi_MidiEvent;
+       LilvNode* rdfs_comment;
        LilvNode* ui_GtkUI;
        LilvNode* ui_external;
 };
@@ -583,6 +584,23 @@ LV2Plugin::get_parameter(uint32_t which) const
        return 0.0f;
 }
 
+std::string
+LV2Plugin::get_parameter_docs(uint32_t which) const
+{
+       LilvNodes* comments = lilv_port_get_value(
+               _impl->plugin,
+               lilv_plugin_get_port_by_index(_impl->plugin, which),
+               _world.rdfs_comment);
+
+       if (comments) {
+               const std::string docs(lilv_node_as_string(lilv_nodes_get_first(comments)));
+               lilv_nodes_free(comments);
+               return docs;
+       }
+
+       return "";
+}
+
 uint32_t
 LV2Plugin::nth_parameter(uint32_t n, bool& ok) const
 {
@@ -1466,6 +1484,7 @@ LV2World::LV2World()
        lv2_toggled        = lilv_new_uri(world, LILV_NS_LV2 "toggled");
        lv2_enumeration    = lilv_new_uri(world, LILV_NS_LV2 "enumeration");
        midi_MidiEvent     = lilv_new_uri(world, LILV_URI_MIDI_EVENT);
+       rdfs_comment       = lilv_new_uri(world, LILV_NS_RDFS "comment");
        ui_GtkUI           = lilv_new_uri(world, NS_UI "GtkUI");
        ui_external        = lilv_new_uri(world, NS_UI "external");
 }