automation drawing: thinning does not work well with snapped-drawn lines

Also, adding points to a ControlList can fail and that's OK
This commit is contained in:
Paul Davis 2023-07-09 22:10:18 -06:00
parent caa278ae55
commit c584bfd374
4 changed files with 16 additions and 14 deletions

View File

@ -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<Selectable*> 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);
}

View File

@ -154,7 +154,7 @@ public:
};
typedef std::vector<DrawnPoint> 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

View File

@ -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)
{
}

View File

@ -1597,6 +1597,7 @@ private:
int direction;
int edge_x;
AutomationTimeAxisView::DrawnPoints drawn_points;
bool did_snap;
};
#endif /* __gtk2_ardour_editor_drag_h_ */