Implement Editor Region Properties

This commit is contained in:
Robin Gareus 2024-11-19 01:49:43 +01:00
parent 00f3ce2e76
commit d8a197a63f
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 48 additions and 0 deletions

View File

@ -63,6 +63,8 @@ public:
RegionEditor (ARDOUR::Session*, RegionView*);
virtual ~RegionEditor ();
std::shared_ptr<ARDOUR::Region> region () const { return _region; }
protected:
virtual void region_changed (const PBD::PropertyChange&);
virtual void region_fx_changed ();

View File

@ -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<AudioRegionView*> (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 ();
}
}
}

View File

@ -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;
};