From c584bfd374d6d0d5333519c0cc1329962adf6ba8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 9 Jul 2023 22:10:18 -0600 Subject: [PATCH] automation drawing: thinning does not work well with snapped-drawn lines Also, adding points to a ControlList can fail and that's OK --- gtk2_ardour/automation_time_axis.cc | 15 ++++----------- gtk2_ardour/automation_time_axis.h | 2 +- gtk2_ardour/editor_drag.cc | 12 ++++++++++-- gtk2_ardour/editor_drag.h | 1 + 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 4405657d82..2b6b7eedee 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -791,7 +791,7 @@ AutomationTimeAxisView::build_display_menu () } void -AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points) +AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points, bool thin) { if (points.empty()) { return; @@ -812,7 +812,6 @@ AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points) XMLNode& before = list->get_state(); std::list results; - bool failed = false; Temporal::timepos_t earliest = points.front().when; Temporal::timepos_t latest = points.back().when; @@ -830,19 +829,13 @@ AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points) /* map using line */ _line->view_to_model_coord_y (y); - if (!list->editor_add (dp.when, y, false)) { - failed = true; - break; - } + list->editor_add (dp.when, y, false); } - if (failed) { - /* XXX do something */ - return; + if (thin) { + list->thin (50.0); } - list->thin (1.0); - if (_control->automation_state () == ARDOUR::Off) { set_automation_state (ARDOUR::Play); } diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index 4a5f0525e4..e78d7c9202 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -154,7 +154,7 @@ public: }; typedef std::vector DrawnPoints; - void merge_drawn_line (DrawnPoints const &); + void merge_drawn_line (DrawnPoints const &, bool thin); protected: /* Note that for MIDI controller "automation" (in regions), all of these diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index ecf6a16636..27705e70be 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -7248,6 +7248,7 @@ AutomationDrawDrag::AutomationDrawDrag (Editor* editor, ArdourCanvas::Rectangle& , dragging_line (nullptr) , direction (0) , edge_x (0) + , did_snap (false) { DEBUG_TRACE (DEBUG::Drags, "New AutomationDrawDrag\n"); } @@ -7282,6 +7283,11 @@ AutomationDrawDrag::motion (GdkEvent* ev, bool first_move) timepos_t pos (_drags->current_pointer_time ()); _editor->snap_to_with_modifier (pos, ev); + + if (pos != _drags->current_pointer_time()) { + did_snap = true; + } + double const pointer_x = _editor->time_to_pixel (pos); ArdourCanvas::Rect r = base_rect.item_to_canvas (base_rect.get()); @@ -7346,11 +7352,13 @@ AutomationDrawDrag::finished (GdkEvent* event, bool motion_occured) return; } - atv->merge_drawn_line (drawn_points); + /* ControlList::thin() works very badly with the stair-cased lines that + result from snapping. + */ + atv->merge_drawn_line (drawn_points, !did_snap); } void AutomationDrawDrag::aborted (bool) { } - diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 142d276821..9b019078fc 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -1597,6 +1597,7 @@ private: int direction; int edge_x; AutomationTimeAxisView::DrawnPoints drawn_points; + bool did_snap; }; #endif /* __gtk2_ardour_editor_drag_h_ */