enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / editor_canvas_events.cc
index c439bdaaa39cfad450d4623b70f031d16e7d207e..30e2504edc927c70bcc20bbf77eb9538f94386a3 100644 (file)
@@ -51,7 +51,7 @@
 #include "ui_config.h"
 #include "verbose_cursor.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -75,11 +75,11 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
        switch (direction) {
        case GDK_SCROLL_UP:
                if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) {
-                       //for mouse-wheel zoom, force zoom-focus to mouse
-                       Editing::ZoomFocus temp_focus = zoom_focus;
-                       zoom_focus = Editing::ZoomFocusMouse;
-                       temporal_zoom_step (false);
-                       zoom_focus = temp_focus;
+                       if (UIConfiguration::instance().get_use_mouse_position_as_zoom_focus_on_scroll()) {
+                               temporal_zoom_step_mouse_focus (false);
+                       } else {
+                               temporal_zoom_step (false);
+                       }
                        return true;
                } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) {
                        scroll_left_step ();
@@ -104,11 +104,11 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
 
        case GDK_SCROLL_DOWN:
                if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) {
-                       //for mouse-wheel zoom, force zoom-focus to mouse
-                       Editing::ZoomFocus temp_focus = zoom_focus;
-                       zoom_focus = Editing::ZoomFocusMouse;
-                       temporal_zoom_step (true);
-                       zoom_focus = temp_focus;
+                       if (UIConfiguration::instance().get_use_mouse_position_as_zoom_focus_on_scroll()) {
+                               temporal_zoom_step_mouse_focus (true);
+                       } else {
+                               temporal_zoom_step (true);
+                       }
                        return true;
                } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) {
                        scroll_right_step ();
@@ -677,10 +677,14 @@ Editor::canvas_line_event (GdkEvent *event, ArdourCanvas::Item* item, Automation
        AudioRegionGainLine* gl;
        if ((gl = dynamic_cast<AudioRegionGainLine*> (al)) != 0) {
                type = GainLineItem;
-               clicked_regionview = &gl->region_view ();
+               if (event->type == GDK_BUTTON_PRESS) {
+                       clicked_regionview = &gl->region_view ();
+               }
        } else {
                type = AutomationLineItem;
-               clicked_regionview = 0;
+               if (event->type == GDK_BUTTON_PRESS) {
+                       clicked_regionview = 0;
+               }
        }
 
        clicked_control_point = 0;
@@ -1009,6 +1013,12 @@ Editor::canvas_tempo_marker_event (GdkEvent *event, ArdourCanvas::Item* item, Te
        return typed_event (item, event, TempoMarkerItem);
 }
 
+bool
+Editor::canvas_tempo_curve_event (GdkEvent *event, ArdourCanvas::Item* item, TempoCurve* /*marker*/)
+{
+       return typed_event (item, event, TempoCurveItem);
+}
+
 bool
 Editor::canvas_meter_marker_event (GdkEvent *event, ArdourCanvas::Item* item, MeterMarker* /*marker*/)
 {
@@ -1018,7 +1028,6 @@ Editor::canvas_meter_marker_event (GdkEvent *event, ArdourCanvas::Item* item, Me
 bool
 Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType type)
 {
-       framepos_t xdelta;
        bool handled = false;
 
        if (event->type == GDK_SCROLL) {
@@ -1029,13 +1038,11 @@ Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType
 
                switch (event->scroll.direction) {
                case GDK_SCROLL_UP:
-
-                       if (Profile->get_mixbus()) {
-                               //for mouse-wheel zoom, force zoom-focus to mouse
-                               Editing::ZoomFocus temp_focus = zoom_focus;
-                               zoom_focus = Editing::ZoomFocusMouse;
-                               temporal_zoom_step (false);
-                               zoom_focus = temp_focus;
+                       if (Keyboard::modifier_state_equals(event->scroll.state,
+                                                           Keyboard::ScrollHorizontalModifier)) {
+                               scroll_left_step ();
+                       } else if (UIConfiguration::instance().get_use_mouse_position_as_zoom_focus_on_scroll()) {
+                               temporal_zoom_step_mouse_focus (false);
                        } else {
                                temporal_zoom_step (false);
                        }
@@ -1043,12 +1050,11 @@ Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType
                        break;
 
                case GDK_SCROLL_DOWN:
-                       if (Profile->get_mixbus()) {
-                               //for mouse-wheel zoom, force zoom-focus to mouse
-                               Editing::ZoomFocus temp_focus = zoom_focus;
-                               zoom_focus = Editing::ZoomFocusMouse;
-                               temporal_zoom_step (true);
-                               zoom_focus = temp_focus;
+                       if (Keyboard::modifier_state_equals(event->scroll.state,
+                                                           Keyboard::ScrollHorizontalModifier)) {
+                               scroll_right_step ();
+                       } else if (UIConfiguration::instance().get_use_mouse_position_as_zoom_focus_on_scroll()) {
+                               temporal_zoom_step_mouse_focus (true);
                        } else {
                                temporal_zoom_step (true);
                        }
@@ -1056,22 +1062,12 @@ Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType
                        break;
 
                case GDK_SCROLL_LEFT:
-                       xdelta = (current_page_samples() / 2);
-                       if (leftmost_frame > xdelta) {
-                               reset_x_origin (leftmost_frame - xdelta);
-                       } else {
-                               reset_x_origin (0);
-                       }
+                       scroll_left_half_page ();
                        handled = true;
                        break;
 
                case GDK_SCROLL_RIGHT:
-                       xdelta = (current_page_samples() / 2);
-                       if (max_framepos - xdelta > leftmost_frame) {
-                               reset_x_origin (leftmost_frame + xdelta);
-                       } else {
-                               reset_x_origin (max_framepos - current_page_samples());
-                       }
+                       scroll_right_half_page ();
                        handled = true;
                        break;
 
@@ -1233,7 +1229,7 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
                         * TODO: check if file is audio/midi, allow drops on same track-type only,
                         * currently: if audio is dropped on a midi-track, it is only added to the region-list
                         */
-                       if (Profile->get_sae() || UIConfiguration::instance().get_only_copy_imported_files()) {
+                       if (UIConfiguration::instance().get_only_copy_imported_files()) {
                                context->drag_status(Gdk::ACTION_COPY, time);
                        } else {
                                if ((context->get_actions() & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY) {
@@ -1284,13 +1280,15 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
                                        output_chan =  session()->master_out()->n_inputs().n_audio();
                                }
                                list<boost::shared_ptr<AudioTrack> > audio_tracks;
-                               audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, ARDOUR::Normal, 0, 1, region->name());
-                               rtav = axis_view_from_route (audio_tracks.front());
+                               audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order);
+                               rtav = dynamic_cast<RouteTimeAxisView*> (axis_view_from_stripable (audio_tracks.front()));
                        } else if (boost::dynamic_pointer_cast<MidiRegion> (region)) {
                                ChanCount one_midi_port (DataType::MIDI, 1);
                                list<boost::shared_ptr<MidiTrack> > midi_tracks;
-                               midi_tracks = session()->new_midi_track (one_midi_port, one_midi_port, boost::shared_ptr<ARDOUR::PluginInfo>(), ARDOUR::Normal, 0, 1, region->name());
-                               rtav = axis_view_from_route (midi_tracks.front());
+                               midi_tracks = session()->new_midi_track (one_midi_port, one_midi_port, boost::shared_ptr<ARDOUR::PluginInfo>(),
+                                                                        (ARDOUR::Plugin::PresetRecord*) 0,
+                                                                        (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order);
+                               rtav = dynamic_cast<RouteTimeAxisView*> (axis_view_from_stripable (midi_tracks.front()));
                        } else {
                                return;
                        }