X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_canvas_events.cc;h=79cc1e066fcacbc0b8f5c87a5a6ca6d71e6ca89a;hb=da1e8701eb90f7e11c74e0104a5f97bf227aa2bd;hp=778d116797d12588230c218d90cd3667fda76cfa;hpb=e5776d1a69f25540da7e30b3b1be516db3cc5ef4;p=ardour.git diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 778d116797..79cc1e066f 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -26,6 +26,7 @@ #include "ardour/midi_region.h" #include "ardour/region_factory.h" +#include "ardour/profile.h" #include "editor.h" #include "keyboard.h" @@ -65,17 +66,17 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) retry: switch (direction) { case GDK_SCROLL_UP: - if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + 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; return true; - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) { direction = GDK_SCROLL_LEFT; goto retry; - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) { if (!current_stepping_trackview) { step_timeout = Glib::signal_timeout().connect (sigc::mem_fun(*this, &Editor::track_height_step_timeout), 500); std::pair const p = trackview_by_y_position (ev->y + vertical_adjustment.get_value() - canvas_timebars_vsize); @@ -94,17 +95,17 @@ Editor::track_canvas_scroll (GdkEventScroll* ev) break; case GDK_SCROLL_DOWN: - if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + 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; return true; - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) { direction = GDK_SCROLL_RIGHT; goto retry; - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) { if (!current_stepping_trackview) { step_timeout = Glib::signal_timeout().connect (sigc::mem_fun(*this, &Editor::track_height_step_timeout), 500); std::pair const p = trackview_by_y_position (ev->y + vertical_adjustment.get_value() - canvas_timebars_vsize); @@ -947,6 +948,12 @@ Editor::canvas_cd_marker_bar_event (GdkEvent *event, ArdourCanvas::Item* item) return typed_event (item, event, CdMarkerBarItem); } +bool +Editor::canvas_videotl_bar_event (GdkEvent *event, ArdourCanvas::Item* item) +{ + return typed_event (item, event, VideoBarItem); +} + bool Editor::canvas_tempo_marker_event (GdkEvent *event, ArdourCanvas::Item* item, TempoMarker* /*marker*/) { @@ -994,63 +1001,152 @@ Editor::canvas_note_event (GdkEvent *event, ArdourCanvas::Item* item) } bool -Editor::track_canvas_drag_motion (Glib::RefPtr const & /*c*/, int x, int y, guint /*time*/) +Editor::track_canvas_drag_motion (Glib::RefPtr const& context, int x, int y, guint time) { double wx; double wy; + boost::shared_ptr region; + boost::shared_ptr region_copy; + RouteTimeAxisView* rtav; + GdkEvent event; + double px; + double py; + + string target = track_canvas->drag_dest_find_target (context, track_canvas->drag_dest_get_target_list()); + + if (target.empty()) { + return false; + } + track_canvas->window_to_world (x, y, wx, wy); - GdkEvent event; event.type = GDK_MOTION_NOTIFY; event.button.x = wx; event.button.y = wy; /* assume we're dragging with button 1 */ event.motion.state = Gdk::BUTTON1_MASK; - if (!_drags->active ()) { + (void) event_frame (&event, &px, &py); - double px; - double py; - framepos_t const pos = event_frame (&event, &px, &py); + std::pair const tv = trackview_by_y_position (py); + bool can_drop = false; + + if (tv.first != 0) { - std::pair const tv = trackview_by_y_position (py); - if (tv.first == 0) { - return true; - } + /* over a time axis view of some kind */ - RouteTimeAxisView* rtav = dynamic_cast (tv.first); - if (rtav == 0 || !rtav->is_track ()) { - return true; + rtav = dynamic_cast (tv.first); + + if (rtav != 0 && rtav->is_track ()) { + /* over a track, not a bus */ + can_drop = true; } + - boost::shared_ptr region = _regions->get_dragged_region (); + } else { + /* not over a time axis view, so drop is possible */ + can_drop = true; + } - if (!region) { + if (can_drop) { + region = _regions->get_dragged_region (); + + if (region) { + + if ((boost::dynamic_pointer_cast (region) != 0 && + dynamic_cast (tv.first) != 0) || + (boost::dynamic_pointer_cast (region) != 0 && + dynamic_cast (tv.first) != 0)) { + + /* audio to audio + OR + midi to midi + */ + + context->drag_status (context->get_suggested_action(), time); + return true; + } + } else { + /* DND originating from outside ardour + * + * 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() || Config->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) { + context->drag_status(Gdk::ACTION_COPY, time); + } else { + context->drag_status(Gdk::ACTION_LINK, time); + } + } return true; } + } + + /* no drop here */ + context->drag_status (Gdk::DragAction (0), time); + return false; +} - boost::shared_ptr region_copy = RegionFactory::create (region, true); +void +Editor::drop_regions (const Glib::RefPtr& /*context*/, + int x, int y, + const SelectionData& /*data*/, + guint /*info*/, guint /*time*/) +{ + double wx; + double wy; + boost::shared_ptr region; + boost::shared_ptr region_copy; + RouteTimeAxisView* rtav; + GdkEvent event; + double px; + double py; - if (boost::dynamic_pointer_cast (region_copy) != 0 && - dynamic_cast (tv.first) == 0) { + track_canvas->window_to_world (x, y, wx, wy); - /* audio -> non-audio */ - return true; - } + event.type = GDK_MOTION_NOTIFY; + event.button.x = wx; + event.button.y = wy; + /* assume we're dragging with button 1 */ + event.motion.state = Gdk::BUTTON1_MASK; - if (boost::dynamic_pointer_cast (region_copy) != 0 && - dynamic_cast (tv.first) == 0) { + framepos_t const pos = event_frame (&event, &px, &py); - /* MIDI -> non-MIDI */ - return true; - } + std::pair const tv = trackview_by_y_position (py); - _drags->set (new RegionInsertDrag (this, region_copy, rtav, pos), &event); - } + if (tv.first != 0) { + + rtav = dynamic_cast (tv.first); + + if (rtav != 0 && rtav->is_track ()) { + + boost::shared_ptr region = _regions->get_dragged_region (); + + if (region) { + + region_copy = RegionFactory::create (region, true); + - _drags->motion_handler (&event, false); + if ((boost::dynamic_pointer_cast (region_copy) != 0 && + dynamic_cast (tv.first) != 0) || + (boost::dynamic_pointer_cast (region_copy) != 0 && + dynamic_cast (tv.first) != 0)) { - return true; + /* audio to audio + OR + midi to midi + */ + + + _drags->set (new RegionInsertDrag (this, region_copy, rtav, pos), &event); + _drags->end_grab (0); + } + } + } + } } bool