mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-26 06:58:22 +01:00
more preparation for MIDI cue editing to propagate to the slot (trigger)
This commit is contained in:
parent
06d5496f70
commit
fcfa4fecb4
9 changed files with 45 additions and 35 deletions
|
|
@ -401,28 +401,25 @@ MidiCueEditor::toolbox ()
|
|||
}
|
||||
|
||||
void
|
||||
MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiTrack> t, std::shared_ptr<ARDOUR::MidiRegion> r)
|
||||
MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiTrack> t, uint32_t slot_index, std::shared_ptr<ARDOUR::MidiRegion> r)
|
||||
{
|
||||
delete view;
|
||||
view = nullptr;
|
||||
|
||||
if (!t || !r) {
|
||||
bg->set_view (nullptr);
|
||||
prh->set_view (nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
view = new MidiCueView (t, *data_group, *this, *bg, 0xff0000ff);
|
||||
view->set_region (r);
|
||||
view = new MidiCueView (t, r, slot_index, *data_group, *this, *bg, 0xff0000ff);
|
||||
|
||||
bg->set_view (view);
|
||||
prh->set_view (*view);
|
||||
prh->set_view (view);
|
||||
|
||||
double w, h;
|
||||
prh->size_request (w, h);
|
||||
|
||||
/* Move stuff around */
|
||||
|
||||
_timeline_origin = w;
|
||||
|
||||
prh->set_position (Duple (0., n_timebars * timebar_height));
|
||||
data_group->set_position (ArdourCanvas::Duple (w, timebar_height * n_timebars));
|
||||
h_scroll_group->set_position (Duple (w, 0.));
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class MidiCueEditor : public CueEditor
|
|||
int32_t get_grid_beat_divisions (Editing::GridType gt) const { return 1; }
|
||||
int32_t get_grid_music_divisions (Editing::GridType gt, uint32_t event_state) const { return 1; }
|
||||
|
||||
void set_region (std::shared_ptr<ARDOUR::MidiTrack>, std::shared_ptr<ARDOUR::MidiRegion>);
|
||||
void set_region (std::shared_ptr<ARDOUR::MidiTrack>, uint32_t slot_index, std::shared_ptr<ARDOUR::MidiRegion>);
|
||||
|
||||
ArdourCanvas::ScrollGroup* get_hscroll_group () const { return h_scroll_group; }
|
||||
ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const { return cursor_scroll_group; }
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "ardour/midi_region.h"
|
||||
#include "ardour/midi_source.h"
|
||||
#include "ardour/midi_track.h"
|
||||
#include "ardour/triggerbox.h"
|
||||
|
||||
#include "gtkmm2ext/utils.h"
|
||||
|
||||
|
|
@ -33,11 +35,14 @@
|
|||
using namespace Gtkmm2ext;
|
||||
|
||||
MidiCueView::MidiCueView (std::shared_ptr<ARDOUR::MidiTrack> mt,
|
||||
std::shared_ptr<ARDOUR::MidiRegion> region,
|
||||
uint32_t slot_index,
|
||||
ArdourCanvas::Item& parent,
|
||||
EditingContext& ec,
|
||||
MidiViewBackground& bg,
|
||||
uint32_t basic_color)
|
||||
: MidiView (mt, parent, ec, bg, basic_color)
|
||||
, _slot_index (slot_index)
|
||||
{
|
||||
CANVAS_DEBUG_NAME (_note_group, X_("note group for MIDI cue"));
|
||||
|
||||
|
|
@ -55,6 +60,7 @@ MidiCueView::MidiCueView (std::shared_ptr<ARDOUR::MidiTrack> mt,
|
|||
_note_group->raise_to_top ();
|
||||
|
||||
set_extensible (true);
|
||||
set_region (region);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -119,15 +125,11 @@ MidiCueView::set_samples_per_pixel (double spp)
|
|||
reset_width_dependent_items (_editing_context.duration_to_pixels (duration));
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<ARDOUR::MidiModel>
|
||||
MidiCueView::model_to_edit() const
|
||||
{
|
||||
return std::shared_ptr<ARDOUR::MidiModel> (new ARDOUR::MidiModel (*_model, *(midi_region()->midi_source())));
|
||||
}
|
||||
|
||||
void
|
||||
MidiCueView::post_edit (std::shared_ptr<ARDOUR::MidiModel> edited_model, ARDOUR::MidiModel::NoteDiffCommand const & diff_command)
|
||||
MidiCueView::post_edit ()
|
||||
{
|
||||
_model = edited_model;
|
||||
std::cerr << "Post-edit\n";
|
||||
std::shared_ptr<ARDOUR::TriggerBox> tb = _midi_track->triggerbox ();
|
||||
assert (tb);
|
||||
std::dynamic_pointer_cast<ARDOUR::MIDITrigger>(tb->trigger (_slot_index))->edited ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,13 @@ class MidiCueView : public MidiView
|
|||
{
|
||||
public:
|
||||
MidiCueView (std::shared_ptr<ARDOUR::MidiTrack> mt,
|
||||
ArdourCanvas::Item& parent,
|
||||
EditingContext& ec,
|
||||
MidiViewBackground& bg,
|
||||
uint32_t basic_color);
|
||||
std::shared_ptr<ARDOUR::MidiRegion> region,
|
||||
uint32_t slot_index,
|
||||
ArdourCanvas::Item& parent,
|
||||
EditingContext& ec,
|
||||
MidiViewBackground& bg,
|
||||
uint32_t basic_color
|
||||
);
|
||||
|
||||
bool canvas_event (GdkEvent*);
|
||||
void set_samples_per_pixel (double);
|
||||
|
|
@ -51,9 +54,9 @@ class MidiCueView : public MidiView
|
|||
|
||||
std::shared_ptr<Temporal::TempoMap const> tempo_map;
|
||||
ArdourCanvas::Rectangle* event_rect;
|
||||
uint32_t _slot_index;
|
||||
|
||||
std::shared_ptr<ARDOUR::MidiModel> model_to_edit() const;
|
||||
void post_edit (std::shared_ptr<ARDOUR::MidiModel>, ARDOUR::MidiModel::NoteDiffCommand const &);
|
||||
void post_edit ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -215,10 +215,12 @@ void
|
|||
MidiView::set_model (std::shared_ptr<MidiModel> m)
|
||||
{
|
||||
_model = m;
|
||||
std::cerr << this << " now has sp<MM> " << _model << " with ref " << _model.use_count() << std::endl;
|
||||
assert (_model);
|
||||
|
||||
//set_height (trackview.current_height());
|
||||
|
||||
#warning paul pianorule needs these fixed
|
||||
/* XXXX
|
||||
region_muted ();
|
||||
region_sync_changed ();
|
||||
|
|
@ -843,6 +845,7 @@ MidiView::start_note_diff_command (string name)
|
|||
{
|
||||
if (!_note_diff_command) {
|
||||
_editing_context.begin_reversible_command (name);
|
||||
std::cerr << "start note diff on " << _model << " uc " << _model.use_count() << std::endl;
|
||||
_note_diff_command = _model->new_note_diff_command (name);
|
||||
} else {
|
||||
std::cerr << "ERROR: start_note_diff_command command called, but a note_diff_command was already underway" << std::endl;
|
||||
|
|
@ -907,17 +910,15 @@ MidiView::apply_note_diff (bool as_subcommand, bool was_copy)
|
|||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<MidiModel> op_model = model_to_edit ();
|
||||
|
||||
{
|
||||
PBD::Unwinder<bool> puw (_select_all_notes_after_add, true);
|
||||
/*note that we don't use as_commit here, because that would BEGIN a new undo record; we already have one underway*/
|
||||
op_model->apply_diff_command_as_subcommand (*_editing_context.session(), _note_diff_command);
|
||||
post_edit (op_model, *_note_diff_command);
|
||||
_model->apply_diff_command_as_subcommand (*_editing_context.session(), _note_diff_command);
|
||||
}
|
||||
|
||||
if (!as_subcommand) {
|
||||
_editing_context.commit_reversible_command (); /*instead, we can explicitly commit the command in progress */
|
||||
post_edit ();
|
||||
}
|
||||
|
||||
_note_diff_command = nullptr;
|
||||
|
|
@ -2748,6 +2749,7 @@ MidiView::note_dropped (NoteBase *, timecnt_t const & d_qn, int8_t dnote, bool c
|
|||
|
||||
apply_note_diff (true /*subcommand, we don't want this to start a new commit*/, copy);
|
||||
_editing_context.commit_reversible_command ();
|
||||
post_edit ();
|
||||
|
||||
// care about notes being moved beyond the upper/lower bounds on the canvas
|
||||
if (lowest_note_in_selection < _midi_context.lowest_note() ||
|
||||
|
|
@ -3245,6 +3247,7 @@ MidiView::set_velocities_for_notes (std::vector<NoteBase*>& notes, std::vector<i
|
|||
|
||||
apply_note_diff (true /*subcommand, we don't want this to start a new commit*/, false);
|
||||
_editing_context.commit_reversible_command ();
|
||||
post_edit ();
|
||||
delete _note_diff_command;
|
||||
_note_diff_command = nullptr;
|
||||
|
||||
|
|
@ -3747,6 +3750,7 @@ MidiView::duplicate_selection ()
|
|||
bool commit = paste (dup_pos, local_selection, ctxt);
|
||||
if (commit) {
|
||||
_editing_context.commit_reversible_command ();
|
||||
post_edit ();
|
||||
} else {
|
||||
_editing_context.abort_reversible_command ();
|
||||
}
|
||||
|
|
@ -3906,6 +3910,7 @@ MidiView::goto_next_note (bool add_to_selection)
|
|||
|
||||
|
||||
_editing_context.commit_reversible_selection_op();
|
||||
post_edit ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -3958,6 +3963,7 @@ MidiView::goto_previous_note (bool add_to_selection)
|
|||
}
|
||||
|
||||
_editing_context.commit_reversible_selection_op();
|
||||
post_edit ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -4488,6 +4494,7 @@ MidiView::quantize_selected_notes ()
|
|||
(*cmd)();
|
||||
_editing_context.session()->add_command (cmd);
|
||||
_editing_context.commit_reversible_command ();
|
||||
post_edit ();
|
||||
_editing_context.session()->set_dirty ();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -641,8 +641,7 @@ class MidiView : public virtual sigc::trackable
|
|||
|
||||
void add_split_notes ();
|
||||
|
||||
virtual std::shared_ptr<ARDOUR::MidiModel> model_to_edit() const { return _model; }
|
||||
virtual void post_edit (std::shared_ptr<ARDOUR::MidiModel>, ARDOUR::MidiModel::NoteDiffCommand const &) {}
|
||||
virtual void post_edit () {}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -104,10 +104,12 @@ PianoRollHeader::resize ()
|
|||
}
|
||||
|
||||
void
|
||||
PianoRollHeader::set_view (MidiView& v)
|
||||
PianoRollHeader::set_view (MidiView* v)
|
||||
{
|
||||
_view = &v;
|
||||
_view->midi_context().NoteRangeChanged.connect (sigc::mem_fun (*this, &PianoRollHeader::note_range_changed));
|
||||
_view = v;
|
||||
if (_view) {
|
||||
_view->midi_context().NoteRangeChanged.connect (sigc::mem_fun (*this, &PianoRollHeader::note_range_changed));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public:
|
|||
sigc::signal<void,uint8_t> ToggleNoteSelection;
|
||||
sigc::signal<void,uint8_t> ExtendNoteSelection;
|
||||
|
||||
void set_view (MidiView&);
|
||||
void set_view (MidiView*);
|
||||
|
||||
private:
|
||||
MidiViewBackground& _midi_context;
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ TriggerPage::selection_changed ()
|
|||
std::shared_ptr<MidiRegion> mr = std::dynamic_pointer_cast<MidiRegion> (trigger->region());
|
||||
if (mr) {
|
||||
std::shared_ptr<MidiTrack> mt = std::dynamic_pointer_cast<MidiTrack> (entry->strip().stripable());
|
||||
_midi_editor->set_region (mt, mr);
|
||||
_midi_editor->set_region (mt, ref.slot, mr);
|
||||
_midi_editor->viewport().show ();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue