Plugin Analysis: show numeric values on mouse over
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Sat, 23 Jul 2016 19:10:44 +0000 (21:10 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Sun, 24 Jul 2016 22:31:47 +0000 (00:31 +0200)
For people who need more precise frequency or response amplitude, show
the values corresponding to the point under the mouse.

gtk2_ardour/clearlooks.rc.in
gtk2_ardour/plugin_eq_gui.cc
gtk2_ardour/plugin_eq_gui.h

index a8eed741799363b99bbdfc57e2787e7c4a60bc10..4e598d5a5727e3b8d91b2dc10a7b64cd5475c3a9 100644 (file)
@@ -1180,6 +1180,7 @@ widget "*PluginSaveButton" style:highest "small_button"
 widget "*PluginSaveButton*" style:highest "small_button"
 widget "*PluginEditorButton*" style:highest "default_toggle_button"
 widget "*PluginEditorButton-active" style:highest "default_toggle_button_active"
+widget "*PluginAnalysisInfoLabel" style:highest "medium_monospace_text"
 
 widget "*BarControlSpinner" style:highest "small_spinner"
 widget "*BarControlSpinner*" style:highest "small_spinner"
index 104b9a09f86896e99b9b2c593a7df0815dd4539c..c33e6b96bbd6c1b62c741da371a690a12ce44d8f 100644 (file)
 
 */
 
+#include <algorithm>
 #include <math.h>
+#include <iomanip>
 #include <iostream>
+#include <sstream>
 
 #ifdef COMPILER_MSVC
 #include <float.h>
@@ -75,8 +78,13 @@ PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
        _analysis_height = 256.0;
        _analysis_area->set_size_request(_analysis_width, _analysis_height);
 
+       _analysis_area->add_events(Gdk::POINTER_MOTION_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK);
+
        _analysis_area->signal_expose_event().connect( sigc::mem_fun (*this, &PluginEqGui::expose_analysis_area));
        _analysis_area->signal_size_allocate().connect( sigc::mem_fun (*this, &PluginEqGui::resize_analysis_area));
+       _analysis_area->signal_motion_notify_event().connect( sigc::mem_fun (*this, &PluginEqGui::analysis_area_mouseover));
+       _analysis_area->signal_leave_notify_event().connect( sigc::mem_fun (*this, &PluginEqGui::analysis_area_mouseexit));
+       _analysis_area->signal_button_press_event().connect( sigc::mem_fun (*this, &PluginEqGui::analysis_area_mousedown));
 
        // dB selection
        dBScaleModel = Gtk::ListStore::create(dBColumns);
@@ -117,10 +125,16 @@ PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
        _phase_button->set_active(true);
        _phase_button->signal_toggled().connect( sigc::mem_fun(*this, &PluginEqGui::redraw_scales));
 
+       // Freq/dB info for mouse over
+       _pointer_info = new Gtk::Label ("", 1, 0.5);
+       _pointer_info->set_size_request(_analysis_width / 4, -1);
+       _pointer_info->set_name("PluginAnalysisInfoLabel");
+
        // populate table
-       attach( *manage(_analysis_area), 1, 3, 1, 2);
+       attach( *manage(_analysis_area), 1, 4, 1, 2);
        attach( *manage(dBSelectBin),    1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
-       attach( *manage(_phase_button),  2, 3, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
+       attach( *manage(_phase_button),  2, 3, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
+       attach( *manage(_pointer_info),  3, 4, 2, 3, Gtk::FILL, Gtk::SHRINK);
 }
 
 PluginEqGui::~PluginEqGui()
@@ -287,6 +301,8 @@ PluginEqGui::resize_analysis_area (Gtk::Allocation& size)
                cairo_surface_destroy (_analysis_scale_surface);
                _analysis_scale_surface = 0;
        }
+
+       _pointer_info->set_size_request(_analysis_width / 4, -1);
 }
 
 bool
@@ -426,6 +442,47 @@ PluginEqGui::run_impulse_analysis()
        ARDOUR_UI::instance()->drop_process_buffers ();
 }
 
+void
+PluginEqGui::update_pointer_info(float x, float y)
+{
+       const int freq = std::max(1, (int) roundf((powf(10, x / _analysis_width * _log_max) - 1) * _samplerate / 2.0 / _log_coeff));
+       const float dB = _max_dB - y / _analysis_height * ( _max_dB - _min_dB );
+       std::stringstream ss;
+       ss << std::fixed;
+       if (freq >= 10000) {
+               ss <<  std::setprecision (1) << freq / 1000 << "kHz";
+       } else if (freq >= 1000) {
+               ss <<  std::setprecision (2) << freq / 1000 << "kHz";
+       } else {
+               ss <<  std::setprecision (0) << freq << "Hz";
+       }
+       ss << "  " << std::setw(5) << std::setprecision (1) << std::showpos << dB;
+       ss << std::setw(0) << "dB";
+       _pointer_info->set_text(ss.str());
+}
+
+bool
+PluginEqGui::analysis_area_mouseover(GdkEventMotion *event)
+{
+       update_pointer_info(event->x, event->y);
+       return true;
+}
+
+bool
+PluginEqGui::analysis_area_mouseexit(GdkEventCrossing *)
+{
+       _pointer_info->set_text("");
+       return true;
+}
+
+bool
+PluginEqGui::analysis_area_mousedown(GdkEventButton *event)
+{
+       update_pointer_info(event->x, event->y);
+       return true;
+}
+
+
 bool
 PluginEqGui::expose_analysis_area(GdkEventExpose *)
 {
index 5743152b15bd908398de8ec43f67c7845c3be455..384359b4395fabdee1bd5cbbe5809fe2af1b927f 100644 (file)
@@ -79,6 +79,11 @@ private:
 
        void plot_signal_amplitude_difference (Gtk::Widget *,cairo_t *);
 
+       void update_pointer_info(float, float);
+       bool analysis_area_mouseover(GdkEventMotion *);
+       bool analysis_area_mouseexit(GdkEventCrossing *);
+       bool analysis_area_mousedown(GdkEventButton *);
+
        // Helpers
        bool timeout_callback ();
        void redraw_scales ();
@@ -117,6 +122,7 @@ private:
        // gui objects
        Gtk::DrawingArea *_analysis_area;
        cairo_surface_t *_analysis_scale_surface;
+       Gtk::Label *_pointer_info;
 
        // dB scale selection:
        class dBSelectionColumns : public Gtk::TreeModel::ColumnRecord