return adjusted_frame (_drags->current_pointer_frame (), event, snap);
}
+double
+Drag::current_pointer_x() const
+{
+ return _drags->current_pointer_x ();
+}
+
double
Drag::current_pointer_y () const
{
{
/* check to see if we have moved in any way that matters since the last motion event */
if (_move_threshold_passed &&
- (!x_movement_matters() || _last_pointer_frame == adjusted_current_frame (event)) &&
+ (!x_movement_matters() || _last_pointer_x == current_pointer_x ()) &&
(!y_movement_matters() || _last_pointer_y == current_pointer_y ()) ) {
return false;
}
if (_brushing) {
_editor->mouse_brush_insert_region (rv, pending_region_position);
} else {
- Duple track_origin (0, 1);
+ Duple track_origin;
/* Get the y coordinate of the top of the track that this region is now over */
track_origin = current_tv->canvas_display()->item_to_canvas (track_origin);
RegionRippleDrag::finished (GdkEvent* event, bool movement_occurred)
{
if (!movement_occurred) {
+
+ /* just a click */
+
+ if (was_double_click() && !_views.empty()) {
+ DraggingView dv = _views.front();
+ dv.view->show_region_editor ();
+
+ }
+
return;
}
if (x_fraction > 0.0 && x_fraction < 0.25) {
cursor = _editor->cursors()->left_side_trim;
+ at_front = true;
} else {
cursor = _editor->cursors()->right_side_trim;
+ at_front = false;
}
Drag::start_grab (event, cursor);
region = &cnote->region_view();
- double const region_start = region->get_position_pixels();
- double const middle_point = region_start + cnote->x0() + (cnote->x1() - cnote->x0()) / 2.0L;
-
- if (grab_x() <= middle_point) {
- cursor = _editor->cursors()->left_side_trim;
- at_front = true;
- } else {
- cursor = _editor->cursors()->right_side_trim;
- at_front = false;
- }
-
_item->grab ();
if (event->motion.state & Keyboard::PrimaryModifier) {
MidiRegionSelection::iterator next;
next = r;
++next;
- (*r)->begin_resizing (at_front);
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*r);
+ if (mrv) {
+ mrv->begin_resizing (at_front);
+ }
r = next;
}
}
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) {
NoteBase* nb = reinterpret_cast<NoteBase*> (_item->get_data ("notebase"));
assert (nb);
- (*r)->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative);
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*r);
+ if (mrv) {
+ mrv->update_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative);
+ }
}
}
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) {
NoteBase* nb = reinterpret_cast<NoteBase*> (_item->get_data ("notebase"));
assert (nb);
- (*r)->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative);
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*r);
+ if (mrv) {
+ mrv->commit_resizing (nb, at_front, _drags->current_pointer_x() - grab_x(), relative);
+ }
}
}
{
MidiRegionSelection& ms (_editor->get_selection().midi_regions);
for (MidiRegionSelection::iterator r = ms.begin(); r != ms.end(); ++r) {
- (*r)->abort_resizing ();
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*r);
+ if (mrv) {
+ mrv->abort_resizing ();
+ }
}
}
_marker = new MeterMarker (
*_editor,
*_editor->meter_group,
- ARDOUR_UI::config()->get_canvasvar_MeterMarker(),
+ ARDOUR_UI::config()->color ("meter marker"),
name,
*new MeterSection (_marker->meter())
);
}
framepos_t const pf = adjusted_current_frame (event);
+
_marker->set_position (pf);
show_verbose_cursor_time (pf);
}
_marker = new TempoMarker (
*_editor,
*_editor->tempo_group,
- ARDOUR_UI::config()->get_canvasvar_TempoMarker(),
+ ARDOUR_UI::config()->color ("tempo marker"),
name,
*new TempoSection (_marker->tempo())
);
motion (event, false);
TempoMap& map (_editor->session()->tempo_map());
- framepos_t beat_time = map.round_to_beat (last_pointer_frame(), 0);
+ framepos_t beat_time = map.round_to_beat (last_pointer_frame(), RoundNearest);
Timecode::BBT_Time when;
map.bbt_time (beat_time, when);
} else if (new_start < copy_location->end()) {
copy_location->set_start (new_start);
} else if (newframe > 0) {
- _editor->snap_to (next, 1, true);
+ _editor->snap_to (next, RoundUpAlways, true);
copy_location->set_end (next);
copy_location->set_start (newframe);
}
} else if (new_end > copy_location->start()) {
copy_location->set_end (new_end);
} else if (newframe > 0) {
- _editor->snap_to (next, -1, true);
+ _editor->snap_to (next, RoundDownAlways, true);
copy_location->set_start (next);
copy_location->set_end (newframe);
}
bool
ControlPointDrag::active (Editing::MouseMode m)
{
- if (m == Editing::MouseGain) {
- /* always active in mouse gain */
+ if (m == Editing::MouseDraw) {
+ /* always active in mouse draw */
return true;
}
if ((mtv = dynamic_cast<MidiTimeAxisView*>(_editor->clicked_axisview)) != 0) {
/* MIDI track */
- if (_editor->selection->empty()) {
+ if (_editor->selection->empty() && _editor->mouse_mode == MouseDraw) {
/* nothing selected */
add_midi_region (mtv);
do_deselect = false;
: Drag (e, i)
, _operation (o)
, _add (false)
- , _extend (false)
, _original_pointer_time_axis (-1)
- , _last_pointer_time_axis (-1)
, _time_selection_at_start (!_editor->get_selection().time.empty())
{
DEBUG_TRACE (DEBUG::Drags, "New SelectionDrag\n");
if (first_move) {
grab = adjusted_current_frame (event, false);
if (grab < pending_position) {
- _editor->snap_to (grab, -1);
+ _editor->snap_to (grab, RoundDownMaybe);
} else {
- _editor->snap_to (grab, 1);
+ _editor->snap_to (grab, RoundUpMaybe);
}
}
physical_screen_height (_editor->get_window())));
_drag_rect->hide ();
- _drag_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_RangeDragRect());
- _drag_rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_RangeDragRect());
+ _drag_rect->set_fill_color (ARDOUR_UI::config()->color ("range drag rect"));
+ _drag_rect->set_outline_color (ARDOUR_UI::config()->color ("range drag rect"));
}
void
}
switch (_operation) {
+ case CreateSkipMarker:
case CreateRangeMarker:
case CreateTransportMarker:
case CreateCDMarker:
ArdourCanvas::Rectangle *crect;
switch (_operation) {
+ case CreateSkipMarker:
+ crect = _editor->range_bar_drag_rect;
+ break;
case CreateRangeMarker:
crect = _editor->range_bar_drag_rect;
break;
framepos_t const pf = adjusted_current_frame (event);
- if (_operation == CreateRangeMarker || _operation == CreateTransportMarker || _operation == CreateCDMarker) {
+ if (_operation == CreateSkipMarker || _operation == CreateRangeMarker || _operation == CreateTransportMarker || _operation == CreateCDMarker) {
framepos_t grab = grab_frame ();
_editor->snap_to (grab);
_drag_rect->hide();
switch (_operation) {
+ case CreateSkipMarker:
case CreateRangeMarker:
case CreateCDMarker:
{
- _editor->begin_reversible_command (_("new range marker"));
XMLNode &before = _editor->session()->locations()->get_state();
- _editor->session()->locations()->next_available_name(rangename,"unnamed");
- if (_operation == CreateCDMarker) {
+ if (_operation == CreateSkipMarker) {
+ _editor->begin_reversible_command (_("new skip marker"));
+ _editor->session()->locations()->next_available_name(rangename,_("skip"));
+ flags = Location::IsRangeMarker | Location::IsSkip;
+ _editor->range_bar_drag_rect->hide();
+ } else if (_operation == CreateCDMarker) {
+ _editor->session()->locations()->next_available_name(rangename, _("CD"));
+ _editor->begin_reversible_command (_("new CD marker"));
flags = Location::IsRangeMarker | Location::IsCDMarker;
_editor->cd_marker_bar_drag_rect->hide();
- }
- else {
+ } else {
+ _editor->begin_reversible_command (_("new skip marker"));
+ _editor->session()->locations()->next_available_name(rangename, _("unnamed"));
flags = Location::IsRangeMarker;
_editor->range_bar_drag_rect->hide();
}
/* didn't drag, but mark is already created so do
* nothing */
- } else { /* operation == CreateRangeMarker */
+ } else { /* operation == CreateRangeMarker || CreateSkipMarker */
framepos_t start;
_drag_rect->set_x1 (x2);
}
-MouseZoomDrag::MouseZoomDrag (Editor* e, ArdourCanvas::Item* i)
- : Drag (e, i)
- , _zoom_out (false)
-{
- DEBUG_TRACE (DEBUG::Drags, "New MouseZoomDrag\n");
-}
-
-void
-MouseZoomDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
-{
- if (Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
- Drag::start_grab (event, _editor->cursors()->zoom_out);
- _zoom_out = true;
- } else {
- Drag::start_grab (event, _editor->cursors()->zoom_in);
- _zoom_out = false;
- }
-
- show_verbose_cursor_time (adjusted_current_frame (event));
-}
-
-void
-MouseZoomDrag::motion (GdkEvent* event, bool first_move)
-{
- framepos_t start;
- framepos_t end;
-
- framepos_t const pf = adjusted_current_frame (event);
-
- framepos_t grab = grab_frame ();
- _editor->snap_to_with_modifier (grab, event);
-
- /* base start and end on initial click position */
- if (pf < grab) {
- start = pf;
- end = grab;
- } else {
- end = pf;
- start = grab;
- }
-
- if (start != end) {
-
- if (first_move) {
- _editor->zoom_rect->show();
- _editor->zoom_rect->raise_to_top();
- }
-
- _editor->reposition_zoom_rect(start, end);
-
- show_verbose_cursor_time (pf);
- }
-}
-
-void
-MouseZoomDrag::finished (GdkEvent* event, bool movement_occurred)
-{
- if (movement_occurred) {
- motion (event, false);
-
- if (grab_frame() < last_pointer_frame()) {
- _editor->temporal_zoom_by_frame (grab_frame(), last_pointer_frame());
- } else {
- _editor->temporal_zoom_by_frame (last_pointer_frame(), grab_frame());
- }
- } else {
- if (Keyboard::the_keyboard().key_is_down (GDK_Shift_L)) {
- _editor->tav_zoom_step (_zoom_out);
- } else {
- _editor->temporal_zoom_to_frame (_zoom_out, grab_frame());
- }
- }
-
- _editor->zoom_rect->hide();
-}
-
-void
-MouseZoomDrag::aborted (bool)
-{
- _editor->zoom_rect->hide ();
-}
-
NoteDrag::NoteDrag (Editor* e, ArdourCanvas::Item* i)
: Drag (e, i)
, _cumulative_dx (0)
void
MidiRubberbandSelectDrag::select_things (int button_state, framepos_t x1, framepos_t x2, double y1, double y2, bool /*drag_in_progress*/)
{
- framepos_t const p = _region_view->region()->position ();
- double const y = _region_view->midi_view()->y_position ();
-
- x1 = max ((framepos_t) 0, x1 - p);
- x2 = max ((framepos_t) 0, x2 - p);
- y1 = max (0.0, y1 - y);
- y2 = max (0.0, y2 - y);
-
_region_view->update_drag_selection (
- _editor->sample_to_pixel (x1),
- _editor->sample_to_pixel (x2),
- y1,
- y2,
- Keyboard::modifier_state_contains (button_state, Keyboard::TertiaryModifier)
- );
+ x1, x2, y1, y2,
+ Keyboard::modifier_state_contains (button_state, Keyboard::TertiaryModifier));
}
void
, _region_view (rv)
, _drag_rect (0)
{
-
+ _note[0] = _note[1] = 0;
}
NoteCreateDrag::~NoteCreateDrag ()
bool success;
Evoral::MusicalTime grid_beats = _editor->get_grid_type_as_beats (success, t);
if (!success) {
- grid_beats = 1;
+ grid_beats = Evoral::MusicalTime(1);
}
return _region_view->region_beats_to_region_frames (grid_beats);
}
_note[0] = adjusted_frame (pf, event) - _region_view->region()->position ();
+ _note[1] = _note[0];
MidiStreamView* sv = _region_view->midi_stream_view ();
double const x = _editor->sample_to_pixel (_note[0]);
NoteCreateDrag::motion (GdkEvent* event, bool)
{
_note[1] = max ((framepos_t)0, adjusted_current_frame (event) - _region_view->region()->position ());
- double const x = _editor->sample_to_pixel (_note[1]);
- if (_note[1] > _note[0]) {
- _drag_rect->set_x1 (x);
- } else {
- _drag_rect->set_x0 (x);
- }
+ double const x0 = _editor->sample_to_pixel (_note[0]);
+ double const x1 = _editor->sample_to_pixel (_note[1]);
+ _drag_rect->set_x0 (std::min(x0, x1));
+ _drag_rect->set_x1 (std::max(x0, x1));
}
void
framecnt_t length = (framecnt_t) fabs ((double)(_note[0] - _note[1]));
framecnt_t const g = grid_frames (start);
- double const one_tick = 1 / Timecode::BBT_Time::ticks_per_beat;
+ Evoral::MusicalTime const one_tick = Evoral::MusicalTime::ticks(1);
if (_editor->snap_mode() == SnapNormal && length < g) {
- length = g - one_tick;
+ length = g;
}
- double const length_beats = max (one_tick, _region_view->region_frames_to_region_beats (length));
+ Evoral::MusicalTime length_beats = max (
+ one_tick, _region_view->region_frames_to_region_beats (length) - one_tick);
_region_view->create_note_at (start, _drag_rect->y0(), length_beats, false);
}