more changes to get mouse interactions with markers + rulers closer to PRD

This commit is contained in:
Paul Davis 2014-09-23 16:54:54 -04:00
parent ef54453554
commit 93cf0a7ccb
4 changed files with 97 additions and 124 deletions

View file

@ -2158,6 +2158,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
friend class ScrubDrag;
friend class SelectionDrag;
friend class RangeMarkerBarDrag;
friend class MarkerBarDrag;
friend class MouseZoomDrag;
friend class RegionCreateDrag;
friend class RegionMotionDrag;

View file

@ -3283,7 +3283,7 @@ MarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
}
void
MarkerDrag::motion (GdkEvent* event, bool)
MarkerDrag::motion (GdkEvent*, bool)
{
framecnt_t f_delta = 0;
Location *real_location;
@ -4768,11 +4768,51 @@ SelectionDrag::aborted (bool)
/* XXX: TODO */
}
MarkerBarDrag::MarkerBarDrag (Editor* e, ArdourCanvas::Item* i)
: Drag (e, i, false)
{
DEBUG_TRACE (DEBUG::Drags, "New MarkerBarDrag\n");
}
void
MarkerBarDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
{
Gdk::Cursor * const cursor = _editor->cursors()->selector;
Drag::start_grab (event, cursor);
show_verbose_cursor_time (adjusted_current_frame (event));
}
void
MarkerBarDrag::motion (GdkEvent*, bool first_move)
{
show_verbose_cursor_time (_drags->current_pointer_frame());
}
void
MarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
{
if (!movement_occurred) {
framepos_t where = _drags->current_pointer_frame();
_editor->snap_to_with_modifier (where, event);
_editor->mouse_add_new_marker (where);
}
_editor->stop_canvas_autoscroll ();
}
void
MarkerBarDrag::aborted (bool)
{
/* XXX: TODO */
}
RangeMarkerBarDrag::RangeMarkerBarDrag (Editor* e, ArdourCanvas::Item* i, Operation o)
: Drag (e, i, false)
, _drag_rect (0)
, _crect (0)
, _operation (o)
, _crect (0)
, _copy (false)
{
DEBUG_TRACE (DEBUG::Drags, "New RangeMarkerBarDrag\n");
@ -4791,20 +4831,7 @@ RangeMarkerBarDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
_editor->temp_location = new Location (*_editor->session());
}
switch (_operation) {
case CreateSkipMarker:
case CreateRangeMarker:
case CreateTransportMarker:
case CreateCDMarker:
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) {
_copy = true;
} else {
_copy = false;
}
cursor = _editor->cursors()->selector;
break;
}
cursor = _editor->cursors()->selector;
Drag::start_grab (event, cursor);
@ -4841,6 +4868,7 @@ RangeMarkerBarDrag::motion (GdkEvent* event, bool first_move)
_crect = _editor->range_bar_drag_rect;
break;
case CreateTransportMarker:
case CreateLoopMarker:
_crect = _editor->transport_bar_drag_rect;
break;
case CreateCDMarker:
@ -4940,7 +4968,11 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
break;
}
case CreateTransportMarker:
break;
case CreateLoopMarker:
/* Ardour used to offer a menu to choose between setting loop + autopunch range here */
_editor->set_loop_range (_editor->temp_location->start(), _editor->temp_location->end(), _("set loop range"));
break;
@ -4948,48 +4980,8 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
} else {
/* just a click, no pointer movement. remember that context menu stuff was handled elsewhere */
/* just a click, no pointer movement... currently do nothing at all */
if (_operation == CreateTransportMarker) {
/* tracks does not locate for a click in the range marker bar */
} else if (_operation == CreateCDMarker) {
/* didn't drag, but mark is already created so do
* nothing */
} else { /* operation == CreateRangeMarker || CreateSkipMarker */
framepos_t start;
framepos_t end;
_editor->session()->locations()->marks_either_side (grab_frame(), start, end);
if (end == max_framepos) {
end = _editor->session()->current_end_frame ();
}
if (start == max_framepos) {
start = _editor->session()->current_start_frame ();
}
switch (_editor->mouse_mode) {
case MouseObject:
/* find the two markers on either side and then make the selection from it */
_editor->select_all_within (start, end, 0.0f, FLT_MAX, _editor->track_views, Selection::Set, false);
break;
case MouseRange:
/* find the two markers on either side of the click and make the range out of it */
_editor->selection->set (start, end);
break;
default:
break;
}
}
}
_editor->stop_canvas_autoscroll ();

View file

@ -987,15 +987,17 @@ private:
framepos_t end_at_start;
};
/** Range marker drag */
/** Drag in a bar that displays Range markers */
class RangeMarkerBarDrag : public Drag
{
public:
enum Operation {
CreateMarker,
CreateSkipMarker,
CreateRangeMarker,
CreateTransportMarker,
CreateCDMarker
CreateCDMarker,
CreateLoopMarker
};
RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
@ -1022,6 +1024,28 @@ private:
bool _copy;
};
/** marker bar drag */
class MarkerBarDrag : public Drag
{
public:
MarkerBarDrag (Editor *, ArdourCanvas::Item *);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *, bool);
void finished (GdkEvent *, bool);
void aborted (bool);
bool allow_vertical_autoscroll () const {
return false;
}
bool y_movement_matters () const {
return false;
}
private:
};
/** Drag of rectangle to set zoom */
class MouseZoomDrag : public Drag
{

View file

@ -668,52 +668,31 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
break;
case MarkerBarItem:
case TempoBarItem:
case MeterBarItem:
case TimecodeRulerItem:
case SamplesRulerItem:
case MinsecRulerItem:
case BBTRulerItem:
case ClockRulerItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateTransportMarker), event);
}
return true;
break;
_drags->set (new MarkerBarDrag (this, item), event);
break;
case SkipBarItem:
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateSkipMarker), event);
return true;
break;
case RangeMarkerBarItem:
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateRangeMarker), event);
} else {
_drags->set (new CursorDrag (this, *playhead_cursor, false), event);
}
return true;
break;
case CdMarkerBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
_drags->set (new CursorDrag (this, *playhead_cursor, false), event);
} else {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateCDMarker), event);
}
return true;
break;
case PunchLoopBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
_drags->set (new CursorDrag (this, *playhead_cursor, false), event);
} else {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateTransportMarker), event);
}
case ClockRulerItem:
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateLoopMarker), event);
return true;
break;
case RangeMarkerBarItem:
case CdMarkerBarItem:
case TempoBarItem:
case MeterBarItem:
case TimecodeRulerItem:
case SamplesRulerItem:
case MinsecRulerItem:
case BBTRulerItem:
/* these are not visible/do not exist in Tracks */
return true;
break;
default:
break;
}
@ -1603,29 +1582,15 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
case AutomationLineItem:
case StartSelectionTrimItem:
case EndSelectionTrimItem:
return true;
case MarkerBarItem:
if (!_dragging_playhead) {
snap_to_with_modifier (where, event, 0, true);
mouse_add_new_marker (where);
}
return true;
case CdMarkerBarItem:
if (!_dragging_playhead) {
// if we get here then a dragged range wasn't done
snap_to_with_modifier (where, event, 0, true);
mouse_add_new_marker (where, true);
}
return true;
case TempoBarItem:
if (!_dragging_playhead) {
snap_to_with_modifier (where, event);
mouse_add_new_tempo_event (where);
}
return true;
case TimecodeRulerItem:
case SamplesRulerItem:
case MinsecRulerItem:
case BBTRulerItem:
/* interactions handled by a Drag object, nothing to do */
return true;
case MeterBarItem:
if (!_dragging_playhead) {
@ -1634,13 +1599,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
return true;
break;
case TimecodeRulerItem:
case SamplesRulerItem:
case MinsecRulerItem:
case BBTRulerItem:
return true;
break;
default:
break;
}
@ -1895,8 +1853,6 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type)
{
AutomationLine* al;
Marker *marker;
Location *loc;
bool is_start;
bool ret = true;
switch (item_type) {