#include <set>
#include <string>
#include <algorithm>
+#include <bitset>
#include "pbd/error.h"
#include "pbd/enumwriter.h"
#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/tearoff.h"
+#include "canvas/canvas.h"
+
+#include "ardour/audioregion.h"
+#include "ardour/operations.h"
+#include "ardour/playlist.h"
+#include "ardour/profile.h"
+#include "ardour/region_factory.h"
+#include "ardour/route.h"
+#include "ardour/session.h"
+#include "ardour/types.h"
+
#include "ardour_ui.h"
#include "actions.h"
-#include "canvas-note.h"
#include "editor.h"
#include "time_axis_view.h"
#include "audio_time_axis.h"
#include "mouse_cursors.h"
#include "editor_cursors.h"
#include "verbose_cursor.h"
-
-#include "ardour/types.h"
-#include "ardour/profile.h"
-#include "ardour/route.h"
-#include "ardour/audio_track.h"
-#include "ardour/playlist.h"
-#include "ardour/audioplaylist.h"
-#include "ardour/audioregion.h"
-#include "ardour/midi_region.h"
-#include "ardour/dB.h"
-#include "ardour/utils.h"
-#include "ardour/region_factory.h"
-#include "ardour/source_factory.h"
-#include "ardour/session.h"
-#include "ardour/operations.h"
-
-#include <bitset>
+#include "note.h"
#include "i18n.h"
}
int x, y;
- double wx, wy;
- Gdk::ModifierType mask;
- Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->track_canvas->get_window();
- Glib::RefPtr<const Gdk::Window> pointer_window;
+ Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->_track_canvas->get_window();
if (!canvas_window) {
return false;
}
- pointer_window = canvas_window->get_pointer (x, y, mask);
+ Glib::RefPtr<const Gdk::Window> pointer_window = Gdk::Display::get_default()->get_window_at_pointer (x, y);
- if (pointer_window == track_canvas->get_bin_window()) {
- wx = x;
- wy = y;
- in_track_canvas = true;
+ if (!pointer_window) {
+ return false;
+ }
- } else {
+ if (pointer_window != canvas_window && pointer_window != _time_bars_canvas->get_window()) {
in_track_canvas = false;
- return false;
+ return false;
}
+ in_track_canvas = true;
+
GdkEvent event;
event.type = GDK_BUTTON_RELEASE;
- event.button.x = wx;
- event.button.y = wy;
+ event.button.x = x;
+ event.button.y = y;
+
+ where = window_event_frame (&event, 0, 0);
- where = event_frame (&event, 0, 0);
return true;
}
framepos_t
-Editor::event_frame (GdkEvent const * event, double* pcx, double* pcy) const
+Editor::window_event_frame (GdkEvent const * event, double* pcx, double* pcy) const
{
- double cx, cy;
+ double x;
+ double y;
- if (pcx == 0) {
- pcx = &cx;
+ if (!gdk_event_get_coords (event, &x, &y)) {
+ return 0;
}
- if (pcy == 0) {
- pcy = &cy;
+
+ /* event coordinates are in window units, so convert to canvas
+ * (i.e. account for scrolling)
+ */
+
+ ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (x, y));
+
+ if (pcx) {
+ *pcx = d.x;
}
- *pcx = 0;
- *pcy = 0;
+ if (pcy) {
+ *pcy = d.y;
+ }
- switch (event->type) {
- case GDK_BUTTON_RELEASE:
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- *pcx = event->button.x;
- *pcy = event->button.y;
- _trackview_group->w2i(*pcx, *pcy);
- break;
- case GDK_MOTION_NOTIFY:
- *pcx = event->motion.x;
- *pcy = event->motion.y;
- _trackview_group->w2i(*pcx, *pcy);
- break;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- track_canvas->w2c(event->crossing.x, event->crossing.y, *pcx, *pcy);
- break;
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- // track_canvas->w2c(event->key.x, event->key.y, *pcx, *pcy);
- break;
- default:
- warning << string_compose (_("Editor::event_frame() used on unhandled event type %1"), event->type) << endmsg;
- break;
+ return pixel_to_sample (d.x);
+}
+
+framepos_t
+Editor::canvas_event_frame (GdkEvent const * event, double* pcx, double* pcy) const
+{
+ double x;
+ double y;
+
+ /* event coordinates are already in canvas units */
+
+ if (!gdk_event_get_coords (event, &x, &y)) {
+ cerr << "!NO c COORDS for event type " << event->type << endl;
+ return 0;
+ }
+
+ if (pcx) {
+ *pcx = x;
}
- /* note that pixel_to_frame() never returns less than zero, so even if the pixel
+ if (pcy) {
+ *pcy = y;
+ }
+
+ /* note that pixel_to_sample() never returns less than zero, so even if the pixel
position is negative (as can be the case with motion events in particular),
the frame location is always positive.
*/
- return pixel_to_frame (*pcx);
+ return pixel_to_sample (x);
}
Gdk::Cursor*
case MouseTimeFX:
c = _cursors->midi_resize;
break;
+
+ case MouseRange:
+ c = _cursors->grabber_note;
+ break;
default:
break;
void
Editor::set_canvas_cursor ()
{
- if (_internal_editing) {
-
- switch (mouse_mode) {
- case MouseDraw:
- current_canvas_cursor = _cursors->midi_pencil;
- break;
-
- case MouseObject:
+ switch (mouse_mode) {
+ case MouseRange:
+ current_canvas_cursor = _cursors->selector;
+ if (_internal_editing) {
current_canvas_cursor = which_grabber_cursor();
- break;
-
- case MouseTimeFX:
- current_canvas_cursor = _cursors->midi_resize;
- break;
-
- default:
- return;
}
+ break;
- } else {
+ case MouseObject:
+ current_canvas_cursor = which_grabber_cursor();
+ break;
- switch (mouse_mode) {
- case MouseRange:
- current_canvas_cursor = _cursors->selector;
- break;
+ case MouseDraw:
+ current_canvas_cursor = _cursors->midi_pencil;
+ break;
- case MouseObject:
- current_canvas_cursor = which_grabber_cursor();
- break;
+ case MouseGain:
+ current_canvas_cursor = _cursors->cross_hair;
+ break;
- case MouseDraw:
- /* shouldn't be possible, but just cover it anyway ... */
- current_canvas_cursor = _cursors->midi_pencil;
- break;
+ case MouseZoom:
+ if (Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
+ current_canvas_cursor = _cursors->zoom_out;
+ } else {
+ current_canvas_cursor = _cursors->zoom_in;
+ }
+ break;
- case MouseGain:
- current_canvas_cursor = _cursors->cross_hair;
- break;
+ case MouseTimeFX:
+ current_canvas_cursor = _cursors->time_fx; // just use playhead
+ break;
- case MouseZoom:
- if (Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
- current_canvas_cursor = _cursors->zoom_out;
- } else {
- current_canvas_cursor = _cursors->zoom_in;
- }
- break;
+ case MouseAudition:
+ current_canvas_cursor = _cursors->speaker;
+ break;
+ }
- case MouseTimeFX:
- current_canvas_cursor = _cursors->time_fx; // just use playhead
+ if (!_internal_editing) {
+ switch (_join_object_range_state) {
+ case JOIN_OBJECT_RANGE_NONE:
break;
-
- case MouseAudition:
- current_canvas_cursor = _cursors->speaker;
+ case JOIN_OBJECT_RANGE_OBJECT:
+ current_canvas_cursor = which_grabber_cursor ();
+ break;
+ case JOIN_OBJECT_RANGE_RANGE:
+ current_canvas_cursor = _cursors->selector;
break;
}
}
- switch (_join_object_range_state) {
- case JOIN_OBJECT_RANGE_NONE:
- break;
- case JOIN_OBJECT_RANGE_OBJECT:
- current_canvas_cursor = which_grabber_cursor ();
- break;
- case JOIN_OBJECT_RANGE_RANGE:
- current_canvas_cursor = _cursors->selector;
- break;
- }
-
/* up-down cursor as a cue that automation can be dragged up and down when in join object/range mode */
- if (smart_mode_action->get_active()) {
+ if (!_internal_editing && get_smart_mode() ) {
+
double x, y;
get_pointer_position (x, y);
- ArdourCanvas::Item* i = track_canvas->get_item_at (x, y);
- if (i && i->property_parent() && (*i->property_parent()).get_data (X_("timeselection"))) {
- pair<TimeAxisView*, int> tvp = trackview_by_y_position (_last_motion_y + vertical_adjustment.get_value() - canvas_timebars_vsize);
- if (dynamic_cast<AutomationTimeAxisView*> (tvp.first)) {
- current_canvas_cursor = _cursors->up_down;
+
+ if (x >= 0 && y >= 0) {
+
+ vector<ArdourCanvas::Item const *> items;
+
+ _track_canvas->root()->add_items_at_point (ArdourCanvas::Duple (x,y), items);
+
+ // first item will be the upper most
+
+ if (!items.empty()) {
+ const ArdourCanvas::Item* i = items.front();
+
+ if (i && i->parent() && i->parent()->get_data (X_("timeselection"))) {
+ pair<TimeAxisView*, int> tvp = trackview_by_y_position (_last_motion_y);
+ if (dynamic_cast<AutomationTimeAxisView*> (tvp.first)) {
+ current_canvas_cursor = _cursors->up_down;
+ }
+ }
}
}
}
set_canvas_cursor (current_canvas_cursor, true);
}
+void
+Editor::mouse_mode_object_range_toggled()
+{
+ MouseMode m = mouse_mode;
+
+ Glib::RefPtr<Action> act = ActionManager::get_action (X_("MouseMode"), X_("set-mouse-mode-range"));
+ assert (act);
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::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
+}
+
void
Editor::set_mouse_mode (MouseMode m, bool force)
{
tact->set_active (false);
tact->set_active (true);
- MouseModeChanged (); /* EMIT SIGNAL */
+ //NOTE: this will result in a call to mouse_mode_toggled which does the heavy lifting
}
void
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);
+ }
mouse_mode = m;
instant_save ();
- if (!internal_editing()) {
- if (mouse_mode != MouseRange && mouse_mode != MouseGain && _join_object_range_state == JOIN_OBJECT_RANGE_NONE) {
-
- /* in all modes except range, gain and joined object/range, hide the range selection,
- show the object (region) selection.
- */
-
- for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
- (*i)->hide_selection ();
- }
-
- } else {
-
- /*
- in range or object/range mode, show the range selection.
- */
-
- for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
- (*i)->show_selection (selection->time);
- }
+ //TODO: set button styles for smart buttons
+/*
+ if ( smart_mode_action->get_active() ) {
+ if( mouse_mode == MouseObject ) { //smart active and object active
+ smart_mode_button.set_active(1);
+ smart_mode_button.set_name("smart mode button");
+ mouse_move_button.set_name("smart mode button");
+ } else { //smart active but object inactive
+ smart_mode_button.set_active(0);
+ smart_mode_button.set_name("smart mode button");
+ mouse_move_button.set_name("mouse mode button");
}
+ } else {
+ smart_mode_button.set_active(0);
+ smart_mode_button.set_name("mouse mode button");
+ mouse_move_button.set_name("mouse mode button");
}
-
+*/
+
set_canvas_cursor ();
+ set_gain_envelope_visibility ();
MouseModeChanged (); /* EMIT SIGNAL */
}
*/
if (((mouse_mode != MouseObject) &&
- (_join_object_range_state != JOIN_OBJECT_RANGE_OBJECT) &&
(mouse_mode != MouseAudition || item_type != RegionItem) &&
(mouse_mode != MouseTimeFX || item_type != RegionItem) &&
(mouse_mode != MouseGain) &&
- (mouse_mode != MouseRange) &&
(mouse_mode != MouseDraw)) ||
((event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE) || event->button.button > 3) ||
- internal_editing()) {
+ (internal_editing() && mouse_mode != MouseTimeFX)) {
return;
}
switch (item_type) {
case RegionItem:
- if (!doing_range_stuff()) {
- set_selected_regionview_from_click (press, op);
- }
-
- if (press) {
- if (doing_range_stuff()) {
- /* don't change the selection unless the
- clicked track is not currently selected. if
- so, "collapse" the selection to just this
- track
- */
- if (!selection->selected (clicked_axisview)) {
- set_selected_track_as_side_effect (Selection::Set);
+ if (!get_smart_mode() || (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT)) {
+ if (press) {
+ if (mouse_mode != MouseRange) {
+ set_selected_regionview_from_click (press, op);
+ } else {
+ /* don't change the selection unless the
+ clicked track is not currently selected. if
+ so, "collapse" the selection to just this
+ track
+ */
+ if (!selection->selected (clicked_axisview)) {
+ set_selected_track_as_side_effect (Selection::Set);
+ }
+ }
+ } else {
+ if (mouse_mode != MouseRange) {
+ set_selected_regionview_from_click (press, op);
}
}
}
case RegionViewName:
case LeftFrameHandle:
case RightFrameHandle:
- if (doing_object_stuff() || (mouse_mode != MouseRange && mouse_mode != MouseObject)) {
+ if ( mouse_mode != MouseRange ) {
set_selected_regionview_from_click (press, op);
} else if (event->type == GDK_BUTTON_PRESS) {
set_selected_track_as_side_effect (op);
}
break;
-
- case StartCrossFadeItem:
- case EndCrossFadeItem:
- break;
-
case FadeInHandleItem:
case FadeInItem:
case FadeOutHandleItem:
case FadeOutItem:
- if (doing_object_stuff() || (mouse_mode != MouseRange && mouse_mode != MouseObject)) {
+ case StartCrossFadeItem:
+ case EndCrossFadeItem:
+ if ( mouse_mode != MouseRange ) {
set_selected_regionview_from_click (press, op);
} else if (event->type == GDK_BUTTON_PRESS) {
set_selected_track_as_side_effect (op);
case ControlPointItem:
set_selected_track_as_side_effect (op);
- if (doing_object_stuff() || (mouse_mode != MouseRange && mouse_mode != MouseObject)) {
+ if ( mouse_mode != MouseRange ) {
set_selected_control_point_from_click (press, op);
}
break;
switch (item_type) {
case PlayheadCursorItem:
- _drags->set (new CursorDrag (this, item, true), event);
+ _drags->set (new CursorDrag (this, *playhead_cursor, true), event);
return true;
case MarkerItem:
}
}
+ case VideoBarItem:
+ _drags->set (new VideoTimeLineDrag (this, item), event);
+ return true;
+ break;
+
case MarkerBarItem:
case TempoBarItem:
case MeterBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
- _drags->set (new CursorDrag (this, &playhead_cursor->canvas_item, false), event);
+ _drags->set (new CursorDrag (this, *playhead_cursor, false), event);
}
return true;
break;
case RangeMarkerBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
- _drags->set (new CursorDrag (this, &playhead_cursor->canvas_item, false), event);
+ _drags->set (new CursorDrag (this, *playhead_cursor, false), event);
} else {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateRangeMarker), event);
}
case CdMarkerBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
- _drags->set (new CursorDrag (this, &playhead_cursor->canvas_item, false), event);
+ _drags->set (new CursorDrag (this, *playhead_cursor, false), event);
} else {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateCDMarker), event);
}
case TransportMarkerBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
- _drags->set (new CursorDrag (this, &playhead_cursor->canvas_item, false), event);
+ _drags->set (new CursorDrag (this, *playhead_cursor, false), event);
} else {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateTransportMarker), event);
}
eff = MouseObject;
}
+ /* there is no Range mode when in internal edit mode */
+ if (eff == MouseRange && internal_editing()) {
+ eff = MouseObject;
+ }
+
switch (eff) {
case MouseRange:
switch (item_type) {
break;
case SelectionItem:
- if (Keyboard::modifier_state_contains
- (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier))) {
- // contains and not equals because I can't use alt as a modifier alone.
+ if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) {
start_selection_grab (item, event);
+ return true;
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) {
/* grab selection for moving */
_drags->set (new SelectionDrag (this, item, SelectionDrag::SelectionMove), event);
} else {
- double const y = event->button.y + vertical_adjustment.get_value() - canvas_timebars_vsize;
+ double const y = event->button.y;
pair<TimeAxisView*, int> tvp = trackview_by_y_position (y);
if (tvp.first) {
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (tvp.first);
- if (smart_mode_action->get_active() && atv) {
+ if ( get_smart_mode() && atv) {
/* smart "join" mode: drag automation */
_drags->set (new AutomationRangeDrag (this, atv, selection->time), event, _cursors->up_down);
} else {
return true;
}
} 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 RegionViewNameHighlight:
if (!clicked_regionview->region()->locked()) {
- RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
- _drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event);
- return true;
- }
- break;
-
- case LeftFrameHandle:
- case RightFrameHandle:
- if (!internal_editing() && doing_object_stuff() && !clicked_regionview->region()->locked()) {
- RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::select.property_id);
_drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event);
return true;
}
default:
if (!internal_editing()) {
- _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;
case NoteItem:
if (internal_editing()) {
/* trim notes if we're in internal edit mode and near the ends of the note */
- ArdourCanvas::CanvasNote* cn = dynamic_cast<ArdourCanvas::CanvasNote*> (item);
+ NoteBase* cn = reinterpret_cast<NoteBase*>(item->get_data ("notebase"));
+ assert (cn);
if (cn && cn->big_enough_to_trim() && cn->mouse_near_ends()) {
_drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
} else {
return true;
}
break;
+ case StreamItem:
+ if (internal_editing()) {
+ if (dynamic_cast<MidiTimeAxisView*> (clicked_axisview)) {
+ _drags->set (new RegionCreateDrag (this, item, clicked_axisview), event);
+ }
+ return true;
+ }
+ break;
default:
break;
switch (item_type) {
case NoteItem:
if (internal_editing()) {
- ArdourCanvas::CanvasNoteEvent* cn = dynamic_cast<ArdourCanvas::CanvasNoteEvent*> (item);
+ NoteBase* cn = reinterpret_cast<NoteBase*> (item->get_data ("notebase"));
+ assert (cn);
if (cn->mouse_near_ends()) {
_drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
} else {
switch (item_type) {
case FadeInHandleItem:
{
- RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::select.property_id);
_drags->set (new FadeInDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), s), event, _cursors->fade_in);
return true;
}
case FadeOutHandleItem:
{
- RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::select.property_id);
_drags->set (new FadeOutDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), s), event, _cursors->fade_out);
return true;
}
case StartCrossFadeItem:
- _drags->set (new CrossfadeEdgeDrag (this, reinterpret_cast<AudioRegionView*>(item->get_data("regionview")), item, true), event, 0);
- break;
-
case EndCrossFadeItem:
- _drags->set (new CrossfadeEdgeDrag (this, reinterpret_cast<AudioRegionView*>(item->get_data("regionview")), item, false), event, 0);
+ /* 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()) {
+// RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
+// _drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer(), true), event);
+// return true;
+// }
break;
case FeatureLineItem:
}
- 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));
- }
+// 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;
case RegionViewNameHighlight:
case LeftFrameHandle:
case RightFrameHandle:
if (!clicked_regionview->region()->locked()) {
- RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::select.property_id);
_drags->set (new TrimDrag (this, item, clicked_regionview, s.by_layer()), event);
return true;
}
case RegionViewName:
{
/* rename happens on edit clicks */
- RegionSelection s = get_equivalent_regions (selection->regions, Properties::edit.property_id);
+ RegionSelection s = get_equivalent_regions (selection->regions, Properties::select.property_id);
_drags->set (new TrimDrag (this, clicked_regionview->get_name_highlight(), clicked_regionview, s.by_layer()), event);
return true;
break;
AutomationTimeAxisView* atv = dynamic_cast<AutomationTimeAxisView*> (clicked_axisview);
assert (atv);
if (parent && dynamic_cast<MidiTimeAxisView*> (parent) && atv->show_regions ()) {
- /* create a MIDI region so that we have somewhere to put automation */
- _drags->set (new RegionCreateDrag (this, item, parent), event);
+
+ RouteTimeAxisView* p = dynamic_cast<RouteTimeAxisView*> (parent);
+ assert (p);
+ boost::shared_ptr<Playlist> pl = p->track()->playlist ();
+ if (pl->n_regions() == 0) {
+ /* Parent has no regions; create one so that we have somewhere to put automation */
+ _drags->set (new RegionCreateDrag (this, item, parent), event);
+ } else {
+ /* See if there's a region before the click that we can extend, and extend it if so */
+ framepos_t const t = canvas_event_frame (event);
+ boost::shared_ptr<Region> prev = pl->find_next_region (t, End, -1);
+ if (!prev) {
+ _drags->set (new RegionCreateDrag (this, item, parent), event);
+ } else {
+ prev->set_length (t - prev->position ());
+ }
+ }
} else {
/* rubberband drag to select automation points */
_drags->set (new EditorRubberbandSelectDrag (this, item), event);
case SelectionItem:
{
- if (smart_mode_action->get_active()) {
+ if ( get_smart_mode() ) {
/* we're in "smart" joined mode, and we've clicked on a Selection */
- double const y = event->button.y + vertical_adjustment.get_value() - canvas_timebars_vsize;
+ double const y = event->button.y;
pair<TimeAxisView*, int> tvp = trackview_by_y_position (y);
if (tvp.first) {
/* if we're over an automation track, start a drag of its data */
/* if we're over a track and a region, and in the `object' part of a region,
put a selection around the region and drag both
*/
- RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tvp.first);
+/* RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tvp.first);
if (rtv && _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) {
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (rtv->route ());
if (t) {
boost::shared_ptr<Playlist> pl = t->playlist ();
if (pl) {
- boost::shared_ptr<Region> r = pl->top_region_at (event_frame (event));
+ boost::shared_ptr<Region> r = pl->top_region_at (canvas_event_frame (event));
if (r) {
RegionView* rv = rtv->view()->find_view (r);
clicked_selection = select_range (rv->region()->position(),
rvs.push_back (rv);
_drags->add (new RegionMoveDrag (this, item, rv, rvs, false, false));
_drags->start_grab (event);
+ return true;
}
}
}
}
+*/
}
}
break;
/* drag notes if we're in internal edit mode */
_drags->set (new NoteResizeDrag (this, item), event, current_canvas_cursor);
return true;
- } else if ((!internal_editing() || dynamic_cast<AudioRegionView*> (clicked_regionview)) && clicked_regionview) {
- /* do time-FX if we're not in internal edit mode, or we are but we clicked on an audio region */
+ } else if (clicked_regionview) {
+ /* do time-FX */
_drags->set (new TimeFXDrag (this, item, clicked_regionview, selection->regions.by_layer()), event);
return true;
}
case MouseZoom:
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
- temporal_zoom_to_frame (false, event_frame (event));
+ temporal_zoom_to_frame (false, canvas_event_frame (event));
} else {
- temporal_zoom_to_frame (true, event_frame(event));
+ temporal_zoom_to_frame (true, canvas_event_frame(event));
}
return true;
break;
return false;
}
- Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->track_canvas->get_window();
+ Glib::RefPtr<Gdk::Window> canvas_window = const_cast<Editor*>(this)->_track_canvas_viewport->get_window();
if (canvas_window) {
Glib::RefPtr<const Gdk::Window> pointer_window;
pointer_window = canvas_window->get_pointer (x, y, mask);
- if (pointer_window == track_canvas->get_bin_window()) {
- track_canvas->window_to_world (x, y, wx, wy);
+ if (pointer_window == _track_canvas->get_window()) {
+ _track_canvas->window_to_canvas (x, y, wx, wy);
}
}
pre_press_cursor = current_canvas_cursor;
- track_canvas->grab_focus();
+ _track_canvas->grab_focus();
if (_session && _session->actively_recording()) {
return true;
}
-
-
if (internal_editing()) {
bool leave_internal_edit_mode = false;
case RangeMarkerBarItem:
case CdMarkerBarItem:
case TransportMarkerBarItem:
+ case StreamItem:
/* button press on these events never does anything to
change the editing mode.
*/
break;
-
- case StreamItem:
- leave_internal_edit_mode = true;
- break;
default:
break;
return true;
}
+ //not rolling, range mode click + join_play_range : locate the PH here
+ if ( !_drags->active () && !_session->transport_rolling() && ( effective_mouse_mode() == MouseRange ) && Config->get_always_play_range() ) {
+ framepos_t where = canvas_event_frame (event, 0, 0);
+ snap_to(where);
+ _session->request_locate (where, false);
+ }
+
switch (event->button.button) {
case 1:
return button_press_handler_1 (item, event, item_type);
bool
Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type)
{
- framepos_t where = event_frame (event, 0, 0);
+ framepos_t where = canvas_event_frame (event, 0, 0);
AutomationTimeAxisView* atv = 0;
if (pre_press_cursor) {
were_dragging = true;
}
- update_region_layering_order_editor ();
+ update_region_layering_order_editor ();
/* edit events get handled here */
break;
case NoteItem:
- edit_note (item);
+ {
+ NoteBase* e = reinterpret_cast<NoteBase*> (item->get_data ("notebase"));
+ assert (e);
+ edit_notes (e->region_view().selection ());
break;
+ }
default:
break;
}
/* context menu events get handled here */
-
if (Keyboard::is_context_menu_event (&event->button)) {
context_click_event = *event;
break;
case StartCrossFadeItem:
- popup_xfade_context_menu (1, event->button.time, item, item_type);
+ popup_xfade_in_context_menu (1, event->button.time, item, item_type);
break;
case EndCrossFadeItem:
- popup_xfade_context_menu (1, event->button.time, item, item_type);
+ popup_xfade_out_context_menu (1, event->button.time, item, item_type);
break;
case StreamItem:
case CdMarkerBarItem:
case TempoBarItem:
case MeterBarItem:
+ case VideoBarItem:
popup_ruler_menu (where, item_type);
break;
case MeterBarItem:
if (!_dragging_playhead) {
- mouse_add_new_meter_event (pixel_to_frame (event->button.x));
+ mouse_add_new_meter_event (pixel_to_sample (event->button.x));
}
return true;
break;
case GainLineItem:
if (mouse_mode == MouseGain) {
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
- if (line)
- line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_EnteredGainLine.get();
+ if (line) {
+ line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_EnteredGainLine());
+ }
if (is_drawable()) {
set_canvas_cursor (_cursors->fader);
}
if (mouse_mode == MouseGain || mouse_mode == MouseObject) {
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
if (line) {
- line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_EnteredAutomationLine.get();
+ line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_EnteredAutomationLine());
}
if (is_drawable()) {
set_canvas_cursor (_cursors->fader);
break;
case RegionViewNameHighlight:
- if (is_drawable() && doing_object_stuff() && entered_regionview) {
+ if (is_drawable() && effective_mouse_mode() == MouseObject && entered_regionview) {
set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview);
_over_region_trim_target = true;
}
case LeftFrameHandle:
case RightFrameHandle:
- if (is_drawable() && doing_object_stuff() && !internal_editing() && entered_regionview) {
+ if (is_drawable() && effective_mouse_mode() == MouseObject && !internal_editing() && entered_regionview) {
set_canvas_cursor_for_region_view (event->crossing.x, entered_regionview);
}
break;
break;
}
entered_marker = marker;
- marker->set_color_rgba (ARDOUR_UI::config()->canvasvar_EnteredMarker.get());
+ marker->set_color_rgba (ARDOUR_UI::config()->get_canvasvar_EnteredMarker());
// fall through
case MeterMarkerItem:
case TempoMarkerItem:
case FadeInHandleItem:
if (mouse_mode == MouseObject && !internal_editing()) {
- ArdourCanvas::SimpleRect *rect = dynamic_cast<ArdourCanvas::SimpleRect *> (item);
+ ArdourCanvas::Rectangle *rect = dynamic_cast<ArdourCanvas::Rectangle *> (item);
if (rect) {
- rect->property_fill_color_rgba() = 0xBBBBBBAA;
+ rect->set_fill_color (0xBBBBBBAA);
}
set_canvas_cursor (_cursors->fade_in);
}
case FadeOutHandleItem:
if (mouse_mode == MouseObject && !internal_editing()) {
- ArdourCanvas::SimpleRect *rect = dynamic_cast<ArdourCanvas::SimpleRect *> (item);
+ ArdourCanvas::Rectangle *rect = dynamic_cast<ArdourCanvas::Rectangle *> (item);
if (rect) {
- rect->property_fill_color_rgba() = 0xBBBBBBAA;
+ rect->set_fill_color (0xBBBBBBAA);
}
set_canvas_cursor (_cursors->fade_out);
}
break;
case FeatureLineItem:
- {
- ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
- line->property_fill_color_rgba() = 0xFF0000FF;
- }
- break;
+ {
+ ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
+ line->set_outline_color (0xFF0000FF);
+ }
+ break;
+
case SelectionItem:
- if (smart_mode_action->get_active()) {
+ if ( get_smart_mode() ) {
set_canvas_cursor ();
}
break;
al = reinterpret_cast<AutomationLine*> (item->get_data ("line"));
{
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
- if (line)
- line->property_fill_color_rgba() = al->get_line_color();
+ if (line) {
+ line->set_outline_color (al->get_line_color());
+ }
}
if (is_drawable()) {
set_canvas_cursor (current_canvas_cursor);
case FadeOutHandleItem:
rv = static_cast<RegionView*>(item->get_data ("regionview"));
{
- ArdourCanvas::SimpleRect *rect = dynamic_cast<ArdourCanvas::SimpleRect *> (item);
+ ArdourCanvas::Rectangle *rect = dynamic_cast<ArdourCanvas::Rectangle *> (item);
if (rect) {
- rect->property_fill_color_rgba() = rv->get_fill_color();
- rect->property_outline_pixels() = 0;
+ rect->set_fill_color (rv->get_fill_color());
}
}
set_canvas_cursor (current_canvas_cursor);
case FeatureLineItem:
{
ArdourCanvas::Line *line = dynamic_cast<ArdourCanvas::Line *> (item);
- line->property_fill_color_rgba() = (guint) ARDOUR_UI::config()->canvasvar_ZeroLine.get();;
+ line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_ZeroLine());
}
break;
event might do, its a good tradeoff.
*/
- track_canvas->get_pointer (x, y);
+ _track_canvas->get_pointer (x, y);
}
if (current_stepping_trackview) {
JoinObjectRangeState const old = _join_object_range_state;
update_join_object_range_location (event->motion.x, event->motion.y);
- if (_join_object_range_state != old) {
+
+ if (!_internal_editing && _join_object_range_state != old) {
set_canvas_cursor ();
}
- if (_over_region_trim_target) {
+ if (!_internal_editing && _over_region_trim_target) {
set_canvas_cursor_for_region_view (event->motion.x, entered_regionview);
}
}
void
-Editor::edit_note (ArdourCanvas::Item* item)
+Editor::edit_notes (MidiRegionView::Selection const & s)
{
- ArdourCanvas::CanvasNoteEvent* e = dynamic_cast<ArdourCanvas::CanvasNoteEvent*> (item);
- assert (e);
-
- EditNoteDialog d (&e->region_view(), e);
+ if (s.empty ()) {
+ return;
+ }
+
+ EditNoteDialog d (&(*s.begin())->region_view(), s);
d.set_position (Gtk::WIN_POS_MOUSE);
ensure_float (d);
clicked_selection = 0;
}
+void
+Editor::cancel_time_selection ()
+{
+ for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
+ (*i)->hide_selection ();
+ }
+ selection->time.clear ();
+ clicked_selection = 0;
+}
void
Editor::point_trim (GdkEvent* event, framepos_t new_bound)
for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin();
i != selection->regions.by_layer().end(); ++i)
{
- if ( (*i) == NULL){
- cerr << "region view contains null region" << endl;
- }
-
if (!(*i)->region()->locked()) {
(*i)->region()->clear_changes ();
(*i)->region()->trim_front (new_bound);
void
Editor::reposition_zoom_rect (framepos_t start, framepos_t end)
{
- double x1 = frame_to_pixel (start);
- double x2 = frame_to_pixel (end);
- double y2 = full_canvas_height - 1.0;
-
- zoom_rect->property_x1() = x1;
- zoom_rect->property_y1() = 1.0;
- zoom_rect->property_x2() = x2;
- zoom_rect->property_y2() = y2;
+ 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));
}
if (Config->get_edit_mode() == Splice) {
_drags->add (new RegionSpliceDrag (this, item, region_view, selection->regions.by_layer()));
} else {
- RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.property_id);
+ RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::select.property_id);
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), false, false));
}
-
- /* sync the canvas to what we think is its current state */
- update_canvas_now();
}
void
_region_motion_group->raise_to_top ();
- RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.property_id);
+ RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::select.property_id);
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), false, true));
}
return;
}
- RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::edit.property_id);
+ RegionSelection s = get_equivalent_regions (selection->regions, ARDOUR::Properties::select.property_id);
_drags->add (new RegionMoveDrag (this, item, region_view, s.by_layer(), true, false));
begin_reversible_command (Operations::drag_region_brush);
that we're over requires searching the playlist.
*/
- if (!smart_mode_action->get_active() || (mouse_mode != MouseRange && mouse_mode != MouseObject)) {
+ if ( !get_smart_mode() ) {
_join_object_range_state = JOIN_OBJECT_RANGE_NONE;
return;
}
}
/* XXX: maybe we should make entered_track work in all cases, rather than resorting to this */
- pair<TimeAxisView*, int> tvp = trackview_by_y_position (y + vertical_adjustment.get_value() - canvas_timebars_vsize);
+ pair<TimeAxisView*, int> tvp = trackview_by_y_position (y);
if (tvp.first) {
double cx = 0;
double cy = y;
- rtv->canvas_display()->w2i (cx, cy);
+ rtv->canvas_display()->canvas_to_item (cx, cy);
double const c = cy / (rtv->view()->child_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE);
- double d;
- double const f = modf (c, &d);
- _join_object_range_state = f < 0.5 ? JOIN_OBJECT_RANGE_RANGE : JOIN_OBJECT_RANGE_OBJECT;
+ _join_object_range_state = c <= 0.5 ? JOIN_OBJECT_RANGE_RANGE : JOIN_OBJECT_RANGE_OBJECT;
}
}
}
void
Editor::remove_midi_note (ArdourCanvas::Item* item, GdkEvent *)
{
- ArdourCanvas::CanvasNoteEvent* e = dynamic_cast<ArdourCanvas::CanvasNoteEvent*> (item);
+ NoteBase* e = reinterpret_cast<NoteBase*> (item->get_data ("notebase"));
assert (e);
e->region_view().delete_note (e->note ());
void
Editor::set_canvas_cursor_for_region_view (double x, RegionView* rv)
{
+ /* XXX: this check should not be necessary */
+ if (rv == 0) {
+ return;
+ }
+
assert (rv);
ArdourCanvas::Group* g = rv->get_canvas_group ();
- ArdourCanvas::Group* p = g->get_parent_group ();
+ ArdourCanvas::Group* p = g->parent ();
/* Compute x in region view parent coordinates */
double dy = 0;
- p->w2i (x, dy);
+ p->canvas_to_item (x, dy);
- double x1, x2, y1, y2;
- g->get_bounds (x1, y1, x2, y2);
+ boost::optional<ArdourCanvas::Rect> item_bbox = g->bounding_box ();
+ assert (item_bbox);
+ ArdourCanvas::Rect parent_bbox = g->item_to_parent (item_bbox.get ());
/* Halfway across the region */
- double const h = (x1 + x2) / 2;
+ double const h = (parent_bbox.x0 + parent_bbox.x1) / 2;
Trimmable::CanTrim ct = rv->region()->can_trim ();
if (x <= h) {
}
}
-/** Obtain the pointer position in world coordinates */
+/** Obtain the pointer position in canvas coordinates */
void
Editor::get_pointer_position (double& x, double& y) const
{
int px, py;
- track_canvas->get_pointer (px, py);
- track_canvas->window_to_world (px, py, x, y);
+ _track_canvas->get_pointer (px, py);
+ _track_canvas->window_to_canvas (px, py, x, y);
}