cue editor end dragging operational

This commit is contained in:
Paul Davis 2024-11-26 13:11:17 -07:00
parent af0162c73c
commit 2096ff7876
4 changed files with 40 additions and 14 deletions

View file

@ -7547,7 +7547,6 @@ ClipStartDrag::ClipStartDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, Mi
, mce (m) , mce (m)
, dragging_rect (&r) , dragging_rect (&r)
, original_rect (r.get()) , original_rect (r.get())
, _cumulative_dx (0)
{ {
} }
@ -7595,7 +7594,6 @@ ClipStartDrag::finished (GdkEvent* event, bool movement_occured)
timepos_t pos = adjusted_current_time (event); timepos_t pos = adjusted_current_time (event);
editing_context.snap_to_with_modifier (pos, event, Temporal::RoundNearest, ARDOUR::SnapToGrid_Scaled, true); editing_context.snap_to_with_modifier (pos, event, Temporal::RoundNearest, ARDOUR::SnapToGrid_Scaled, true);
std::cerr << "drag to " << pos.beats().str() << std::endl;
mce.set_trigger_start (pos); mce.set_trigger_start (pos);
} }
@ -7605,10 +7603,11 @@ ClipStartDrag::aborted (bool)
dragging_rect->set (original_rect); dragging_rect->set (original_rect);
} }
ClipEndDrag::ClipEndDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, Temporal::timepos_t const & oe) ClipEndDrag::ClipEndDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, MidiCueEditor& m)
: Drag (ec, &r, oe.time_domain(), nullptr, false) : Drag (ec, &r, Temporal::BeatTime, nullptr, false)
, mce (m)
, dragging_rect (&r) , dragging_rect (&r)
, original_end (oe) , original_rect (r.get())
{ {
} }
@ -7632,14 +7631,35 @@ ClipEndDrag::end_grab (GdkEvent* ev)
void void
ClipEndDrag::motion (GdkEvent*, bool) ClipEndDrag::motion (GdkEvent*, bool)
{ {
ArdourCanvas::Rect r (original_rect);
double pix = current_pointer_x();
double crx1 = dragging_rect->item_to_canvas (Duple (r.x0, 0.)).x;
if (pix > editing_context.timeline_origin()) {
r.x0 = dragging_rect->parent()->canvas_to_item (Duple (pix, 0.0)).x;
} else {
r.x0 = r.x1 - 1.;
}
dragging_rect->set (r);
} }
void void
ClipEndDrag::finished (GdkEvent*, bool) ClipEndDrag::finished (GdkEvent* event, bool movement_occured)
{ {
if (!movement_occured) {
dragging_rect->set (original_rect);
return;
}
timepos_t pos = adjusted_current_time (event);
editing_context.snap_to_with_modifier (pos, event, Temporal::RoundNearest, ARDOUR::SnapToGrid_Scaled, true);
mce.set_trigger_end (pos);
} }
void void
ClipEndDrag::aborted (bool) ClipEndDrag::aborted (bool)
{ {
dragging_rect->set (original_rect);
} }

View file

@ -1657,13 +1657,12 @@ class ClipStartDrag : public Drag
MidiCueEditor& mce; MidiCueEditor& mce;
ArdourCanvas::Rectangle* dragging_rect; ArdourCanvas::Rectangle* dragging_rect;
ArdourCanvas::Rect original_rect; ArdourCanvas::Rect original_rect;
double _cumulative_dx;
}; };
class ClipEndDrag : public Drag class ClipEndDrag : public Drag
{ {
public: public:
ClipEndDrag (EditingContext&, ArdourCanvas::Rectangle &, Temporal::timepos_t const &); ClipEndDrag (EditingContext&, ArdourCanvas::Rectangle &, MidiCueEditor& m);
~ClipEndDrag (); ~ClipEndDrag ();
void start_grab (GdkEvent*,Gdk::Cursor*); void start_grab (GdkEvent*,Gdk::Cursor*);
@ -1673,9 +1672,9 @@ class ClipEndDrag : public Drag
void aborted (bool); void aborted (bool);
private: private:
MidiCueEditor& mce;
ArdourCanvas::Rectangle* dragging_rect; ArdourCanvas::Rectangle* dragging_rect;
Temporal::timepos_t original_end; ArdourCanvas::Rect original_rect;
}; };
#endif /* __gtk2_ardour_editor_drag_h_ */ #endif /* __gtk2_ardour_editor_drag_h_ */

View file

@ -513,6 +513,12 @@ MidiCueEditor::set_trigger_start (Temporal::timepos_t const & p)
ref.trigger()->the_region()->trim_front (p); ref.trigger()->the_region()->trim_front (p);
} }
void
MidiCueEditor::set_trigger_end (Temporal::timepos_t const & p)
{
ref.trigger()->the_region()->trim_end (p);
}
Gtk::Widget& Gtk::Widget&
MidiCueEditor::viewport() MidiCueEditor::viewport()
{ {
@ -670,7 +676,7 @@ MidiCueEditor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event
case ClipEndItem: { case ClipEndItem: {
ArdourCanvas::Rectangle* r = dynamic_cast<ArdourCanvas::Rectangle*> (item); ArdourCanvas::Rectangle* r = dynamic_cast<ArdourCanvas::Rectangle*> (item);
if (r) { if (r) {
_drags->set (new ClipEndDrag (*this, *r, timepos_t (BeatTime)), event); _drags->set (new ClipEndDrag (*this, *r, *this), event);
} }
return true; return true;
break; break;

View file

@ -252,8 +252,9 @@ MidiView::show_end (bool yn)
if (!_end_boundary_rect) { if (!_end_boundary_rect) {
_end_boundary_rect = new ArdourCanvas::Rectangle (_note_group->parent()); _end_boundary_rect = new ArdourCanvas::Rectangle (_note_group->parent());
_end_boundary_rect->set_fill_color (0xff000043); _end_boundary_rect->set_outline_what (ArdourCanvas::Rectangle::LEFT);
_end_boundary_rect->set_outline_color (0xff0000ff); _end_boundary_rect->set_fill_color (UIConfiguration::instance().color_mod ("cue editor end rect fill", "cue boundary alpha"));
_end_boundary_rect->set_outline_color (UIConfiguration::instance().color ("cue editor end rect outline"));
_end_boundary_rect->Event.connect (sigc::mem_fun (*this, &MidiView::end_boundary_event)); _end_boundary_rect->Event.connect (sigc::mem_fun (*this, &MidiView::end_boundary_event));
} }
@ -280,7 +281,7 @@ MidiView::size_end_rect ()
double offset = _editing_context.sample_to_pixel ((_midi_region->start() + _midi_region->length()).samples()); double offset = _editing_context.sample_to_pixel ((_midi_region->start() + _midi_region->length()).samples());
std::cerr << "end starts at " << (_midi_region->start() + _midi_region->length()).beats().str() << " aka " << offset << " from " << (_midi_region->start() + _midi_region->length()).samples() << std::endl; std::cerr << "end starts at " << (_midi_region->start() + _midi_region->length()).beats().str() << " aka " << offset << " from " << (_midi_region->start() + _midi_region->length()).samples() << std::endl;
_end_boundary_rect->set (ArdourCanvas::Rect (offset, 0., offset + 10., height())); _end_boundary_rect->set (ArdourCanvas::Rect (offset, 0., ArdourCanvas::COORD_MAX, height()));
} }
void void