further adventures in drag-refactoring do that LineDrag can be used in MidiCueEditor also
This commit is contained in:
parent
302337e8fd
commit
01068fe306
@ -509,6 +509,7 @@ public:
|
||||
void make_region_markers_global (bool as_cd_markers);
|
||||
|
||||
bool rb_click (GdkEvent*, Temporal::timepos_t const &);
|
||||
void line_drag_click (GdkEvent*, Temporal::timepos_t const &, double);
|
||||
|
||||
protected:
|
||||
void map_transport_state ();
|
||||
|
@ -4938,8 +4938,8 @@ ControlPointDrag::active (Editing::MouseMode m)
|
||||
return dynamic_cast<AutomationLine*> (&(_point->line ())) != 0;
|
||||
}
|
||||
|
||||
LineDrag::LineDrag (Editor& e, ArdourCanvas::Item* i)
|
||||
: EditorDrag (e, i, e.time_domain (), e.get_trackview_group())
|
||||
LineDrag::LineDrag (EditingContext& e, ArdourCanvas::Item* i, std::function<void(GdkEvent*,timepos_t const &,double)> cf)
|
||||
: Drag (e, i, e.time_domain (), e.get_trackview_group())
|
||||
, _line (0)
|
||||
, _fixed_grab_x (0.0)
|
||||
, _fixed_grab_y (0.0)
|
||||
@ -4947,6 +4947,7 @@ LineDrag::LineDrag (Editor& e, ArdourCanvas::Item* i)
|
||||
, _before (0)
|
||||
, _after (0)
|
||||
, have_command (false)
|
||||
, click_functor (cf)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Drags, "New LineDrag\n");
|
||||
}
|
||||
@ -5049,27 +5050,10 @@ LineDrag::finished (GdkEvent* event, bool movement_occurred)
|
||||
editing_context.commit_reversible_command ();
|
||||
have_command = false;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* add a new control point on the line */
|
||||
|
||||
AutomationTimeAxisView* atv;
|
||||
|
||||
if ((atv = dynamic_cast<AutomationTimeAxisView*> (_editor.clicked_axisview)) != 0) {
|
||||
timepos_t where = grab_time ();
|
||||
|
||||
double cx = 0;
|
||||
double cy = _fixed_grab_y;
|
||||
|
||||
_line->grab_item ().item_to_canvas (cx, cy);
|
||||
|
||||
atv->add_automation_event (event, where, cy, false);
|
||||
} else if (dynamic_cast<AudioTimeAxisView*> (_editor.clicked_axisview) != 0) {
|
||||
AudioRegionView* arv;
|
||||
|
||||
if ((arv = dynamic_cast<AudioRegionView*> (_editor.clicked_regionview)) != 0) {
|
||||
arv->add_gain_point_event (&arv->fx_line ()->grab_item (), event, false);
|
||||
}
|
||||
}
|
||||
click_functor (event, grab_time(), _fixed_grab_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1233,10 +1233,10 @@ private:
|
||||
};
|
||||
|
||||
/** Gain or automation line drag */
|
||||
class LineDrag : public EditorDrag
|
||||
class LineDrag : public Drag
|
||||
{
|
||||
public:
|
||||
LineDrag (Editor&e, ArdourCanvas::Item *i);
|
||||
LineDrag (EditingContext &e, ArdourCanvas::Item *i, std::function<void(GdkEvent*,Temporal::timepos_t const &,double)>);
|
||||
~LineDrag ();
|
||||
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
@ -1257,6 +1257,7 @@ private:
|
||||
uint32_t _before;
|
||||
uint32_t _after;
|
||||
bool have_command;
|
||||
std::function<void(GdkEvent*,Temporal::timepos_t const &,double)> click_functor;
|
||||
};
|
||||
|
||||
/** Transient feature line drags*/
|
||||
|
@ -848,7 +848,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
||||
return true;
|
||||
|
||||
case GainLineItem:
|
||||
_drags->set (new LineDrag (*this, item), event);
|
||||
_drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double y) { line_drag_click (ev, pos, y); }), event);
|
||||
return true;
|
||||
break;
|
||||
|
||||
@ -858,7 +858,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
||||
break;
|
||||
|
||||
case EditorAutomationLineItem:
|
||||
_drags->set (new LineDrag (*this, item), event);
|
||||
_drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double y) { line_drag_click (ev, pos, y); }), event);
|
||||
return true;
|
||||
break;
|
||||
|
||||
@ -999,7 +999,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
||||
break;
|
||||
|
||||
case EditorAutomationLineItem:
|
||||
_drags->set (new LineDrag (*this, item), event);
|
||||
_drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double y) { line_drag_click (ev, pos, y); }), event);
|
||||
return true;
|
||||
break;
|
||||
|
||||
@ -1062,7 +1062,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
||||
case MouseDraw:
|
||||
switch (item_type) {
|
||||
case GainLineItem:
|
||||
_drags->set (new LineDrag (*this, item), event);
|
||||
_drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double y) { line_drag_click (ev, pos, y); }), event);
|
||||
return true;
|
||||
|
||||
case ControlPointItem:
|
||||
@ -2617,3 +2617,22 @@ Editor::rb_click (GdkEvent* event, timepos_t const & where)
|
||||
|
||||
return do_deselect;
|
||||
}
|
||||
|
||||
void
|
||||
Editor::line_drag_click (GdkEvent* event, timepos_t const & where, double y)
|
||||
{
|
||||
AutomationTimeAxisView* atv;
|
||||
|
||||
if ((atv = dynamic_cast<AutomationTimeAxisView*> (clicked_axisview)) != 0) {
|
||||
|
||||
atv->add_automation_event (event, where, y, false);
|
||||
|
||||
} else if (dynamic_cast<AudioTimeAxisView*> (clicked_axisview) != 0) {
|
||||
|
||||
AudioRegionView* arv;
|
||||
|
||||
if ((arv = dynamic_cast<AudioRegionView*> (clicked_regionview)) != 0) {
|
||||
arv->add_gain_point_event (&arv->fx_line ()->grab_item (), event, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -563,6 +563,13 @@ MidiCueEditor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event
|
||||
case EditorAutomationLineItem: {
|
||||
ARDOUR::SelectionOperation op = ArdourKeyboard::selection_type (event->button.state);
|
||||
select_automation_line (&event->button, item, op);
|
||||
switch (mouse_mode) {
|
||||
case Editing::MouseContent:
|
||||
_drags->set (new LineDrag (*this, item, [&](GdkEvent* ev,timepos_t const & pos, double) { view->line_drag_click (ev, pos); }), event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -318,3 +318,9 @@ MidiCueView::automation_rb_click (GdkEvent* event, Temporal::timepos_t const & p
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
MidiCueView::line_drag_click (GdkEvent* event, Temporal::timepos_t const & pos)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,6 +60,7 @@ class MidiCueView : public MidiView
|
||||
MergeableLine* make_merger ();
|
||||
|
||||
bool automation_rb_click (GdkEvent*, Temporal::timepos_t const &);
|
||||
void line_drag_click (GdkEvent*, Temporal::timepos_t const &);
|
||||
|
||||
protected:
|
||||
bool scroll (GdkEventScroll* ev);
|
||||
|
Loading…
Reference in New Issue
Block a user