y_delta = yposition - rv->get_canvas_group()->canvas_origin().y;
}
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(rv);
+ if (mrv) {
+ mrv->apply_note_range (60, 71, true);
+ }
} else {
/* The TimeAxisView that this region is now over */
y_delta = track_origin.y - rv->get_canvas_group()->canvas_origin().y;
}
+
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(rv);
+ if (mrv) {
+ MidiStreamView* msv;
+ if ((msv = dynamic_cast <MidiStreamView*> (current_tv->view())) != 0) {
+ mrv->apply_note_range (msv->lowest_note(), msv->highest_note(), true);
+ }
+ }
}
/* Now move the region view */
return 0;
}
- MidiStreamView* msv = _region->midi_stream_view ();
double const y = _region->midi_view()->y_position ();
/* new current note */
- uint8_t n = msv->y_to_note (current_pointer_y () - y);
+ uint8_t n = _region->y_to_note (current_pointer_y () - y);
/* clamp */
+ MidiStreamView* msv = _region->midi_stream_view ();
n = max (msv->lowest_note(), n);
n = min (msv->highest_note(), n);
/* and work out delta */
- return n - msv->y_to_note (grab_y() - y);
+ return n - _region->y_to_note (grab_y() - y);
}
void
framecnt_t
NoteCreateDrag::grid_frames (framepos_t t) const
{
- bool success;
- Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, t);
- if (!success) {
- grid_beats = Evoral::Beats(1);
- }
+
+ const Evoral::Beats grid_beats = _region_view->get_grid_beats (t);
const Evoral::Beats t_beats = _region_view->region_frames_to_region_beats (t);
return _region_view->region_beats_to_region_frames (t_beats + grid_beats)
- _region_view->region_beats_to_region_frames (t_beats);
-
}
void
const framepos_t pf = _drags->current_pointer_frame ();
const int32_t divisions = _editor->get_grid_music_divisions (event->button.state);
- bool success = false;
- Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, pf);
- if (!success) {
- grid_beats = Evoral::Beats(1);
- }
+ const Evoral::Beats grid_beats = _region_view->get_grid_beats (pf);
double eqaf = map.exact_qn_at_frame (pf, divisions);
eqaf -= grid_beats.to_double();
}
}
- /* minimum initial length is grid beats */
- const double end_qn = eqaf + grid_beats.to_double();
_note[0] = map.frame_at_quarter_note (eqaf) - _region_view->region()->position();
- _note[1] = map.frame_at_quarter_note (end_qn) - _region_view->region()->position();
+ /* minimum initial length is grid beats */
+ _note[1] = map.frame_at_quarter_note (eqaf + grid_beats.to_double()) - _region_view->region()->position();
- MidiStreamView* sv = _region_view->midi_stream_view ();
double const x0 = _editor->sample_to_pixel (_note[0]);
double const x1 = _editor->sample_to_pixel (_note[1]);
- double const y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y)));
+ double const y = _region_view->note_to_y (_region_view->y_to_note (y_to_region (event->button.y)));
_drag_rect->set (ArdourCanvas::Rect (x0, y, x1, y + floor (_region_view->midi_stream_view()->note_height ())));
_drag_rect->set_outline_all ();
double eqaf = map.exact_qn_at_frame (pf, divisions);
if (divisions != 0) {
- bool success = false;
- Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, pf);
- if (!success) {
- grid_beats = Evoral::Beats(1);
- }
+
+ const Evoral::Beats grid_beats = _region_view->get_grid_beats (pf);
const double qaf = map.quarter_note_at_frame (pf);
/* Hack so that we always snap to the note that we are over, instead of snapping
}
-PercussiveCreateDrag::PercussiveCreateDrag (Editor* e, ArdourCanvas::Item* i, MidiRegionView* rv)
+HitCreateDrag::HitCreateDrag (Editor* e, ArdourCanvas::Item* i, MidiRegionView* rv)
: Drag (e, i)
, _region_view (rv)
- , _y (0.0)
+ , _last_pos (0)
+ , _last_y (0.0)
{
}
-PercussiveCreateDrag::~PercussiveCreateDrag ()
+HitCreateDrag::~HitCreateDrag ()
{
}
-framecnt_t
-PercussiveCreateDrag::grid_frames (framepos_t t) const
-{
- bool success;
- Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, t);
- if (!success) {
- grid_beats = Evoral::Beats(1);
- }
- const Evoral::Beats t_beats = _region_view->region_frames_to_region_beats (t);
-
- return _region_view->region_beats_to_region_frames (t_beats + grid_beats)
- - _region_view->region_beats_to_region_frames (t_beats);
-
-}
-
void
-PercussiveCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
+HitCreateDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
{
Drag::start_grab (event, cursor);
const framepos_t pf = _drags->current_pointer_frame ();
const int32_t divisions = _editor->get_grid_music_divisions (event->button.state);
- bool success = false;
- Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, pf);
- if (!success) {
- grid_beats = Evoral::Beats(1);
+ const double eqaf = map.exact_qn_at_frame (pf, divisions);
+
+ boost::shared_ptr<MidiRegion> mr = _region_view->midi_region();
+
+ if (eqaf >= mr->quarter_note() + mr->length_beats()) {
+ return;
}
- const double eqaf = map.exact_qn_at_frame (pf, divisions);
const framepos_t start = map.frame_at_quarter_note (eqaf) - _region_view->region()->position();
+ const double y = _region_view->note_to_y (_region_view->y_to_note (y_to_region (event->button.y)));
- MidiStreamView* sv = _region_view->midi_stream_view ();
- _y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y)));
+ Evoral::Beats length = _region_view->get_grid_beats (pf);
- _region_view->create_note_at (start, _y, grid_beats, event->button.state, false);
+ _region_view->create_note_at (start, y, length, event->button.state, false);
+
+ _last_pos = start;
+ _last_y = y;
}
void
-PercussiveCreateDrag::motion (GdkEvent* event, bool)
+HitCreateDrag::motion (GdkEvent* event, bool)
{
TempoMap& map (_editor->session()->tempo_map());
const framepos_t pf = _drags->current_pointer_frame ();
const int32_t divisions = _editor->get_grid_music_divisions (event->button.state);
+
+ if (divisions == 0) {
+ return;
+ }
+
const double eqaf = map.exact_qn_at_frame (pf, divisions);
const framepos_t start = map.frame_at_quarter_note (eqaf) - _region_view->region()->position ();
+ const double y = _region_view->note_to_y (_region_view->y_to_note (y_to_region (event->button.y)));
+
+ if (_last_pos == start && y == _last_y) {
+ return;
+ }
- MidiStreamView* sv = _region_view->midi_stream_view ();
- _y = sv->note_to_y (sv->y_to_note (y_to_region (event->button.y)));
+ Evoral::Beats length = _region_view->get_grid_beats (pf);
- bool success = false;
- Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, pf);
- if (!success) {
- grid_beats = Evoral::Beats(1);
+ boost::shared_ptr<MidiRegion> mr = _region_view->midi_region();
+ if (eqaf >= mr->quarter_note() + mr->length_beats()) {
+ return;
}
- _region_view->create_note_at (start, _y, grid_beats, event->button.state, false);
+ _region_view->create_note_at (start, y, length, event->button.state, false);
+ _last_pos = start;
+ _last_y = y;
}
void
-PercussiveCreateDrag::finished (GdkEvent* /* ev */, bool /* had_movement */)
+HitCreateDrag::finished (GdkEvent* /* ev */, bool /* had_movement */)
{
}
double
-PercussiveCreateDrag::y_to_region (double y) const
+HitCreateDrag::y_to_region (double y) const
{
double x = 0;
_region_view->get_canvas_group()->canvas_to_item (x, y);
}
void
-PercussiveCreateDrag::aborted (bool)
+HitCreateDrag::aborted (bool)
{
// umm..
}
{
line->set_position (pos);
line->show ();
+ line->track_canvas_item().reparent (_editor->_drag_motion_group);
}
RegionCutDrag::~RegionCutDrag ()
}
void
-RegionCutDrag::motion (GdkEvent*, bool)
+RegionCutDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
{
- framepos_t where = _drags->current_pointer_frame();
- _editor->snap_to (where);
+ Drag::start_grab (event, c);
+ motion (event, false);
+}
- line->set_position (where);
+void
+RegionCutDrag::motion (GdkEvent* event, bool)
+{
+ framepos_t pos = _drags->current_pointer_frame();
+ _editor->snap_to_with_modifier (pos, event);
+
+ line->set_position (pos);
}
void
_editor->get_track_canvas()->canvas()->re_enter();
framepos_t pos = _drags->current_pointer_frame();
+ _editor->snap_to_with_modifier (pos, event);
line->hide ();
return;
}
- _editor->split_regions_at (pos, rs, _editor->get_grid_music_divisions (event->button.state));
+ _editor->split_regions_at (pos, rs, _editor->get_grid_music_divisions (event->button.state),
+ false);
}
void