diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 16129ae2e1..4ef185ed5a 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -7540,3 +7540,81 @@ VelocityLineDrag::aborted (bool) { vd->end_line_drag (false); } + +ClipStartDrag::ClipStartDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, Temporal::timepos_t const & os) + : Drag (ec, &r, os.time_domain(), nullptr, false) + , dragging_rect (&r) + , original_start (os) +{ +} + +ClipStartDrag::~ClipStartDrag () +{ +} + +void +ClipStartDrag::start_grab (GdkEvent* ev,Gdk::Cursor* c) +{ + Drag::start_grab (ev, c); +} + +bool +ClipStartDrag::end_grab (GdkEvent* ev) +{ + Drag::end_grab (ev); + return false; +} + +void +ClipStartDrag::motion (GdkEvent*, bool) +{ +} + +void +ClipStartDrag::finished (GdkEvent*, bool) +{ +} + +void +ClipStartDrag::aborted (bool) +{ +} + +ClipEndDrag::ClipEndDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, Temporal::timepos_t const & oe) + : Drag (ec, &r, oe.time_domain(), nullptr, false) + , dragging_rect (&r) + , original_end (oe) +{ +} + +ClipEndDrag::~ClipEndDrag () +{ +} + +void +ClipEndDrag::start_grab (GdkEvent* ev,Gdk::Cursor* c) +{ + Drag::start_grab (ev, c); +} + +bool +ClipEndDrag::end_grab (GdkEvent* ev) +{ + Drag::end_grab (ev); + return false; +} + +void +ClipEndDrag::motion (GdkEvent*, bool) +{ +} + +void +ClipEndDrag::finished (GdkEvent*, bool) +{ +} + +void +ClipEndDrag::aborted (bool) +{ +} diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index cd9a9fe879..9775da2389 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -1640,6 +1640,39 @@ class VelocityLineDrag : public FreehandLineDrag r) } view->set_region (r); + view->show_start (true); + view->show_end (true); /* Compute zoom level to show entire source plus some margin if possible */ @@ -1815,7 +1817,8 @@ MidiCueEditor::set_region (std::shared_ptr r) { EditingContext::TempoMapScope tms (*this, map); double width = bg->width(); - samplecnt_t samples = duration.samples(); + /* make it 20% wider than we need */ + samplecnt_t samples = (samplecnt_t) floor (1.2 * duration.samples()); std::cerr << "new spp from " << samples << " / " << width << std::endl; samplecnt_t spp = floor (samples / width); reset_zoom (spp); diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 97dd279a8f..8a74295e9d 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -122,6 +122,8 @@ MidiView::MidiView (std::shared_ptr mt, , _channel_selection_scoped_note (0) , _mouse_state(None) , _pressed_button(0) + , _start_boundary_rect (nullptr) + , _end_boundary_rect (nullptr) , _optimization_iterator (_events.end()) , _list_editor (nullptr) , _no_sound_notes (false) @@ -184,6 +186,52 @@ MidiView::init (std::shared_ptr mt) _midi_context.NoteRangeChanged.connect (sigc::mem_fun (*this, &MidiView::view_changed)); } +void +MidiView::show_start (bool yn) +{ + if (!yn) { + delete _start_boundary_rect; + _start_boundary_rect = nullptr; + return; + } + + if (!_midi_region) { + return; + } + + if (!_start_boundary_rect) { + _start_boundary_rect = new ArdourCanvas::Rectangle (_note_group->parent()); + _start_boundary_rect->set_fill_color (0xff000087); + _start_boundary_rect->set_outline_color (0xff0000ff); + } + + double width = _editing_context.sample_to_pixel (_midi_region->start().samples()); + _start_boundary_rect->set (ArdourCanvas::Rect (0., 0., width, height())); +} + +void +MidiView::show_end (bool yn) +{ + if (!yn) { + delete _end_boundary_rect; + _end_boundary_rect = nullptr; + return; + } + + if (!_midi_region) { + return; + } + + if (!_end_boundary_rect) { + _end_boundary_rect = new ArdourCanvas::Rectangle (_note_group->parent()); + _end_boundary_rect->set_fill_color (0xff000087); + _end_boundary_rect->set_outline_color (0xff0000ff); + } + + double offset = _editing_context.sample_to_pixel ((_midi_region->start() + _midi_region->length()).samples()); + _end_boundary_rect->set (ArdourCanvas::Rect (offset, 0., ArdourCanvas::COORD_MAX, height())); +} + void MidiView::set_track (std::shared_ptr mt) { diff --git a/gtk2_ardour/midi_view.h b/gtk2_ardour/midi_view.h index 17bb434437..601042bdf2 100644 --- a/gtk2_ardour/midi_view.h +++ b/gtk2_ardour/midi_view.h @@ -348,6 +348,9 @@ class MidiView : public virtual sigc::trackable, public LineMerger void select_self () { select_self (false); } virtual void select_self_uniquely () {} + void show_start (bool yn); + void show_end (bool yn); + protected: void init (std::shared_ptr); virtual void region_resized (const PBD::PropertyChange&); @@ -505,6 +508,8 @@ class MidiView : public virtual sigc::trackable, public LineMerger NoteBase* _channel_selection_scoped_note; MouseState _mouse_state; int _pressed_button; + ArdourCanvas::Rectangle* _start_boundary_rect; + ArdourCanvas::Rectangle* _end_boundary_rect; /** Currently selected NoteBase objects */ Selection _selection;