diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 703ae52ef6..2ac57c7c9c 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -7547,7 +7547,6 @@ ClipStartDrag::ClipStartDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, Mi , mce (m) , dragging_rect (&r) , 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); 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); } @@ -7605,10 +7603,11 @@ ClipStartDrag::aborted (bool) dragging_rect->set (original_rect); } -ClipEndDrag::ClipEndDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, Temporal::timepos_t const & oe) - : Drag (ec, &r, oe.time_domain(), nullptr, false) +ClipEndDrag::ClipEndDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, MidiCueEditor& m) + : Drag (ec, &r, Temporal::BeatTime, nullptr, false) + , mce (m) , dragging_rect (&r) - , original_end (oe) + , original_rect (r.get()) { } @@ -7632,14 +7631,35 @@ ClipEndDrag::end_grab (GdkEvent* ev) void 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 -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 ClipEndDrag::aborted (bool) { + dragging_rect->set (original_rect); } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index b35a942055..f77bc341be 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -1657,13 +1657,12 @@ class ClipStartDrag : public Drag MidiCueEditor& mce; ArdourCanvas::Rectangle* dragging_rect; ArdourCanvas::Rect original_rect; - double _cumulative_dx; }; class ClipEndDrag : public Drag { public: - ClipEndDrag (EditingContext&, ArdourCanvas::Rectangle &, Temporal::timepos_t const &); + ClipEndDrag (EditingContext&, ArdourCanvas::Rectangle &, MidiCueEditor& m); ~ClipEndDrag (); void start_grab (GdkEvent*,Gdk::Cursor*); @@ -1673,9 +1672,9 @@ class ClipEndDrag : public Drag void aborted (bool); private: + MidiCueEditor& mce; ArdourCanvas::Rectangle* dragging_rect; - Temporal::timepos_t original_end; - + ArdourCanvas::Rect original_rect; }; #endif /* __gtk2_ardour_editor_drag_h_ */ diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 543a3e3284..d2a4c90f42 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -513,6 +513,12 @@ MidiCueEditor::set_trigger_start (Temporal::timepos_t const & 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& MidiCueEditor::viewport() { @@ -670,7 +676,7 @@ MidiCueEditor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event case ClipEndItem: { ArdourCanvas::Rectangle* r = dynamic_cast (item); if (r) { - _drags->set (new ClipEndDrag (*this, *r, timepos_t (BeatTime)), event); + _drags->set (new ClipEndDrag (*this, *r, *this), event); } return true; break; diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 7d22a4a393..de4036018d 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -252,8 +252,9 @@ MidiView::show_end (bool yn) if (!_end_boundary_rect) { _end_boundary_rect = new ArdourCanvas::Rectangle (_note_group->parent()); - _end_boundary_rect->set_fill_color (0xff000043); - _end_boundary_rect->set_outline_color (0xff0000ff); + _end_boundary_rect->set_outline_what (ArdourCanvas::Rectangle::LEFT); + _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)); } @@ -280,7 +281,7 @@ MidiView::size_end_rect () 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; - _end_boundary_rect->set (ArdourCanvas::Rect (offset, 0., offset + 10., height())); + _end_boundary_rect->set (ArdourCanvas::Rect (offset, 0., ArdourCanvas::COORD_MAX, height())); } void