13
0

skeleton for clip start/end editing

This commit is contained in:
Paul Davis 2024-11-12 18:54:41 -07:00
parent e7b10fc37d
commit 48ed5be776
6 changed files with 170 additions and 1 deletions

View File

@ -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)
{
}

View File

@ -1640,6 +1640,39 @@ class VelocityLineDrag : public FreehandLineDrag<Evoral::ControlList::OrderedPoi
bool drag_did_change;
};
class ClipStartDrag : public Drag
{
public:
ClipStartDrag (EditingContext&, ArdourCanvas::Rectangle &, Temporal::timepos_t const &);
~ClipStartDrag ();
void start_grab (GdkEvent*,Gdk::Cursor*);
bool end_grab (GdkEvent*);
void motion (GdkEvent*, bool);
void finished (GdkEvent*, bool);
void aborted (bool);
private:
ArdourCanvas::Rectangle* dragging_rect;
Temporal::timepos_t original_start;
};
class ClipEndDrag : public Drag
{
public:
ClipEndDrag (EditingContext&, ArdourCanvas::Rectangle &, Temporal::timepos_t const &);
~ClipEndDrag ();
void start_grab (GdkEvent*,Gdk::Cursor*);
bool end_grab (GdkEvent*);
void motion (GdkEvent*, bool);
void finished (GdkEvent*, bool);
void aborted (bool);
private:
ArdourCanvas::Rectangle* dragging_rect;
Temporal::timepos_t original_end;
};
#endif /* __gtk2_ardour_editor_drag_h_ */

View File

@ -69,6 +69,8 @@ enum ItemType {
GridZoneItem,
VelocityItem,
VelocityBaseItem,
ClipStartItem,
ClipEndItem,
/* don't remove this */

View File

@ -1793,6 +1793,8 @@ MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiRegion> 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<ARDOUR::MidiRegion> 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);

View File

@ -122,6 +122,8 @@ MidiView::MidiView (std::shared_ptr<MidiTrack> 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<MidiTrack> 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<MidiTrack> mt)
{

View File

@ -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<ARDOUR::MidiTrack>);
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;