From 12dc428a609c66fe041b066851f8e8f241febdbc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 9 Dec 2021 19:45:25 -0700 Subject: [PATCH] change class names and heirarchy for the GUI elements that will be used to edit/trim clips --- ...on_trimmer_box.cc => audio_clip_editor.cc} | 94 +++++-------------- ...gion_trimmer_box.h => audio_clip_editor.h} | 41 +++----- ...ion_trimmer_box.cc => midi_clip_editor.cc} | 93 +++++------------- ...egion_trimmer_box.h => midi_clip_editor.h} | 35 ++----- gtk2_ardour/trigger_page.cc | 6 +- gtk2_ardour/trigger_page.h | 8 +- gtk2_ardour/trigger_ui.cc | 6 +- gtk2_ardour/trigger_ui.h | 4 +- gtk2_ardour/wscript | 5 +- 9 files changed, 81 insertions(+), 211 deletions(-) rename gtk2_ardour/{audio_region_trimmer_box.cc => audio_clip_editor.cc} (60%) rename gtk2_ardour/{audio_region_trimmer_box.h => audio_clip_editor.h} (68%) rename gtk2_ardour/{midi_region_trimmer_box.cc => midi_clip_editor.cc} (60%) rename gtk2_ardour/{midi_region_trimmer_box.h => midi_clip_editor.h} (70%) diff --git a/gtk2_ardour/audio_region_trimmer_box.cc b/gtk2_ardour/audio_clip_editor.cc similarity index 60% rename from gtk2_ardour/audio_region_trimmer_box.cc rename to gtk2_ardour/audio_clip_editor.cc index 04d938926f..595fd00e33 100644 --- a/gtk2_ardour/audio_region_trimmer_box.cc +++ b/gtk2_ardour/audio_clip_editor.cc @@ -41,26 +41,24 @@ #include "region_view.h" #include "ui_config.h" -#include "audio_region_trimmer_box.h" +#include "audio_clip_editor.h" #include "pbd/i18n.h" using namespace Gtk; using namespace ARDOUR; -using namespace ArdourWidgets; +using namespace ArdourCanvas; using std::min; using std::max; /* ------------ */ -AudioTrimmerCanvas::AudioTrimmerCanvas (ArdourCanvas::Item* parent) - : Rectangle (parent) +AudioClipEditor::AudioClipEditor () { // set_homogenous (true); // set_row_spacing (4); - set_fill_color (UIConfiguration::instance().color (X_("theme:darkest"))); - set_fill (true); + set_background_color (UIConfiguration::instance().color (X_("theme:darkest"))); const double scale = UIConfiguration::instance().get_ui_scale(); const double width = 600. * scale; @@ -68,42 +66,23 @@ AudioTrimmerCanvas::AudioTrimmerCanvas (ArdourCanvas::Item* parent) // name = string_compose ("trigger %1", _trigger.index()); - Event.connect (sigc::mem_fun (*this, &AudioTrimmerCanvas::event_handler)); + frame = new Rectangle (this); ArdourCanvas::Rect r (0, 0, width, height); - set (r); - set_outline_all (); - + frame->set (r); + frame->set_outline_all (); + + frame->Event.connect (sigc::mem_fun (*this, &AudioClipEditor::event_handler)); + // selection_connection = PublicEditor::instance().get_selection().TriggersChanged.connect (sigc::mem_fun (*this, &TriggerBoxUI::selection_changed)); } -AudioTrimmerCanvas::~AudioTrimmerCanvas () +AudioClipEditor::~AudioClipEditor () { } -void -AudioTrimmerCanvas::render (ArdourCanvas::Rect const & area, Cairo::RefPtr cr) const -{ -// ArdourCanvas::Rect self (item_to_window (_rect, NO_ROUND)); -// boost::optional i = self.intersection (area); -// if (!i) { -// return; -// } - cr->set_identity_matrix(); - cr->translate (area.x0, area.y0-0.5); //should be self - - float height = area.height(); //should be self - float width = area.width(); - - //black border...this should be in draw_bg - Gtkmm2ext::set_source_rgba (cr, Gtkmm2ext::rgba_to_color (0,0,0,1)); - cr->set_line_width(1); - cr->rectangle(0, 0, width, height); - cr->fill (); -} - bool -AudioTrimmerCanvas::event_handler (GdkEvent* ev) +AudioClipEditor::event_handler (GdkEvent* ev) { switch (ev->type) { case GDK_BUTTON_PRESS: @@ -122,55 +101,27 @@ AudioTrimmerCanvas::event_handler (GdkEvent* ev) return false; } -/* ------------ */ - -AudioTrimmerBoxWidget::AudioTrimmerBoxWidget () -{ - trimmer = new AudioTrimmerCanvas (root()); - set_background_color (UIConfiguration::instance().color (X_("theme:bg"))); -} - -void -AudioTrimmerBoxWidget::size_request (double& w, double& h) const -{ - trimmer->size_request (w, h); - w=600; - h=210; -} - -void -AudioTrimmerBoxWidget::on_map () -{ - GtkCanvas::on_map (); -} - -void -AudioTrimmerBoxWidget::on_unmap () -{ - GtkCanvas::on_unmap (); -} - /* ====================================================== */ -AudioRegionTrimmerBox::AudioRegionTrimmerBox () +AudioClipEditorBox::AudioClipEditorBox () { _header_label.set_text(_("AUDIO Region Trimmer:")); _header_label.set_alignment(0.0, 0.5); pack_start(_header_label, false, false, 6); - trimmer_widget = manage (new AudioTrimmerBoxWidget()); - trimmer_widget->set_size_request(600,120); + editor = manage (new AudioClipEditor); + editor->set_size_request(600,120); - pack_start(*trimmer_widget, true, true); - trimmer_widget->show(); + pack_start(*editor, true, true); + editor->show(); } -AudioRegionTrimmerBox::~AudioRegionTrimmerBox () +AudioClipEditorBox::~AudioClipEditorBox () { } void -AudioRegionTrimmerBox::set_region (boost::shared_ptr r) +AudioClipEditorBox::set_region (boost::shared_ptr r) { set_session(&r->session()); @@ -181,11 +132,11 @@ AudioRegionTrimmerBox::set_region (boost::shared_ptr r) PBD::PropertyChange interesting_stuff; region_changed(interesting_stuff); - _region->PropertyChanged.connect (state_connection, invalidator (*this), boost::bind (&AudioRegionTrimmerBox::region_changed, this, _1), gui_context()); + _region->PropertyChanged.connect (state_connection, invalidator (*this), boost::bind (&AudioClipEditorBox::region_changed, this, _1), gui_context()); } void -AudioRegionTrimmerBox::region_changed (const PBD::PropertyChange& what_changed) +AudioClipEditorBox::region_changed (const PBD::PropertyChange& what_changed) { //ToDo: refactor the region_editor.cc to cover this basic stuff // if (what_changed.contains (ARDOUR::Properties::name)) { @@ -199,6 +150,3 @@ AudioRegionTrimmerBox::region_changed (const PBD::PropertyChange& what_changed) { } } - - - diff --git a/gtk2_ardour/audio_region_trimmer_box.h b/gtk2_ardour/audio_clip_editor.h similarity index 68% rename from gtk2_ardour/audio_region_trimmer_box.h rename to gtk2_ardour/audio_clip_editor.h index 73973f2f80..2517afb330 100644 --- a/gtk2_ardour/audio_region_trimmer_box.h +++ b/gtk2_ardour/audio_clip_editor.h @@ -47,46 +47,33 @@ namespace ArdourCanvas { class Polygon; }; -class RegionTrimmerBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr +class ClipEditorBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr { public: - RegionTrimmerBox () {} - ~RegionTrimmerBox () {} + ClipEditorBox () {} + ~ClipEditorBox () {} virtual void set_region (boost::shared_ptr) =0; }; -class AudioTrimmerCanvas : public ArdourCanvas::Rectangle +class AudioClipEditor : public ArdourCanvas::GtkCanvas { - public: - AudioTrimmerCanvas (ArdourCanvas::Item* parent); - ~AudioTrimmerCanvas (); - - void render (ArdourCanvas::Rect const & area, Cairo::RefPtr) const; - -// void _size_allocate (ArdourCanvas::Rect const &); - bool event_handler (GdkEvent*); -}; - -class AudioTrimmerBoxWidget : public ArdourCanvas::GtkCanvas -{ - public: - AudioTrimmerBoxWidget (); - void size_request (double& w, double& h) const; - - void on_map (); - void on_unmap (); + public: + AudioClipEditor (); + ~AudioClipEditor (); private: - AudioTrimmerCanvas* trimmer; + ArdourCanvas::Rectangle* frame; + bool event_handler (GdkEvent* ev); + }; -class AudioRegionTrimmerBox : public RegionTrimmerBox +class AudioClipEditorBox : public ClipEditorBox { public: - AudioRegionTrimmerBox (); - ~AudioRegionTrimmerBox (); + AudioClipEditorBox (); + ~AudioClipEditorBox (); void set_region (boost::shared_ptr); void region_changed (const PBD::PropertyChange& what_changed); @@ -95,7 +82,7 @@ private: Gtk::Label _header_label; Gtk::Table table; - AudioTrimmerBoxWidget *trimmer_widget; + AudioClipEditor *editor; PBD::ScopedConnection state_connection; diff --git a/gtk2_ardour/midi_region_trimmer_box.cc b/gtk2_ardour/midi_clip_editor.cc similarity index 60% rename from gtk2_ardour/midi_region_trimmer_box.cc rename to gtk2_ardour/midi_clip_editor.cc index a477954afa..f6e83c003a 100644 --- a/gtk2_ardour/midi_region_trimmer_box.cc +++ b/gtk2_ardour/midi_clip_editor.cc @@ -41,26 +41,24 @@ #include "region_view.h" #include "ui_config.h" -#include "midi_region_trimmer_box.h" +#include "midi_clip_editor.h" #include "pbd/i18n.h" using namespace Gtk; using namespace ARDOUR; -using namespace ArdourWidgets; +using namespace ArdourCanvas; using std::min; using std::max; /* ------------ */ -MidiTrimmerCanvas::MidiTrimmerCanvas (ArdourCanvas::Item* parent) - : Rectangle (parent) +MidiClipEditor::MidiClipEditor () { // set_homogenous (true); // set_row_spacing (4); - set_fill_color (UIConfiguration::instance().color (X_("theme:darkest"))); - set_fill (true); + set_background_color (UIConfiguration::instance().color (X_("theme:darkest"))); const double scale = UIConfiguration::instance().get_ui_scale(); const double width = 600. * scale; @@ -68,42 +66,23 @@ MidiTrimmerCanvas::MidiTrimmerCanvas (ArdourCanvas::Item* parent) // name = string_compose ("trigger %1", _trigger.index()); - Event.connect (sigc::mem_fun (*this, &MidiTrimmerCanvas::event_handler)); + frame = new Rectangle (this); ArdourCanvas::Rect r (0, 0, width, height); - set (r); - set_outline_all (); - + frame->set (r); + frame->set_outline_all (); + + frame->Event.connect (sigc::mem_fun (*this, &MidiClipEditor::event_handler)); + // selection_connection = PublicEditor::instance().get_selection().TriggersChanged.connect (sigc::mem_fun (*this, &TriggerBoxUI::selection_changed)); } -MidiTrimmerCanvas::~MidiTrimmerCanvas () +MidiClipEditor::~MidiClipEditor () { } -void -MidiTrimmerCanvas::render (ArdourCanvas::Rect const & area, Cairo::RefPtr cr) const -{ -// ArdourCanvas::Rect self (item_to_window (_rect, NO_ROUND)); -// boost::optional i = self.intersection (area); -// if (!i) { -// return; -// } - cr->set_identity_matrix(); - cr->translate (area.x0, area.y0-0.5); //should be self - - float height = area.height(); //should be self - float width = area.width(); - - //black border...this should be in draw_bg - Gtkmm2ext::set_source_rgba (cr, Gtkmm2ext::rgba_to_color (0,0,0,1)); - cr->set_line_width(1); - cr->rectangle(0, 0, width, height); - cr->fill (); -} - bool -MidiTrimmerCanvas::event_handler (GdkEvent* ev) +MidiClipEditor::event_handler (GdkEvent* ev) { switch (ev->type) { case GDK_BUTTON_PRESS: @@ -122,61 +101,33 @@ MidiTrimmerCanvas::event_handler (GdkEvent* ev) return false; } -/* ------------ */ - -MidiTrimmerBoxWidget::MidiTrimmerBoxWidget () -{ - trimmer = new MidiTrimmerCanvas (root()); - set_background_color (UIConfiguration::instance().color (X_("theme:bg"))); -} - -void -MidiTrimmerBoxWidget::size_request (double& w, double& h) const -{ - trimmer->size_request (w, h); - w=600; - h=210; -} - -void -MidiTrimmerBoxWidget::on_map () -{ - GtkCanvas::on_map (); -} - -void -MidiTrimmerBoxWidget::on_unmap () -{ - GtkCanvas::on_unmap (); -} - /* ====================================================== */ -MidiRegionTrimmerBox::MidiRegionTrimmerBox () +MidiClipEditorBox::MidiClipEditorBox () { _header_label.set_text(_("MIDI Region Trimmer:")); _header_label.set_alignment(0.0, 0.5); pack_start(_header_label, false, false, 6); - trimmer_widget = manage (new MidiTrimmerBoxWidget()); - trimmer_widget->set_size_request(600,120); + editor = manage (new MidiClipEditor()); + editor->set_size_request(600,120); - pack_start(*trimmer_widget, true, true); - trimmer_widget->show(); + pack_start(*editor, true, true); + editor->show(); } -MidiRegionTrimmerBox::~MidiRegionTrimmerBox () +MidiClipEditorBox::~MidiClipEditorBox () { } void -MidiRegionTrimmerBox::set_session (Session* s) +MidiClipEditorBox::set_session (Session* s) { SessionHandlePtr::set_session (s); } void -MidiRegionTrimmerBox::set_region (boost::shared_ptr r) +MidiClipEditorBox::set_region (boost::shared_ptr r) { set_session(&r->session()); @@ -187,11 +138,11 @@ MidiRegionTrimmerBox::set_region (boost::shared_ptr r) PBD::PropertyChange interesting_stuff; region_changed(interesting_stuff); - _region->PropertyChanged.connect (state_connection, invalidator (*this), boost::bind (&MidiRegionTrimmerBox::region_changed, this, _1), gui_context()); + _region->PropertyChanged.connect (state_connection, invalidator (*this), boost::bind (&MidiClipEditorBox::region_changed, this, _1), gui_context()); } void -MidiRegionTrimmerBox::region_changed (const PBD::PropertyChange& what_changed) +MidiClipEditorBox::region_changed (const PBD::PropertyChange& what_changed) { //ToDo: refactor the region_editor.cc to cover this basic stuff // if (what_changed.contains (ARDOUR::Properties::name)) { diff --git a/gtk2_ardour/midi_region_trimmer_box.h b/gtk2_ardour/midi_clip_editor.h similarity index 70% rename from gtk2_ardour/midi_region_trimmer_box.h rename to gtk2_ardour/midi_clip_editor.h index bce5953b79..6a7fa68596 100644 --- a/gtk2_ardour/midi_region_trimmer_box.h +++ b/gtk2_ardour/midi_clip_editor.h @@ -31,11 +31,10 @@ #include "gtkmm2ext/cairo_packer.h" -#include "canvas/table.h" #include "canvas/canvas.h" #include "canvas/rectangle.h" -#include "audio_region_trimmer_box.h" +#include "audio_clip_editor.h" #include "audio_clock.h" @@ -49,36 +48,22 @@ namespace ArdourCanvas { class Polygon; }; -class MidiTrimmerCanvas : public ArdourCanvas::Rectangle +class MidiClipEditor : public ArdourCanvas::GtkCanvas { public: - MidiTrimmerCanvas (ArdourCanvas::Item* parent); - ~MidiTrimmerCanvas (); - - void render (ArdourCanvas::Rect const & area, Cairo::RefPtr) const; - -// void _size_allocate (ArdourCanvas::Rect const &); - bool event_handler (GdkEvent*); -}; - -class MidiTrimmerBoxWidget : public ArdourCanvas::GtkCanvas -{ - public: - MidiTrimmerBoxWidget (); - void size_request (double& w, double& h) const; - - void on_map (); - void on_unmap (); + MidiClipEditor (); + ~MidiClipEditor (); private: - MidiTrimmerCanvas* trimmer; + ArdourCanvas::Rectangle* frame; + bool event_handler (GdkEvent* ev); }; -class MidiRegionTrimmerBox : public RegionTrimmerBox +class MidiClipEditorBox : public ClipEditorBox { public: - MidiRegionTrimmerBox (); - ~MidiRegionTrimmerBox (); + MidiClipEditorBox (); + ~MidiClipEditorBox (); void set_session (ARDOUR::Session*); @@ -89,7 +74,7 @@ private: Gtk::Label _header_label; Gtk::Table table; - MidiTrimmerBoxWidget *trimmer_widget; + MidiClipEditor *editor; PBD::ScopedConnection state_connection; diff --git a/gtk2_ardour/trigger_page.cc b/gtk2_ardour/trigger_page.cc index fcd4d26d12..92044b5e45 100644 --- a/gtk2_ardour/trigger_page.cc +++ b/gtk2_ardour/trigger_page.cc @@ -42,7 +42,7 @@ #include "audio_region_operations_box.h" #include "midi_region_operations_box.h" #include "slot_properties_box.h" -#include "midi_region_trimmer_box.h" +#include "midi_clip_editor.h" #include "trigger_page.h" #include "trigger_strip.h" @@ -88,8 +88,8 @@ TriggerPage::TriggerPage () _audio_ops_box = new AudioRegionOperationsBox (); _midi_ops_box = new MidiRegionOperationsBox (); - _audio_trim_box = new AudioRegionTrimmerBox (); - _midi_trim_box = new MidiRegionTrimmerBox (); + _audio_trim_box = new AudioClipEditorBox (); + _midi_trim_box = new MidiClipEditorBox (); Gtk::Table* table = manage (new Gtk::Table); table->set_homogeneous (false); diff --git a/gtk2_ardour/trigger_page.h b/gtk2_ardour/trigger_page.h index 90a0264e6e..bbeaa1393f 100644 --- a/gtk2_ardour/trigger_page.h +++ b/gtk2_ardour/trigger_page.h @@ -38,8 +38,8 @@ class AudioRegionPropertiesBox; class MidiRegionPropertiesBox; class AudioRegionOperationsBox; class MidiRegionOperationsBox; -class AudioRegionTrimmerBox; -class MidiRegionTrimmerBox; +class AudioClipEditorBox; +class MidiClipEditorBox; class TriggerPage : public ArdourWidgets::Tabbable, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList { @@ -96,11 +96,11 @@ private: AudioRegionPropertiesBox* _audio_prop_box; AudioRegionOperationsBox* _audio_ops_box; - AudioRegionTrimmerBox* _audio_trim_box; + AudioClipEditorBox* _audio_trim_box; MidiRegionPropertiesBox* _midi_prop_box; MidiRegionOperationsBox* _midi_ops_box; - MidiRegionTrimmerBox* _midi_trim_box; + MidiClipEditorBox* _midi_trim_box; std::list _strips; sigc::connection _fast_screen_update_connection; diff --git a/gtk2_ardour/trigger_ui.cc b/gtk2_ardour/trigger_ui.cc index 3b792b0016..438b38af22 100644 --- a/gtk2_ardour/trigger_ui.cc +++ b/gtk2_ardour/trigger_ui.cc @@ -37,7 +37,7 @@ #include "audio_region_operations_box.h" #include "midi_region_operations_box.h" #include "slot_properties_box.h" -#include "midi_region_trimmer_box.h" +#include "midi_clip_editor.h" #include "ardour_ui.h" #include "gui_thread.h" @@ -401,11 +401,11 @@ TriggerWindow::TriggerWindow (Trigger* slot) if (slot->region()->data_type() == DataType::AUDIO) { _prop_box = manage(new AudioRegionPropertiesBox ()); _ops_box = manage(new AudioRegionOperationsBox ()); - _trim_box = manage(new AudioRegionTrimmerBox ()); + _trim_box = manage(new AudioClipEditorBox ()); } else { _prop_box = manage(new MidiRegionPropertiesBox ()); _ops_box = manage(new MidiRegionOperationsBox ()); - _trim_box = manage(new MidiRegionTrimmerBox ()); + _trim_box = manage(new MidiClipEditorBox ()); } _prop_box->set_region(slot->region()); diff --git a/gtk2_ardour/trigger_ui.h b/gtk2_ardour/trigger_ui.h index d49194d60e..fbea5d0a0d 100644 --- a/gtk2_ardour/trigger_ui.h +++ b/gtk2_ardour/trigger_ui.h @@ -28,7 +28,7 @@ namespace ArdourWidgets { class RegionPropertiesBox; class RegionOperationsBox; -class RegionTrimmerBox; +class ClipEditorBox; class TriggerUI : public Gtk::Table //, public sigc::trackable { @@ -91,7 +91,7 @@ class TriggerWindow : public Gtk::Window RegionPropertiesBox *_prop_box; RegionOperationsBox *_ops_box; - RegionTrimmerBox *_trim_box; + ClipEditorBox *_trim_box; }; #endif /* __ardour_gtk_trigger_ui_h__ */ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index c3f1a2be5d..678fe86314 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -49,13 +49,12 @@ gtk2_ardour_sources = [ 'ardour_ui_startup.cc', 'ardour_ui_video.cc', 'ardour_window.cc', - 'audio_clip_editor.cc', 'audio_clock.cc', + 'audio_clip_editor.cc', 'audio_region_editor.cc', 'audio_region_view.cc', 'audio_region_operations_box.cc', 'audio_region_properties_box.cc', - 'audio_region_trimmer_box.cc', 'audio_streamview.cc', 'audio_time_axis.cc', 'automation_controller.cc', @@ -163,13 +162,13 @@ gtk2_ardour_sources = [ 'midi_automation_line.cc', 'midi_channel_dialog.cc', 'midi_channel_selector.cc', + 'midi_clip_editor.cc', 'midi_cut_buffer.cc', 'midi_export_dialog.cc', 'midi_list_editor.cc', 'midi_region_view.cc', 'midi_region_operations_box.cc', 'midi_region_properties_box.cc', - 'midi_region_trimmer_box.cc', 'midi_scroomer.cc', 'midi_selection.cc', 'midi_streamview.cc',