From 8da5d49e54e7deb8f7653a781ec3eeabf183a001 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Wed, 13 Sep 2023 09:04:22 -0500 Subject: [PATCH] Add a checkbox for 'stretch markers' and show it when MouseGrid is active Also, de-sensitize the checkbox if the session is AudioTime --- gtk2_ardour/editor.cc | 15 +++++++++++++++ gtk2_ardour/editor.h | 8 ++++++++ gtk2_ardour/editor_actions.cc | 2 ++ gtk2_ardour/editor_mouse.cc | 6 +++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 2943e2794e..ea1dd390dc 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3332,6 +3332,8 @@ Editor::setup_toolbar () mouse_mode_size_group->add_widget (visible_tracks_selector); } + mouse_mode_size_group->add_widget (stretch_marker_cb); + mouse_mode_size_group->add_widget (grid_type_selector); mouse_mode_size_group->add_widget (draw_length_selector); mouse_mode_size_group->add_widget (draw_velocity_selector); @@ -3449,6 +3451,8 @@ Editor::setup_toolbar () snap_box.set_spacing (2); snap_box.set_border_width (2); + stretch_marker_cb.set_name ("mouse mode button"); + grid_type_selector.set_name ("mouse mode button"); draw_length_selector.set_name ("mouse mode button"); draw_velocity_selector.set_name ("mouse mode button"); @@ -3480,6 +3484,14 @@ Editor::setup_toolbar () nudge_box->pack_start (nudge_forward_button, false, false); nudge_box->pack_start (*nudge_clock, false, false); + stretch_marker_cb.set_label (_("Stretch Markers")); + stretch_marker_cb.set_active (true); + + /* Grid - these tools are only visible when in Grid mode */ + grid_box.set_spacing (2); + grid_box.set_border_width (2); + grid_box.pack_start (stretch_marker_cb, false, false, 4); + /* Draw - these MIDI tools are only visible when in Draw mode */ draw_box.set_spacing (2); draw_box.set_border_width (2); @@ -3518,6 +3530,8 @@ Editor::setup_toolbar () toolbar_hbox.pack_start (snap_box, false, false); toolbar_hbox.pack_start (*(manage (new ArdourVSpacer ())), false, false, 3); toolbar_hbox.pack_start (*nudge_box, false, false); + toolbar_hbox.pack_start (_grid_box_spacer, false, false, 3); + toolbar_hbox.pack_start (grid_box, false, false); toolbar_hbox.pack_start (_draw_box_spacer, false, false, 3); toolbar_hbox.pack_start (draw_box, false, false); toolbar_hbox.pack_end (_zoom_box, false, false, 2); @@ -3695,6 +3709,7 @@ Editor::setup_tooltips () set_tooltip (tav_expand_button, _("Expand Tracks")); set_tooltip (tav_shrink_button, _("Shrink Tracks")); set_tooltip (visible_tracks_selector, _("Number of visible tracks")); + set_tooltip (stretch_marker_cb, _("Move markers and ranges when stretching the Grid\n(this option is only available when session Time Domain is Beat Time)")); set_tooltip (draw_length_selector, _("Note Length to Draw (AUTO uses the current Grid setting)")); set_tooltip (draw_velocity_selector, _("Note Velocity to Draw (AUTO uses the nearest note's velocity)")); set_tooltip (draw_channel_selector, _("Note Channel to Draw (AUTO uses the nearest note's channel)")); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index f4038f542d..d1c8d1e171 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2014,12 +2014,20 @@ private: ArdourWidgets::ArdourDropdown draw_channel_selector; void build_draw_midi_menus (); + Gtk::CheckButton stretch_marker_cb; + + bool should_stretch_markers() const { + return stretch_marker_cb.get_active (); + } + ArdourWidgets::ArdourButton snap_mode_button; bool snap_mode_button_clicked (GdkEventButton*); Gtk::HBox snap_box; + Gtk::HBox grid_box; Gtk::HBox draw_box; + ArdourWidgets::ArdourVSpacer _grid_box_spacer; ArdourWidgets::ArdourVSpacer _draw_box_spacer; Gtk::HBox ebox_hpacker; diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index c2a3b6e073..9091901805 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -1810,6 +1810,8 @@ Editor::parameter_changed (std::string p) } } else if (p == "track-name-number") { queue_redisplay_track_views (); + } else if (p == "default-time-domain") { + stretch_marker_cb.set_sensitive (_session->config.get_default_time_domain () == Temporal::BeatTime); } } diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 986e0d6216..d15777b697 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -379,8 +379,12 @@ Editor::mouse_mode_toggled (MouseMode m) } if (mouse_mode == MouseGrid) { + grid_box.show(); + _grid_box_spacer.show (); _canvas_grid_zone->set_ignore_events (false); } else { + grid_box.hide (); + _grid_box_spacer.hide (); _canvas_grid_zone->set_ignore_events (true); } @@ -3045,7 +3049,7 @@ Editor::choose_mapping_drag (ArdourCanvas::Item* item, GdkEvent* event) /* The reversible command starts here, must be ended/aborted in drag */ begin_reversible_command (""); - domain_bounce_info = new Temporal::DomainBounceInfo (Temporal::BeatTime, Temporal::AudioTime); + domain_bounce_info = new Temporal::DomainBounceInfo (Temporal::BeatTime, Temporal::AudioTime, should_stretch_markers()); Temporal::TempoMap::WritableSharedPtr map = begin_tempo_mapping (*domain_bounce_info); /* Decide between a mid-twist, which we do if the