refine track drag API to control whether cursor can change on button press
This commit is contained in:
parent
3dd8b930e4
commit
0ec926668c
@ -7030,7 +7030,7 @@ Editor::default_time_domain () const
|
||||
}
|
||||
|
||||
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);
|
||||
DEBUG_TRACE (DEBUG::TrackDrag, string_compose ("start track drag with %1\n", track_drag));
|
||||
@ -7038,6 +7038,13 @@ Editor::start_track_drag (TimeAxisView& tav, int y, Gtk::Widget& w)
|
||||
int xo, yo;
|
||||
w.translate_coordinates (edit_controls_vbox, 0, y, xo, yo);
|
||||
|
||||
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->previous = yo;
|
||||
track_drag->start = yo;
|
||||
@ -7061,10 +7068,12 @@ Editor::mid_track_drag (GdkEventMotion* ev, Gtk::Widget& w)
|
||||
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;
|
||||
}
|
||||
|
@ -1405,7 +1405,7 @@ private:
|
||||
void insert_patch_change (bool from_context);
|
||||
void fork_selected_regions ();
|
||||
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 end_track_drag ();
|
||||
void maybe_move_tracks ();
|
||||
|
@ -596,7 +596,7 @@ public:
|
||||
|
||||
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 end_track_drag () = 0;
|
||||
virtual bool track_dragging() const = 0;
|
||||
|
@ -411,6 +411,19 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
|
||||
bool
|
||||
TimeAxisView::controls_ebox_button_press (GdkEventButton* event)
|
||||
{
|
||||
bool inside_name_label = false;
|
||||
|
||||
if (name_label.is_ancestor (controls_ebox)) {
|
||||
int nlx;
|
||||
int nly;
|
||||
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()) {
|
||||
inside_name_label = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* double-click inside the name area */
|
||||
|
||||
if ((event->button == 1 && event->type == GDK_2BUTTON_PRESS) || Keyboard::is_edit_event (event)) {
|
||||
@ -430,17 +443,7 @@ TimeAxisView::controls_ebox_button_press (GdkEventButton* event)
|
||||
|
||||
_editor.end_track_drag ();
|
||||
|
||||
/* see if it is inside the name label */
|
||||
|
||||
|
||||
if (name_label.is_ancestor (controls_ebox)) {
|
||||
|
||||
int nlx;
|
||||
int nly;
|
||||
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 (inside_name_label) {
|
||||
|
||||
if ((event->type == GDK_2BUTTON_PRESS) || Keyboard::is_edit_event (event)) {
|
||||
begin_name_edit ();
|
||||
@ -449,7 +452,6 @@ TimeAxisView::controls_ebox_button_press (GdkEventButton* event)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* double-click outside the name area */
|
||||
|
||||
@ -464,11 +466,9 @@ TimeAxisView::controls_ebox_button_press (GdkEventButton* event)
|
||||
_ebox_release_can_act = true;
|
||||
|
||||
if (maybe_set_cursor (event->y) > 0) {
|
||||
|
||||
_resize_drag_start = event->y_root;
|
||||
|
||||
} else if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
|
||||
_editor.start_track_drag (*this, event->y, controls_ebox);
|
||||
_editor.start_track_drag (*this, event->y, controls_ebox, !inside_name_label);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user