AutomationRangeDrag tweaks for stacked layer view
Use y-pos and height of given TAV *layer* where the drag was initiated.
This commit is contained in:
parent
546d5d09b5
commit
56047a094c
@ -6216,6 +6216,7 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, AutomationTimeAxisView
|
||||
: Drag (editor, atv->base_item ())
|
||||
, _ranges (r)
|
||||
, _y_origin (atv->y_position())
|
||||
, _y_height (atv->effective_height()) // or atv->lines()->front()->height() ?!
|
||||
, _nothing_to_drag (false)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Drags, "New AutomationRangeDrag\n");
|
||||
@ -6223,10 +6224,11 @@ AutomationRangeDrag::AutomationRangeDrag (Editor* editor, AutomationTimeAxisView
|
||||
}
|
||||
|
||||
/** Make an AutomationRangeDrag for region gain lines or MIDI controller regions */
|
||||
AutomationRangeDrag::AutomationRangeDrag (Editor* editor, list<RegionView*> const & v, list<AudioRange> const & r, double y_origin)
|
||||
AutomationRangeDrag::AutomationRangeDrag (Editor* editor, list<RegionView*> const & v, list<AudioRange> const & r, double y_origin, double y_height)
|
||||
: Drag (editor, v.front()->get_canvas_group ())
|
||||
, _ranges (r)
|
||||
, _y_origin (y_origin)
|
||||
, _y_height (y_height)
|
||||
, _nothing_to_drag (false)
|
||||
, _integral (false)
|
||||
{
|
||||
@ -6295,9 +6297,9 @@ AutomationRangeDrag::setup (list<boost::shared_ptr<AutomationLine> > const & lin
|
||||
}
|
||||
|
||||
double
|
||||
AutomationRangeDrag::y_fraction (boost::shared_ptr<AutomationLine> line, double global_y) const
|
||||
AutomationRangeDrag::y_fraction (double global_y) const
|
||||
{
|
||||
return 1.0 - ((global_y - _y_origin) / line->height());
|
||||
return 1.0 - ((global_y - _y_origin) / _y_height);
|
||||
}
|
||||
|
||||
double
|
||||
@ -6442,12 +6444,12 @@ AutomationRangeDrag::motion (GdkEvent*, bool first_move)
|
||||
}
|
||||
|
||||
for (list<Line>::iterator i = _lines.begin(); i != _lines.end(); ++i) {
|
||||
i->line->start_drag_multiple (i->points, y_fraction (i->line, current_pointer_y()), i->state);
|
||||
i->line->start_drag_multiple (i->points, y_fraction (current_pointer_y()), i->state);
|
||||
}
|
||||
}
|
||||
|
||||
for (list<Line>::iterator l = _lines.begin(); l != _lines.end(); ++l) {
|
||||
float const f = y_fraction (l->line, current_pointer_y());
|
||||
float const f = y_fraction (current_pointer_y());
|
||||
/* we are ignoring x position for this drag, so we can just pass in anything */
|
||||
pair<float, float> result;
|
||||
uint32_t ignored;
|
||||
|
@ -1244,7 +1244,7 @@ class AutomationRangeDrag : public Drag
|
||||
{
|
||||
public:
|
||||
AutomationRangeDrag (Editor *, AutomationTimeAxisView *, std::list<ARDOUR::AudioRange> const &);
|
||||
AutomationRangeDrag (Editor *, std::list<RegionView*> const &, std::list<ARDOUR::AudioRange> const &, double y_origin);
|
||||
AutomationRangeDrag (Editor *, std::list<RegionView*> const &, std::list<ARDOUR::AudioRange> const &, double y_origin, double y_height);
|
||||
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void motion (GdkEvent *, bool);
|
||||
@ -1257,7 +1257,7 @@ public:
|
||||
|
||||
private:
|
||||
void setup (std::list<boost::shared_ptr<AutomationLine> > const &);
|
||||
double y_fraction (boost::shared_ptr<AutomationLine>, double global_y_position) const;
|
||||
double y_fraction (double global_y_position) const;
|
||||
double value (boost::shared_ptr<ARDOUR::AutomationList> list, double x) const;
|
||||
|
||||
std::list<ARDOUR::AudioRange> _ranges;
|
||||
@ -1272,6 +1272,7 @@ private:
|
||||
|
||||
std::list<Line> _lines;
|
||||
double _y_origin;
|
||||
double _y_height;
|
||||
bool _nothing_to_drag;
|
||||
bool _integral;
|
||||
};
|
||||
|
@ -1138,18 +1138,25 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
||||
/* MIDI CC or similar -- TODO handle multiple? */
|
||||
list<RegionView*> rvl;
|
||||
rvl.push_back (clicked_regionview);
|
||||
_drags->set (new AutomationRangeDrag (this, rvl, selection->time, clicked_regionview->get_time_axis_view().y_position()), event, _cursors->up_down);
|
||||
_drags->set (new AutomationRangeDrag (this, rvl, selection->time,
|
||||
clicked_regionview->get_time_axis_view().y_position(),
|
||||
clicked_regionview->get_time_axis_view().current_height()),
|
||||
event, _cursors->up_down);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* no shift+drag: only apply to clicked_regionview (if any) */
|
||||
if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) {
|
||||
/* shift+drag: only apply to clicked_regionview (if any) */
|
||||
if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) {
|
||||
if (dynamic_cast<AudioRegionView*>(clicked_regionview) == 0) {
|
||||
return true;
|
||||
}
|
||||
list<RegionView*> rvl;
|
||||
rvl.push_back (clicked_regionview);
|
||||
_drags->set (new AutomationRangeDrag (this, rvl, selection->time, clicked_regionview->get_time_axis_view().y_position()), event, _cursors->up_down);
|
||||
// TODO: handle layer_display() == Stacked
|
||||
_drags->set (new AutomationRangeDrag (this, rvl, selection->time,
|
||||
clicked_regionview->get_time_axis_view().y_position(),
|
||||
clicked_regionview->get_time_axis_view().current_height()),
|
||||
event, _cursors->up_down);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1180,7 +1187,16 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
||||
}
|
||||
/* region-gain drag */
|
||||
if (!rvl.empty ()) {
|
||||
_drags->set (new AutomationRangeDrag (this, rvl, selection->time, tvp.first->y_position()), event, _cursors->up_down);
|
||||
double y_pos = tvp.first->y_position();
|
||||
double height = tvp.first->current_height();
|
||||
StreamView* cv = tvp.first->view ();
|
||||
if (cv->layer_display() == Stacked && cv->layers() > 1) {
|
||||
height /= cv->layers();
|
||||
double yy = event->button.y - _trackview_group->canvas_origin().y;
|
||||
y_pos += floor ((yy - y_pos) / height) * height;
|
||||
}
|
||||
_drags->set (new AutomationRangeDrag (this, rvl, selection->time, y_pos, height),
|
||||
event, _cursors->up_down);
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user