in non-note-edit mouse object mode, single click on midi track creates a region if nothing is selected (because said click would then clear the selection, as before). this makes getting started with hand-edited MIDI regions massively easier

git-svn-id: svn://localhost/ardour2/branches/3.0@11350 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-01-25 19:39:20 +00:00
parent 0740fab6ed
commit f2e542afe7
2 changed files with 37 additions and 19 deletions

View file

@ -396,6 +396,22 @@ Drag::show_verbose_cursor_text (string const & text)
);
}
boost::shared_ptr<Region>
Drag::add_midi_region (MidiTimeAxisView* view)
{
if (_editor->session()) {
const TempoMap& map (_editor->session()->tempo_map());
framecnt_t pos = grab_frame();
const Meter& m = map.meter_at (pos);
/* not that the frame rate used here can be affected by pull up/down which
might be wrong.
*/
framecnt_t len = m.frames_per_bar (map.tempo_at (pos), _editor->session()->frame_rate());
return view->add_region (grab_frame(), len, true);
}
return boost::shared_ptr<Region>();
}
struct EditorOrderTimeAxisViewSorter {
bool operator() (TimeAxisView* a, TimeAxisView* b) {
@ -1443,7 +1459,7 @@ void
RegionCreateDrag::motion (GdkEvent* event, bool first_move)
{
if (first_move) {
add_region();
_region = add_midi_region (_view);
_view->playlist()->freeze ();
} else {
if (_region) {
@ -1469,7 +1485,7 @@ void
RegionCreateDrag::finished (GdkEvent*, bool movement_occurred)
{
if (!movement_occurred) {
add_region ();
add_midi_region (_view);
} else {
_view->playlist()->thaw ();
}
@ -1479,21 +1495,6 @@ RegionCreateDrag::finished (GdkEvent*, bool movement_occurred)
}
}
void
RegionCreateDrag::add_region ()
{
if (_editor->session()) {
const TempoMap& map (_editor->session()->tempo_map());
framecnt_t pos = grab_frame();
const Meter& m = map.meter_at (pos);
/* not that the frame rate used here can be affected by pull up/down which
might be wrong.
*/
framecnt_t len = m.frames_per_bar (map.tempo_at (pos), _editor->session()->frame_rate());
_region = _view->add_region (grab_frame(), len, false);
}
}
void
RegionCreateDrag::aborted (bool)
{
@ -3221,7 +3222,23 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred)
} else {
deselect_things ();
/* just a click */
bool do_deselect = true;
MidiTimeAxisView* mtv;
if ((mtv = dynamic_cast<MidiTimeAxisView*>(_editor->clicked_axisview)) != 0) {
/* MIDI track */
if (_editor->selection->empty()) {
/* nothing selected */
add_midi_region (mtv);
do_deselect = false;
}
}
if (do_deselect) {
deselect_things ();
}
}

View file

@ -212,6 +212,8 @@ protected:
return _last_pointer_frame;
}
boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*);
void show_verbose_cursor_time (framepos_t);
void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);
void show_verbose_cursor_text (std::string const &);
@ -417,7 +419,6 @@ public:
private:
MidiTimeAxisView* _view;
boost::shared_ptr<ARDOUR::Region> _region;
void add_region ();
};
/** Drags to resize MIDI notes */