X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_mouse.cc;h=e34c38c43cb61291291a7bff4bcc6aa0637dce88;hb=4cb00905838ba6ae35317876ae8601a4076745ed;hp=6e11b16862093de176f647e994e31740c93f80ad;hpb=1873bcfa9d7a37b4b751fabe962932d4d151bf12;p=ardour.git diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 6e11b16862..e34c38c43c 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -34,7 +34,6 @@ #include "gtkmm2ext/bindings.h" #include "gtkmm2ext/utils.h" -#include "gtkmm2ext/tearoff.h" #include "canvas/canvas.h" @@ -47,8 +46,8 @@ #include "ardour/session.h" #include "ardour/types.h" -#include "ardour_ui.h" #include "actions.h" +#include "ardour_ui.h" #include "editor.h" #include "time_axis_view.h" #include "audio_time_axis.h" @@ -73,7 +72,7 @@ #include "verbose_cursor.h" #include "note.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -86,7 +85,7 @@ bool Editor::mouse_frame (framepos_t& where, bool& in_track_canvas) const { /* gdk_window_get_pointer() has X11's XQueryPointer semantics in that it only - pays attentions to subwindows. this means that menu windows are ignored, and + pays attentions to subwindows. this means that menu windows are ignored, and if the pointer is in a menu, the return window from the call will be the the regular subwindow *under* the menu. @@ -208,19 +207,37 @@ void Editor::mouse_mode_object_range_toggled() { MouseMode m = mouse_mode; - + Glib::RefPtr act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-range")); assert (act); Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act); assert (tact); - if (tact->get_active()) { - m = MouseObject; //Smart mode turned to ON, force editing to Object mode - } - set_mouse_mode(m, true); //call this so the button styles can get updated } +static Glib::RefPtr +get_mouse_mode_action(MouseMode m) +{ + switch (m) { + case MouseRange: + return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-range")); + case MouseObject: + return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-object")); + case MouseCut: + return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-cut")); + case MouseDraw: + return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-draw")); + case MouseTimeFX: + return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-timefx")); + case MouseContent: + return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-content")); + case MouseAudition: + return ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-audition")); + } + return Glib::RefPtr(); +} + void Editor::set_mouse_mode (MouseMode m, bool force) { @@ -233,50 +250,11 @@ Editor::set_mouse_mode (MouseMode m, bool force) } if (ARDOUR::Profile->get_mixbus()) { - if ( m == MouseZoom) m = MouseObject; if ( m == MouseCut) m = MouseObject; } - Glib::RefPtr act; - - switch (m) { - case MouseRange: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-range")); - break; - - case MouseCut: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-cut")); - break; - - case MouseObject: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-object")); - break; - - case MouseDraw: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-draw")); - break; - - case MouseGain: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-gain")); - break; - - case MouseZoom: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-zoom")); - break; - - case MouseTimeFX: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-timefx")); - break; - - case MouseAudition: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-audition")); - break; - } - - assert (act); - - Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act); - assert (tact); + Glib::RefPtr act = get_mouse_mode_action(m); + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); /* go there and back to ensure that the toggled handler is called to set up mouse_mode */ tact->set_active (false); @@ -288,52 +266,12 @@ Editor::set_mouse_mode (MouseMode m, bool force) void Editor::mouse_mode_toggled (MouseMode m) { - Glib::RefPtr act; - Glib::RefPtr tact; - if (ARDOUR::Profile->get_mixbus()) { - if ( m == MouseZoom) m = MouseObject; if ( m == MouseCut) m = MouseObject; } - switch (m) { - case MouseRange: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-range")); - break; - - case MouseObject: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-object")); - break; - - case MouseCut: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-cut")); - break; - - case MouseDraw: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-draw")); - break; - - case MouseGain: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-gain")); - break; - - case MouseZoom: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-zoom")); - break; - - case MouseTimeFX: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-timefx")); - break; - - case MouseAudition: - act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-audition")); - break; - } - - assert (act); - - tact = Glib::RefPtr::cast_dynamic (act); - assert (tact); + Glib::RefPtr act = get_mouse_mode_action(m); + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); if (!tact->get_active()) { /* this was just the notification that the old mode has been @@ -343,24 +281,27 @@ Editor::mouse_mode_toggled (MouseMode m) return; } - switch (m) { - case MouseDraw: - act = ActionManager::get_action (X_("MouseMode"), X_("toggle-internal-edit")); - tact = Glib::RefPtr::cast_dynamic(act); - tact->set_active (true); - break; - default: - break; - } - if (_session && mouse_mode == MouseAudition) { /* stop transport and reset default speed to avoid oddness with auditioning */ _session->request_transport_speed (0.0, true); } + const bool was_internal = internal_editing(); + mouse_mode = m; + /* Switch snap type/mode if we're moving to/from an internal tool. Note + this must toggle the actions and not call set_snap_*() directly, + otherwise things get out of sync and the combo box stops working. */ + if (!was_internal && internal_editing()) { + snap_type_action(internal_snap_type)->set_active(true); + snap_mode_action(internal_snap_mode)->set_active(true); + } else if (was_internal && !internal_editing()) { + snap_type_action(pre_internal_snap_type)->set_active(true); + snap_mode_action(pre_internal_snap_mode)->set_active(true); + } + instant_save (); /* this should generate a new enter event which will @@ -372,122 +313,95 @@ Editor::mouse_mode_toggled (MouseMode m) } set_gain_envelope_visibility (); - + update_time_selection_display (); + update_all_enter_cursors (); + MouseModeChanged (); /* EMIT SIGNAL */ } -void -Editor::update_time_selection_display () +bool +Editor::internal_editing() const { - if (smart_mode_action->get_active()) { - /* not sure what to do here */ - if (mouse_mode == MouseObject) { - } else { - } - } else { - switch (mouse_mode) { - case MouseRange: - selection->clear_objects (); - break; - default: - selection->clear_time (); - break; - } - } + return mouse_mode == Editing::MouseContent || mouse_mode == Editing::MouseDraw; } void -Editor::step_mouse_mode (bool next) +Editor::update_time_selection_display () { - switch (current_mouse_mode()) { - case MouseObject: - if (next) { - if (Profile->get_sae()) { - set_mouse_mode (MouseZoom); - } else { - set_mouse_mode (MouseRange); - } - } else { - set_mouse_mode (MouseTimeFX); - } - break; - + switch (mouse_mode) { case MouseRange: - if (next) set_mouse_mode (MouseDraw); - else set_mouse_mode (MouseCut); + selection->clear_objects (); + selection->clear_midi_notes (); break; - - case MouseCut: - if (next) set_mouse_mode (MouseRange); - else set_mouse_mode (MouseDraw); + case MouseObject: + selection->clear_time (); + selection->clear_tracks (); + selection->clear_midi_notes (); break; - case MouseDraw: - if (next) set_mouse_mode (MouseCut); - else set_mouse_mode (MouseRange); - break; - - case MouseZoom: - if (next) { - if (Profile->get_sae()) { - set_mouse_mode (MouseTimeFX); - } else { - set_mouse_mode (MouseGain); - } - } else { - if (Profile->get_sae()) { - set_mouse_mode (MouseObject); - } else { - set_mouse_mode (MouseDraw); - } - } - break; + /* Clear regions, but not time or tracks, since that + would destroy the range selection rectangle, which we need to stick + around for AutomationRangeDrag. */ + selection->clear_regions (); + selection->clear_playlists (); + break; + case MouseContent: + /* This handles internal edit. + Clear everything except points and notes. + */ + selection->clear_regions(); + selection->clear_lines(); + selection->clear_playlists (); - case MouseGain: - if (next) set_mouse_mode (MouseTimeFX); - else set_mouse_mode (MouseZoom); + selection->clear_time (); + selection->clear_tracks (); break; case MouseTimeFX: - if (next) { - set_mouse_mode (MouseAudition); - } else { - if (Profile->get_sae()) { - set_mouse_mode (MouseZoom); - } else { - set_mouse_mode (MouseGain); - } - } + /* We probably want to keep region selection */ + selection->clear_points (); + selection->clear_lines(); + selection->clear_playlists (); + + selection->clear_time (); + selection->clear_tracks (); break; case MouseAudition: - if (next) set_mouse_mode (MouseObject); - else set_mouse_mode (MouseTimeFX); + /*Don't lose lines or points if no action in this mode */ + selection->clear_regions (); + selection->clear_playlists (); + selection->clear_time (); + selection->clear_tracks (); + break; + + default: + /*Clear everything */ + selection->clear_objects(); + selection->clear_time (); + selection->clear_tracks (); break; } } -bool -Editor::toggle_internal_editing_from_double_click (GdkEvent* event) +void +Editor::step_mouse_mode (bool next) { - if (_drags->active()) { - _drags->end_grab (event); - } - - ActionManager::do_action ("MouseMode", "toggle-internal-edit"); - - /* prevent reversion of edit cursor on button release */ - - pre_press_cursor = 0; - - return true; + const int n_mouse_modes = (int)MouseContent + 1; + int current = (int)current_mouse_mode(); + if (next) { + set_mouse_mode((MouseMode)((current + 1) % n_mouse_modes)); + } else { + set_mouse_mode((MouseMode)((current + n_mouse_modes - 1) % n_mouse_modes)); + } } void -Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemType item_type) +Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type) { + /* in object/audition/timefx/gain-automation mode, any button press sets the selection if the object can be selected. this is a bit of hack, because @@ -532,11 +446,9 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp if (((mouse_mode != MouseObject) && (mouse_mode != MouseAudition || item_type != RegionItem) && (mouse_mode != MouseTimeFX || item_type != RegionItem) && - (mouse_mode != MouseGain) && - (mouse_mode != MouseDraw)) || - ((event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE) || event->button.button > 3) || - (internal_editing() && mouse_mode != MouseTimeFX)) { - + (mouse_mode != MouseDraw) && + (mouse_mode != MouseContent || item_type == RegionItem)) || + ((event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE) || event->button.button > 3)) { return; } @@ -546,7 +458,9 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp /* almost no selection action on modified button-2 or button-3 events */ - if (item_type != RegionItem && event->button.button != 2) { + if ((item_type != RegionItem && event->button.button != 2) + /* for selection of control points prior to delete (shift-right click) */ + && !(item_type == ControlPointItem && event->button.button == 3 && event->type == GDK_BUTTON_PRESS)) { return; } } @@ -555,11 +469,18 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp Selection::Operation op = ArdourKeyboard::selection_type (event->button.state); bool press = (event->type == GDK_BUTTON_PRESS); + if (press) { + _mouse_changed_selection = false; + } + switch (item_type) { case RegionItem: + if (eff_mouse_mode == MouseDraw) { + break; + } if (press) { if (eff_mouse_mode != MouseRange) { - set_selected_regionview_from_click (press, op); + _mouse_changed_selection = set_selected_regionview_from_click (press, op); } else { /* don't change the selection unless the clicked track is not currently selected. if @@ -572,7 +493,7 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp } } else { if (eff_mouse_mode != MouseRange) { - set_selected_regionview_from_click (press, op); + _mouse_changed_selection |= set_selected_regionview_from_click (press, op); } } break; @@ -590,16 +511,109 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp case StartCrossFadeItem: case EndCrossFadeItem: if (get_smart_mode() || eff_mouse_mode != MouseRange) { - set_selected_regionview_from_click (press, op); + _mouse_changed_selection |= set_selected_regionview_from_click (press, op); } else if (event->type == GDK_BUTTON_PRESS) { set_selected_track_as_side_effect (op); } break; case ControlPointItem: - set_selected_track_as_side_effect (op); + /* for object/track exclusivity, we don't call set_selected_track_as_side_effect (op); */ + + if (eff_mouse_mode != MouseRange) { + if (event->button.button != 3) { + _mouse_changed_selection |= set_selected_control_point_from_click (press, op); + } else { + _mouse_changed_selection |= set_selected_control_point_from_click (press, Selection::Set); + } + } + break; + + case GainLineItem: if (eff_mouse_mode != MouseRange) { - set_selected_control_point_from_click (press, op); + AutomationLine* argl = reinterpret_cast (item->get_data ("line")); + + std::list selectables; + uint32_t before, after; + framecnt_t const where = (framecnt_t) floor (event->button.x * samples_per_pixel) - clicked_regionview->region ()->position (); + + if (!argl || !argl->control_points_adjacent (where, before, after)) { + break; + } + + selectables.push_back (argl->nth (before)); + selectables.push_back (argl->nth (after)); + + switch (op) { + case Selection::Set: + if (press) { + selection->set (selectables); + _mouse_changed_selection = true; + } + break; + case Selection::Add: + if (press) { + selection->add (selectables); + _mouse_changed_selection = true; + } + break; + case Selection::Toggle: + if (press) { + selection->toggle (selectables); + _mouse_changed_selection = true; + } + break; + + case Selection::Extend: + /* XXX */ + break; + } + } + break; + + case AutomationLineItem: + if (eff_mouse_mode != MouseRange) { + AutomationLine* al = reinterpret_cast (item->get_data ("line")); + std::list selectables; + double mx = event->button.x; + double my = event->button.y; + + al->grab_item().canvas_to_item (mx, my); + + uint32_t before, after; + framecnt_t const where = (framecnt_t) floor (mx * samples_per_pixel); + + if (!al || !al->control_points_adjacent (where, before, after)) { + break; + } + + selectables.push_back (al->nth (before)); + selectables.push_back (al->nth (after)); + + switch (op) { + case Selection::Set: + if (press) { + selection->set (selectables); + _mouse_changed_selection = true; + } + break; + case Selection::Add: + if (press) { + selection->add (selectables); + _mouse_changed_selection = true; + } + break; + case Selection::Toggle: + if (press) { + selection->toggle (selectables); + _mouse_changed_selection = true; + } + break; + + case Selection::Extend: + /* XXX */ + break; + } } break; @@ -608,16 +622,42 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp if (event->button.button == 3) { selection->clear_tracks (); set_selected_track_as_side_effect (op); + + /* We won't get a release.*/ + begin_reversible_selection_op (X_("Button 3 Menu Select")); + commit_reversible_selection_op (); } break; case AutomationTrackItem: - set_selected_track_as_side_effect (op); + if (eff_mouse_mode != MouseDraw && op == Selection::Set) { + set_selected_track_as_side_effect (op); + } + break; + + case NoteItem: + if (press && event->button.button == 3) { + NoteBase* cnote = reinterpret_cast (item->get_data ("notebase")); + assert (cnote); + if (cnote->region_view().selection_size() == 0 || !cnote->selected()) { + selection->clear_points(); + cnote->region_view().unique_select (cnote); + /* we won't get the release, so store the selection change now */ + begin_reversible_selection_op (X_("Button 3 Note Selection")); + commit_reversible_selection_op (); + } + } break; default: break; } + + if ((!press) && _mouse_changed_selection) { + begin_reversible_selection_op (X_("Button Selection")); + commit_reversible_selection_op (); + _mouse_changed_selection = false; + } } bool @@ -629,6 +669,8 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT them to be modeless. */ + NoteBase* note = NULL; + switch (item_type) { case PlayheadCursorItem: _drags->set (new CursorDrag (this, *playhead_cursor, true), event); @@ -644,13 +686,11 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case TempoMarkerItem: { - TempoMarker* m = reinterpret_cast (item->get_data ("marker")); - assert (m); _drags->set ( new TempoMarkerDrag ( this, item, - Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier) + ArdourKeyboard::indicates_copy (event->button.state) ), event ); @@ -659,13 +699,11 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case MeterMarkerItem: { - MeterMarker* m = reinterpret_cast (item->get_data ("marker")); - assert (m); _drags->set ( new MeterMarkerDrag ( this, item, - Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier) + ArdourKeyboard::indicates_copy (event->button.state) ), event ); @@ -679,23 +717,29 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case MarkerBarItem: case TempoBarItem: + case TempoCurveItem: case MeterBarItem: case TimecodeRulerItem: case SamplesRulerItem: case MinsecRulerItem: case BBTRulerItem: - if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { + if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier) + && !ArdourKeyboard::indicates_constraint (event->button.state)) { _drags->set (new CursorDrag (this, *playhead_cursor, false), event); + } else if (ArdourKeyboard::indicates_constraint (event->button.state)) { + _drags->set (new BBTRulerDrag (this, item), event); } return true; break; case RangeMarkerBarItem: - if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { - _drags->set (new CursorDrag (this, *playhead_cursor, false), event); - } else { + if (Keyboard::modifier_state_contains (event->button.state, Keyboard::TertiaryModifier)) { + _drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateSkipMarker), event); + } else 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; @@ -739,7 +783,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT Editing::MouseMode eff = effective_mouse_mode (); /* special case: allow drag of region fade in/out in object mode with join object/range enabled */ - if (get_smart_mode()) { + if (get_smart_mode()) { switch (item_type) { case FadeInHandleItem: case FadeInTrimHandleItem: @@ -752,11 +796,6 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT } } - /* there is no Range mode when in internal edit mode */ - if (eff == MouseRange && internal_editing()) { - eff = MouseObject; - } - switch (eff) { case MouseRange: switch (item_type) { @@ -783,19 +822,12 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case StreamItem: - if (internal_editing()) { - if (dynamic_cast (clicked_axisview)) { - _drags->set (new RegionCreateDrag (this, item, clicked_axisview), event); - return true; - } + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::RangeSelectModifier)) { + _drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionExtend), event); } else { - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::RangeSelectModifier)) { - _drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionExtend), event); - } else { - _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event); - } - return true; + _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event); } + return true; break; case RegionViewNameHighlight: @@ -806,47 +838,15 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; default: - if (!internal_editing()) { - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::RangeSelectModifier)) { - _drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionExtend), event); - } else { - _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event); - } + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::RangeSelectModifier)) { + _drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionExtend), event); + } else { + _drags->set (new SelectionDrag (this, item, SelectionDrag::CreateSelection), event); } } return true; break; - case MouseDraw: - switch (item_type) { - case NoteItem: - /* Existing note: allow trimming/motion */ - if (internal_editing()) { - /* trim notes if we're in internal edit mode and near the ends of the note */ - NoteBase* cn = reinterpret_cast(item->get_data ("notebase")); - assert (cn); - if (cn->big_enough_to_trim() && 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; - case StreamItem: - if (internal_editing()) { - if (dynamic_cast (clicked_axisview)) { - _drags->set (new RegionCreateDrag (this, item, clicked_axisview), event); - } - return true; - } - break; - - default: - break; - } - break; - case MouseCut: switch (item_type) { case RegionItem: @@ -859,7 +859,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case RegionViewName: case StreamItem: case AutomationTrackItem: - _drags->set (new RegionCutDrag (this, item, canvas_event_sample (event)), event, current_canvas_cursor); + _drags->set (new RegionCutDrag (this, item, canvas_event_sample (event)), event, get_canvas_cursor()); return true; break; default: @@ -867,18 +867,48 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT } break; - case MouseObject: + case MouseContent: switch (item_type) { case NoteItem: /* Existing note: allow trimming/motion */ - if (internal_editing()) { - NoteBase* cn = reinterpret_cast (item->get_data ("notebase")); - assert (cn); - if (cn->big_enough_to_trim() && cn->mouse_near_ends()) { - _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor); + if ((note = reinterpret_cast (item->get_data ("notebase")))) { + if (note->big_enough_to_trim() && note->mouse_near_ends()) { + _drags->set (new NoteResizeDrag (this, item), event, get_canvas_cursor()); } else { _drags->set (new NoteDrag (this, item), event); } + } + return true; + + case GainLineItem: + _drags->set (new LineDrag (this, item), event); + return true; + break; + + case ControlPointItem: + _drags->set (new ControlPointDrag (this, item), event); + return true; + break; + + case AutomationLineItem: + _drags->set (new LineDrag (this, item), event); + return true; + break; + + case StreamItem: + //in the past, we created a new midi region here, but perhaps that is best left to the Draw mode + break; + + case AutomationTrackItem: + /* rubberband drag to select automation points */ + _drags->set (new EditorRubberbandSelectDrag (this, item), event); + return true; + break; + + case RegionItem: + if (dynamic_cast(clicked_regionview)) { + /* rubberband drag to select automation points */ + _drags->set (new EditorRubberbandSelectDrag (this, item), event); return true; } break; @@ -886,7 +916,9 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT default: break; } + break; + case MouseObject: if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier|Keyboard::SecondaryModifier)) && event->type == GDK_BUTTON_PRESS) { @@ -909,7 +941,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case StartCrossFadeItem: case EndCrossFadeItem: - /* we might allow user to grab inside the fade to trim a region with preserve_fade_anchor. for not this is not fully implemented */ + /* we might allow user to grab inside the fade to trim a region with preserve_fade_anchor. for not this is not fully implemented */ // if (!clicked_regionview->region()->locked()) { // _drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer(), true), event); // return true; @@ -936,12 +968,8 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; } - if (internal_editing ()) { - break; - } - /* click on a normal region view */ - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)) { + if (ArdourKeyboard::indicates_copy (event->button.state)) { add_region_copy_drag (item, event, clicked_regionview); } else if (Keyboard::the_keyboard().key_is_down (GDK_b)) { add_region_brush_drag (item, event, clicked_regionview); @@ -950,10 +978,6 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT } -// if (!internal_editing() && (_join_object_range_state == JOIN_OBJECT_RANGE_RANGE && !selection->regions.empty())) { -// _drags->add (new SelectionDrag (this, clicked_axisview->get_selection_rect (clicked_selection)->rect, SelectionDrag::SelectionMove)); -// } - _drags->start_grab (event); return true; break; @@ -996,15 +1020,8 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case StreamItem: - if (internal_editing()) { - if (dynamic_cast (clicked_axisview)) { - _drags->set (new RegionCreateDrag (this, item, clicked_axisview), event); - } - return true; - } else { - _drags->set (new EditorRubberbandSelectDrag (this, item), event); - } - break; + _drags->set (new EditorRubberbandSelectDrag (this, item), event); + return true; case AutomationTrackItem: { @@ -1026,7 +1043,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT if (!prev) { _drags->set (new RegionCreateDrag (this, item, parent), event); } else { - prev->set_length (t - prev->position ()); + prev->set_length (t - prev->position (), get_grid_music_divisions (event->button.state)); } } } else { @@ -1052,7 +1069,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT return true; break; - case MouseGain: + case MouseDraw: switch (item_type) { case GainLineItem: _drags->set (new LineDrag (this, item), event); @@ -1065,12 +1082,13 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case SelectionItem: { - AudioRegionView* arv = dynamic_cast (clicked_regionview); - if (arv) { - _drags->set (new AutomationRangeDrag (this, arv, selection->time), event, _cursors->up_down); + if (dynamic_cast(clicked_regionview) || + dynamic_cast(clicked_regionview)) { + _drags->set (new AutomationRangeDrag (this, clicked_regionview, selection->time), + event, _cursors->up_down); } else { double const y = event->button.y; - pair tvp = trackview_by_y_position (y); + pair tvp = trackview_by_y_position (y, false); if (tvp.first) { AutomationTimeAxisView* atv = dynamic_cast (tvp.first); if ( atv) { @@ -1086,28 +1104,39 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case AutomationLineItem: _drags->set (new LineDrag (this, item), event); break; - + + case NoteItem: + if ((note = reinterpret_cast(item->get_data ("notebase")))) { + if (note->big_enough_to_trim() && note->mouse_near_ends()) { + /* Note is big and pointer is near the end, trim */ + _drags->set (new NoteResizeDrag (this, item), event, get_canvas_cursor()); + } else { + /* Drag note */ + _drags->set (new NoteDrag (this, item), event); + } + return true; + } + return true; + + case StreamItem: + if (dynamic_cast (clicked_axisview)) { + _drags->set (new RegionCreateDrag (this, item, clicked_axisview), event); + } + return true; + default: break; } return true; break; - case MouseZoom: - if (event->type == GDK_BUTTON_PRESS) { - _drags->set (new MouseZoomDrag (this, item), event); - } - - return true; - break; - case MouseTimeFX: - if (internal_editing() && item_type == NoteItem ) { - /* drag notes if we're in internal edit mode */ - NoteBase* cn = reinterpret_cast(item->get_data ("notebase")); - assert (cn); - if (cn->big_enough_to_trim()) { - _drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor); + if (item_type == NoteItem) { + /* resize-drag notes */ + if ((note = reinterpret_cast(item->get_data ("notebase")))) { + if (note->big_enough_to_trim()) { + _drags->set (new NoteResizeDrag (this, item), event, get_canvas_cursor()); + } } return true; } else if (clicked_regionview) { @@ -1118,12 +1147,11 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case MouseAudition: - _drags->set (new ScrubDrag (this, item), event); + _drags->set (new ScrubDrag (this, item), event, _cursors->transparent); scrub_reversals = 0; scrub_reverse_distance = 0; last_scrub_x = event->button.x; scrubbing_direction = 0; - push_canvas_cursor (_cursors->transparent); return true; break; @@ -1142,12 +1170,7 @@ Editor::button_press_handler_2 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case MouseObject: switch (item_type) { case RegionItem: - if (internal_editing ()) { - /* no region drags in internal edit mode */ - return false; - } - - if (Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)) { + if (ArdourKeyboard::indicates_copy (event->button.state)) { add_region_copy_drag (item, event, clicked_regionview); } else { add_region_drag (item, event, clicked_regionview); @@ -1172,9 +1195,7 @@ Editor::button_press_handler_2 (ArdourCanvas::Item* item, GdkEvent* event, ItemT case LeftFrameHandle: case RightFrameHandle: - if (!internal_editing ()) { - _drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event); - } + _drags->set (new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()), event); return true; break; @@ -1197,23 +1218,13 @@ Editor::button_press_handler_2 (ArdourCanvas::Item* item, GdkEvent* event, ItemT return true; break; - - case MouseZoom: - if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { - temporal_zoom_to_frame (false, canvas_event_sample (event)); - } else { - temporal_zoom_to_frame (true, canvas_event_sample(event)); - } - return true; - break; - default: break; } return false; } - + bool Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type) { @@ -1227,56 +1238,12 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp return false; } - pre_press_cursor = current_canvas_cursor; - _track_canvas->grab_focus(); if (_session && _session->actively_recording()) { return true; } - if (internal_editing()) { - bool leave_internal_edit_mode = false; - - switch (item_type) { - case NoteItem: - break; - - case RegionItem: - if (!dynamic_cast (clicked_regionview) && !dynamic_cast (clicked_regionview)) { - leave_internal_edit_mode = true; - } - break; - - case PlayheadCursorItem: - case MarkerItem: - case TempoMarkerItem: - case MeterMarkerItem: - case MarkerBarItem: - case TempoBarItem: - case MeterBarItem: - case RangeMarkerBarItem: - case CdMarkerBarItem: - case TransportMarkerBarItem: - case StreamItem: - case TimecodeRulerItem: - case SamplesRulerItem: - case MinsecRulerItem: - case BBTRulerItem: - /* button press on these items never does anything to - change the editing mode. - */ - break; - - default: - break; - } - - if (leave_internal_edit_mode) { - ActionManager::do_action ("MouseMode", "toggle-internal-edit"); - } - } - button_selection (item, event, item_type); if (!_drags->active () && @@ -1289,7 +1256,7 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp } //not rolling, range mode click + join_play_range : locate the PH here - if ( !_drags->active () && !_session->transport_rolling() && ( effective_mouse_mode() == MouseRange ) && Config->get_follow_edits() ) { + if ( !_drags->active () && _session && !_session->transport_rolling() && ( effective_mouse_mode() == MouseRange ) && UIConfiguration::instance().get_follow_edits() && !_session->config.get_external_sync() ) { framepos_t where = canvas_event_sample (event); snap_to(where); _session->request_locate (where, false); @@ -1342,10 +1309,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT framepos_t where = canvas_event_sample (event); AutomationTimeAxisView* atv = 0; - if (pre_press_cursor) { - set_canvas_cursor (pre_press_cursor); - pre_press_cursor = 0; - } + _press_cursor_ctx.reset(); /* no action if we're recording */ @@ -1353,20 +1317,24 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT return true; } - /* see if we're finishing a drag */ + bool were_dragging = false; - bool were_dragging = false; - if (_drags->active ()) { - bool const r = _drags->end_grab (event); - if (r) { - /* grab dragged, so do nothing else */ - return true; - } + if (!Keyboard::is_context_menu_event (&event->button)) { - were_dragging = true; - } + /* see if we're finishing a drag */ + + if (_drags->active ()) { + bool const r = _drags->end_grab (event); + if (r) { + /* grab dragged, so do nothing else */ + return true; + } + + were_dragging = true; + } - update_region_layering_order_editor (); + update_region_layering_order_editor (); + } /* edit events get handled here */ @@ -1375,37 +1343,36 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case RegionItem: show_region_properties (); break; - case TempoMarkerItem: { - Marker* marker; + ArdourMarker* marker; TempoMarker* tempo_marker; - - if ((marker = reinterpret_cast (item->get_data ("marker"))) == 0) { + + if ((marker = reinterpret_cast (item->get_data ("marker"))) == 0) { fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } - + if ((tempo_marker = dynamic_cast (marker)) == 0) { fatal << _("programming error: marker for tempo is not a tempo marker!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } - + edit_tempo_marker (*tempo_marker); break; } case MeterMarkerItem: { - Marker* marker; + ArdourMarker* marker; MeterMarker* meter_marker; - - if ((marker = reinterpret_cast (item->get_data ("marker"))) == 0) { + + if ((marker = reinterpret_cast (item->get_data ("marker"))) == 0) { fatal << _("programming error: tempo marker canvas item has no marker object pointer!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } - + if ((meter_marker = dynamic_cast (marker)) == 0) { fatal << _("programming error: marker for meter is not a meter marker!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } edit_meter_marker (*meter_marker); break; @@ -1443,7 +1410,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case FadeInHandleItem: case FadeInTrimHandleItem: case StartCrossFadeItem: - case LeftFrameHandle: popup_xfade_in_context_menu (1, event->button.time, item, item_type); break; @@ -1451,10 +1417,13 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case FadeOutHandleItem: case FadeOutTrimHandleItem: case EndCrossFadeItem: - case RightFrameHandle: popup_xfade_out_context_menu (1, event->button.time, item, item_type); break; + case LeftFrameHandle: + case RightFrameHandle: + break; + case StreamItem: popup_track_context_menu (1, event->button.time, item_type, false); break; @@ -1468,7 +1437,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case SelectionItem: 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); break; @@ -1478,6 +1447,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case TransportMarkerBarItem: case CdMarkerBarItem: case TempoBarItem: + case TempoCurveItem: case MeterBarItem: case VideoBarItem: case TimecodeRulerItem: @@ -1507,6 +1477,12 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT popup_control_point_context_menu (item, event); break; + case NoteItem: + if (internal_editing()) { + popup_note_context_menu (item, event); + } + break; + default: break; } @@ -1569,7 +1545,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case MarkerBarItem: if (!_dragging_playhead) { - snap_to_with_modifier (where, event, 0, true); + snap_to_with_modifier (where, event, RoundNearest, true); mouse_add_new_marker (where); } return true; @@ -1577,12 +1553,12 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case CdMarkerBarItem: if (!_dragging_playhead) { // if we get here then a dragged range wasn't done - snap_to_with_modifier (where, event, 0, true); + snap_to_with_modifier (where, event, RoundNearest, true); mouse_add_new_marker (where, true); } return true; - case TempoBarItem: + case TempoCurveItem: if (!_dragging_playhead) { snap_to_with_modifier (where, event); mouse_add_new_tempo_event (where); @@ -1608,22 +1584,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT } switch (eff) { - case MouseObject: - switch (item_type) { - case AutomationTrackItem: - atv = dynamic_cast(clicked_axisview); - if (atv) { - bool with_guard_points = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier); - atv->add_automation_event (event, where, event->button.y, with_guard_points); - } - return true; - break; - default: - break; - } - break; - - case MouseGain: + case MouseDraw: switch (item_type) { case RegionItem: { @@ -1642,8 +1603,10 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case AutomationTrackItem: { bool with_guard_points = Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier); - dynamic_cast(clicked_axisview)-> - add_automation_event (event, where, event->button.y, with_guard_points); + atv = dynamic_cast(clicked_axisview); + if (atv) { + atv->add_automation_event (event, where, event->button.y, with_guard_points); + } return true; break; } @@ -1653,7 +1616,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT break; case MouseAudition: - pop_canvas_cursor (); if (scrubbing_direction == 0) { /* no drag, just a click */ switch (item_type) { @@ -1663,7 +1625,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT default: break; } - } else { + } else if (_session) { /* make sure we stop */ _session->request_transport_speed (0.0); } @@ -1675,7 +1637,8 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT } /* do any (de)selection operations that should occur on button release */ - button_selection (item, event, item_type); + button_selection (item, event, item_type); + return true; break; @@ -1704,7 +1667,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT case MouseDraw: return true; - + case MouseRange: // x_style_paste (where, 1.0); return true; @@ -1730,22 +1693,24 @@ bool Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type) { ControlPoint* cp; - Marker * marker; + ArdourMarker * marker; + MeterMarker* m_marker = 0; + TempoMarker* t_marker = 0; double fraction; bool ret = true; /* by the time we reach here, entered_regionview and entered trackview - * will have already been set as appropriate. Things are done this + * will have already been set as appropriate. Things are done this * way because this method isn't passed a pointer to a variable type of * thing that is entered (which may or may not be canvas item). * (e.g. the actual entered regionview) */ - choose_canvas_cursor_on_entry (&event->crossing, item_type); + choose_canvas_cursor_on_entry (item_type); switch (item_type) { case ControlPointItem: - if (mouse_mode == MouseGain || mouse_mode == MouseObject) { + if (mouse_mode == MouseDraw || mouse_mode == MouseObject || mouse_mode == MouseContent) { cp = static_cast(item->get_data ("control_point")); cp->show (); @@ -1757,19 +1722,19 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ break; case GainLineItem: - if (mouse_mode == MouseGain) { + if (mouse_mode == MouseDraw) { ArdourCanvas::Line *line = dynamic_cast (item); if (line) { - line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_EnteredGainLine()); + line->set_outline_color (UIConfiguration::instance().color ("entered gain line")); } } break; case AutomationLineItem: - if (mouse_mode == MouseGain || mouse_mode == MouseObject) { + if (mouse_mode == MouseDraw || mouse_mode == MouseObject) { ArdourCanvas::Line *line = dynamic_cast (item); if (line) { - line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_EnteredAutomationLine()); + line->set_outline_color (UIConfiguration::instance().color ("entered automation line")); } } break; @@ -1783,19 +1748,40 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ break; case MarkerItem: - if ((marker = static_cast (item->get_data ("marker"))) == 0) { + if ((marker = static_cast (item->get_data ("marker"))) == 0) { break; } entered_marker = marker; - marker->set_color_rgba (ARDOUR_UI::config()->get_canvasvar_EnteredMarker()); - // fall through + marker->set_color_rgba (UIConfiguration::instance().color ("entered marker")); + break; + case MeterMarkerItem: + if ((m_marker = static_cast (item->get_data ("marker"))) == 0) { + break; + } + entered_marker = m_marker; + if (m_marker->meter().position_lock_style() == MusicTime) { + m_marker->set_color_rgba (UIConfiguration::instance().color ("meter marker")); + } else { + m_marker->set_color_rgba (UIConfiguration::instance().color ("meter marker music")); + } + break; + case TempoMarkerItem: + if ((t_marker = static_cast (item->get_data ("marker"))) == 0) { + break; + } + entered_marker = t_marker; + if (t_marker->tempo().position_lock_style() == MusicTime) { + t_marker->set_color_rgba (UIConfiguration::instance().color ("tempo marker")); + } else { + t_marker->set_color_rgba (UIConfiguration::instance().color ("tempo marker music")); + } break; case FadeInHandleItem: case FadeInTrimHandleItem: - if (mouse_mode == MouseObject && !internal_editing()) { + if (mouse_mode == MouseObject) { ArdourCanvas::Rectangle *rect = dynamic_cast (item); if (rect) { RegionView* rv = static_cast(item->get_data ("regionview")); @@ -1806,7 +1792,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case FadeOutHandleItem: case FadeOutTrimHandleItem: - if (mouse_mode == MouseObject && !internal_editing()) { + if (mouse_mode == MouseObject) { ArdourCanvas::Rectangle *rect = dynamic_cast (item); if (rect) { RegionView* rv = static_cast(item->get_data ("regionview")); @@ -1825,6 +1811,14 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_ case SelectionItem: break; + case WaveItem: + { + if (entered_regionview) { + entered_regionview->entered(); + } + } + break; + default: break; } @@ -1856,14 +1850,20 @@ bool Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type) { AutomationLine* al; - Marker *marker; + ArdourMarker *marker; + TempoMarker *t_marker; + MeterMarker *m_marker; Location *loc; bool is_start; bool ret = true; + if (!_enter_stack.empty()) { + _enter_stack.pop_back(); + } + switch (item_type) { case ControlPointItem: - _verbose_cursor->hide (); + _verbose_cursor->hide (); break; case GainLineItem: @@ -1878,16 +1878,37 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type) break; case MarkerItem: - if ((marker = static_cast (item->get_data ("marker"))) == 0) { + if ((marker = static_cast (item->get_data ("marker"))) == 0) { break; } entered_marker = 0; if ((loc = find_location_from_marker (marker, is_start)) != 0) { - location_flags_changed (loc, this); + location_flags_changed (loc); } - // fall through + break; + case MeterMarkerItem: + if ((m_marker = static_cast (item->get_data ("marker"))) == 0) { + break; + } + entered_marker = 0; + if (m_marker->meter().position_lock_style() == MusicTime) { + m_marker->set_color_rgba (UIConfiguration::instance().color ("meter marker music")); + } else { + m_marker->set_color_rgba (UIConfiguration::instance().color ("meter marker")); + } + break; + case TempoMarkerItem: + if ((t_marker = static_cast (item->get_data ("marker"))) == 0) { + break; + } + entered_marker = 0; + if (t_marker->tempo().position_lock_style() == MusicTime) { + t_marker->set_color_rgba (UIConfiguration::instance().color ("tempo marker music")); + } else { + t_marker->set_color_rgba (UIConfiguration::instance().color ("tempo marker")); + } break; case FadeInTrimHandleItem: @@ -1897,7 +1918,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type) { ArdourCanvas::Rectangle *rect = dynamic_cast (item); if (rect) { - rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_InactiveFadeHandle()); + rect->set_fill_color (UIConfiguration::instance().color ("inactive fade handle")); } } break; @@ -1908,7 +1929,7 @@ Editor::leave_handler (ArdourCanvas::Item* item, GdkEvent*, ItemType item_type) case FeatureLineItem: { ArdourCanvas::Line *line = dynamic_cast (item); - line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_ZeroLine()); + line->set_outline_color (UIConfiguration::instance().color ("zero line")); } break; @@ -2023,14 +2044,14 @@ Editor::motion_handler (ArdourCanvas::Item* /*item*/, GdkEvent* event, bool from current_stepping_trackview = 0; step_timeout.disconnect (); } - + if (_session && _session->actively_recording()) { /* Sorry. no dragging stuff around while we record */ return true; } - + update_join_object_range_location (event->motion.y); - + if (_drags->active ()) { return _drags->motion_handler (event, from_autoscroll); } @@ -2045,7 +2066,7 @@ Editor::can_remove_control_point (ArdourCanvas::Item* item) if ((control_point = reinterpret_cast (item->get_data ("control_point"))) == 0) { fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } AutomationLine& line = control_point->line (); @@ -2070,7 +2091,7 @@ Editor::remove_control_point (ArdourCanvas::Item* item) if ((control_point = reinterpret_cast (item->get_data ("control_point"))) == 0) { fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } control_point->line().remove_point (*control_point); @@ -2083,11 +2104,10 @@ Editor::edit_control_point (ArdourCanvas::Item* item) if (p == 0) { fatal << _("programming error: control point canvas item has no control point object pointer!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } ControlPointDialog d (p); - ensure_float (d); if (d.run () != RESPONSE_ACCEPT) { return; @@ -2097,23 +2117,16 @@ Editor::edit_control_point (ArdourCanvas::Item* item) } void -Editor::edit_notes (TimeAxisViewItem& tavi) +Editor::edit_notes (MidiRegionView* mrv) { - MidiRegionView* mrv = dynamic_cast(&tavi); - - if (!mrv) { - return; - } - MidiRegionView::Selection const & s = mrv->selection(); if (s.empty ()) { return; } - EditNoteDialog* d = new EditNoteDialog (&(*s.begin())->region_view(), s); + EditNoteDialog* d = new EditNoteDialog (mrv, s); d->show_all (); - ensure_float (*d); d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &Editor::note_edit_done), d)); } @@ -2121,8 +2134,22 @@ Editor::edit_notes (TimeAxisViewItem& tavi) void Editor::note_edit_done (int r, EditNoteDialog* d) { + begin_reversible_command (_("edit note(s)")); + d->done (r); delete d; + + commit_reversible_command(); +} + +void +Editor::edit_region (RegionView* rv) +{ + if (UIConfiguration::instance().get_use_double_click_to_zoom_to_selection()) { + temporal_zoom_selection (Both); + } else { + rv->show_region_editor (); + } } void @@ -2135,7 +2162,7 @@ Editor::visible_order_range (int* low, int* high) const RouteTimeAxisView* rtv = dynamic_cast (*i); - if (!rtv->hidden()) { + if (rtv && !rtv->hidden()) { if (*high < rtv->order()) { *high = rtv->order (); @@ -2215,7 +2242,7 @@ Editor::cancel_time_selection () } selection->time.clear (); clicked_selection = 0; -} +} void Editor::point_trim (GdkEvent* event, framepos_t new_bound) @@ -2250,7 +2277,7 @@ Editor::point_trim (GdkEvent* event, framepos_t new_bound) break; case 2: - begin_reversible_command (_("End point trim")); + begin_reversible_command (_("end point trim")); if (selection->selected (rv)) { @@ -2283,30 +2310,18 @@ Editor::point_trim (GdkEvent* event, framepos_t new_bound) void Editor::hide_marker (ArdourCanvas::Item* item, GdkEvent* /*event*/) { - Marker* marker; + ArdourMarker* marker; bool is_start; - if ((marker = static_cast (item->get_data ("marker"))) == 0) { + if ((marker = static_cast (item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } Location* location = find_location_from_marker (marker, is_start); location->set_hidden (true, this); } - -void -Editor::reposition_zoom_rect (framepos_t start, framepos_t end) -{ - double x1 = sample_to_pixel (start); - double x2 = sample_to_pixel (end); - double y2 = _full_canvas_height - 1.0; - - zoom_rect->set (ArdourCanvas::Rect (x1, 1.0, x2, y2)); -} - - gint Editor::mouse_rename_region (ArdourCanvas::Item* /*item*/, GdkEvent* /*event*/) { @@ -2360,7 +2375,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, framepos_t pos) RouteTimeAxisView* rtv = dynamic_cast(&rv->get_time_axis_view()); - if (rtv == 0 || !rtv->is_track()) { + if (!rtv || !rtv->is_track()) { return; } @@ -2374,7 +2389,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, framepos_t pos) // playlist is frozen, so we have to update manually XXX this is disgusting - playlist->RegionAdded (new_region); /* EMIT SIGNAL */ + //playlist->RegionAdded (new_region); /* EMIT SIGNAL */ } gint @@ -2436,8 +2451,6 @@ Editor::add_region_brush_drag (ArdourCanvas::Item* item, GdkEvent*, RegionView* } _drags->add (new RegionMoveDrag (this, item, region_view, selection->regions.by_layer(), true, false)); - - begin_reversible_command (Operations::drag_region_brush); } /** Start a grab where a time range is selected, track(s) are selected, and the @@ -2477,7 +2490,6 @@ Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event) /* A selection grab currently creates two undo/redo operations, one for creating the new region and another for moving it. */ - begin_reversible_command (Operations::selection_grab); boost::shared_ptr playlist = clicked_axisview->playlist(); @@ -2486,20 +2498,22 @@ Editor::start_selection_grab (ArdourCanvas::Item* /*item*/, GdkEvent* event) clicked_routeview->playlist()->add_region (region, selection->time[clicked_selection].start); _session->add_command(new StatefulDiffCommand (playlist)); - commit_reversible_command (); - c.disconnect (); if (latest_regionviews.empty()) { /* something went wrong */ + abort_reversible_command (); return; } /* we need to deselect all other regionviews, and select this one i'm ignoring undo stuff, because the region creation will take care of it */ + selection->set (latest_regionviews); + commit_reversible_command (); + _drags->set (new RegionMoveDrag (this, latest_regionviews.front()->get_canvas_group(), latest_regionviews.front(), latest_regionviews, false, false), event); } @@ -2511,48 +2525,8 @@ Editor::escape () } else { selection->clear (); } -} - -void -Editor::set_internal_edit (bool yn) -{ - if (_internal_editing == yn) { - return; - } - - _internal_editing = yn; - - if (yn) { - pre_internal_mouse_mode = mouse_mode; - pre_internal_snap_type = _snap_type; - pre_internal_snap_mode = _snap_mode; - - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - (*i)->enter_internal_edit_mode (); - } - - set_snap_to (internal_snap_type); - set_snap_mode (internal_snap_mode); - - } else { - - internal_snap_mode = _snap_mode; - internal_snap_type = _snap_type; - - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - (*i)->leave_internal_edit_mode (); - } - - if (mouse_mode == MouseDraw && pre_internal_mouse_mode != MouseDraw) { - /* we were drawing .. flip back to something sensible */ - set_mouse_mode (pre_internal_mouse_mode); - } - - set_snap_to (pre_internal_snap_type); - set_snap_mode (pre_internal_snap_mode); - } - reset_canvas_cursor (); + ARDOUR_UI::instance()->reset_focus (&contents()); } /** Update _join_object_range_state which indicate whether we are over the top @@ -2562,7 +2536,7 @@ Editor::set_internal_edit (bool yn) void Editor::update_join_object_range_location (double y) { - if (_internal_editing || !get_smart_mode()) { + if (!get_smart_mode()) { _join_object_range_state = JOIN_OBJECT_RANGE_NONE; return; } @@ -2577,19 +2551,24 @@ Editor::update_join_object_range_location (double y) if (entered_regionview) { + //ToDo: there is currently a bug here(?) + //when we are inside a region fade handle, it acts as though we are in range mode because it is in the top half of the region + //can it be fixed here? + ArdourCanvas::Duple const item_space = entered_regionview->get_canvas_group()->canvas_to_item (ArdourCanvas::Duple (0, y)); double const c = item_space.y / entered_regionview->height(); - + _join_object_range_state = c <= 0.5 ? JOIN_OBJECT_RANGE_RANGE : JOIN_OBJECT_RANGE_OBJECT; - - if (_join_object_range_state != old) { - set_canvas_cursor (which_track_cursor ()); + + Editor::EnterContext* ctx = get_enter_context(RegionItem); + if (_join_object_range_state != old && ctx) { + ctx->cursor_ctx->change(which_track_cursor()); } } else if (entered_track) { RouteTimeAxisView* entered_route_view = dynamic_cast (entered_track); - + if (entered_route_view) { double cx = 0; @@ -2598,7 +2577,7 @@ Editor::update_join_object_range_location (double y) entered_route_view->canvas_display()->canvas_to_item (cx, cy); double track_height = entered_route_view->view()->child_height(); - if (Config->get_show_name_highlight()) { + if (UIConfiguration::instance().get_show_name_highlight()) { track_height -= TimeAxisViewItem::NAME_HIGHLIGHT_SIZE; } double const c = cy / track_height; @@ -2615,8 +2594,9 @@ Editor::update_join_object_range_location (double y) _join_object_range_state = JOIN_OBJECT_RANGE_OBJECT; } - if (_join_object_range_state != old) { - set_canvas_cursor (which_track_cursor ()); + Editor::EnterContext* ctx = get_enter_context(StreamItem); + if (_join_object_range_state != old && ctx) { + ctx->cursor_ctx->change(which_track_cursor()); } } }