From 57271c81ff56fce56f1674e7f88c8739771cab45 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 25 Apr 2011 15:23:44 +0000 Subject: implemented event clipping --- muse2/muse/midiedit/scoreedit.cpp | 54 ++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index ee3f658c..60558c91 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -2863,6 +2863,12 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) newevent.setTick(relative_tick); newevent.setLenTick((new_len>0)?new_len:last_len); + if (newevent.endTick() > curr_part->lenTick()) + { + cout << "DEBUG: clipping inserted note from len="<msgDeleteEvent(dragged_event, dragged_event_part, false, false, false); } else @@ -2977,9 +2983,30 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) if (dragged_event.tick()+dragged_event_part->tick() != unsigned(tick)) //TODO FINDMICHJETZT tick kann unsigned werden { Event tmp=dragged_event.clone(); + signed relative_tick=tick-signed(dragged_event_part->tick()); - if (tick-signed(dragged_event_part->tick()) >= 0) //TODO FINDMICH do that better - tmp.setTick(tick-dragged_event_part->tick()); + if (relative_tick >= 0) + tmp.setTick(relative_tick); + else + { + tmp.setTick(0); + cout << "DEBUG: not moving note before begin of part; setting it directly to the begin" << endl; + } + + if (tmp.endTick() > dragged_event_part->lenTick()) + { + signed new_len=dragged_event_part->lenTick() - tmp.tick(); + if (new_len>=0) + { + tmp.setLenTick(dragged_event_part->lenTick() - tmp.tick()); + cout << "DEBUG: moved note would exceed its part; clipping length to " << tmp.lenTick() << endl; + } + else + { + tmp.setLenTick(0); + cout << "DEBUG: moved note would exceed its part; clipping length to 0 (actually negative)" << endl; + } + } audio->msgChangeEvent(dragged_event, tmp, dragged_event_part, false, false, false); dragged_event=tmp; @@ -2994,9 +3021,22 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) if (dragged_event.tick()+dragged_event.lenTick() + dragged_event_part->tick() != unsigned(tick)) { Event tmp=dragged_event.clone(); + signed relative_tick=tick-signed(dragged_event_part->tick()); + signed new_len=relative_tick-dragged_event.tick(); + + if (new_len>=0) + tmp.setLenTick(new_len); + else + { + tmp.setLenTick(0); + cout << "DEBUG: not setting len to a negative value. using 0 instead" << endl; + } - if (tick-signed(dragged_event.tick() -dragged_event_part->tick()) >= 0) //TODO FINDMICH do that better - tmp.setLenTick(tick-dragged_event.tick() -dragged_event_part->tick()); + if (tmp.endTick() > dragged_event_part->lenTick()) + { + tmp.setLenTick(dragged_event_part->lenTick() - tmp.tick()); + cout << "DEBUG: resized note would exceed its part; limiting length to " << tmp.lenTick() << endl; + } audio->msgChangeEvent(dragged_event, tmp, dragged_event_part, false, false, false); dragged_event=tmp; @@ -3387,8 +3427,8 @@ set staff_t::parts_at_tick(unsigned tick) * x nothing atm * * IMPORTANT TODO - * o when inserting or moving or resizing a note: clip to part's boundaries * o invalidate len-buttons for lens which are outside of the quantisation setting + * o add toolbar for new note's velocities * o implement color=velocity * * less important stuff -- cgit v1.2.3