#include "ui_config.h"
#include "verbose_cursor.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
bool
Editor::track_canvas_scroll (GdkEventScroll* ev)
{
- if (Keyboard::some_magic_widget_has_focus()) {
- return false;
- }
-
- framepos_t xdelta;
int direction = ev->direction;
/* this event arrives without transformation by the canvas, so we have
Duple event_coords = _track_canvas->window_to_canvas (Duple (ev->x, ev->y));
- retry:
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)) {
- direction = GDK_SCROLL_LEFT;
- goto retry;
+ scroll_left_step ();
+ return true;
} 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);
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)) {
- direction = GDK_SCROLL_RIGHT;
- goto retry;
+ scroll_right_step ();
+ return true;
} 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);
break;
case GDK_SCROLL_LEFT:
- xdelta = (current_page_samples() / 8);
- if (leftmost_frame > xdelta) {
- reset_x_origin (leftmost_frame - xdelta);
- } else {
- reset_x_origin (0);
- }
+ scroll_left_step ();
+ return true;
break;
case GDK_SCROLL_RIGHT:
- xdelta = (current_page_samples() / 8);
- if (max_framepos - xdelta > leftmost_frame) {
- reset_x_origin (leftmost_frame + xdelta);
- } else {
- reset_x_origin (max_framepos - current_page_samples());
- }
+ scroll_right_step ();
+ return true;
break;
default:
begin_reversible_selection_op (X_("Clear Selection Click (track canvas)"));
selection->clear ();
commit_reversible_selection_op();
- }
+ }
return false;
}
Editor::track_canvas_button_release_event (GdkEventButton *event)
{
if (!Keyboard::is_context_menu_event (event)) {
- if (_drags->active ()) {
- _drags->end_grab ((GdkEvent*) event);
- }
- }
+ if (_drags->active ()) {
+ _drags->end_grab ((GdkEvent*) event);
+ }
+ }
return false;
}
bool
Editor::typed_event (ArdourCanvas::Item* item, GdkEvent *event, ItemType type)
{
+ if (!session () || session()->loading () || session()->deletion_in_progress ()) {
+ return false;
+ }
+
gint ret = FALSE;
switch (event->type) {
}
return ret;
-}
+}
bool
case GDK_BUTTON_RELEASE:
ret = button_release_handler (item, event, trim ? FadeInTrimHandleItem : FadeInHandleItem);
- maybe_locate_with_edit_preroll ( rv->region()->position() );
break;
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_RELEASE:
ret = button_release_handler (item, event, trim ? FadeOutTrimHandleItem : FadeOutHandleItem);
- maybe_locate_with_edit_preroll ( rv->region()->last_frame() - rv->get_fade_out_shape_width() );
break;
case GDK_MOTION_NOTIFY:
}
struct DescendingRegionLayerSorter {
- bool operator()(boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
- return a->layer() > b->layer();
- }
+ bool operator()(boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
+ return a->layer() > b->layer();
+ }
};
bool
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;
}
bool
-Editor::canvas_frame_handle_event (GdkEvent* event, ArdourCanvas::Item* item, RegionView* rv)
+Editor::canvas_sample_handle_event (GdkEvent* event, ArdourCanvas::Item* item, RegionView* rv)
{
bool ret = false;
- /* frame handles are not active when in internal edit mode, because actual notes
+ /* sample handles are not active when in internal edit mode, because actual notes
might be in the area occupied by the handle - we want them to be editable as normal.
*/
return false;
}
- /* NOTE: frame handles pretend to be the colored trim bar from an event handling
+ /* NOTE: sample handles pretend to be the colored trim bar from an event handling
perspective. XXX change this ??
*/
}
bool
-Editor::canvas_tempo_marker_event (GdkEvent *event, ArdourCanvas::Item* item, TempoMarker* /*marker*/)
+Editor::canvas_tempo_marker_event (GdkEvent *event, ArdourCanvas::Item* item, TempoMarker* marker)
{
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*/)
{
bool
Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType type)
{
- framepos_t xdelta;
bool handled = false;
if (event->type == GDK_SCROLL) {
-
+
/* scroll events in the rulers are handled a little differently from
scrolling elsewhere in the canvas.
*/
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);
}
handled = true;
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);
}
handled = true;
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;
-
+
default:
/* what? */
break;
bool
Editor::canvas_drop_zone_event (GdkEvent* event)
{
- GdkEventScroll scroll;
+ GdkEventScroll scroll;
ArdourCanvas::Duple winpos;
-
+
switch (event->type) {
case GDK_BUTTON_RELEASE:
if (event->button.button == 1) {
std::pair<TimeAxisView*, int> const tv = trackview_by_y_position (py, false);
bool can_drop = false;
-
+
if (tv.first != 0) {
/* over a time axis view of some kind */
rtav = dynamic_cast<RouteTimeAxisView*> (tv.first);
-
+
if (rtav != 0 && rtav->is_track ()) {
/* over a track, not a bus */
can_drop = true;
}
-
+
} else {
/* not over a time axis view, so drop is possible */
if (can_drop) {
region = _regions->get_dragged_region ();
-
+
if (region) {
if (tv.first == 0
&& (
- boost::dynamic_pointer_cast<AudioRegion> (region) != 0 ||
- boost::dynamic_pointer_cast<MidiRegion> (region) != 0
+ boost::dynamic_pointer_cast<AudioRegion> (region) != 0 ||
+ boost::dynamic_pointer_cast<MidiRegion> (region) != 0
)
)
{
context->drag_status (context->get_suggested_action(), time);
return true;
}
-
+
if ((boost::dynamic_pointer_cast<AudioRegion> (region) != 0 &&
dynamic_cast<AudioTimeAxisView*> (tv.first) != 0) ||
(boost::dynamic_pointer_cast<MidiRegion> (region) != 0 &&
dynamic_cast<MidiTimeAxisView*> (tv.first) != 0)) {
-
- /* audio to audio
- OR
+
+ /* audio to audio
+ OR
midi to midi
*/
-
+
context->drag_status (context->get_suggested_action(), time);
return true;
}
* 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) {
void
Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
- int x, int y,
- const SelectionData& /*data*/,
- guint /*info*/, guint /*time*/)
+ int x, int y,
+ const SelectionData& /*data*/,
+ guint /*info*/, guint /*time*/)
{
GdkEvent event;
double px;
event.button.y = y;
/* assume we're dragging with button 1 */
event.motion.state = Gdk::BUTTON1_MASK;
- framepos_t const pos = window_event_sample (&event, &px, &py);
+ samplepos_t const pos = window_event_sample (&event, &px, &py);
boost::shared_ptr<Region> region = _regions->get_dragged_region ();
if (!region) { return; }
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*> (time_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,
+ Config->get_strict_io () || Profile->get_mixbus (),
+ boost::shared_ptr<ARDOUR::PluginInfo>(),
+ (ARDOUR::Plugin::PresetRecord*) 0,
+ (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order);
+ rtav = dynamic_cast<RouteTimeAxisView*> (time_axis_view_from_stripable (midi_tracks.front()));
} else {
return;
}
if ((boost::dynamic_pointer_cast<AudioRegion> (region_copy) != 0 && dynamic_cast<AudioTimeAxisView*> (rtav) != 0) ||
(boost::dynamic_pointer_cast<MidiRegion> (region_copy) != 0 && dynamic_cast<MidiTimeAxisView*> (rtav) != 0)) {
_drags->set (new RegionInsertDrag (this, region_copy, rtav, pos), &event);
- _drags->end_grab (0);
+ _drags->end_grab (&event);
}
}
}