13
0

Compare commits

...

5 Commits

5 changed files with 71 additions and 32 deletions

View File

@ -7252,21 +7252,21 @@ Editor::default_time_domain () const
} }
void void
Editor::start_track_drag (TimeAxisView& tav, int y, Gtk::Widget& w) Editor::start_track_drag (TimeAxisView& tav, int y, Gtk::Widget& w, bool can_change_cursor)
{ {
track_drag = new TrackDrag (dynamic_cast<RouteTimeAxisView*> (&tav), *_session); track_drag = new TrackDrag (dynamic_cast<RouteTimeAxisView*> (&tav), *_session);
DEBUG_TRACE (DEBUG::TrackDrag, string_compose ("start track drag with %1\n", track_drag)); DEBUG_TRACE (DEBUG::TrackDrag, string_compose ("start track drag with %1\n", track_drag));
PBD::stacktrace (std::cerr, 20);
track_drag->drag_cursor = _cursors->move->gobj();
track_drag->predrag_cursor = gdk_window_get_cursor (edit_controls_vbox.get_window()->gobj());
gdk_window_set_cursor (edit_controls_vbox.get_toplevel()->get_window()->gobj(), track_drag->drag_cursor);
int xo, yo; int xo, yo;
w.translate_coordinates (edit_controls_vbox, 0, y, xo, yo); w.translate_coordinates (edit_controls_vbox, 0, y, xo, yo);
track_drag->have_predrag_cursor = true; if (can_change_cursor) {
track_drag->drag_cursor = _cursors->move->gobj();
track_drag->predrag_cursor = gdk_window_get_cursor (edit_controls_vbox.get_window()->gobj());
gdk_window_set_cursor (edit_controls_vbox.get_toplevel()->get_window()->gobj(), track_drag->drag_cursor);
track_drag->have_predrag_cursor = true;
}
track_drag->bump_track = nullptr; track_drag->bump_track = nullptr;
track_drag->previous = yo; track_drag->previous = yo;
track_drag->start = yo; track_drag->start = yo;
@ -7289,6 +7289,14 @@ Editor::mid_track_drag (GdkEventMotion* ev, Gtk::Widget& w)
if (!track_drag->track->selected()) { if (!track_drag->track->selected()) {
set_selected_track (*track_drag->track, Selection::Set, false); set_selected_track (*track_drag->track, Selection::Set, false);
} }
if (!track_drag->have_predrag_cursor) {
track_drag->drag_cursor = _cursors->move->gobj();
track_drag->predrag_cursor = gdk_window_get_cursor (edit_controls_vbox.get_window()->gobj());
gdk_window_set_cursor (edit_controls_vbox.get_toplevel()->get_window()->gobj(), track_drag->drag_cursor);
track_drag->have_predrag_cursor = true;
}
track_drag->first_move = false; track_drag->first_move = false;
} }

View File

@ -1408,7 +1408,7 @@ private:
void insert_patch_change (bool from_context); void insert_patch_change (bool from_context);
void fork_selected_regions (); void fork_selected_regions ();
void fork_regions_from_unselected (); void fork_regions_from_unselected ();
void start_track_drag (TimeAxisView&, int y, Gtk::Widget& w); void start_track_drag (TimeAxisView&, int y, Gtk::Widget& w, bool can_change_cursor);
void mid_track_drag (GdkEventMotion*, Gtk::Widget& e); void mid_track_drag (GdkEventMotion*, Gtk::Widget& e);
void end_track_drag (); void end_track_drag ();
void maybe_move_tracks (); void maybe_move_tracks ();

View File

@ -598,7 +598,7 @@ public:
virtual void set_tempo_curve_range (double& max, double& min) const = 0; virtual void set_tempo_curve_range (double& max, double& min) const = 0;
virtual void start_track_drag (TimeAxisView&, int y, Gtk::Widget&) = 0; virtual void start_track_drag (TimeAxisView&, int y, Gtk::Widget&, bool can_change_cursor) = 0;
virtual void mid_track_drag (GdkEventMotion*, Gtk::Widget&) = 0; virtual void mid_track_drag (GdkEventMotion*, Gtk::Widget&) = 0;
virtual void end_track_drag () = 0; virtual void end_track_drag () = 0;
virtual bool track_dragging() const = 0; virtual bool track_dragging() const = 0;

View File

@ -411,28 +411,50 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
bool bool
TimeAxisView::controls_ebox_button_press (GdkEventButton* event) TimeAxisView::controls_ebox_button_press (GdkEventButton* event)
{ {
if (event->button == 1) { bool inside_name_label = false;
/* see if it is inside the name label */
if (name_label.is_ancestor (controls_ebox)) {
int nlx; if (name_label.is_ancestor (controls_ebox)) {
int nly; int nlx;
controls_ebox.translate_coordinates (name_label, event->x, event->y, nlx, nly); int nly;
Gtk::Allocation a = name_label.get_allocation (); controls_ebox.translate_coordinates (name_label, event->x, event->y, nlx, nly);
Gtk::Allocation a = name_label.get_allocation ();
if (nlx > 0 && nlx < a.get_width() && nly > 0 && nly < a.get_height()) { if (nlx > 0 && nlx < a.get_width() && nly > 0 && nly < a.get_height()) {
inside_name_label = true;
}
}
if ((event->type == GDK_2BUTTON_PRESS) || Keyboard::is_edit_event (event)) { /* double-click inside the name area */
begin_name_edit ();
_ebox_release_can_act = false; if ((event->button == 1 && event->type == GDK_2BUTTON_PRESS) || Keyboard::is_edit_event (event)) {
return true;
} else { /* Remember, for a dbl-click, X Window/GDK sends:
return true;
} button press
button release
button press
2button press
(and later, button release)
since we would have "started" a track drag
on the button press that precded the 2button press,
we need to cancel it here.
*/
_editor.end_track_drag ();
if (inside_name_label) {
if ((event->type == GDK_2BUTTON_PRESS) || Keyboard::is_edit_event (event)) {
begin_name_edit ();
_ebox_release_can_act = false;
return true;
} }
} }
} }
/* double-click outside the name area */
if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
if (_effective_height < preset_height (HeightLargest)) { if (_effective_height < preset_height (HeightLargest)) {
set_height_enum (HeightLargest); set_height_enum (HeightLargest);
@ -444,13 +466,9 @@ TimeAxisView::controls_ebox_button_press (GdkEventButton* event)
_ebox_release_can_act = true; _ebox_release_can_act = true;
if (maybe_set_cursor (event->y) > 0) { if (maybe_set_cursor (event->y) > 0) {
_resize_drag_start = event->y_root; _resize_drag_start = event->y_root;
} else if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
} else { _editor.start_track_drag (*this, event->y, controls_ebox, !inside_name_label);
if (event->button == 1) {
_editor.start_track_drag (*this, event->y, controls_ebox);
}
} }
return true; return true;

View File

@ -1086,7 +1086,20 @@ Track::use_captured_midi_sources (SourceList& srcs, CaptureInfos const & capture
if (time_domain() == Temporal::BeatTime) { if (time_domain() == Temporal::BeatTime) {
const timepos_t ss (start_off); const timepos_t ss (start_off);
const timecnt_t ll ((*ci)->samples, ss); /* 2nd argument is the timeline position of the
* start of the region in samples. We have to
* get this right so that the conversion of
* the capture duration (samples) to beats is
* using the actual position where the region
* will end up, rather than using its
* source-relative start offset as a timeline position.
*
* This matters if the region ought to cover
* part of the timeline where the tempo is
* different from the value at the natural
* position of the source.
*/
const timecnt_t ll ((*ci)->samples, timepos_t (initial_capture + start_off));
s = timepos_t (ss.beats()); s = timepos_t (ss.beats());
l = timecnt_t (ll.beats(), s); l = timecnt_t (ll.beats(), s);