diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index 6c11c68984..96bfde26a4 100644 --- a/gtk2_ardour/audio_region_editor.cc +++ b/gtk2_ardour/audio_region_editor.cc @@ -130,8 +130,6 @@ AudioRegionEditor::AudioRegionEditor (Session* s, AudioRegionView* arv) snprintf (name, 64, "peak amplitude-%p", this); pthread_create_and_store (name, &_peak_amplitude_thread_handle, _peak_amplitude_thread, this); signal_peak_thread (); - - } AudioRegionEditor::~AudioRegionEditor () @@ -357,5 +355,4 @@ void AudioRegionEditor::on_unmap () { _show_on_touch.set_active (false); - ArdourDialog::on_unmap (); } diff --git a/gtk2_ardour/audio_region_editor.h b/gtk2_ardour/audio_region_editor.h index ec94e6fb52..7185ff88f7 100644 --- a/gtk2_ardour/audio_region_editor.h +++ b/gtk2_ardour/audio_region_editor.h @@ -104,4 +104,3 @@ private: PBD::ScopedConnection _peak_amplitude_connection; CrossThreadChannel _peak_channel; }; - diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index c43557ed15..791830dd22 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -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 AudioRegionView::transients_changed () { diff --git a/gtk2_ardour/audio_region_view.h b/gtk2_ardour/audio_region_view.h index e4765028bb..f8f85b97ea 100644 --- a/gtk2_ardour/audio_region_view.h +++ b/gtk2_ardour/audio_region_view.h @@ -122,8 +122,6 @@ public: void update_transient(float old_pos, float new_pos); void remove_transient(float pos); - void show_region_editor (); - void set_frame_color (); uint32_t get_fill_color () const; diff --git a/gtk2_ardour/region_editor.cc b/gtk2_ardour/region_editor.cc index d16e6f2c4b..5e8e712587 100644 --- a/gtk2_ardour/region_editor.cc +++ b/gtk2_ardour/region_editor.cc @@ -5,6 +5,7 @@ * Copyright (C) 2010-2012 Carl Hetherington * Copyright (C) 2013-2019 Robin Gareus * Copyright (C) 2014-2015 Nick Mainsbridge + * Copyright (C) 2024 Ben Loftis * * 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 @@ -64,7 +65,7 @@ using namespace std; using namespace Gtkmm2ext; RegionEditor::RegionEditor (Session* s, RegionView* rv) - : ArdourDialog (_("Region")) + : SessionHandlePtr (s) , _table (9, 3) , _table_row (0) , _region (rv->region ()) @@ -81,8 +82,6 @@ RegionEditor::RegionEditor (Session* s, RegionView* rv) , _region_fx_box (_region) , _sources (1) { - set_session (s); - switch (_region->time_domain()) { case Temporal::AudioTime: /* 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_box, 2, 3, 1, _table_row + 2, Gtk::FILL, Gtk::FILL); - get_vbox()->pack_start (_table, true, true); - - 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())); + add (_table); for (uint32_t i = 0; i < _region->sources().size(); ++i) { _sources.append (_region->source(i)->name()); @@ -241,6 +231,7 @@ RegionEditor::RegionEditor (Session* s, RegionView* rv) RegionEditor::~RegionEditor () { + remove (); /* unpack and unmap table */ delete _clock_group; } @@ -500,12 +491,6 @@ RegionEditor::on_delete_event (GdkEventAny*) return true; } -void -RegionEditor::handle_response (int) -{ - hide (); -} - /* ****************************************************************************/ static std::list diff --git a/gtk2_ardour/region_editor.h b/gtk2_ardour/region_editor.h index b53d71391a..7dc41ecbba 100644 --- a/gtk2_ardour/region_editor.h +++ b/gtk2_ardour/region_editor.h @@ -41,12 +41,12 @@ #include "gtkmm2ext/dndtreeview.h" #include "gtkmm2ext/dndvbox.h" +#include "widgets/frame.h" + #include "pbd/signals.h" #include "audio_clock.h" -#include "ardour_dialog.h" #include "plugin_interest.h" -#include "region_editor.h" namespace ARDOUR { class Region; @@ -57,7 +57,7 @@ namespace ARDOUR { class RegionView; class ClockGroup; -class RegionEditor : public ArdourDialog +class RegionEditor : public ArdourWidgets::Frame, public ARDOUR::SessionHandlePtr { public: RegionEditor (ARDOUR::Session*, RegionView*); @@ -186,7 +186,6 @@ private: gint breleased (GdkEventButton* ev, Gtk::SpinButton* but, void (RegionEditor::*pmf)()); bool on_delete_event (GdkEventAny *); - void handle_response (int); bool spin_arrow_grab; @@ -195,4 +194,3 @@ private: void set_clock_mode_from_primary (); }; - diff --git a/gtk2_ardour/region_editor_window.cc b/gtk2_ardour/region_editor_window.cc new file mode 100644 index 0000000000..434c9647ac --- /dev/null +++ b/gtk2_ardour/region_editor_window.cc @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2024 Robin Gareus + * + * 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 (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 (); +} diff --git a/gtk2_ardour/region_editor_window.h b/gtk2_ardour/region_editor_window.h new file mode 100644 index 0000000000..e345afc65c --- /dev/null +++ b/gtk2_ardour/region_editor_window.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 Robin Gareus + * + * 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; +}; diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 52b1e945ea..3a85d1419c 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -48,7 +48,7 @@ #include "region_view.h" #include "automation_region_view.h" #include "public_editor.h" -#include "region_editor.h" +#include "region_editor_window.h" #include "ghostregion.h" #include "ui_config.h" #include "utils.h" @@ -82,7 +82,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent, , _region (r) , sync_mark (nullptr) , sync_line (nullptr) - , editor (nullptr) + , _editor (nullptr) , current_visible_sync_position (0.0) , valid (false) , _disable_display (0) @@ -162,7 +162,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent, , _region (r) , sync_mark (nullptr) , sync_line (nullptr) - , editor (nullptr) + , _editor (nullptr) , current_visible_sync_position (0.0) , valid (false) , _disable_display (0) @@ -181,7 +181,7 @@ RegionView::RegionView (ArdourCanvas::Container* parent, void RegionView::init (bool wfd) { - editor = nullptr; + _editor = nullptr; valid = true; in_destructor = false; wait_for_data = wfd; @@ -268,7 +268,7 @@ RegionView::~RegionView () drop_silent_frames (); - delete editor; + delete _editor; } bool @@ -749,19 +749,19 @@ RegionView::set_sync_mark_color () void RegionView::show_region_editor () { - if (!editor) { - editor = new RegionEditor (trackview.session(), this); + if (!_editor) { + _editor = new RegionEditorWindow (trackview.session(), this); } - editor->present (); - editor->show_all(); + _editor->present (); + _editor->show_all(); } void RegionView::hide_region_editor() { - if (editor) { - editor->hide_all (); + if (_editor) { + _editor->hide_all (); } } diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index 4a27eeef6b..13d701a6d6 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -40,7 +40,7 @@ #include "marker.h" class TimeAxisView; -class RegionEditor; +class ArdourWindow; class GhostRegion; class AutomationTimeAxisView; class AutomationRegionView; @@ -87,7 +87,7 @@ public: 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 (); virtual void region_changed (const PBD::PropertyChange&); @@ -202,7 +202,7 @@ protected: ArdourCanvas::Polygon* sync_mark; ///< polygon for sync position ArdourCanvas::Line* sync_line; ///< polygon for sync position - RegionEditor* editor; + ArdourWindow* _editor; std::vector control_points; double current_visible_sync_position; diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 92d170a65e..38534363c6 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -253,6 +253,7 @@ gtk2_ardour_sources = [ 'recorder_group_tabs.cc', 'recorder_ui.cc', 'region_editor.cc', + 'region_editor_window.cc', 'region_fx_line.cc', 'region_gain_line.cc', 'region_layering_order_editor.cc',