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 ScrubDrag;
friend class SelectionDrag; friend class SelectionDrag;
friend class RangeMarkerBarDrag; friend class RangeMarkerBarDrag;
friend class MarkerBarDrag;
friend class MouseZoomDrag; friend class MouseZoomDrag;
friend class RegionCreateDrag; friend class RegionCreateDrag;
friend class RegionMotionDrag; friend class RegionMotionDrag;

View file

@ -3283,7 +3283,7 @@ MarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
} }
void void
MarkerDrag::motion (GdkEvent* event, bool) MarkerDrag::motion (GdkEvent*, bool)
{ {
framecnt_t f_delta = 0; framecnt_t f_delta = 0;
Location *real_location; Location *real_location;
@ -4768,11 +4768,51 @@ SelectionDrag::aborted (bool)
/* XXX: TODO */ /* 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) RangeMarkerBarDrag::RangeMarkerBarDrag (Editor* e, ArdourCanvas::Item* i, Operation o)
: Drag (e, i, false) : Drag (e, i, false)
, _drag_rect (0) , _drag_rect (0)
, _crect (0)
, _operation (o) , _operation (o)
, _crect (0)
, _copy (false) , _copy (false)
{ {
DEBUG_TRACE (DEBUG::Drags, "New RangeMarkerBarDrag\n"); 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()); _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; cursor = _editor->cursors()->selector;
break;
}
Drag::start_grab (event, cursor); Drag::start_grab (event, cursor);
@ -4841,6 +4868,7 @@ RangeMarkerBarDrag::motion (GdkEvent* event, bool first_move)
_crect = _editor->range_bar_drag_rect; _crect = _editor->range_bar_drag_rect;
break; break;
case CreateTransportMarker: case CreateTransportMarker:
case CreateLoopMarker:
_crect = _editor->transport_bar_drag_rect; _crect = _editor->transport_bar_drag_rect;
break; break;
case CreateCDMarker: case CreateCDMarker:
@ -4940,7 +4968,11 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
break; break;
} }
case CreateTransportMarker: case CreateTransportMarker:
break;
case CreateLoopMarker:
/* Ardour used to offer a menu to choose between setting loop + autopunch range here */ /* 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")); _editor->set_loop_range (_editor->temp_location->start(), _editor->temp_location->end(), _("set loop range"));
break; break;
@ -4948,48 +4980,8 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
} else { } 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 (); _editor->stop_canvas_autoscroll ();

View file

@ -987,15 +987,17 @@ private:
framepos_t end_at_start; framepos_t end_at_start;
}; };
/** Range marker drag */ /** Drag in a bar that displays Range markers */
class RangeMarkerBarDrag : public Drag class RangeMarkerBarDrag : public Drag
{ {
public: public:
enum Operation { enum Operation {
CreateMarker,
CreateSkipMarker, CreateSkipMarker,
CreateRangeMarker, CreateRangeMarker,
CreateTransportMarker, CreateTransportMarker,
CreateCDMarker CreateCDMarker,
CreateLoopMarker
}; };
RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation); RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
@ -1022,6 +1024,28 @@ private:
bool _copy; 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 */ /** Drag of rectangle to set zoom */
class MouseZoomDrag : public Drag class MouseZoomDrag : public Drag
{ {

View file

@ -668,52 +668,31 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
break; break;
case MarkerBarItem: case MarkerBarItem:
case TempoBarItem: _drags->set (new MarkerBarDrag (this, item), event);
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; break;
case SkipBarItem: case SkipBarItem:
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateSkipMarker), event); _drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateSkipMarker), event);
return true; return true;
break; 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: case PunchLoopBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { case ClockRulerItem:
_drags->set (new CursorDrag (this, *playhead_cursor, false), event); _drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateLoopMarker), event);
} else {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateTransportMarker), event);
}
return true; return true;
break; 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: default:
break; break;
} }
@ -1603,28 +1582,14 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
case AutomationLineItem: case AutomationLineItem:
case StartSelectionTrimItem: case StartSelectionTrimItem:
case EndSelectionTrimItem: case EndSelectionTrimItem:
return true;
case MarkerBarItem: case MarkerBarItem:
if (!_dragging_playhead) {
snap_to_with_modifier (where, event, 0, true);
mouse_add_new_marker (where);
}
return true;
case CdMarkerBarItem: 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: case TempoBarItem:
if (!_dragging_playhead) { case TimecodeRulerItem:
snap_to_with_modifier (where, event); case SamplesRulerItem:
mouse_add_new_tempo_event (where); case MinsecRulerItem:
} case BBTRulerItem:
/* interactions handled by a Drag object, nothing to do */
return true; return true;
case MeterBarItem: case MeterBarItem:
@ -1634,13 +1599,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
return true; return true;
break; break;
case TimecodeRulerItem:
case SamplesRulerItem:
case MinsecRulerItem:
case BBTRulerItem:
return true;
break;
default: default:
break; break;
} }
@ -1895,8 +1853,6 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type)
{ {
AutomationLine* al; AutomationLine* al;
Marker *marker; Marker *marker;
Location *loc;
bool is_start;
bool ret = true; bool ret = true;
switch (item_type) { switch (item_type) {