add plural forms for pt to gtk2_ardour/po/pt.po
[ardour.git] / gtk2_ardour / editor_mouse.cc
index 23961cef91f156c8019c8e840369e5197bf8c2dd..8a8a9518cf02b9ee912a2cbcf744dd97cda600f8 100644 (file)
@@ -34,7 +34,6 @@
 
 #include "gtkmm2ext/bindings.h"
 #include "gtkmm2ext/utils.h"
-#include "gtkmm2ext/tearoff.h"
 
 #include "canvas/canvas.h"
 
@@ -72,7 +71,7 @@
 #include "verbose_cursor.h"
 #include "note.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -333,12 +332,12 @@ Editor::update_time_selection_display ()
        switch (mouse_mode) {
        case MouseRange:
                selection->clear_objects ();
-               selection->ClearMidiNoteSelection ();  /* EMIT SIGNAL */
+               selection->clear_midi_notes ();
                break;
        case MouseObject:
                selection->clear_time ();
                selection->clear_tracks ();
-               selection->ClearMidiNoteSelection ();  /* EMIT SIGNAL */
+               selection->clear_midi_notes ();
                break;
        case MouseDraw:
                /* Clear regions, but not time or tracks, since that
@@ -458,7 +457,9 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
 
                        /* almost no selection action on modified button-2 or button-3 events */
 
-                       if ((item_type != RegionItem && event->button.button != 2) && !(item_type == ControlPointItem && event->button.button == 3)) {
+                       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;
                        }
                }
@@ -628,6 +629,20 @@ Editor::button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType it
                }
                break;
 
+       case NoteItem:
+               if (press && event->button.button == 3) {
+                       NoteBase* cnote = reinterpret_cast<NoteBase*> (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;
        }
@@ -669,7 +684,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                        new TempoMarkerDrag (
                                this,
                                item,
-                               Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)
+                               Keyboard::modifier_state_equals (event->button.state, Keyboard::CopyModifier)
                                ),
                        event
                        );
@@ -682,7 +697,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                        new MeterMarkerDrag (
                                this,
                                item,
-                               Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)
+                               Keyboard::modifier_state_equals (event->button.state, Keyboard::CopyModifier)
                                ),
                        event
                        );
@@ -696,13 +711,17 @@ 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)
+                       && !Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::constraint_modifier())) {
                        _drags->set (new CursorDrag (this, *playhead_cursor, false), event);
+               } else if (Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::constraint_modifier())) {
+                       _drags->set (new BBTRulerDrag (this, item), event);
                }
                return true;
                break;
@@ -1018,7 +1037,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 {
@@ -1318,7 +1337,6 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                case RegionItem:
                        show_region_properties ();
                        break;
-
                case TempoMarkerItem: {
                        ArdourMarker* marker;
                        TempoMarker* tempo_marker;
@@ -1423,6 +1441,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:
@@ -1532,8 +1551,8 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
                                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);
@@ -2063,8 +2082,12 @@ Editor::edit_notes (MidiRegionView* mrv)
 void
 Editor::note_edit_done (int r, EditNoteDialog* d)
 {
+       begin_reversible_command (_("edit note(s)"));
+
        d->done (r);
        delete d;
+
+       commit_reversible_command();
 }
 
 void
@@ -2077,7 +2100,7 @@ Editor::visible_order_range (int* low, int* high) const
 
                RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
 
-               if (!rtv->hidden()) {
+               if (rtv && !rtv->hidden()) {
 
                        if (*high < rtv->order()) {
                                *high = rtv->order ();
@@ -2290,7 +2313,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, framepos_t pos)
 
        RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&rv->get_time_axis_view());
 
-       if (rtv == 0 || !rtv->is_track()) {
+       if (!rtv || !rtv->is_track()) {
                return;
        }
 
@@ -2441,7 +2464,7 @@ Editor::escape ()
                selection->clear ();
        }
 
-       reset_focus ();
+       reset_focus (&contents());
 }
 
 /** Update _join_object_range_state which indicate whether we are over the top