X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_mouse.cc;h=d1d9afc985c74f48ab92a1b2b65f6b8b330b4a86;hb=a052488c002f21839ca7babb855a481a86eba648;hp=8e5db51948568050d3ece03c8d249a8af907a3c7;hpb=c246926e4148e9996060bd6865ff03a962ddab2e;p=ardour.git diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 8e5db51948..d1d9afc985 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -56,6 +56,8 @@ #include "editor_drag.h" #include "automation_region_view.h" #include "edit_note_dialog.h" +#include "mouse_cursors.h" +#include "editor_cursors.h" #include "ardour/types.h" #include "ardour/profile.h" @@ -72,6 +74,7 @@ #include "ardour/region_factory.h" #include "ardour/source_factory.h" #include "ardour/session.h" +#include "ardour/operations.h" #include @@ -171,20 +174,20 @@ Editor::event_frame (GdkEvent const * event, double* pcx, double* pcy) const Gdk::Cursor* Editor::which_grabber_cursor () { - Gdk::Cursor* c = grabber_cursor; + Gdk::Cursor* c = _cursors->grabber; if (_internal_editing) { switch (mouse_mode) { case MouseRange: - c = midi_pencil_cursor; + c = _cursors->midi_pencil; break; case MouseObject: - c = grabber_note_cursor; + c = _cursors->grabber_note; break; case MouseTimeFX: - c = midi_resize_cursor; + c = _cursors->midi_resize; break; default: @@ -195,13 +198,13 @@ Editor::which_grabber_cursor () switch (_edit_point) { case EditAtMouse: - c = grabber_edit_point_cursor; + c = _cursors->grabber_edit_point; break; default: - boost::shared_ptr m = _movable.lock(); - if (m && m->locked()) { - c = speaker_cursor; - } + boost::shared_ptr m = _movable.lock(); + if (m && m->locked()) { + c = _cursors->speaker; + } break; } } @@ -212,24 +215,23 @@ Editor::which_grabber_cursor () void Editor::set_current_trimmable (boost::shared_ptr t) { - boost::shared_ptr st = _trimmable.lock(); + boost::shared_ptr st = _trimmable.lock(); - if (!st || st == t) { - _trimmable = t; - set_canvas_cursor (); - } - + if (!st || st == t) { + _trimmable = t; + set_canvas_cursor (); + } } void Editor::set_current_movable (boost::shared_ptr m) { - boost::shared_ptr sm = _movable.lock(); + boost::shared_ptr sm = _movable.lock(); - if (!sm || sm != m) { - _movable = m; - set_canvas_cursor (); - } + if (!sm || sm != m) { + _movable = m; + set_canvas_cursor (); + } } void @@ -239,7 +241,7 @@ Editor::set_canvas_cursor () switch (mouse_mode) { case MouseRange: - current_canvas_cursor = midi_pencil_cursor; + current_canvas_cursor = _cursors->midi_pencil; break; case MouseObject: @@ -247,7 +249,7 @@ Editor::set_canvas_cursor () break; case MouseTimeFX: - current_canvas_cursor = midi_resize_cursor; + current_canvas_cursor = _cursors->midi_resize; break; default: @@ -258,7 +260,7 @@ Editor::set_canvas_cursor () switch (mouse_mode) { case MouseRange: - current_canvas_cursor = selector_cursor; + current_canvas_cursor = _cursors->selector; break; case MouseObject: @@ -266,23 +268,23 @@ Editor::set_canvas_cursor () break; case MouseGain: - current_canvas_cursor = cross_hair_cursor; + current_canvas_cursor = _cursors->cross_hair; break; case MouseZoom: if (Keyboard::the_keyboard().key_is_down (GDK_Control_L)) { - current_canvas_cursor = zoom_out_cursor; + current_canvas_cursor = _cursors->zoom_out; } else { - current_canvas_cursor = zoom_in_cursor; + current_canvas_cursor = _cursors->zoom_in; } break; case MouseTimeFX: - current_canvas_cursor = time_fx_cursor; // just use playhead + current_canvas_cursor = _cursors->time_fx; // just use playhead break; case MouseAudition: - current_canvas_cursor = speaker_cursor; + current_canvas_cursor = _cursors->speaker; break; } } @@ -294,7 +296,7 @@ Editor::set_canvas_cursor () current_canvas_cursor = which_grabber_cursor (); break; case JOIN_OBJECT_RANGE_RANGE: - current_canvas_cursor = selector_cursor; + current_canvas_cursor = _cursors->selector; break; } @@ -303,12 +305,12 @@ Editor::set_canvas_cursor () if (last_item_entered->property_parent() && (*last_item_entered->property_parent()).get_data (X_("timeselection"))) { pair tvp = trackview_by_y_position (_last_motion_y + vertical_adjustment.get_value() - canvas_timebars_vsize); if (dynamic_cast (tvp.first)) { - current_canvas_cursor = up_down_cursor; + current_canvas_cursor = _cursors->up_down; } } } - set_canvas_cursor (current_canvas_cursor, true); + set_canvas_cursor (current_canvas_cursor, true); } void @@ -358,6 +360,8 @@ Editor::set_mouse_mode (MouseMode m, bool force) /* go there and back to ensure that the toggled handler is called to set up mouse_mode */ tact->set_active (false); tact->set_active (true); + + MouseModeChanged (); /* EMIT SIGNAL */ } void @@ -367,33 +371,35 @@ Editor::mouse_mode_toggled (MouseMode m) instant_save (); - if (!internal_editing()) { - if (mouse_mode != MouseRange && _join_object_range_state == JOIN_OBJECT_RANGE_NONE) { + if (!internal_editing()) { + if (mouse_mode != MouseRange && _join_object_range_state == JOIN_OBJECT_RANGE_NONE) { - /* in all modes except range and joined object/range, hide the range selection, - show the object (region) selection. - */ + /* in all modes except range and joined object/range, hide the range selection, + show the object (region) selection. + */ - for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { - (*i)->set_should_show_selection (true); - } - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - (*i)->hide_selection (); - } + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + (*i)->set_should_show_selection (true); + } + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + (*i)->hide_selection (); + } - } else { + } else { - /* - in range or object/range mode, show the range selection. - */ + /* + in range or object/range mode, show the range selection. + */ - for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { - (*i)->show_selection (selection->time); - } - } - } + for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + (*i)->show_selection (selection->time); + } + } + } set_canvas_cursor (); + + MouseModeChanged (); /* EMIT SIGNAL */ } void @@ -517,8 +523,8 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp case RegionViewNameHighlight: case RegionViewName: - case LeftFrameHandle: - case RightFrameHandle: + case LeftFrameHandle: + case RightFrameHandle: if (mouse_mode != MouseRange || _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) { set_selected_regionview_from_click (press, op, true); } else if (event->type == GDK_BUTTON_PRESS) { @@ -694,7 +700,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT AutomationTimeAxisView* atv = dynamic_cast (tvp.first); if (join_object_range_button.get_active() && atv) { /* smart "join" mode: drag automation */ - _drags->set (new AutomationRangeDrag (this, atv->base_item(), selection->time), event, up_down_cursor); + _drags->set (new AutomationRangeDrag (this, atv->base_item(), selection->time), event, _cursors->up_down); } else { /* this was debated, but decided the more common action was to make a new selection */ @@ -704,45 +710,45 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT } break; - case NoteItem: - if (internal_editing()) { - /* trim notes if we're in internal edit mode and near the ends of the note */ - ArdourCanvas::CanvasNote* cn = dynamic_cast (item); - cerr << "NoteItem button press, cursor = " << current_canvas_cursor << endl; - if (cn->mouse_near_ends()) { - _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor); - } else { - _drags->set (new NoteDrag (this, item), event); - } - } + case NoteItem: + if (internal_editing()) { + /* trim notes if we're in internal edit mode and near the ends of the note */ + ArdourCanvas::CanvasNote* cn = dynamic_cast (item); + cerr << "NoteItem button press, cursor = " << current_canvas_cursor << endl; + if (cn->mouse_near_ends()) { + _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor); + } else { + _drags->set (new NoteDrag (this, item), event); + } + } return true; - case StreamItem: - if (internal_editing()) { + case StreamItem: + if (internal_editing()) { if (dynamic_cast (clicked_axisview)) { _drags->set (new RegionCreateDrag (this, item, clicked_axisview), event); return true; } - } else { + } else { _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event); return true; } - break; + break; - case RegionViewNameHighlight: - case LeftFrameHandle: - case RightFrameHandle: - if (!clicked_regionview->region()->locked()) { - RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id); - _drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event); - return true; - } - break; + case RegionViewNameHighlight: + case LeftFrameHandle: + case RightFrameHandle: + if (!clicked_regionview->region()->locked()) { + RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id); + _drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event); + return true; + } + break; default: - if (!internal_editing()) { - _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event); - } + if (!internal_editing()) { + _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event); + } } return true; break; @@ -751,12 +757,12 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT switch (item_type) { case NoteItem: if (internal_editing()) { - ArdourCanvas::CanvasNote* cn = dynamic_cast (item); - if (cn->mouse_near_ends()) { - _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor); - } else { - _drags->set (new NoteDrag (this, item), event); - } + ArdourCanvas::CanvasNoteEvent* cn = dynamic_cast (item); + if (cn->mouse_near_ends()) { + _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor); + } else { + _drags->set (new NoteDrag (this, item), event); + } return true; } break; @@ -776,14 +782,14 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case FadeInHandleItem: { RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id); - _drags->set (new FadeInDrag (this, item, reinterpret_cast (item->get_data("regionview")), s), event); + _drags->set (new FadeInDrag (this, item, reinterpret_cast (item->get_data("regionview")), s), event, _cursors->fade_in); return true; } case FadeOutHandleItem: { RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id); - _drags->set (new FadeOutDrag (this, item, reinterpret_cast (item->get_data("regionview")), s), event); + _drags->set (new FadeOutDrag (this, item, reinterpret_cast (item->get_data("regionview")), s), event, _cursors->fade_out); return true; } @@ -884,7 +890,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT /* if we're over an automation track, start a drag of its data */ AutomationTimeAxisView* atv = dynamic_cast (tvp.first); if (atv) { - _drags->set (new AutomationRangeDrag (this, atv->base_item(), selection->time), event, up_down_cursor); + _drags->set (new AutomationRangeDrag (this, atv->base_item(), selection->time), event, _cursors->up_down); } /* if we're over a track and a region, and in the `object' part of a region, @@ -1022,7 +1028,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT scrub_reverse_distance = 0; last_scrub_x = event->button.x; scrubbing_direction = 0; - set_canvas_cursor (transparent_cursor); + set_canvas_cursor (_cursors->transparent); return true; break; @@ -1249,7 +1255,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case StreamItem: - popup_track_context_menu (1, event->button.time, item_type, false, where); + popup_track_context_menu (1, event->button.time, item_type, false); break; case RegionItem: @@ -1257,15 +1263,15 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case LeftFrameHandle: case RightFrameHandle: case RegionViewName: - popup_track_context_menu (1, event->button.time, item_type, false, where); + popup_track_context_menu (1, event->button.time, item_type, false); break; case SelectionItem: - popup_track_context_menu (1, event->button.time, item_type, true, where); + popup_track_context_menu (1, event->button.time, item_type, true); break; case AutomationTrackItem: - popup_track_context_menu (1, event->button.time, item_type, false, where); + popup_track_context_menu (1, event->button.time, item_type, false); break; case MarkerBarItem: @@ -1290,7 +1296,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case CrossfadeViewItem: - popup_track_context_menu (1, event->button.time, item_type, false, where); + popup_track_context_menu (1, event->button.time, item_type, false); break; #ifdef WITH_CMT @@ -1542,7 +1548,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ fraction = 1.0 - (cp->get_y() / cp->line().height()); if (is_drawable() && !_drags->active ()) { - set_canvas_cursor (fader_cursor); + set_canvas_cursor (_cursors->fader); } set_verbose_canvas_cursor (cp->line().get_verbose_cursor_string (fraction), at_x, at_y); @@ -1556,7 +1562,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ if (line) line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_EnteredGainLine.get(); if (is_drawable()) { - set_canvas_cursor (fader_cursor); + set_canvas_cursor (_cursors->fader); } } break; @@ -1569,36 +1575,22 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_EnteredAutomationLine.get(); } if (is_drawable()) { - set_canvas_cursor (fader_cursor); + set_canvas_cursor (_cursors->fader); } } break; case RegionViewNameHighlight: - if (is_drawable() && mouse_mode == MouseObject && !internal_editing()) { - set_canvas_cursor (trimmer_cursor); + if (is_drawable() && mouse_mode == MouseObject && !internal_editing() && entered_regionview) { + set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview); + _over_region_trim_target = true; } break; case LeftFrameHandle: - if (is_drawable() && mouse_mode == MouseObject && !internal_editing()) { - if (entered_regionview) { - Trimmable::CanTrim ct = entered_regionview->region()->can_trim(); - if ((ct & Trimmable::EndTrimEarlier) || (ct & Trimmable::EndTrimLater)) { - set_canvas_cursor (left_side_trim_cursor); - } - } - } - break; - case RightFrameHandle: - if (is_drawable() && mouse_mode == MouseObject && !internal_editing()) { - if (entered_regionview) { - Trimmable::CanTrim ct = entered_regionview->region()->can_trim(); - if ((ct & Trimmable::FrontTrimEarlier) || (ct & Trimmable::FrontTrimLater)) { - set_canvas_cursor (right_side_trim_cursor); - } - } + if (is_drawable() && mouse_mode == MouseObject && !internal_editing() && entered_regionview) { + set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview); } break; @@ -1613,7 +1605,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ #endif if (is_drawable()) { - set_canvas_cursor (trimmer_cursor); + set_canvas_cursor (_cursors->trimmer); } break; @@ -1621,10 +1613,10 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ if (is_drawable()) { switch (_edit_point) { case EditAtMouse: - set_canvas_cursor (grabber_edit_point_cursor); + set_canvas_cursor (_cursors->grabber_edit_point); break; default: - set_canvas_cursor (grabber_cursor); + set_canvas_cursor (_cursors->grabber); break; } } @@ -1636,7 +1628,8 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ if (!reinterpret_cast (item->get_data ("regionview"))->name_active()) { if (mouse_mode == MouseObject && is_drawable()) { - set_canvas_cursor (trimmer_cursor); + set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview); + _over_region_trim_target = true; } } break; @@ -1647,13 +1640,13 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ Gdk::Cursor *cursor; switch (mouse_mode) { case MouseRange: - cursor = selector_cursor; + cursor = _cursors->selector; break; case MouseZoom: - cursor = zoom_in_cursor; + cursor = _cursors->zoom_in; break; default: - cursor = cross_hair_cursor; + cursor = _cursors->cross_hair; break; } @@ -1674,7 +1667,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case MeterBarItem: case TempoBarItem: if (is_drawable()) { - set_canvas_cursor (timebar_cursor); + set_canvas_cursor (_cursors->timebar); } break; @@ -1688,7 +1681,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case MeterMarkerItem: case TempoMarkerItem: if (is_drawable()) { - set_canvas_cursor (timebar_cursor); + set_canvas_cursor (_cursors->timebar); } break; @@ -1698,9 +1691,9 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ if (rect) { rect->property_fill_color_rgba() = 0xBBBBBBAA; } - set_canvas_cursor (fade_in_cursor); + set_canvas_cursor (_cursors->fade_in); } - break; + break; case FadeOutHandleItem: if (mouse_mode == MouseObject && !internal_editing()) { @@ -1708,7 +1701,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ if (rect) { rect->property_fill_color_rgba() = 0xBBBBBBAA; } - set_canvas_cursor (fade_out_cursor); + set_canvas_cursor (_cursors->fade_out); } break; case FeatureLineItem: @@ -1759,7 +1752,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ Location *loc; RegionView* rv; bool is_start; - bool ret = true; + bool ret = true; switch (item_type) { case ControlPointItem: @@ -1771,7 +1764,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ } if (is_drawable()) { - set_canvas_cursor (current_canvas_cursor); + set_canvas_cursor (current_canvas_cursor); } hide_verbose_canvas_cursor (); @@ -1791,8 +1784,10 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case MarkerViewHandleEndItem: #endif + _over_region_trim_target = false; + if (is_drawable()) { - set_canvas_cursor (current_canvas_cursor); + set_canvas_cursor (current_canvas_cursor); } break; @@ -1805,15 +1800,17 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ line->property_fill_color_rgba() = al->get_line_color(); } if (is_drawable()) { - set_canvas_cursor (current_canvas_cursor); + set_canvas_cursor (current_canvas_cursor); } break; case RegionViewName: /* see enter_handler() for notes */ + _over_region_trim_target = false; + if (!reinterpret_cast (item->get_data ("regionview"))->name_active()) { if (is_drawable() && mouse_mode == MouseObject) { - set_canvas_cursor (current_canvas_cursor); + set_canvas_cursor (current_canvas_cursor); } } break; @@ -1825,7 +1822,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case TempoBarItem: case MarkerBarItem: if (is_drawable()) { - set_canvas_cursor (current_canvas_cursor); + set_canvas_cursor (current_canvas_cursor); } break; @@ -1842,7 +1839,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case TempoMarkerItem: if (is_drawable()) { - set_canvas_cursor (timebar_cursor); + set_canvas_cursor (_cursors->timebar); } break; @@ -1857,12 +1854,12 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ rect->property_outline_pixels() = 0; } } - set_canvas_cursor (current_canvas_cursor); + set_canvas_cursor (current_canvas_cursor); break; case AutomationTrackItem: if (is_drawable()) { - set_canvas_cursor (current_canvas_cursor); + set_canvas_cursor (current_canvas_cursor); clear_entered_track = true; Glib::signal_idle().connect (sigc::mem_fun(*this, &Editor::left_automation_track)); } @@ -2007,6 +2004,10 @@ Editor::motion_handler (ArdourCanvas::Item* /*item*/, GdkEvent* event, bool from set_canvas_cursor (); } + if (_over_region_trim_target) { + set_canvas_cursor_for_region_view (event->motion.x, entered_regionview); + } + bool handled = false; if (_drags->active ()) { handled = _drags->motion_handler (event, from_autoscroll); @@ -2150,7 +2151,7 @@ Editor::show_verbose_time_cursor (framepos_t frame, double offset, double xpos, { char buf[128]; Timecode::Time timecode; - BBT_Time bbt; + Timecode::BBT_Time bbt; int hours, mins; framepos_t frame_rate; float secs; @@ -2207,8 +2208,8 @@ Editor::show_verbose_duration_cursor (framepos_t start, framepos_t end, double o { char buf[128]; Timecode::Time timecode; - BBT_Time sbbt; - BBT_Time ebbt; + Timecode::BBT_Time sbbt; + Timecode::BBT_Time ebbt; int hours, mins; framepos_t distance, frame_rate; float secs; @@ -2247,7 +2248,7 @@ Editor::show_verbose_duration_cursor (framepos_t start, framepos_t end, double o ebbt.ticks -= sbbt.ticks; } else { ebbt.beats--; - ebbt.ticks = int(Meter::ticks_per_beat) + ebbt.ticks - sbbt.ticks; + ebbt.ticks = int(Timecode::BBT_Time::ticks_per_beat) + ebbt.ticks - sbbt.ticks; } snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, ebbt.bars, ebbt.beats, ebbt.ticks); @@ -2467,9 +2468,9 @@ Editor::mouse_brush_insert_region (RegionView* rv, framepos_t pos) boost::shared_ptr playlist = rtv->playlist(); double speed = rtv->track()->speed(); - playlist->clear_changes (); + playlist->clear_changes (); boost::shared_ptr new_region (RegionFactory::create (rv->region())); - playlist->add_region (new_region, (framepos_t) (pos * speed)); + playlist->add_region (new_region, (framepos_t) (pos * speed)); _session->add_command (new StatefulDiffCommand (playlist)); // playlist is frozen, so we have to update manually XXX this is disgusting @@ -2492,9 +2493,9 @@ Editor::add_region_drag (ArdourCanvas::Item* item, GdkEvent* event, RegionView* { assert (region_view); - if (!region_view->region()->playlist()) { - return; - } + if (!region_view->region()->playlist()) { + return; + } _region_motion_group->raise_to_top (); @@ -2514,9 +2515,9 @@ Editor::add_region_copy_drag (ArdourCanvas::Item* item, GdkEvent* event, RegionV { assert (region_view); - if (!region_view->region()->playlist()) { - return; - } + if (!region_view->region()->playlist()) { + return; + } _region_motion_group->raise_to_top (); @@ -2529,9 +2530,9 @@ Editor::add_region_brush_drag (ArdourCanvas::Item* item, GdkEvent* event, Region { assert (region_view); - if (!region_view->region()->playlist()) { - return; - } + if (!region_view->region()->playlist()) { + return; + } if (Config->get_edit_mode() == Splice) { return; @@ -2540,7 +2541,7 @@ Editor::add_region_brush_drag (ArdourCanvas::Item* item, GdkEvent* event, Region RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.property_id); _drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), true, false)); - begin_reversible_command (_("Drag region brush")); + begin_reversible_command (Operations::drag_region_brush); } /** Start a grab where a time range is selected, track(s) are selected, and the @@ -2581,11 +2582,11 @@ Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event) creating the new region and another for moving it. */ - begin_reversible_command (_("selection grab")); + begin_reversible_command (Operations::selection_grab); boost::shared_ptr playlist = clicked_axisview->playlist(); - playlist->clear_changes (); + playlist->clear_changes (); clicked_routeview->playlist()->add_region (region, selection->time[clicked_selection].start); _session->add_command(new StatefulDiffCommand (playlist)); @@ -2624,20 +2625,15 @@ Editor::set_internal_edit (bool yn) if (yn) { mouse_select_button.set_image (*(manage (new Image (::get_icon("midi_tool_pencil"))))); mouse_select_button.get_image ()->show (); - ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Draw/Edit MIDI Notes")); - set_canvas_cursor (); - - /* deselect everything to avoid confusion when e.g. we can't now cut a previously selected - region because cut means "cut note" rather than "cut region". - */ - selection->clear (); + ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Draw/Edit MIDI Notes")); + mouse_mode_toggled (mouse_mode); } else { mouse_select_button.set_image (*(manage (new Image (::get_icon("tool_range"))))); mouse_select_button.get_image ()->show (); - ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Select/Move Ranges")); - mouse_mode_toggled (mouse_mode); // sets cursor + ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Select/Move Ranges")); + mouse_mode_toggled (mouse_mode); // sets cursor } } @@ -2704,3 +2700,35 @@ Editor::remove_midi_note (ArdourCanvas::Item* item, GdkEvent *) e->region_view().delete_note (e->note ()); } + +void +Editor::set_canvas_cursor_for_region_view (double x, RegionView* rv) +{ + ArdourCanvas::Group* g = rv->get_canvas_group (); + ArdourCanvas::Group* p = g->get_parent_group (); + + /* Compute x in region view parent coordinates */ + double dy = 0; + p->w2i (x, dy); + + double x1, x2, y1, y2; + g->get_bounds (x1, y1, x2, y2); + + /* Halfway across the region */ + double const h = (x1 + x2) / 2; + + Trimmable::CanTrim ct = rv->region()->can_trim (); + if (x <= h) { + if (ct & Trimmable::FrontTrimEarlier) { + set_canvas_cursor (_cursors->left_side_trim); + } else { + set_canvas_cursor (_cursors->left_side_trim_right_only); + } + } else { + if (ct & Trimmable::EndTrimLater) { + set_canvas_cursor (_cursors->right_side_trim); + } else { + set_canvas_cursor (_cursors->right_side_trim_left_only); + } + } +}