From d8a197a63fae9f5aa8ad915a9b2be93975a42bab Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 19 Nov 2024 01:49:43 +0100 Subject: [PATCH] Implement Editor Region Properties --- gtk2_ardour/region_editor.h | 2 ++ gtk2_ardour/selection_properties_box.cc | 41 +++++++++++++++++++++++++ gtk2_ardour/selection_properties_box.h | 5 +++ 3 files changed, 48 insertions(+) diff --git a/gtk2_ardour/region_editor.h b/gtk2_ardour/region_editor.h index 7dc41ecbba..e235343928 100644 --- a/gtk2_ardour/region_editor.h +++ b/gtk2_ardour/region_editor.h @@ -63,6 +63,8 @@ public: RegionEditor (ARDOUR::Session*, RegionView*); virtual ~RegionEditor (); + std::shared_ptr region () const { return _region; } + protected: virtual void region_changed (const PBD::PropertyChange&); virtual void region_fx_changed (); diff --git a/gtk2_ardour/selection_properties_box.cc b/gtk2_ardour/selection_properties_box.cc index dc3831f16f..9fe5ee11a8 100644 --- a/gtk2_ardour/selection_properties_box.cc +++ b/gtk2_ardour/selection_properties_box.cc @@ -41,6 +41,7 @@ using std::min; using std::max; SelectionPropertiesBox::SelectionPropertiesBox () + : _region_editor (nullptr) { init (); @@ -49,9 +50,11 @@ SelectionPropertiesBox::SelectionPropertiesBox () pack_start(*_time_info_box, false, false, 0); pack_start(*_route_prop_box, true, true, 0); + pack_start(_region_editor_box, false, false, 0); _time_info_box->set_no_show_all (); _route_prop_box->set_no_show_all (); + _region_editor_box.set_no_show_all (); _time_info_box->hide (); _route_prop_box->hide (); @@ -61,6 +64,7 @@ SelectionPropertiesBox::~SelectionPropertiesBox () { delete _time_info_box; delete _route_prop_box; + delete _region_editor; } void @@ -104,12 +108,25 @@ SelectionPropertiesBox::track_mouse_mode () /* maybe do something here? */ } +void +SelectionPropertiesBox::delete_region_editor () +{ + if (!_region_editor) { + return; + } + _region_editor_box.remove (); + delete _region_editor; + _region_editor = nullptr; + _region_editor_box.hide (); +} + void SelectionPropertiesBox::selection_changed () { if (!_session || _session->inital_connect_or_deletion_in_progress ()) { _time_info_box->hide (); _route_prop_box->hide (); + delete_region_editor (); return; } @@ -130,5 +147,29 @@ SelectionPropertiesBox::selection_changed () _route_prop_box->hide(); } + if (selection.regions.size () == 1) { + RegionView* rv = (selection.regions.front ()); + if (!_region_editor || _region_editor->region () != rv->region ()) { + delete_region_editor (); + AudioRegionView* arv = dynamic_cast (rv); + if (arv) { + _region_editor = new AudioRegionEditor (_session, arv); + } else { + _region_editor = new RegionEditor (_session, rv); + } + // TODO subscribe to region name changes + _region_editor->set_label (string_compose (_("Region '%1'"), rv->region()->name ())); + _region_editor->set_padding (4); + _region_editor->set_edge_color (0x000000ff); // black + _region_editor->show_all (); + _region_editor_box.add (*_region_editor); + rv->RegionViewGoingAway.connect_same_thread (_region_connection, std::bind (&SelectionPropertiesBox::delete_region_editor, this)); + } + _region_editor_box.show (); + } else { + /* only hide region props when selecting a track or trigger ..*/ + if (_route_prop_box->get_visible () || !selection.markers.empty () || !selection.playlists.empty () || !selection.triggers.empty ()) { + delete_region_editor (); + } } } diff --git a/gtk2_ardour/selection_properties_box.h b/gtk2_ardour/selection_properties_box.h index cf6f5cb0f2..809977964a 100644 --- a/gtk2_ardour/selection_properties_box.h +++ b/gtk2_ardour/selection_properties_box.h @@ -27,6 +27,7 @@ #include "ardour/ardour.h" #include "ardour/session_handle.h" +#include "widgets/eventboxext.h" namespace ARDOUR { class Session; @@ -48,10 +49,14 @@ private: void init (); void selection_changed (); void track_mouse_mode (); + void delete_region_editor (); TimeInfoBox* _time_info_box; RoutePropertiesBox* _route_prop_box; + ArdourWidgets::EventBoxExt _region_editor_box; + RegionEditor* _region_editor; + PBD::ScopedConnection _region_connection; PBD::ScopedConnection _editor_connection; };