clean up that godawful ugly latency GUI in plugin UIs
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 4 May 2009 17:49:28 +0000 (17:49 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 4 May 2009 17:49:28 +0000 (17:49 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5038 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/generic_pluginui.cc
gtk2_ardour/latency_gui.cc
gtk2_ardour/plugin_ui.cc
gtk2_ardour/plugin_ui.h
libs/ardour/ardour/latent.h
libs/ardour/lv2_plugin.cc
libs/ardour/plugin_manager.cc

index 5d6dd172d995953006ee235978b54fdcf2525e7e..713fcfcc8779573c2be567ac6dae826c25c0dc34 100644 (file)
@@ -82,11 +82,11 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrol
        Label* combo_label = manage (new Label (_("<span size=\"large\">Presets</span>")));
        combo_label->set_use_markup (true);
 
-       Label* latency_label = manage (new Label (_("<span size=\"large\">Latency</span>")));
-       latency_label->set_use_markup (true);
-
-       smaller_hbox->pack_start (*latency_label, false, false, 10);
-       smaller_hbox->pack_start (latency_gui, false, false, 10);
+       latency_button.add (latency_label);
+       latency_button.signal_clicked().connect (mem_fun (*this, &PlugUIBase::latency_button_clicked));
+       set_latency_label ();
+       
+       smaller_hbox->pack_start (latency_button, false, false, 10);
        smaller_hbox->pack_start (preset_combo, false, false);
        smaller_hbox->pack_start (save_button, false, false);
        smaller_hbox->pack_start (bypass_button, false, true);
index 5ca139cd403a176b9ca55b2195f23cbd83e00bb9..1f3ae38da49e9b65aa2c63674bc67f2fd4456d2a 100644 (file)
@@ -45,7 +45,7 @@ LatencyGUI::LatencyGUI (Latent& l, nframes64_t sr, nframes64_t psz)
          /* max 1 second, step by frames, page by msecs */
          adjustment (initial_value, 0.0, sample_rate, 1.0, sample_rate / 1000.0f),
          bc (adjustment, ignored, sigc::mem_fun (*this, &LatencyGUI::latency_printer)),
-         reset_button (_("Automatic"))
+         reset_button (_("Reset"))
 {
        Widget* w;
 
index 38de2bae04a7538ac3a061f79b35eec19b795585..21f0a938d6c8c7182f2b81bf71e65320718f0cf7 100644 (file)
@@ -50,6 +50,7 @@
 
 #include <lrdf.h>
 
+#include "ardour_dialog.h"
 #include "ardour_ui.h"
 #include "prompter.h"
 #include "plugin_ui.h"
@@ -57,6 +58,7 @@
 #include "gui_thread.h"
 #include "public_editor.h"
 #include "keyboard.h"
+#include "latency_gui.h"
 #include "plugin_eq_gui.h"
 
 #include "i18n.h"
@@ -345,7 +347,7 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
          plugin (insert->plugin()),
          save_button(_("Add")),
          bypass_button (_("Bypass")),
-         latency_gui (*pi, pi->session().frame_rate(), pi->session().get_block_size()),
+         latency_gui (0),
          eqgui_toggle (_("Freq Analysis"))
 {
        //preset_combo.set_use_arrows_always(true);
@@ -389,6 +391,36 @@ PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi)
 
 PlugUIBase::~PlugUIBase()
 {
+       delete latency_gui;
+}
+
+void
+PlugUIBase::set_latency_label ()
+{
+       char buf[64];
+       nframes_t l = insert->effective_latency ();
+       nframes_t sr = insert->session().frame_rate();
+
+       if (l < sr / 1000) {
+               snprintf (buf, sizeof (buf), "latency (%d samples)", l);
+       } else {
+               snprintf (buf, sizeof (buf), "latency (%.2f msecs)", (float) l / ((float) sr / 1000.0f));
+       }
+
+       latency_label.set_text (buf);
+}
+
+void
+PlugUIBase::latency_button_clicked ()
+{
+       if (!latency_gui) {
+               latency_gui = new LatencyGUI (*(insert.get()), insert->session().frame_rate(), insert->session().get_block_size());
+               latency_dialog = new ArdourDialog ("Edit Latency", false, false);
+               latency_dialog->get_vbox()->pack_start (*latency_gui);
+               latency_dialog->signal_hide().connect (mem_fun (*this, &PlugUIBase::set_latency_label));
+       }
+
+       latency_dialog->show_all ();
 }
 
 void
index e074a9f7b08102c3d4c7423a1f2bd5a362fdc1df..e65abbac59d33a8741988d6d1c441aa943f426c1 100644 (file)
@@ -43,8 +43,6 @@
 
 #include "ardour/types.h"
 
-#include "ardour_dialog.h"
-#include "latency_gui.h"
 #include "automation_controller.h"
 
 namespace ARDOUR {
@@ -67,6 +65,9 @@ namespace Gtkmm2ext {
        class PixmapButton;
 }
 
+class LatencyGUI;
+class ArdourDialog;
+
 class PlugUIBase : public virtual sigc::trackable
 {
   public:
@@ -83,6 +84,8 @@ class PlugUIBase : public virtual sigc::trackable
 
        virtual void update_presets ();
 
+       void latency_button_clicked ();
+
   protected:
        boost::shared_ptr<ARDOUR::PluginInsert> insert;
        boost::shared_ptr<ARDOUR::Plugin> plugin;
@@ -91,7 +94,12 @@ class PlugUIBase : public virtual sigc::trackable
        Gtk::ToggleButton bypass_button;
        Gtk::EventBox focus_button;
 
-       LatencyGUI latency_gui;
+       Gtk::Label latency_label;
+       Gtk::Button latency_button;
+       void set_latency_label ();
+
+       LatencyGUI* latency_gui;
+       ArdourDialog* latency_dialog;
 
        Gtk::Expander plugin_eq_bin;
        Gtk::ToggleButton eqgui_toggle;
index 53a6882a3cfe155f616357ed8db0797c5fa3afc5..c5dc792f0639b90669be6a670121da2c0aee3067 100644 (file)
@@ -13,6 +13,14 @@ class Latent {
        virtual nframes_t signal_latency() const = 0;
        nframes_t user_latency () const { return _user_latency; }
 
+       nframes_t effective_latency() const { 
+               if (_user_latency) { 
+                       return _user_latency;
+               } else {
+                       return signal_latency ();
+               }
+       }
+
        virtual void set_latency_delay (nframes_t val) { _own_latency = val; }
        virtual void set_user_latency (nframes_t val) { _user_latency = val; }
 
index e7617671a02a9d2481804369cbdeeb8a6f31eb66..5b4696b48c88cdf205d02b318db8e0249790053e 100644 (file)
@@ -683,6 +683,8 @@ LV2PluginInfo::discover (void* lv2_world)
        LV2World* world = (LV2World*)lv2_world;
        SLV2Plugins plugins = slv2_world_get_all_plugins(world->world);
 
+       cerr << "Discovered " << slv2_plugins_size (plugins) << " Lv2 plugins\n";
+
        for (unsigned i=0; i < slv2_plugins_size(plugins); ++i) {
                SLV2Plugin p = slv2_plugins_get_at(plugins, i);
                LV2PluginInfoPtr info (new LV2PluginInfo(lv2_world, p));
index c0c854180f85dc3ecf6b4aa904794bb1847775df..ce7a94a517249cfb0fffe47579e50aeb1a4fa942 100644 (file)
@@ -127,6 +127,7 @@ PluginManager::PluginManager ()
        } 
 
 #ifdef HAVE_SLV2
+       cerr << "Creating a new lv2 world\n";
        _lv2_world = new LV2World();
 #endif