automation drawing: add point at grab start & use new ControlList API for speed

This commit is contained in:
Paul Davis 2023-07-10 11:20:40 -06:00
parent 45b02538e6
commit 6453049c0a
4 changed files with 28 additions and 29 deletions

View File

@ -791,7 +791,7 @@ AutomationTimeAxisView::build_display_menu ()
}
void
AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points, bool thin)
AutomationTimeAxisView::merge_drawn_line (Evoral::ControlList::OrderedPoints& points, bool thin)
{
if (points.empty()) {
return;
@ -820,21 +820,23 @@ AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points, bool thin)
swap (earliest, latest);
}
list->erase_range (earliest, latest);;
for (auto const & dp : points) {
/* Convert each point's "value" from geometric coordinate space to
* value space for the control
*/
for (auto & dp : points) {
/* compute vertical fractional position */
double y = 1.0 - (dp.y / _line->height());
dp.value = 1.0 - (dp.value / _line->height());
/* map using line */
_line->view_to_model_coord_y (y);
list->editor_add (dp.when, y, false);
_line->view_to_model_coord_y (dp.value);
}
list->freeze ();
list->editor_add_ordered (points, false);
if (thin) {
list->thin (50.0);
}
list->thaw ();
if (_control->automation_state () == ARDOUR::Off) {
set_automation_state (ARDOUR::Play);
@ -844,7 +846,6 @@ AutomationTimeAxisView::merge_drawn_line (DrawnPoints const & points, bool thin)
RouteTimeAxisView::signal_ctrl_touched (false);
}
XMLNode& after = list->get_state();
_editor.begin_reversible_command (_("draw automation"));
_session->add_command (new MementoCommand<ARDOUR::AutomationList> (*list.get (), &before, &after));

View File

@ -147,14 +147,7 @@ public:
void set_selected_regionviews (RegionSelection&);
struct DrawnPoint {
DrawnPoint (Temporal::timepos_t w, double v) : when (w), y (v) {}
Temporal::timepos_t when;
double y;
};
typedef std::vector<DrawnPoint> DrawnPoints;
void merge_drawn_line (DrawnPoints const &, bool thin);
void merge_drawn_line (Evoral::ControlList::OrderedPoints&, bool thin);
protected:
/* Note that for MIDI controller "automation" (in regions), all of these

View File

@ -7258,12 +7258,6 @@ AutomationDrawDrag::~AutomationDrawDrag ()
delete dragging_line;
}
void
AutomationDrawDrag::start_grab (GdkEvent* ev, Gdk::Cursor* c)
{
Drag::start_grab (ev, c);
}
void
AutomationDrawDrag::motion (GdkEvent* ev, bool first_move)
{
@ -7278,10 +7272,19 @@ AutomationDrawDrag::motion (GdkEvent* ev, bool first_move)
direction = -1;
}
edge_x = grab_x ();
/* Add a point correspding to the start of the drag */
maybe_add_point (ev, raw_grab_time());
}
timepos_t pos (_drags->current_pointer_time ());
maybe_add_point (ev, _drags->current_pointer_time());
}
void
AutomationDrawDrag::maybe_add_point (GdkEvent* ev, timepos_t const & cpos)
{
timepos_t pos (cpos);
_editor->snap_to_with_modifier (pos, ev);
if (pos != _drags->current_pointer_time()) {
@ -7333,7 +7336,7 @@ AutomationDrawDrag::motion (GdkEvent* ev, bool first_move)
if (add_point) {
if (drawn_points.empty() || (pos != drawn_points.back().when)) {
dragging_line->add_point (ArdourCanvas::Duple (x, y));
drawn_points.push_back (AutomationTimeAxisView::DrawnPoint (pos, y));
drawn_points.push_back (Evoral::ControlList::OrderedPoint (pos, y));
}
edge_x = x;
}

View File

@ -35,11 +35,12 @@
#include "ardour/tempo.h"
#include "ardour/types.h"
#include "evoral/ControlList.h"
#include "canvas/types.h"
#include "gtkmm2ext/bindings.h"
#include "automation_time_axis.h"
#include "cursor_context.h"
#include "editor_items.h"
#include "mouse_cursors.h"
@ -1586,7 +1587,6 @@ class AutomationDrawDrag : public Drag
AutomationDrawDrag (Editor*, ArdourCanvas::Rectangle&, Temporal::TimeDomain);
~AutomationDrawDrag ();
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent*, bool);
void finished (GdkEvent*, bool);
void aborted (bool);
@ -1596,8 +1596,10 @@ private:
ArdourCanvas::PolyLine* dragging_line;
int direction;
int edge_x;
AutomationTimeAxisView::DrawnPoints drawn_points;
Evoral::ControlList::OrderedPoints drawn_points;
bool did_snap;
void maybe_add_point (GdkEvent*, Temporal::timepos_t const &);
};
#endif /* __gtk2_ardour_editor_drag_h_ */