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 void
AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points) AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points, bool thin)
{ {
if (points.empty()) { if (points.empty()) {
return; return;
@ -812,7 +812,6 @@ AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points)
XMLNode& before = list->get_state(); XMLNode& before = list->get_state();
std::list<Selectable*> results; std::list<Selectable*> results;
bool failed = false;
Temporal::timepos_t earliest = points.front().when; Temporal::timepos_t earliest = points.front().when;
Temporal::timepos_t latest = points.back().when; Temporal::timepos_t latest = points.back().when;
@ -830,19 +829,13 @@ AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points)
/* map using line */ /* map using line */
_line->view_to_model_coord_y (y); _line->view_to_model_coord_y (y);
if (!list->editor_add (dp.when, y, false)) { list->editor_add (dp.when, y, false);
failed = true;
break;
}
} }
if (failed) { if (thin) {
/* XXX do something */ list->thin (50.0);
return;
} }
list->thin (1.0);
if (_control->automation_state () == ARDOUR::Off) { if (_control->automation_state () == ARDOUR::Off) {
set_automation_state (ARDOUR::Play); set_automation_state (ARDOUR::Play);
} }

View File

@ -154,7 +154,7 @@ public:
}; };
typedef std::vector<DrawnPoint> DrawnPoints; typedef std::vector<DrawnPoint> DrawnPoints;
void merge_drawn_line (DrawnPoints const &); void merge_drawn_line (DrawnPoints const &, bool thin);
protected: protected:
/* Note that for MIDI controller "automation" (in regions), all of these /* 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) , dragging_line (nullptr)
, direction (0) , direction (0)
, edge_x (0) , edge_x (0)
, did_snap (false)
{ {
DEBUG_TRACE (DEBUG::Drags, "New AutomationDrawDrag\n"); 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 ()); timepos_t pos (_drags->current_pointer_time ());
_editor->snap_to_with_modifier (pos, ev); _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); double const pointer_x = _editor->time_to_pixel (pos);
ArdourCanvas::Rect r = base_rect.item_to_canvas (base_rect.get()); ArdourCanvas::Rect r = base_rect.item_to_canvas (base_rect.get());
@ -7346,11 +7352,13 @@ AutomationDrawDrag::finished (GdkEvent* event, bool motion_occured)
return; 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 void
AutomationDrawDrag::aborted (bool) AutomationDrawDrag::aborted (bool)
{ {
} }

View File

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