From f2744a9ce8f8654a11e4925f6d01131524f7cd4e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 4 Jan 2026 17:05:07 -0700 Subject: [PATCH] improve behavior when editing BBT markers setting the name should now work reliably, in particular --- gtk2_ardour/bbt_marker_dialog.cc | 5 ++++- gtk2_ardour/bbt_marker_dialog.h | 6 ++++-- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_drag.cc | 2 +- gtk2_ardour/editor_markers.cc | 2 +- gtk2_ardour/editor_tempodisplay.cc | 31 +++++++++++++++++++----------- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/gtk2_ardour/bbt_marker_dialog.cc b/gtk2_ardour/bbt_marker_dialog.cc index a6caa2a077..1c4de80377 100644 --- a/gtk2_ardour/bbt_marker_dialog.cc +++ b/gtk2_ardour/bbt_marker_dialog.cc @@ -37,12 +37,13 @@ BBTMarkerDialog::BBTMarkerDialog (timepos_t const & pos, BBT_Time const& bbt) , bar_label (_("Bar")) , beat_label (_("Beat")) , name_label (_("Name")) + , name_changed (false) { init (true); } -BBTMarkerDialog::BBTMarkerDialog (MusicTimePoint& p) +BBTMarkerDialog::BBTMarkerDialog (MusicTimePoint const & p) : ArdourDialog (_("Edit Music Time")) , _point (&p) , _position (timepos_t::from_superclock (p.sclock())) @@ -50,6 +51,7 @@ BBTMarkerDialog::BBTMarkerDialog (MusicTimePoint& p) , bar_label (_("Bar")) , beat_label (_("Beat")) , name_label (_("Name")) + , name_changed (false) { init (false); } @@ -81,6 +83,7 @@ BBTMarkerDialog::init (bool add) } name_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &BBTMarkerDialog::response), Gtk::RESPONSE_OK)); + name_entry.signal_changed().connect ([&]() { name_changed = true; }); get_vbox()->pack_start (name_box); get_vbox()->pack_start (bbt_box); diff --git a/gtk2_ardour/bbt_marker_dialog.h b/gtk2_ardour/bbt_marker_dialog.h index 449e78ddcf..28e692eacd 100644 --- a/gtk2_ardour/bbt_marker_dialog.h +++ b/gtk2_ardour/bbt_marker_dialog.h @@ -33,15 +33,16 @@ class BBTMarkerDialog : public ArdourDialog { public: BBTMarkerDialog (Temporal::timepos_t const &, Temporal::BBT_Time const&); - BBTMarkerDialog (Temporal::MusicTimePoint&); + BBTMarkerDialog (Temporal::MusicTimePoint const &); Temporal::timepos_t position() const; Temporal::BBT_Time bbt_value () const; std::string name() const; + bool name_edited() const { return name_changed; } private: void init (bool add); - Temporal::MusicTimePoint* _point; + Temporal::MusicTimePoint const * _point; Temporal::timepos_t _position; Temporal::BBT_Time _bbt; @@ -54,5 +55,6 @@ private: Gtk::HBox name_box; Gtk::Entry name_entry; Gtk::Label name_label; + bool name_changed; }; diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 8457fd3d41..fbe442905e 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -469,7 +469,7 @@ public: void mouse_add_bbt_marker_event (Temporal::timepos_t where); void add_bbt_marker_at_playhead_cursor (); - void edit_bbt (Temporal::MusicTimePoint&); + void edit_bbt (BBTMarker&); bool should_ripple () const; bool should_ripple_all () const; /* RippleAll will ripple all similar regions and the timeline markers */ diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 5e3b903f09..ef8c0f179c 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3438,7 +3438,7 @@ BBTMarkerDrag::finished (GdkEvent* event, bool movement_occurred) _editor.abort_tempo_map_edit (); if (was_double_click ()) { - _editor.edit_bbt (point); + _editor.edit_bbt (*_marker); } return; diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 4efafde1a5..ab944082ac 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -1680,7 +1680,7 @@ Editor::marker_menu_edit () } else if (tm) { edit_tempo_section (const_cast(tm->tempo())); } else if (bm) { - edit_bbt (const_cast(bm->mt_point())); + edit_bbt (*bm); } } diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index f35a795c2c..456c65d1d3 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -636,8 +636,9 @@ Editor::edit_meter_section (Temporal::MeterPoint& section) } void -Editor::edit_bbt (MusicTimePoint& point) +Editor::edit_bbt (BBTMarker& bm) { + MusicTimePoint const & point (bm.mt_point()); BBTMarkerDialog dialog (point); switch (dialog.run ()) { @@ -648,16 +649,24 @@ Editor::edit_bbt (MusicTimePoint& point) return; } - if (dialog.bbt_value() == point.bbt()) { - /* just a name change, no need to modify the map */ - point.set_name (dialog.name()); - /* XXX need to update marker label */ - return; - } + BBT_Time bbt (dialog.bbt_value()); + Temporal::timepos_t pos (dialog.position()); + std::string name (dialog.name()); - TempoMapChange tmc (*this, _("edit tempo")); - tmc.map().remove_bartime (point); - tmc.map().set_bartime (dialog.bbt_value(), dialog.position(), dialog.name()); + if (bbt != point.bbt() || + pos.superclocks() != point.sclock() || + name != point.name()) { + TempoMapChange tmc (*this, _("edit tempo")); + tmc.map().remove_bartime (point); + tmc.map().set_bartime (bbt, pos, name); + + /* XXX this ought to be set via MVC-style design, but currently + * there is no signal to notify anyone that the + * MusicTimePoint's name has been changed. + */ + + bm.set_name (name); + } } void @@ -745,7 +754,7 @@ Editor::edit_meter_marker (MeterMarker& mm) void Editor::edit_bbt_marker (BBTMarker& bm) { - edit_bbt (const_cast(bm.mt_point())); + edit_bbt (bm); } gint