From 9a9a9f9eacae4553195854d2ae60dc109b05aff5 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Thu, 20 Oct 2016 14:53:34 -0500 Subject: [PATCH] Track Add/Remove Time dialog improvements: Add a clock to show the position of the edit, to remove ambiguity If a Range is selected, pre-fill the position and length clocks Clock format should default to the editor's secondary clock mode --- gtk2_ardour/editor_ops.cc | 5 +-- gtk2_ardour/insert_remove_time_dialog.cc | 56 +++++++++++++++++++----- gtk2_ardour/insert_remove_time_dialog.h | 4 +- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 88a784b0b6..803d3e0774 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -7393,7 +7393,7 @@ Editor::do_insert_time () } insert_time ( - get_preferred_edit_position (EDIT_IGNORE_MOUSE), + d.position(), d.distance(), d.intersected_region_action (), d.all_playlists(), @@ -7542,7 +7542,6 @@ Editor::do_remove_time () return; } - framepos_t pos = get_preferred_edit_position (EDIT_IGNORE_MOUSE); InsertRemoveTimeDialog d (*this, true); int response = d.run (); @@ -7558,7 +7557,7 @@ Editor::do_remove_time () } remove_time ( - pos, + d.position(), distance, SplitIntersected, d.move_glued(), diff --git a/gtk2_ardour/insert_remove_time_dialog.cc b/gtk2_ardour/insert_remove_time_dialog.cc index 419d627898..815820f3a3 100644 --- a/gtk2_ardour/insert_remove_time_dialog.cc +++ b/gtk2_ardour/insert_remove_time_dialog.cc @@ -23,49 +23,75 @@ #include #include "insert_remove_time_dialog.h" #include "audio_clock.h" +#include "ardour_ui.h" +#include "main_clock.h" #include "pbd/i18n.h" using namespace Gtk; using namespace Editing; +using namespace ARDOUR; InsertRemoveTimeDialog::InsertRemoveTimeDialog (PublicEditor& e, bool remove) : ArdourDialog (remove ? _("Remove Time") : _("Insert Time")) , _editor (e) - , _clock ("insertTimeClock", true, "", + , duration_clock ("insertTimeClock", true, "", true, // editable false, // follows_playhead true, // duration false, // with_info true // accept_on_focus_out ) + , position_clock ("insertPosTimeClock", true, "", + true, // editable + false, // follows_playhead + false, // duration + false, // with_info + true // accept_on_focus_out + ) { set_session (_editor.session ()); - framepos_t const pos = _editor.get_preferred_edit_position (EDIT_IGNORE_MOUSE); - get_vbox()->set_border_width (12); get_vbox()->set_spacing (4); - Table* table = manage (new Table (2, 2)); + Table* table = manage (new Table (2, 3)); table->set_spacings (4); - Label* time_label = manage (new Label (remove ? _("Time to remove") : _("Time to insert:"))); + Label* time_label = manage (new Label (remove ? _("Remove Time starting at:") : _("Insert Time starting at:"))); time_label->set_alignment (1, 0.5); table->attach (*time_label, 0, 1, 0, 1, FILL | EXPAND); - _clock.set (0); - _clock.set_session (_session); - _clock.set_bbt_reference (pos); - table->attach (_clock, 1, 2, 0, 1); + position_clock.set_session (_session); + position_clock.set_mode (ARDOUR_UI::instance()->secondary_clock->mode()); + table->attach (position_clock, 1, 2, 0, 1); + time_label = manage (new Label (remove ? _("Time to remove:") : _("Time to insert:"))); + time_label->set_alignment (1, 0.5); + table->attach (*time_label, 0, 1, 1, 2, FILL | EXPAND); + duration_clock.set_session (_session); + duration_clock.set_mode (ARDOUR_UI::instance()->secondary_clock->mode()); + table->attach (duration_clock, 1, 2, 1, 2); + + //if a Range is selected, assume the user wants to insert/remove the length of the range + if ( _editor.get_selection().time.length() != 0 ) { + position_clock.set ( _editor.get_selection().time.start(), true ); + duration_clock.set ( _editor.get_selection().time.end_frame(), true, _editor.get_selection().time.start() ); + duration_clock.set_bbt_reference (_editor.get_selection().time.start()); + } else { + framepos_t const pos = _editor.get_preferred_edit_position (EDIT_IGNORE_MOUSE); + position_clock.set ( pos, true ); + duration_clock.set_bbt_reference (pos); + duration_clock.set (0); + } + if (!remove) { Label* intersected_label = manage (new Label (_("Intersected regions should:"))); intersected_label->set_alignment (1, 0.5); - table->attach (*intersected_label, 0, 1, 1, 2, FILL | EXPAND); + table->attach (*intersected_label, 0, 1, 2, 3, FILL | EXPAND); _intersected_combo.append_text (_("stay in position")); _intersected_combo.append_text (_("move")); _intersected_combo.append_text (_("be split")); _intersected_combo.set_active (0); - table->attach (_intersected_combo, 1, 2, 1, 2); + table->attach (_intersected_combo, 1, 2, 2, 3); } get_vbox()->pack_start (*table); @@ -161,10 +187,16 @@ InsertRemoveTimeDialog::move_locked_markers () const return _move_locked_markers.get_active (); } +framepos_t +InsertRemoveTimeDialog::position () const +{ + return position_clock.current_time(); +} + framepos_t InsertRemoveTimeDialog::distance () const { - return _clock.current_duration (_editor.get_preferred_edit_position (EDIT_IGNORE_MOUSE)); + return duration_clock.current_duration ( position_clock.current_time() ); } void diff --git a/gtk2_ardour/insert_remove_time_dialog.h b/gtk2_ardour/insert_remove_time_dialog.h index ea3b24238e..999c0ca272 100644 --- a/gtk2_ardour/insert_remove_time_dialog.h +++ b/gtk2_ardour/insert_remove_time_dialog.h @@ -34,6 +34,7 @@ public: bool move_glued_markers () const; bool move_locked_markers () const; bool move_tempos () const; + framepos_t position () const; framepos_t distance () const; private: @@ -49,5 +50,6 @@ private: Gtk::CheckButton _move_locked_markers; Gtk::CheckButton _move_tempos; Gtk::Label tempo_label; - AudioClock _clock; + AudioClock duration_clock; + AudioClock position_clock; };