AutomationLine::update_visibility ()
{
if (_visible & Line) {
- /* Only show the line there are some points, otherwise we may show an out-of-date line
+ /* Only show the line when there are some points, otherwise we may show an out-of-date line
when automation points have been removed (the line will still follow the shape of the
old points).
*/
#include "control_protocol/control_protocol.h"
-#include "actions.h"
#include "actions.h"
#include "analysis_window.h"
#include "audio_clock.h"
Editor::Editor ()
: _join_object_range_state (JOIN_OBJECT_RANGE_NONE)
+ , _mouse_changed_selection (false)
/* time display buttons */
, minsec_label (_("Mins:Secs"))
, bbt_label (_("Bars:Beats"))
Editor::begin_reversible_selection_op (string name)
{
if (_session) {
- //cerr << name << endl;
+ cerr << name << endl;
/* begin/commit pairs can be nested */
selection_op_cmd_depth++;
}
if (selection_op_cmd_depth == 1) {
if (selection_op_history_it > 0 && selection_op_history_it < selection_op_history.size()) {
+ /* the user has undone some selection ops and then made a new one */
list<XMLNode *>::iterator it = selection_op_history.begin();
advance (it, selection_op_history_it);
selection_op_history.erase (selection_op_history.begin(), it);
}
+
selection_op_history.push_front (&_selection_memento->get_state ());
selection_op_history_it = 0;
+
+ selection_undo_action->set_sensitive (true);
+ selection_redo_action->set_sensitive (false);
}
if (selection_op_cmd_depth > 0) {
selection_op_cmd_depth--;
}
-
- selection_undo_action->set_sensitive (true);
- selection_redo_action->set_sensitive (false);
}
}
selection_redo_action->set_sensitive (true);
}
++n;
-
}
/* is there an earlier entry? */
if ((selection_op_history_it + 1) >= selection_op_history.size()) {
selection_undo_action->set_sensitive (true);
}
++n;
-
}
if (selection_op_history_it == 0) {
}
void
-Editor::get_regionviews_by_id (PBD::ID const & id, RegionSelection & regions) const
+Editor::get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const
{
for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
- RouteTimeAxisView* tatv;
+ RouteTimeAxisView* rtav;
- if ((tatv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
+ if ((rtav = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) {
boost::shared_ptr<Playlist> pl;
std::vector<boost::shared_ptr<Region> > results;
boost::shared_ptr<Track> tr;
- if ((tr = tatv->track()) == 0) {
+ if ((tr = rtav->track()) == 0) {
/* bus */
continue;
}
if ((pl = (tr->playlist())) != 0) {
boost::shared_ptr<Region> r = pl->region_by_id (id);
if (r) {
- RegionView* marv = tatv->view()->find_view (r);
- if (marv) {
- regions.push_back (marv);
+ RegionView* rv = rtav->view()->find_view (r);
+ if (rv) {
+ regions.push_back (rv);
}
}
}
}
}
+void
+Editor::get_per_region_note_selection (list<pair<PBD::ID, set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > > &selection) const
+{
+
+ for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
+ MidiTimeAxisView* mtav;
+
+ if ((mtav = dynamic_cast<MidiTimeAxisView*> (*i)) != 0) {
+
+ mtav->get_per_region_note_selection (selection);
+ }
+ }
+
+}
+
void
Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions, bool src_comparison)
{
break;
}
}
+
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (rv);
+ if (mrv) {
+ list<pair<PBD::ID const, list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >::iterator rnote;
+ for (rnote = selection->pending_midi_note_selection.begin(); rnote != selection->pending_midi_note_selection.end(); ++rnote) {
+ if (rv->region()->id () == (*rnote).first) {
+ mrv->select_notes ((*rnote).second);
+ selection->pending_midi_note_selection.erase(rnote);
+ break;
+ }
+ }
+ }
+
_summary->set_background_dirty ();
}
void get_regions_corresponding_to (boost::shared_ptr<ARDOUR::Region> region, std::vector<RegionView*>& regions, bool src_comparison);
- void get_regionviews_by_id (PBD::ID const & id, RegionSelection & regions) const;
+ void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const;
+ void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >&) const;
void center_screen (framepos_t);
void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
bool button_release_can_deselect;
+ bool _mouse_changed_selection;
void catch_vanishing_regionview (RegionView *);
bool
Editor::track_canvas_button_press_event (GdkEventButton */*event*/)
{
+ begin_reversible_selection_op (_("Clear Selection Click (track canvas)"));
selection->clear ();
+ commit_reversible_selection_op();
_track_canvas->grab_focus();
return false;
}
switch (event->type) {
case GDK_BUTTON_RELEASE:
if (event->button.button == 1) {
+ begin_reversible_selection_op (_("Nowhere Click"));
selection->clear_objects ();
selection->clear_tracks ();
+ commit_reversible_selection_op ();
}
break;
} else {
_region->unique_select (_primary);
}
+
+ _editor->begin_reversible_selection_op(_("Select Note Press"));
+ _editor->commit_reversible_selection_op();
}
}
}
{
if (!moved) {
/* no motion - select note */
-
+
if (_editor->current_mouse_mode() == Editing::MouseObject ||
_editor->current_mouse_mode() == Editing::MouseDraw) {
-
+
+ bool changed = false;
+
if (_was_selected) {
bool add = Keyboard::modifier_state_equals (ev->button.state, Keyboard::PrimaryModifier);
if (add) {
_region->note_deselected (_primary);
+ changed = true;
}
} else {
bool extend = Keyboard::modifier_state_equals (ev->button.state, Keyboard::TertiaryModifier);
if (!extend && !add && _region->selection_size() > 1) {
_region->unique_select (_primary);
+ changed = true;
} else if (extend) {
_region->note_selected (_primary, true, true);
+ changed = true;
} else {
/* it was added during button press */
}
}
+
+ if (changed) {
+ _editor->begin_reversible_selection_op(_("Select Note Release"));
+ _editor->commit_reversible_selection_op();
+ }
}
} else {
_region->note_dropped (_primary, total_dx(), total_dy());
void
EditorRubberbandSelectDrag::deselect_things ()
{
- if (!getenv("ARDOUR_SAE")) {
- _editor->selection->clear_tracks();
- }
+ _editor->begin_reversible_selection_op (_("Clear Selection (rubberband)"));
+
+ _editor->selection->clear_tracks();
_editor->selection->clear_regions();
_editor->selection->clear_points ();
_editor->selection->clear_lines ();
+ _editor->selection->clear_midi_notes ();
+
+ _editor->commit_reversible_selection_op();
}
NoteCreateDrag::NoteCreateDrag (Editor* e, ArdourCanvas::Item* i, MidiRegionView* rv)
Selection::Operation op = ArdourKeyboard::selection_type (event->button.state);
bool press = (event->type == GDK_BUTTON_PRESS);
+ if (press) {
+ _mouse_changed_selection = false;
+ }
+
switch (item_type) {
case RegionItem:
if (press) {
if (eff_mouse_mode != MouseRange) {
- set_selected_regionview_from_click (press, op);
+ _mouse_changed_selection = set_selected_regionview_from_click (press, op);
} else {
/* don't change the selection unless the
clicked track is not currently selected. if
}
} else {
if (eff_mouse_mode != MouseRange) {
- set_selected_regionview_from_click (press, op);
+ _mouse_changed_selection = set_selected_regionview_from_click (press, op);
}
}
break;
case StartCrossFadeItem:
case EndCrossFadeItem:
if (get_smart_mode() || eff_mouse_mode != MouseRange) {
- set_selected_regionview_from_click (press, op);
+ _mouse_changed_selection = set_selected_regionview_from_click (press, op);
} else if (event->type == GDK_BUTTON_PRESS) {
set_selected_track_as_side_effect (op);
}
case ControlPointItem:
set_selected_track_as_side_effect (op);
if (eff_mouse_mode != MouseRange) {
- set_selected_control_point_from_click (press, op);
+ _mouse_changed_selection = set_selected_control_point_from_click (press, op);
}
break;
if (event->button.button == 3) {
selection->clear_tracks ();
set_selected_track_as_side_effect (op);
+ _mouse_changed_selection = true;
}
break;
default:
break;
}
+
+ if ((!press) && _mouse_changed_selection) {
+ begin_reversible_selection_op (_("Button Selection"));
+ commit_reversible_selection_op ();
+ _mouse_changed_selection = false;
+ }
}
bool
case AutomationTrackItem:
/* rubberband drag to select automation points */
_drags->set (new EditorRubberbandSelectDrag (this, item), event);
+ return true;
break;
default:
}
/* do any (de)selection operations that should occur on button release */
-
- begin_reversible_selection_op (_("Button Select"));
- button_selection (item, event, item_type);
- commit_reversible_selection_op ();
+ button_selection (item, event, item_type);
return true;
break;
}
} else if (group && group->is_active()) {
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
- if ((*i)->route_group() == group)
+ if ((*i)->route_group() == group) {
selection->remove(*i);
+ }
}
} else {
selection->remove (clicked_axisview);
}
} else if (group && group->is_active()) {
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
- if ( (*i)->route_group() == group)
+ if ((*i)->route_group() == group) {
selection->add(*i);
+ }
}
} else {
selection->add (clicked_axisview);
}
} else if (group && group->is_active()) {
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
- if ((*i)->route_group() == group)
+ if ((*i)->route_group() == group) {
selection->add(*i);
+ }
}
} else {
selection->add (clicked_axisview);
}
} else if (group && group->is_active()) {
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) {
- if ((*i)->route_group() == group)
+ if ((*i)->route_group() == group) {
selection->add(*i);
+ }
}
} else {
selection->set (clicked_axisview);
void
Editor::deselect_all ()
{
- begin_reversible_selection_op(_("Clear Selection"));
+ begin_reversible_selection_op(_("Deselect All"));
selection->clear ();
commit_reversible_selection_op ();
}
, _last_event_y (0)
, _grabbed_keyboard (false)
, _entered (false)
+ , _mouse_changed_selection (false)
{
CANVAS_DEBUG_NAME (_note_group, string_compose ("note group for %1", get_item_name()));
_note_group->raise_to_top();
, _last_event_y (0)
, _grabbed_keyboard (false)
, _entered (false)
+ , _mouse_changed_selection (false)
{
CANVAS_DEBUG_NAME (_note_group, string_compose ("note group for %1", get_item_name()));
_note_group->raise_to_top();
, _last_event_y (0)
, _grabbed_keyboard (false)
, _entered (false)
+ , _mouse_changed_selection (false)
{
init (false);
}
, _last_event_y (0)
, _grabbed_keyboard (false)
, _entered (false)
+ , _mouse_changed_selection (false)
{
init (true);
}
}
_pressed_button = ev->button;
+ _mouse_changed_selection = false;
return true;
}
case MouseRange:
/* no motion occured - simple click */
clear_selection ();
+ _mouse_changed_selection = true;
break;
case MouseContent:
case MouseTimeFX:
{
clear_selection();
+ _mouse_changed_selection = true;
if (Keyboard::is_insert_note_event(ev)) {
break;
}
+ if(_mouse_changed_selection) {
+ trackview.editor().begin_reversible_selection_op (_("Mouse Selection Change"));
+ trackview.editor().commit_reversible_selection_op ();
+ }
+
return false;
}
editor.drags()->set (new MidiRubberbandSelectDrag (dynamic_cast<Editor *> (&editor), this), (GdkEvent *) ev);
if (!Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
clear_selection ();
+ _mouse_changed_selection = true;
}
_mouse_state = SelectRectDragging;
return true;
} else if (ev->keyval == GDK_Tab) {
+ trackview.editor().begin_reversible_selection_op (_("Select Adjacent Note"));
+
if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
goto_previous_note (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier));
} else {
goto_next_note (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier));
}
+
+ trackview.editor().commit_reversible_selection_op();
+
return true;
} else if (ev->keyval == GDK_ISO_Left_Tab) {
/* Shift-TAB generates ISO Left Tab, for some reason */
+ trackview.editor().begin_reversible_selection_op (_("Select Adjacent Note"));
+
if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
goto_previous_note (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier));
} else {
goto_next_note (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier));
}
+
+ trackview.editor().commit_reversible_selection_op();
+
return true;
view->update_note_range(new_note->note());
+ trackview.editor().begin_reversible_command(_("add note"));
MidiModel::NoteDiffCommand* cmd = _model->new_note_diff_command(_("add note"));
cmd->add (new_note);
_model->apply_command(*trackview.session(), cmd);
+ trackview.editor().commit_reversible_command();
play_midi_note (new_note);
}
content_connection.disconnect ();
_model->ContentsChanged.connect (content_connection, invalidator (*this), boost::bind (&MidiRegionView::redisplay_model, this), gui_context());
-
- clear_events ();
+ /* Don't signal as nobody else needs to know until selection has been altered.*/
+ clear_events (false);
if (_enable_display) {
redisplay_model();
MidiRegionView::start_note_diff_command (string name)
{
if (!_note_diff_command) {
+ trackview.editor().begin_reversible_command (name);
_note_diff_command = _model->new_note_diff_command (name);
}
}
MidiRegionView::apply_diff (bool as_subcommand)
{
bool add_or_remove;
+ bool commit = false;
if (!_note_diff_command) {
return;
_model->apply_command_as_subcommand (*trackview.session(), _note_diff_command);
} else {
_model->apply_command (*trackview.session(), _note_diff_command);
+ commit = true;
}
_note_diff_command = 0;
}
_marked_for_velocity.clear();
+ if (commit) {
+ trackview.editor().commit_reversible_command ();
+ }
}
void
return 0;
}
+/** This version finds any canvas note matching the supplied note.*/
+NoteBase*
+MidiRegionView::find_canvas_note (NoteType note)
+{
+ if (_optimization_iterator != _events.end()) {
+ ++_optimization_iterator;
+ }
+
+ if (_optimization_iterator != _events.end() && (*(*_optimization_iterator)->note()) == note) {
+ return *_optimization_iterator;
+ }
+
+ for (_optimization_iterator = _events.begin(); _optimization_iterator != _events.end(); ++_optimization_iterator) {
+ if (*((*_optimization_iterator)->note()) == note) {
+ return *_optimization_iterator;
+ }
+ }
+
+ return 0;
+}
+
void
MidiRegionView::get_events (Events& e, Evoral::Sequence<Evoral::Beats>::NoteOperator op, uint8_t val, int chan_mask)
{
add_note (note, visible);
}
+ set<boost::shared_ptr<NoteType> >::iterator it;
+ for (it = _pending_note_selection.begin(); it != _pending_note_selection.end(); ++it) {
+ if (*(*it) == *note) {
+ add_to_selection (cne);
+ }
+ }
+
} else {
if (!empty_when_starting && (cne = find_canvas_note (note)) != 0) {
}
}
-
/* remove note items that are no longer valid */
if (!empty_when_starting) {
_marked_for_selection.clear ();
_marked_for_velocity.clear ();
+ _pending_note_selection.clear ();
/* we may have caused _events to contain things out of order (e.g. if a note
moved earlier or later). we don't generally need them in time order, but
void
MidiRegionView::change_patch_change (PatchChange& pc, const MIDI::Name::PatchPrimaryKey& new_patch)
{
- MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("alter patch change"));
+ string name = _("alter patch change");
+ trackview.editor().begin_reversible_command (name);
+ MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (name);
if (pc.patch()->program() != new_patch.program()) {
c->change_program (pc.patch (), new_patch.program());
}
_model->apply_command (*trackview.session(), c);
+ trackview.editor().commit_reversible_command ();
_patch_changes.clear ();
display_patch_changes ();
void
MidiRegionView::change_patch_change (MidiModel::PatchChangePtr old_change, const Evoral::PatchChange<Evoral::Beats> & new_change)
{
- MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("alter patch change"));
+ string name = _("alter patch change");
+ trackview.editor().begin_reversible_command (name);
+ MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (name);
if (old_change->time() != new_change.time()) {
c->change_time (old_change, new_change.time());
}
_model->apply_command (*trackview.session(), c);
+ trackview.editor().commit_reversible_command ();
_patch_changes.clear ();
display_patch_changes ();
MidiRegionView::add_patch_change (framecnt_t t, Evoral::PatchChange<Evoral::Beats> const & patch)
{
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
+ string name = _("add patch change");
- MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("add patch change"));
+ trackview.editor().begin_reversible_command (name);
+ MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (name);
c->add (MidiModel::PatchChangePtr (
new Evoral::PatchChange<Evoral::Beats> (
absolute_frames_to_source_beats (_region->position() + t),
);
_model->apply_command (*trackview.session(), c);
+ trackview.editor().commit_reversible_command ();
_patch_changes.clear ();
display_patch_changes ();
void
MidiRegionView::move_patch_change (PatchChange& pc, Evoral::Beats t)
{
+ trackview.editor().begin_reversible_command (_("move patch change"));
MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("move patch change"));
c->change_time (pc.patch (), t);
_model->apply_command (*trackview.session(), c);
+ trackview.editor().commit_reversible_command ();
_patch_changes.clear ();
display_patch_changes ();
void
MidiRegionView::delete_patch_change (PatchChange* pc)
{
+ trackview.editor().begin_reversible_command (_("delete patch change"));
MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("delete patch change"));
c->remove (pc->patch ());
_model->apply_command (*trackview.session(), c);
+ trackview.editor().commit_reversible_command ();
_patch_changes.clear ();
display_patch_changes ();
}
}
+/** Used for selection undo/redo.
+ The requested notes most likely won't exist in the view until the next model redisplay.
+*/
+void
+MidiRegionView::select_notes (list<boost::shared_ptr<NoteType> > notes)
+{
+ NoteBase* cne;
+ list<boost::shared_ptr<NoteType> >::iterator n;
+
+ for (n = notes.begin(); n != notes.end(); ++n) {
+ if ((cne = find_canvas_note(*(*n))) != 0) {
+ add_to_selection (cne);
+ } else {
+ _pending_note_selection.insert(*n);
+ }
+ }
+}
+
void
MidiRegionView::select_matching_notes (uint8_t notenum, uint16_t channel_mask, bool add, bool extend)
{
void move_selection(double dx, double dy, double cumulative_dy);
void note_dropped (NoteBase* ev, ARDOUR::frameoffset_t, int8_t d_note);
+ void select_notes (std::list<boost::shared_ptr<NoteType> >);
void select_matching_notes (uint8_t notenum, uint16_t channel_mask, bool add, bool extend);
void toggle_matching_notes (uint8_t notenum, uint16_t channel_mask);
* when they appear after the command is applied. */
std::set< boost::shared_ptr<NoteType> > _marked_for_selection;
+ /** Notes that should be selected when the model is redisplayed. */
+ std::set< boost::shared_ptr<NoteType> > _pending_note_selection;
+
/** New notes (created in the current command) which should have visible velocity
* when they appear after the command is applied. */
std::set< boost::shared_ptr<NoteType> > _marked_for_velocity;
PBD::ScopedConnection content_connection;
NoteBase* find_canvas_note (boost::shared_ptr<NoteType>);
+ NoteBase* find_canvas_note (NoteType);
Events::iterator _optimization_iterator;
void update_note (NoteBase*, bool update_ghost_regions = true);
bool _grabbed_keyboard;
bool _entered;
+ bool _mouse_changed_selection;
+
framepos_t snap_frame_to_grid_underneath (framepos_t p, framecnt_t &) const;
PBD::ScopedConnection _mouse_mode_connection;
{
uint16_t chn_mask = midi_track()->get_playback_channel_mask();
+ _editor.begin_reversible_selection_op(_("Set Note Selection"));
+
if (_view->num_selected_regionviews() == 0) {
_view->foreach_regionview (
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection_region_view),
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection_region_view),
note, chn_mask));
}
+
+ _editor.commit_reversible_selection_op();
}
void
{
const uint16_t chn_mask = midi_track()->get_playback_channel_mask();
+ _editor.begin_reversible_selection_op(_("Add Note Selection"));
+
if (_view->num_selected_regionviews() == 0) {
_view->foreach_regionview (
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::add_note_selection_region_view),
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::add_note_selection_region_view),
note, chn_mask));
}
+
+ _editor.commit_reversible_selection_op();
}
void
{
const uint16_t chn_mask = midi_track()->get_playback_channel_mask();
+ _editor.begin_reversible_selection_op(_("Extend Note Selection"));
+
if (_view->num_selected_regionviews() == 0) {
_view->foreach_regionview (
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::extend_note_selection_region_view),
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::extend_note_selection_region_view),
note, chn_mask));
}
+
+ _editor.commit_reversible_selection_op();
}
void
{
const uint16_t chn_mask = midi_track()->get_playback_channel_mask();
+ _editor.begin_reversible_selection_op(_("Toggle Note Selection"));
+
if (_view->num_selected_regionviews() == 0) {
_view->foreach_regionview (
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::toggle_note_selection_region_view),
sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::toggle_note_selection_region_view),
note, chn_mask));
}
+
+ _editor.commit_reversible_selection_op();
+}
+
+void
+MidiTimeAxisView::get_per_region_note_selection (list<pair<PBD::ID, set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >& selection)
+{
+ _view->foreach_regionview (
+ sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::get_per_region_note_selection_region_view), sigc::ref(selection)));
}
void
dynamic_cast<MidiRegionView*>(rv)->toggle_matching_notes (note, chn_mask);
}
+void
+MidiTimeAxisView::get_per_region_note_selection_region_view (RegionView* rv, list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > > &selection)
+{
+ Evoral::Sequence<Evoral::Beats>::Notes selected;
+ dynamic_cast<MidiRegionView*>(rv)->selection_as_notelist (selected, false);
+
+ std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > notes;
+
+ Evoral::Sequence<Evoral::Beats>::Notes::iterator sel_it;
+ for (sel_it = selected.begin(); sel_it != selected.end(); ++sel_it) {
+ notes.insert (*sel_it);
+ }
+
+ if (!notes.empty()) {
+ selection.push_back (make_pair ((rv)->region()->id(), notes));
+ }
+}
+
void
MidiTimeAxisView::set_channel_mode (ChannelMode, uint16_t)
{
#include <gtkmm2ext/selector.h>
#include <list>
+#include "evoral/Note.hpp"
+
#include "ardour/types.h"
#include "ardour/region.h"
class MidiTimeAxisView : public RouteTimeAxisView
{
- public:
+public:
MidiTimeAxisView (PublicEditor&, ARDOUR::Session*, ArdourCanvas::Canvas& canvas);
virtual ~MidiTimeAxisView ();
uint8_t get_channel_for_add () const;
- protected:
+ void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >&);
+
+protected:
void start_step_editing ();
void stop_step_editing ();
- private:
+private:
sigc::signal<void, std::string, std::string> _midi_patch_settings_changed;
void model_changed(const std::string& model);
void add_note_selection_region_view (RegionView* rv, uint8_t note, uint16_t chn_mask);
void extend_note_selection_region_view (RegionView*, uint8_t note, uint16_t chn_mask);
void toggle_note_selection_region_view (RegionView*, uint8_t note, uint16_t chn_mask);
+ void get_per_region_note_selection_region_view (RegionView*, std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >&);
void ensure_step_editor ();
#include <gtkmm/actiongroup.h>
#include <sigc++/signal.h>
+#include "evoral/Note.hpp"
#include "evoral/types.hpp"
#include "pbd/statefuldestructible.h"
virtual void stop_canvas_autoscroll () = 0;
virtual bool autoscroll_active() const = 0;
+ virtual void begin_reversible_selection_op (std::string cmd_name) = 0;
+ virtual void commit_reversible_selection_op () = 0;
virtual void begin_reversible_command (std::string cmd_name) = 0;
virtual void begin_reversible_command (GQuark) = 0;
virtual void commit_reversible_command () = 0;
virtual void get_regions_at (RegionSelection &, framepos_t where, TrackViewList const &) const = 0;
virtual RegionSelection get_regions_from_selection_and_mouse (framepos_t) = 0;
- virtual void get_regionviews_by_id (PBD::ID const & id, RegionSelection & regions) const = 0;
+ virtual void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const = 0;
+ virtual void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >&) const = 0;
/// Singleton instance, set up by Editor::Editor()
clear_midi_notes ();
clear_midi_regions ();
clear_markers ();
+ pending_midi_note_selection.clear();
}
void
if (find (regions.begin(), regions.end(), r) == regions.end()) {
bool changed = regions.add (r);
- if (changed) {
- RegionsChanged ();
- }
+ if (changed) {
+ RegionsChanged ();
+ }
}
}
for (RegionSelection::const_iterator i = regions.begin(); i != regions.end(); ++i) {
XMLNode* r = node->add_child (X_("Region"));
r->add_property (X_("id"), atoi ((*i)->region ()->id ().to_s ().c_str()));
-
+ }
+
+ /* midi region views have thir own internal selection. */
+ XMLNode* n;
+ list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > > rid_notes;
+ editor->get_per_region_note_selection (rid_notes);
+ if (!rid_notes.empty()) {
+ n = node->add_child (X_("MIDINote"));
+ }
+ list<pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > >::iterator rn_it;
+ for (rn_it = rid_notes.begin(); rn_it != rid_notes.end(); ++rn_it) {
+ n->add_property (X_("region_id"), atoi((*rn_it).first.to_s().c_str()));
+
+ for (std::set<boost::shared_ptr<Evoral::Note<Evoral::Beats> > >::iterator i = (*rn_it).second.begin(); i != (*rn_it).second.end(); ++i) {
+ XMLNode* nc = n->add_child(X_("note"));
+ snprintf(buf, sizeof(buf), "%d", (*i)->channel());
+ nc->add_property(X_("channel"), string(buf));
+
+ snprintf(buf, sizeof(buf), "%f", (*i)->time().to_double());
+ nc->add_property(X_("time"), string(buf));
+
+ snprintf(buf, sizeof(buf), "%d", (*i)->note());
+ nc->add_property(X_("note"), string(buf));
+
+ snprintf(buf, sizeof(buf), "%f", (*i)->length().to_double());
+ nc->add_property(X_("length"), string(buf));
+
+ snprintf(buf, sizeof(buf), "%d", (*i)->velocity());
+ nc->add_property(X_("velocity"), string(buf));
+
+ snprintf(buf, sizeof(buf), "%d", (*i)->off_velocity());
+ nc->add_property(X_("off-velocity"), string(buf));
+ }
}
for (PointSelection::const_iterator i = points.begin(); i != points.end(); ++i) {
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (&(*i)->line().trackview);
if (atv) {
+
XMLNode* r = node->add_child (X_("ControlPoint"));
r->add_property (X_("type"), "track");
r->add_property (X_("route-id"), atoi (atv->parent_route()->id ().to_s ().c_str()));
snprintf(buf, sizeof(buf), "%d", (*i)->view_index());
r->add_property (X_("view-index"), string(buf));
+
}
}
add (rs);
} else {
/*
- regionviews are being constructed - stash the region IDs
+ regionviews haven't been constructed - stash the region IDs
so we can identify them in Editor::region_view_added ()
*/
regions.pending.push_back (id);
}
+ } else if ((*i)->name() == X_("MIDINote")) {
+ XMLProperty* prop_region_id = (*i)->property (X_("region-id"));
+
+ assert (prop_region_id);
+
+ PBD::ID const id (prop_region_id->value ());
+ RegionSelection rs;
+
+ editor->get_regionviews_by_id (id, rs); // there could be more than one
+
+ std::list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > notes;
+ XMLNodeList children = (*i)->children ();
+
+ for (XMLNodeList::const_iterator ci = children.begin(); ci != children.end(); ++ci) {
+ XMLProperty* prop_channel = (*ci)->property (X_("channel"));
+ XMLProperty* prop_time = (*ci)->property (X_("time"));
+ XMLProperty* prop_note = (*ci)->property (X_("note"));
+ XMLProperty* prop_length = (*ci)->property (X_("length"));
+ XMLProperty* prop_velocity = (*ci)->property (X_("velocity"));
+ XMLProperty* prop_off_velocity = (*ci)->property (X_("off-velocity"));
+
+ assert (prop_channel);
+ assert (prop_time);
+ assert (prop_note);
+ assert (prop_length);
+ assert (prop_velocity);
+ assert (prop_off_velocity);
+
+ uint8_t channel = atoi(prop_channel->value());
+ Evoral::Beats time (atof(prop_time->value()));
+ Evoral::Beats length (atof(prop_length->value()));
+ uint8_t note = atoi(prop_note->value());
+ uint8_t velocity = atoi(prop_velocity->value());
+ uint8_t off_velocity = atoi(prop_off_velocity->value());
+ boost::shared_ptr<Evoral::Note<Evoral::Beats> > the_note
+ (new Evoral::Note<Evoral::Beats> (channel, time, length, note, velocity));
+ the_note->set_off_velocity (off_velocity);
+
+ notes.push_back (the_note);
+ }
+
+ for (RegionSelection::iterator rsi = rs.begin(); rsi != rs.end(); ++rsi) {
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (*rsi);
+ if (mrv) {
+ mrv->select_notes(notes);
+ }
+ }
+
+ if (rs.empty()) {
+ /* regionviews containing these notes don't yet exist on the canvas.*/
+ pending_midi_note_selection.push_back (make_pair (id, notes));
+ }
+
} else if ((*i)->name() == X_("ControlPoint")) {
XMLProperty* prop_type = (*i)->property (X_("type"));
- XMLProperty* prop_route_id = (*i)->property (X_("route-id"));
- XMLProperty* prop_alist_id = (*i)->property (X_("automation-list-id"));
- XMLProperty* prop_parameter = (*i)->property (X_("parameter"));
- XMLProperty* prop_view_index = (*i)->property (X_("view-index"));
-
- assert (prop_type);
- assert (prop_route_id);
- assert (prop_alist_id);
- assert (prop_parameter);
- assert (prop_view_index);
+
+ assert(prop_type);
if (prop_type->value () == "track") {
- PBD::ID id (prop_route_id->value ());
- RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (id);
+
+ XMLProperty* prop_route_id = (*i)->property (X_("route-id"));
+ XMLProperty* prop_alist_id = (*i)->property (X_("automation-list-id"));
+ XMLProperty* prop_parameter = (*i)->property (X_("parameter"));
+ XMLProperty* prop_view_index = (*i)->property (X_("view-index"));
+
+ assert (prop_type);
+ assert (prop_route_id);
+ assert (prop_alist_id);
+ assert (prop_parameter);
+ assert (prop_view_index);
+
+ PBD::ID route_id (prop_route_id->value ());
+ RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (route_id);
+ vector <ControlPoint *> cps;
if (rtv) {
boost::shared_ptr<AutomationTimeAxisView> atv = rtv->automation_child (EventTypeMap::instance().from_symbol (prop_parameter->value ()));
if (atv) {
list<boost::shared_ptr<AutomationLine> > lines = atv->lines();
- for (list<boost::shared_ptr<AutomationLine> > ::iterator i = lines.begin(); i != lines.end(); ++i) {
- if ((*i)->the_list()->id() == prop_alist_id->value()) {
- ControlPoint* cp = (*i)->nth(atol(prop_view_index->value().c_str()));
+ for (list<boost::shared_ptr<AutomationLine> > ::iterator li = lines.begin(); li != lines.end(); ++li) {
+ if ((*li)->the_list()->id() == prop_alist_id->value()) {
+ ControlPoint* cp = (*li)->nth(atol(prop_view_index->value().c_str()));
if (cp) {
- add (cp);
+ cps.push_back (cp);
+ cp->show();
}
}
}
}
}
- }
+ if (!cps.empty()) {
+ add (cps);
+ }
+ }
} else if ((*i)->name() == X_("AudioRange")) {
XMLProperty* prop_start = (*i)->property (X_("start"));
PBD::Signal0<void> ClearMidiNoteSelection;
+ std::list<std::pair<PBD::ID const, std::list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > > > > pending_midi_note_selection;
+
private:
PublicEditor const * editor;
uint32_t next_time_id;