From a5caa2778bf4facd4d9ffd6379136d17e5568011 Mon Sep 17 00:00:00 2001 From: VKamyshniy Date: Sat, 19 Jul 2014 18:32:45 +0300 Subject: [PATCH] [Summary] Progressing TRACKS Meter Bridge (invented name = compact meter bridge) --- gtk2_ardour/compact_meter_bridge.cc | 188 ++++++++++++++++++ gtk2_ardour/compact_meter_bridge.h | 70 +++++++ gtk2_ardour/compact_meter_strip.cc | 88 ++++++++ gtk2_ardour/compact_meter_strip.h | 54 +++++ gtk2_ardour/editor.cc | 5 +- gtk2_ardour/editor.h | 7 +- gtk2_ardour/editor_mixer.cc | 2 +- .../icons/meter_bridge_level_scale.png | Bin 0 -> 2439 bytes gtk2_ardour/meterbridge.cc | 1 - gtk2_ardour/ui/compact_meter_bridge.xml | 13 ++ gtk2_ardour/ui/compact_meter_strip.xml | 7 + gtk2_ardour/ui/editor_window.xml | 9 +- gtk2_ardour/ui/mixer_gain_meter.xml | 14 +- gtk2_ardour/wscript | 2 + 14 files changed, 446 insertions(+), 14 deletions(-) create mode 100644 gtk2_ardour/compact_meter_bridge.cc create mode 100644 gtk2_ardour/compact_meter_bridge.h create mode 100644 gtk2_ardour/compact_meter_strip.cc create mode 100644 gtk2_ardour/compact_meter_strip.h create mode 100644 gtk2_ardour/icons/meter_bridge_level_scale.png create mode 100644 gtk2_ardour/ui/compact_meter_bridge.xml create mode 100644 gtk2_ardour/ui/compact_meter_strip.xml diff --git a/gtk2_ardour/compact_meter_bridge.cc b/gtk2_ardour/compact_meter_bridge.cc new file mode 100644 index 0000000000..6122c7a9a5 --- /dev/null +++ b/gtk2_ardour/compact_meter_bridge.cc @@ -0,0 +1,188 @@ +/* + Copyright (C) 2014 Waves Audio Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifdef WAF_BUILD +#include "gtk2ardour-config.h" +#endif + +#include +#include + +#include + +#include + +#include +#include +#include + +#include "ardour/debug.h" +#include "ardour/midi_track.h" +#include "ardour/route_group.h" +#include "ardour/session.h" + +#include "ardour/audio_track.h" +#include "ardour/midi_track.h" + +#include "compact_meter_bridge.h" + +#include "keyboard.h" +#include "monitor_section.h" +#include "public_editor.h" +#include "ardour_ui.h" +#include "utils.h" +#include "route_sorter.h" +#include "actions.h" +#include "gui_thread.h" +#include "global_signals.h" +#include "meter_patterns.h" + +#include "i18n.h" + +using namespace ARDOUR; +using namespace PBD; +using namespace Gtk; +using namespace Glib; +using namespace Gtkmm2ext; +using namespace std; +using namespace ArdourMeter; + +using PBD::atoi; + +struct SignalOrderRouteSorter { + bool operator() (boost::shared_ptr a, boost::shared_ptr b) { + if (a->is_master() || a->is_monitor()) { + /* "a" is a special route (master, monitor, etc), and comes + * last in the mixer ordering + */ + return false; + } else if (b->is_master() || b->is_monitor()) { + /* everything comes before b */ + return true; + } + return a->order_key () < b->order_key (); + } +}; + +CompactMeterbridge::CompactMeterbridge () + : Gtk::EventBox() + , WavesUI ("compact_meter_bridge.xml", *this) + , _compact_meter_strips_home (get_box ("compact_meter_strips_home")) +{ + set_attributes (*this, *xml_tree ()->root (), XMLNodeMap ()); + signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler)); + CompactMeterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&CompactMeterbridge::remove_strip, this, _1), gui_context()); +} + +CompactMeterbridge::~CompactMeterbridge () +{ +} + +void +CompactMeterbridge::set_session (Session* s) +{ + SessionHandlePtr::set_session (s); + + if (!_session) { + return; + } + + SignalOrderRouteSorter sorter; + boost::shared_ptr routes = _session->get_routes(); + + RouteList copy(*routes); + copy.sort(sorter); + add_strips(copy); + + _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&CompactMeterbridge::add_strips, this, _1), gui_context()); + + start_updating (); +} + +void +CompactMeterbridge::session_going_away () +{ + ENSURE_GUI_THREAD (*this, &CompactMeterbridge::session_going_away); + + for (list::iterator i = _strips.begin(); i != _strips.end(); ++i) { + delete *i; + } + + _strips.clear (); + stop_updating (); + + SessionHandlePtr::session_going_away (); + _session = 0; +} + +gint +CompactMeterbridge::start_updating () +{ + fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &CompactMeterbridge::fast_update_strips)); + return 0; +} + +gint +CompactMeterbridge::stop_updating () +{ + fast_screen_update_connection.disconnect(); + return 0; +} + +void +CompactMeterbridge::fast_update_strips () +{ + if (!is_mapped () || !_session) { + return; + } + for (list::iterator i = _strips.begin(); i != _strips.end(); ++i) { + (*i)->fast_update (); + } +} + +void +CompactMeterbridge::add_strips (RouteList& routes) +{ + for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) { + boost::shared_ptr route = (*x); + if (route->is_auditioner() || route->is_monitor() || route->is_master()) { + continue; + } + + CompactMeterStrip* strip = new CompactMeterStrip (_session, route); + _strips.push_back (strip); + strip->show(); + _compact_meter_strips_home.pack_start (*strip, false, false); + } +} + +void +CompactMeterbridge::remove_strip (CompactMeterStrip* strip) +{ + if (_session && _session->deletion_in_progress()) { + return; + } + + for (list::iterator i = _strips.begin(); i != _strips.end(); ++i) { + if ( (*i) == strip) { + _strips.erase (i); + break; + } + } +} diff --git a/gtk2_ardour/compact_meter_bridge.h b/gtk2_ardour/compact_meter_bridge.h new file mode 100644 index 0000000000..be10b61789 --- /dev/null +++ b/gtk2_ardour/compact_meter_bridge.h @@ -0,0 +1,70 @@ +/* + Copyright (C) 2014 Waves Audio Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ +#ifndef __ardour_compact_meter_bridge_h__ +#define __ardour_compact_meter_bridge_h__ + +#include + +#include +#include +#include +#include + +#include "ardour/ardour.h" +#include "ardour/types.h" +#include "ardour/session_handle.h" + +#include "pbd/stateful.h" +#include "pbd/signals.h" + +#include "gtkmm2ext/visibility_tracker.h" + +#include "waves_ui.h" +#include "compact_meter_strip.h" + +class CompactMeterbridge : + public Gtk::EventBox, + public WavesUI, + public PBD::ScopedConnectionList, + public ARDOUR::SessionHandlePtr +{ + public: + CompactMeterbridge (); + ~CompactMeterbridge(); + void set_session (ARDOUR::Session *); + + private: + + Gtk::Box& _compact_meter_strips_home; + + gint start_updating (); + gint stop_updating (); + + sigc::connection fast_screen_update_connection; + void fast_update_strips (); + + void add_strips (ARDOUR::RouteList&); + void remove_strip (CompactMeterStrip *); + + void session_going_away (); + + std::list _strips; +}; + +#endif //__ardour_compact_meter_bridge_h__ diff --git a/gtk2_ardour/compact_meter_strip.cc b/gtk2_ardour/compact_meter_strip.cc new file mode 100644 index 0000000000..115a44399f --- /dev/null +++ b/gtk2_ardour/compact_meter_strip.cc @@ -0,0 +1,88 @@ +/* + Copyright (C) 2014 Waves Audio Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "ardour/meter.h" +#include "ardour_ui.h" +#include "gui_thread.h" +#include "meter_patterns.h" +#include "compact_meter_strip.h" + +#include "dbg_msg.h" + +using namespace ARDOUR; +using namespace PBD; +using namespace Gtk; +using namespace Gtkmm2ext; +using namespace std; +using namespace ArdourMeter; + +PBD::Signal1 CompactMeterStrip::CatchDeletion; +int CompactMeterStrip::__meter_width = 4; + +CompactMeterStrip::CompactMeterStrip (Session* sess, boost::shared_ptr rt) + : EventBox() + , WavesUI ("compact_meter_strip.xml", *this) + , _route(rt) + , level_meter_home (get_box ("level_meter_home")) + , level_meter (sess) +{ + set_attributes (*this, *xml_tree ()->root (), XMLNodeMap ()); + + level_meter.set_meter (_route->shared_peak_meter().get()); + level_meter.clear_meters(); + level_meter.set_type (_route->meter_type()); + level_meter.setup_meters (__meter_width, __meter_width); + level_meter_home.add (level_meter); + + _route->shared_peak_meter()->ConfigurationChanged.connect ( + route_connections, invalidator (*this), boost::bind (&CompactMeterStrip::meter_configuration_changed, this, _1), gui_context() + ); + + meter_configuration_changed (_route->shared_peak_meter()->input_streams ()); + + _route->DropReferences.connect (route_connections, invalidator (*this), boost::bind (&CompactMeterStrip::self_delete, this), gui_context()); +} + +CompactMeterStrip::~CompactMeterStrip () +{ + CatchDeletion (this); +} + +void +CompactMeterStrip::self_delete () +{ + delete this; +} + +void +CompactMeterStrip::update_rec_display () +{ +} + +void +CompactMeterStrip::fast_update () +{ + level_meter.update_meters(); +} + +void +CompactMeterStrip::meter_configuration_changed (ChanCount c) +{ + level_meter.setup_meters (__meter_width, __meter_width); +} + diff --git a/gtk2_ardour/compact_meter_strip.h b/gtk2_ardour/compact_meter_strip.h new file mode 100644 index 0000000000..986180345f --- /dev/null +++ b/gtk2_ardour/compact_meter_strip.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2014 Waves Audio Ltd. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __tracks_compact_meter_strip__ +#define __tracks_compact_meter_strip__ + +#include "waves_ui.h" +#include "level_meter.h" + +namespace ARDOUR { + class Route; + class Session; +} + +class CompactMeterStrip :public Gtk::EventBox, public WavesUI +{ + public: + CompactMeterStrip (ARDOUR::Session*, boost::shared_ptr); + ~CompactMeterStrip (); + + void fast_update (); + boost::shared_ptr route() { return _route; } + static PBD::Signal1 CatchDeletion; + + + protected: + boost::shared_ptr _route; + void self_delete (); + + private: + Gtk::Box& level_meter_home; + LevelMeterHBox level_meter; + PBD::ScopedConnectionList route_connections; + static int __meter_width; + void meter_configuration_changed (ARDOUR::ChanCount); + void update_rec_display (); +}; + +#endif /* __tracks_compact_meter_strip__ */ diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 2f701c907b..56161e9dd3 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -251,7 +251,8 @@ Editor::Editor () , global_hpacker (get_h_box ("global_hpacker")) , global_vpacker (get_v_box ("global_vpacker")) , inspector_home (get_container ("inspector_home")) - , master_bus_ui_home (get_container ("master_bus_ui_home")) + , _master_bus_ui_home (get_container ("master_bus_ui_home")) + , _compact_meter_bridge_home (get_container ("compact_meter_bridge_home")) , vpacker (get_v_box ("vpacker")) , _tool_marker_button (get_waves_button ("tool_marker_button")) , _tool_zoom_button (get_waves_button ("tool_zoom_button")) @@ -308,6 +309,7 @@ Editor::Editor () /* we are a singleton */ PublicEditor::_instance = this; + _compact_meter_bridge_home.add (_compact_meter_bridge); _have_idled = false; @@ -1301,6 +1303,7 @@ Editor::set_session (Session *t) _snapshots->set_session (_session); _routes->set_session (_session); _locations->set_session (_session); + _compact_meter_bridge.set_session (_session); if (rhythm_ferret) { rhythm_ferret->set_session (_session); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index cd4171abf6..74c2931c93 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -56,6 +56,7 @@ #include "enums.h" #include "editor_items.h" #include "region_selection.h" +#include "compact_meter_bridge.h" namespace Gtkmm2ext { class TearOff; @@ -689,9 +690,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD Gtk::HBox& global_hpacker; Gtk::VBox& global_vpacker; Gtk::Container& inspector_home; - Gtk::Container& master_bus_ui_home; - Gtk::VBox& vpacker; + Gtk::Container& _master_bus_ui_home; + Gtk::Container& _compact_meter_bridge_home; MasterBusUI* _master_bus_ui; + Gtk::VBox& vpacker; Gdk::Cursor* current_canvas_cursor; Gdk::Cursor* which_grabber_cursor (); @@ -1905,6 +1907,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD /* editor-mixer strip */ MixerStrip *current_mixer_strip; + CompactMeterbridge _compact_meter_bridge; bool show_editor_mixer_when_tracks_arrive; void cms_new (boost::shared_ptr); void current_mixer_strip_hidden (); diff --git a/gtk2_ardour/editor_mixer.cc b/gtk2_ardour/editor_mixer.cc index 9ea70ea11a..3a47a66f6b 100644 --- a/gtk2_ardour/editor_mixer.cc +++ b/gtk2_ardour/editor_mixer.cc @@ -179,7 +179,7 @@ Editor::create_editor_mixer () current_mixer_strip->Hiding.connect (sigc::mem_fun(*this, &Editor::current_mixer_strip_hidden)); current_mixer_strip->set_embedded (true); _master_bus_ui = new MasterBusUI (*this, _session); - master_bus_ui_home.add (*_master_bus_ui); + _master_bus_ui_home.add (*_master_bus_ui); } void diff --git a/gtk2_ardour/icons/meter_bridge_level_scale.png b/gtk2_ardour/icons/meter_bridge_level_scale.png new file mode 100644 index 0000000000000000000000000000000000000000..90420c725339b02e65933d284acb5c4e6ad71ffc GIT binary patch literal 2439 zcmbVOdsGu=7LOvuqEy22P!NsLR76N72qB3CBoE%NK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 diff --git a/gtk2_ardour/meterbridge.cc b/gtk2_ardour/meterbridge.cc index b31b9b3382..13be0cc2b2 100644 --- a/gtk2_ardour/meterbridge.cc +++ b/gtk2_ardour/meterbridge.cc @@ -625,7 +625,6 @@ Meterbridge::remove_strip (MeterStrip* strip) return; } - list::iterator i; for (list::iterator i = strips.begin(); i != strips.end(); ++i) { if ( (*i).s == strip) { strips.erase (i); diff --git a/gtk2_ardour/ui/compact_meter_bridge.xml b/gtk2_ardour/ui/compact_meter_bridge.xml new file mode 100644 index 0000000000..e95ab18888 --- /dev/null +++ b/gtk2_ardour/ui/compact_meter_bridge.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/gtk2_ardour/ui/compact_meter_strip.xml b/gtk2_ardour/ui/compact_meter_strip.xml new file mode 100644 index 0000000000..625aeca34e --- /dev/null +++ b/gtk2_ardour/ui/compact_meter_strip.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/gtk2_ardour/ui/editor_window.xml b/gtk2_ardour/ui/editor_window.xml index e98ba4ce99..21b9606f54 100644 --- a/gtk2_ardour/ui/editor_window.xml +++ b/gtk2_ardour/ui/editor_window.xml @@ -189,10 +189,11 @@ - + + - + + + + +