13
0

Refactor RegionEditor to be a Widget

This commit is contained in:
Robin Gareus 2024-11-18 23:07:08 +01:00
parent 3c5681b2c9
commit c35fa54b3f
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
11 changed files with 120 additions and 55 deletions

View File

@ -130,8 +130,6 @@ AudioRegionEditor::AudioRegionEditor (Session* s, AudioRegionView* arv)
snprintf (name, 64, "peak amplitude-%p", this); snprintf (name, 64, "peak amplitude-%p", this);
pthread_create_and_store (name, &_peak_amplitude_thread_handle, _peak_amplitude_thread, this); pthread_create_and_store (name, &_peak_amplitude_thread_handle, _peak_amplitude_thread, this);
signal_peak_thread (); signal_peak_thread ();
} }
AudioRegionEditor::~AudioRegionEditor () AudioRegionEditor::~AudioRegionEditor ()
@ -357,5 +355,4 @@ void
AudioRegionEditor::on_unmap () AudioRegionEditor::on_unmap ()
{ {
_show_on_touch.set_active (false); _show_on_touch.set_active (false);
ArdourDialog::on_unmap ();
} }

View File

@ -104,4 +104,3 @@ private:
PBD::ScopedConnection _peak_amplitude_connection; PBD::ScopedConnection _peak_amplitude_connection;
CrossThreadChannel _peak_channel; CrossThreadChannel _peak_channel;
}; };

View File

@ -1813,17 +1813,6 @@ AudioRegionView::update_coverage_frame (LayerDisplay d)
} }
} }
void
AudioRegionView::show_region_editor ()
{
if (editor == 0) {
editor = new AudioRegionEditor (trackview.session(), this);
}
editor->present ();
editor->show_all();
}
void void
AudioRegionView::transients_changed () AudioRegionView::transients_changed ()
{ {

View File

@ -122,8 +122,6 @@ public:
void update_transient(float old_pos, float new_pos); void update_transient(float old_pos, float new_pos);
void remove_transient(float pos); void remove_transient(float pos);
void show_region_editor ();
void set_frame_color (); void set_frame_color ();
uint32_t get_fill_color () const; uint32_t get_fill_color () const;

View File

@ -5,6 +5,7 @@
* Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net> * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
* Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org> * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
* Copyright (C) 2014-2015 Nick Mainsbridge <mainsbridge@gmail.com> * Copyright (C) 2014-2015 Nick Mainsbridge <mainsbridge@gmail.com>
* Copyright (C) 2024 Ben Loftis <ben.loftis@harrisonaudio.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -64,7 +65,7 @@ using namespace std;
using namespace Gtkmm2ext; using namespace Gtkmm2ext;
RegionEditor::RegionEditor (Session* s, RegionView* rv) RegionEditor::RegionEditor (Session* s, RegionView* rv)
: ArdourDialog (_("Region")) : SessionHandlePtr (s)
, _table (9, 3) , _table (9, 3)
, _table_row (0) , _table_row (0)
, _region (rv->region ()) , _region (rv->region ())
@ -81,8 +82,6 @@ RegionEditor::RegionEditor (Session* s, RegionView* rv)
, _region_fx_box (_region) , _region_fx_box (_region)
, _sources (1) , _sources (1)
{ {
set_session (s);
switch (_region->time_domain()) { switch (_region->time_domain()) {
case Temporal::AudioTime: case Temporal::AudioTime:
/* XXX check length of region and choose samples or minsec */ /* XXX check length of region and choose samples or minsec */
@ -190,16 +189,7 @@ RegionEditor::RegionEditor (Session* s, RegionView* rv)
_table.attach (region_fx_label, 2, 3, 0, 1, Gtk::FILL, Gtk::FILL); _table.attach (region_fx_label, 2, 3, 0, 1, Gtk::FILL, Gtk::FILL);
_table.attach (_region_fx_box, 2, 3, 1, _table_row + 2, Gtk::FILL, Gtk::FILL); _table.attach (_region_fx_box, 2, 3, 1, _table_row + 2, Gtk::FILL, Gtk::FILL);
get_vbox()->pack_start (_table, true, true); add (_table);
add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_ACCEPT);
set_name ("RegionEditorWindow");
add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
signal_response().connect (sigc::mem_fun (*this, &RegionEditor::handle_response));
set_title (string_compose (_("Region '%1'"), _region->name()));
for (uint32_t i = 0; i < _region->sources().size(); ++i) { for (uint32_t i = 0; i < _region->sources().size(); ++i) {
_sources.append (_region->source(i)->name()); _sources.append (_region->source(i)->name());
@ -241,6 +231,7 @@ RegionEditor::RegionEditor (Session* s, RegionView* rv)
RegionEditor::~RegionEditor () RegionEditor::~RegionEditor ()
{ {
remove (); /* unpack and unmap table */
delete _clock_group; delete _clock_group;
} }
@ -500,12 +491,6 @@ RegionEditor::on_delete_event (GdkEventAny*)
return true; return true;
} }
void
RegionEditor::handle_response (int)
{
hide ();
}
/* ****************************************************************************/ /* ****************************************************************************/
static std::list<Gtk::TargetEntry> static std::list<Gtk::TargetEntry>

View File

@ -41,12 +41,12 @@
#include "gtkmm2ext/dndtreeview.h" #include "gtkmm2ext/dndtreeview.h"
#include "gtkmm2ext/dndvbox.h" #include "gtkmm2ext/dndvbox.h"
#include "widgets/frame.h"
#include "pbd/signals.h" #include "pbd/signals.h"
#include "audio_clock.h" #include "audio_clock.h"
#include "ardour_dialog.h"
#include "plugin_interest.h" #include "plugin_interest.h"
#include "region_editor.h"
namespace ARDOUR { namespace ARDOUR {
class Region; class Region;
@ -57,7 +57,7 @@ namespace ARDOUR {
class RegionView; class RegionView;
class ClockGroup; class ClockGroup;
class RegionEditor : public ArdourDialog class RegionEditor : public ArdourWidgets::Frame, public ARDOUR::SessionHandlePtr
{ {
public: public:
RegionEditor (ARDOUR::Session*, RegionView*); RegionEditor (ARDOUR::Session*, RegionView*);
@ -186,7 +186,6 @@ private:
gint breleased (GdkEventButton* ev, Gtk::SpinButton* but, void (RegionEditor::*pmf)()); gint breleased (GdkEventButton* ev, Gtk::SpinButton* but, void (RegionEditor::*pmf)());
bool on_delete_event (GdkEventAny *); bool on_delete_event (GdkEventAny *);
void handle_response (int);
bool spin_arrow_grab; bool spin_arrow_grab;
@ -195,4 +194,3 @@ private:
void set_clock_mode_from_primary (); void set_clock_mode_from_primary ();
}; };

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2024 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "region_editor_window.h"
#include "audio_region_editor.h"
#include "audio_region_view.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
RegionEditorWindow::RegionEditorWindow (Session* s, RegionView* rv)
: ArdourWindow (_("Region"))
{
AudioRegionView* arv = dynamic_cast<AudioRegionView*> (rv);
if (arv) {
_region_editor = new AudioRegionEditor (s, arv);
} else {
_region_editor = new RegionEditor (s, rv);
}
add (*_region_editor);
set_name ("RegionEditorWindow");
}
RegionEditorWindow::~RegionEditorWindow ()
{
delete _region_editor;
}
void
RegionEditorWindow::set_session (Session* s)
{
ArdourWindow::set_session (s);
if (s) {
_region_editor->set_session (s);
}
}
void
RegionEditorWindow::on_unmap ()
{
_region_editor->unmap ();
ArdourWindow::on_unmap ();
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2024 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include "ardour_window.h"
class RegionEditor;
class RegionView;
class RegionEditorWindow : public ArdourWindow
{
public:
RegionEditorWindow (ARDOUR::Session*, RegionView*);
~RegionEditorWindow ();
void set_session (ARDOUR::Session*);
protected:
void on_unmap ();
private:
RegionEditor* _region_editor;
};

View File

@ -48,7 +48,7 @@
#include "region_view.h" #include "region_view.h"
#include "automation_region_view.h" #include "automation_region_view.h"
#include "public_editor.h" #include "public_editor.h"
#include "region_editor.h" #include "region_editor_window.h"
#include "ghostregion.h" #include "ghostregion.h"
#include "ui_config.h" #include "ui_config.h"
#include "utils.h" #include "utils.h"
@ -82,7 +82,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent,
, _region (r) , _region (r)
, sync_mark (nullptr) , sync_mark (nullptr)
, sync_line (nullptr) , sync_line (nullptr)
, editor (nullptr) , _editor (nullptr)
, current_visible_sync_position (0.0) , current_visible_sync_position (0.0)
, valid (false) , valid (false)
, _disable_display (0) , _disable_display (0)
@ -162,7 +162,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent,
, _region (r) , _region (r)
, sync_mark (nullptr) , sync_mark (nullptr)
, sync_line (nullptr) , sync_line (nullptr)
, editor (nullptr) , _editor (nullptr)
, current_visible_sync_position (0.0) , current_visible_sync_position (0.0)
, valid (false) , valid (false)
, _disable_display (0) , _disable_display (0)
@ -181,7 +181,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent,
void void
RegionView::init (bool wfd) RegionView::init (bool wfd)
{ {
editor = nullptr; _editor = nullptr;
valid = true; valid = true;
in_destructor = false; in_destructor = false;
wait_for_data = wfd; wait_for_data = wfd;
@ -268,7 +268,7 @@ RegionView::~RegionView ()
drop_silent_frames (); drop_silent_frames ();
delete editor; delete _editor;
} }
bool bool
@ -749,19 +749,19 @@ RegionView::set_sync_mark_color ()
void void
RegionView::show_region_editor () RegionView::show_region_editor ()
{ {
if (!editor) { if (!_editor) {
editor = new RegionEditor (trackview.session(), this); _editor = new RegionEditorWindow (trackview.session(), this);
} }
editor->present (); _editor->present ();
editor->show_all(); _editor->show_all();
} }
void void
RegionView::hide_region_editor() RegionView::hide_region_editor()
{ {
if (editor) { if (_editor) {
editor->hide_all (); _editor->hide_all ();
} }
} }

View File

@ -40,7 +40,7 @@
#include "marker.h" #include "marker.h"
class TimeAxisView; class TimeAxisView;
class RegionEditor; class ArdourWindow;
class GhostRegion; class GhostRegion;
class AutomationTimeAxisView; class AutomationTimeAxisView;
class AutomationRegionView; class AutomationRegionView;
@ -87,7 +87,7 @@ public:
bool set_position(Temporal::timepos_t const & pos, void* src, double* delta = 0); bool set_position(Temporal::timepos_t const & pos, void* src, double* delta = 0);
virtual void show_region_editor (); void show_region_editor ();
void hide_region_editor (); void hide_region_editor ();
virtual void region_changed (const PBD::PropertyChange&); virtual void region_changed (const PBD::PropertyChange&);
@ -202,7 +202,7 @@ protected:
ArdourCanvas::Polygon* sync_mark; ///< polygon for sync position ArdourCanvas::Polygon* sync_mark; ///< polygon for sync position
ArdourCanvas::Line* sync_line; ///< polygon for sync position ArdourCanvas::Line* sync_line; ///< polygon for sync position
RegionEditor* editor; ArdourWindow* _editor;
std::vector<ControlPoint *> control_points; std::vector<ControlPoint *> control_points;
double current_visible_sync_position; double current_visible_sync_position;

View File

@ -253,6 +253,7 @@ gtk2_ardour_sources = [
'recorder_group_tabs.cc', 'recorder_group_tabs.cc',
'recorder_ui.cc', 'recorder_ui.cc',
'region_editor.cc', 'region_editor.cc',
'region_editor_window.cc',
'region_fx_line.cc', 'region_fx_line.cc',
'region_gain_line.cc', 'region_gain_line.cc',
'region_layering_order_editor.cc', 'region_layering_order_editor.cc',