Compare commits

...

2 Commits

5 changed files with 54 additions and 14 deletions

View File

@ -70,6 +70,7 @@
#include "gui_thread.h"
#include "keyboard.h"
#include "mergeable_line.h"
#include "midi_cue_editor.h"
#include "midi_region_view.h"
#include "midi_selection.h"
#include "midi_time_axis.h"
@ -7541,12 +7542,13 @@ 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)
ClipStartDrag::ClipStartDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, MidiCueEditor& m)
: Drag (ec, &r, Temporal::BeatTime, nullptr, false)
, mce (m)
, dragging_rect (&r)
, original_start (os)
, original_rect (r.get())
, _cumulative_dx (0)
{
std::cerr << "CSD!\n";
}
ClipStartDrag::~ClipStartDrag ()
@ -7567,20 +7569,39 @@ ClipStartDrag::end_grab (GdkEvent* ev)
}
void
ClipStartDrag::motion (GdkEvent*, bool)
ClipStartDrag::motion (GdkEvent* event, bool first_move)
{
std::cerr << "clip start drag\n";
double dx = current_pointer_x () - last_pointer_x ();
_cumulative_dx += dx;
ArdourCanvas::Rect r (original_rect);
if (_cumulative_dx > r.x1) {
r.x1 = r.x1 + _cumulative_dx;
} else {
r.x1 = r.x0 + 1.;
}
dragging_rect->set (r);
}
void
ClipStartDrag::finished (GdkEvent*, bool)
ClipStartDrag::finished (GdkEvent* event, bool movement_occured)
{
std::cerr << "clip start drag ALL DONE\n";
if (!movement_occured) {
dragging_rect->set (original_rect);
return;
}
Temporal::Beats b (random() % 12, 0);
std::cerr << "set start @ " << b.str() << std::endl;
mce.set_trigger_start (timepos_t (b));
}
void
ClipStartDrag::aborted (bool)
{
dragging_rect->set (original_rect);
}
ClipEndDrag::ClipEndDrag (EditingContext& ec, ArdourCanvas::Rectangle& r, Temporal::timepos_t const & oe)

View File

@ -70,6 +70,7 @@ class EditingContext;
class Editor;
class EditorCursor;
class TimeAxisView;
class MidiCueEditor;
class MidiTimeAxisView;
class Drag;
class NoteBase;
@ -1643,7 +1644,7 @@ class VelocityLineDrag : public FreehandLineDrag<Evoral::ControlList::OrderedPoi
class ClipStartDrag : public Drag
{
public:
ClipStartDrag (EditingContext&, ArdourCanvas::Rectangle &, Temporal::timepos_t const &);
ClipStartDrag (EditingContext&, ArdourCanvas::Rectangle &, MidiCueEditor& m);
~ClipStartDrag ();
void start_grab (GdkEvent*,Gdk::Cursor*);
@ -1653,8 +1654,10 @@ class ClipStartDrag : public Drag
void aborted (bool);
private:
MidiCueEditor& mce;
ArdourCanvas::Rectangle* dragging_rect;
Temporal::timepos_t original_start;
ArdourCanvas::Rect original_rect;
double _cumulative_dx;
};
class ClipEndDrag : public Drag

View File

@ -507,6 +507,12 @@ MidiCueEditor::canvas_cue_end_event (GdkEvent* event, ArdourCanvas::Item* item)
return typed_event (item, event, ClipEndItem);
}
void
MidiCueEditor::set_trigger_start (Temporal::timepos_t const & p)
{
ref.trigger()->the_region()->set_start (p);
}
Gtk::Widget&
MidiCueEditor::viewport()
{
@ -655,7 +661,7 @@ MidiCueEditor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event
case ClipStartItem: {
ArdourCanvas::Rectangle* r = dynamic_cast<ArdourCanvas::Rectangle*> (item);
if (r) {
_drags->set (new ClipStartDrag (*this, *r, timepos_t (BeatTime)), event);
_drags->set (new ClipStartDrag (*this, *r, *this), event);
}
return true;
break;

View File

@ -113,6 +113,11 @@ class MidiCueEditor : public CueEditor
void set_visible_channel (int chan);
void set_trigger_start (Temporal::timepos_t const &);
void set_trigger_end (Temporal::timepos_t const &);
void set_trigger_length (Temporal::timecnt_t const &);
void set_trigger_bounds (Temporal::timepos_t const &, Temporal::timepos_t const &);
protected:
void register_actions ();

View File

@ -721,7 +721,7 @@ void
Trigger::set_region_internal (std::shared_ptr<Region> r)
{
region_connection.disconnect ();
/* No whole file regions in the triggerbox, just like we do not allow
* them in playlists either.
*/
@ -740,7 +740,10 @@ Trigger::set_region_internal (std::shared_ptr<Region> r)
void
Trigger::region_property_change (PropertyChange const & what_changed)
{
//std::cerr << "region prop change\n";
if (what_changed.contains (Properties::start) || what_changed.contains (Properties::length)) {
//std::cerr << "bounds changed\n";
//PBD::stacktrace (std::cerr, 23);
bounds_changed (_region->start(), _region->end());
}
}
@ -2395,7 +2398,7 @@ MIDITrigger::check_edit_swap (timepos_t const & time, bool playing, BufferSet& b
return;
}
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1/%2 noticed pending swap\n", _box.order(), index()));
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1/%2 noticed pending swap @ %3\n", _box.order(), index(), pending));
if (pending->rt_midibuffer) {
if (playing) {
@ -2431,7 +2434,7 @@ MIDITrigger::check_edit_swap (timepos_t const & time, bool playing, BufferSet& b
}
}
adjust_bounds (pending->play_start, pending->play_end, pending->length, false);
adjust_bounds (pending->play_start, pending->play_end, pending->length, true);
pending->rt_midibuffer = old_rtmb;
old_pending_swap.store (pending);
@ -3177,6 +3180,7 @@ MIDITrigger::model_contents_changed ()
/* And set it. RT thread will find this and do what needs to be done */
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1/%2 pushed pending swap @ %3 for model contents change\n", _box.order(), index(), pending));
pending_swap.store (pending);
/* Clean up a previous RT midi buffer swap */
@ -3201,6 +3205,7 @@ MIDITrigger::bounds_changed (Temporal::timepos_t const & start, Temporal::timepo
/* And set it. RT thread will find this and do what needs to be done */
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1/%2 pushed pending swap @ %3 for bounds change\n", _box.order(), index(), pending));
pending_swap.store (pending);
/* Clean up a previous RT midi buffer swap (if there is one) */