From cc2c6e8064521af8cc0a71b2643b31add09dfbdd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 29 Jun 2013 01:23:29 +0200 Subject: [PATCH] add peak-hold button (independent from mixer) --- gtk2_ardour/meter_strip.cc | 81 +++++++++++++++++++++++++++++--------- gtk2_ardour/meter_strip.h | 12 ++++++ 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/gtk2_ardour/meter_strip.cc b/gtk2_ardour/meter_strip.cc index db07e0511c..329bbf5bda 100644 --- a/gtk2_ardour/meter_strip.cc +++ b/gtk2_ardour/meter_strip.cc @@ -67,7 +67,7 @@ MeterStrip::MeterStrip (Meterbridge& mtr, Session* sess, boost::shared_ptrset_meter (_route->shared_peak_meter().get()); level_meter->clear_meters(); @@ -82,38 +82,41 @@ MeterStrip::MeterStrip (Meterbridge& mtr, Session* sess, boost::shared_ptrname().c_str()); label.set_name("MeterbridgeLabel"); -#if 0 - label.set_ellipsize(Pango::ELLIPSIZE_MIDDLE); - label.set_max_width_chars(7); - label.set_width_chars(7); - label.set_alignment(0.5, 0.5); -#else //ellipsize & angle are incompatible :( label.set_angle(90.0); label.set_alignment(0.5, 0.0); -#endif label.set_size_request(12, 36); - Gtk::HBox* btnbox = Gtk::manage (new Gtk::HBox()); - btnbox->pack_start(*rec_enable_button, true, false); - btnbox->set_size_request(-1, 16); + // rec-enable button + btnbox.pack_start(*rec_enable_button, true, false); + btnbox.set_size_request(-1, 16); + pack_start (peakbx, false, false); pack_start (meterbox, true, true); - pack_start (*btnbox, false, false); + pack_start (btnbox, false, false); pack_start (label, false, false); + peak_display.show(); + peakbx.show(); meter_ticks1_area.hide(); meter_ticks2_area.show(); meter_metric_area.show(); meterbox.show(); level_meter->show(); meter_align->show(); - btnbox->show(); + btnbox.show(); label.show(); _route->shared_peak_meter()->ConfigurationChanged.connect ( @@ -133,6 +136,8 @@ MeterStrip::MeterStrip (Meterbridge& mtr, Session* sess, boost::shared_ptrDropReferences.connect (route_connections, invalidator (*this), boost::bind (&MeterStrip::self_delete, this), gui_context()); _route->PropertyChanged.connect (route_connections, invalidator (*this), boost::bind (&MeterStrip::strip_property_changed, this, _1), gui_context()); + peak_display.signal_button_release_event().connect (sigc::mem_fun(*this, &MeterStrip::peak_button_release), false); + UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &MeterStrip::on_theme_changed)); } @@ -179,8 +184,21 @@ MeterStrip::strip_property_changed (const PropertyChange& what_changed) void MeterStrip::fast_update () { - const float mpeak = level_meter->update_meters(); - // TODO peak indicator if mpeak > 0 + char buf[32]; + float mpeak = level_meter->update_meters(); + if (mpeak > max_peak) { + max_peak = mpeak; + if (mpeak <= -200.0f) { + peak_display.set_label (_("-inf")); + } else { + snprintf (buf, sizeof(buf), "%.1f", mpeak); + peak_display.set_label (buf); + } + + if (mpeak >= 0.0f) { + peak_display.set_name ("MixerStripPeakDisplayPeak"); + } + } } void @@ -637,3 +655,28 @@ MeterStrip::meter_ticks_expose (GdkEventExpose *ev, Gtk::DrawingArea *mta) return true; } + +void +MeterStrip::reset_group_peak_display (RouteGroup* group) +{ + if (_route && group == _route->route_group()) { + reset_peak_display (); + } +} + +void +MeterStrip::reset_peak_display () +{ + _route->shared_peak_meter()->reset_max(); + level_meter->clear_meters(); + max_peak = -INFINITY; + peak_display.set_label (_("-inf")); + peak_display.set_name ("MixerStripPeakDisplay"); +} + +bool +MeterStrip::peak_button_release (GdkEventButton* ev) +{ + reset_peak_display (); + return true; +} diff --git a/gtk2_ardour/meter_strip.h b/gtk2_ardour/meter_strip.h index 0d9dcaa0aa..c27c7346af 100644 --- a/gtk2_ardour/meter_strip.h +++ b/gtk2_ardour/meter_strip.h @@ -80,6 +80,8 @@ class MeterStrip : public Gtk::VBox, public RouteUI void on_size_allocate (Gtk::Allocation&); void on_size_request (Gtk::Requisition*); + bool peak_button_release (GdkEventButton*); + /* route UI */ void update_rec_display (); std::string state_id() const; @@ -91,11 +93,21 @@ class MeterStrip : public Gtk::VBox, public RouteUI Gtk::DrawingArea meter_metric_area; Gtk::DrawingArea meter_ticks1_area; Gtk::DrawingArea meter_ticks2_area; + + Gtk::Alignment meter_align; + Gtk::HBox peakbx; + Gtk::HBox btnbox; + Gtk::Button peak_display; + std::vector _types; + float max_peak; LevelMeter *level_meter; void meter_changed (); + void reset_peak_display (); + void reset_group_peak_display (ARDOUR::RouteGroup*); + PBD::ScopedConnection _config_connection; void strip_property_changed (const PBD::PropertyChange&); void meter_configuration_changed (ARDOUR::ChanCount);