From d41f7a0a701bb7af04ab4b3c2a26ff23f96407f9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 4 Jan 2008 17:23:51 +0000 Subject: [PATCH] a few fixes for zoom, plus the results of unfinished work on zoom redrawing, plus cleanup of debugging code in DnDTreevew git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2827 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 11 ++++---- gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_canvas.cc | 36 ++++++++++++++------------ gtk2_ardour/editor_ops.cc | 18 +++++++++---- gtk2_ardour/editor_selection.cc | 2 -- libs/gtkmm2ext/gtkmm2ext/dndtreeview.h | 4 --- 6 files changed, 39 insertions(+), 33 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index c84c9bb909..8beb3d77bc 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -343,7 +343,7 @@ Editor::Editor () initialize_canvas (); edit_controls_vbox.set_spacing (0); - horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled)); + horizontal_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::canvas_horizontally_scrolled), false); vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling), true); track_canvas.set_hadjustment (horizontal_adjustment); @@ -4046,7 +4046,7 @@ Editor::post_zoom () reset_hscrollbar_stepping (); reset_scrolling_region (); - + if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame); instant_save (); @@ -4093,10 +4093,11 @@ Editor::idle_visual_changer () } if (p & VisualChange::TimeOrigin) { - double val = horizontal_adjustment.get_value(); - if ((nframes_t) floor (val * frames_per_unit) != pending_visual_change.time_origin) { + + nframes_t time_origin = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit); + + if (time_origin != pending_visual_change.time_origin) { horizontal_adjustment.set_value (pending_visual_change.time_origin/frames_per_unit); - /* the signal handler will do the rest */ } else { update_fixed_rulers(); redisplay_tempo (true); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 1667ce6cd2..a5a2a62222 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -749,6 +749,7 @@ class Editor : public PublicEditor void tie_vertical_scrolling (); void canvas_horizontally_scrolled (); + void canvas_scroll_to (nframes64_t); struct VisualChange { enum Type { diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 574d10719b..1af8bad997 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -356,20 +356,18 @@ Editor::reset_scrolling_region (Gtk::Allocation* alloc) } } - double last_canvas_unit = last_canvas_frame / frames_per_unit; + double last_canvas_unit = max ((last_canvas_frame / frames_per_unit), canvas_width); - track_canvas.set_scroll_region (0.0, 0.0, max (last_canvas_unit, canvas_width), pos); + track_canvas.set_scroll_region (0.0, 0.0, last_canvas_unit, pos); // XXX what is the correct height value for the time canvas ? this overstates it - time_canvas.set_scroll_region ( 0.0, 0.0, max (last_canvas_unit, canvas_width), canvas_height); - - guint track_canvas_width,track_canvas_height; - track_canvas.get_size(track_canvas_width,track_canvas_height); - range_marker_drag_rect->property_y2() = track_canvas_height; - transport_loop_range_rect->property_y2() = track_canvas_height; - transport_punch_range_rect->property_y2() = track_canvas_height; - transport_punchin_line->property_y2() = track_canvas_height; - transport_punchout_line->property_y2() = track_canvas_height; + time_canvas.set_scroll_region ( 0.0, 0.0, last_canvas_unit, canvas_height); + + range_marker_drag_rect->property_y2() = canvas_height; + transport_loop_range_rect->property_y2() = canvas_height; + transport_punch_range_rect->property_y2() = canvas_height; + transport_punchin_line->property_y2() = canvas_height; + transport_punchout_line->property_y2() = canvas_height; update_punch_range_view (true); @@ -687,13 +685,17 @@ Editor::left_track_canvas (GdkEventCrossing *ev) void Editor::canvas_horizontally_scrolled () { - /* this is the core function that controls horizontal scrolling of the canvas. it is called - whenever the horizontal_adjustment emits its "value_changed" signal. it typically executes in an - idle handler, which is important because tempo_map_changed() should issue redraws immediately - and not defer them to an idle handler. - */ + nframes64_t time_origin = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit); - leftmost_frame = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit); + if (time_origin != leftmost_frame) { + canvas_scroll_to (time_origin); + } +} + +void +Editor::canvas_scroll_to (nframes64_t time_origin) +{ + leftmost_frame = time_origin; nframes_t rightmost_frame = leftmost_frame + current_page_frames (); if (rightmost_frame > last_canvas_frame) { diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 88e284776c..c3202f6a90 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1518,6 +1518,7 @@ Editor::temporal_zoom (gdouble fpu) nframes64_t where; bool in_track_canvas; double nfpu; + double l; nfpu = fpu; @@ -1548,11 +1549,18 @@ Editor::temporal_zoom (gdouble fpu) break; case ZoomFocusPlayhead: - /* try to keep the playhead in the center */ - if (playhead_cursor->current_frame < half_page_size) { + /* try to keep the playhead in the same place */ + + where = playhead_cursor->current_frame; + + l = - ((new_page_size * ((where - current_leftmost)/(double)current_page)) - where); + + if (l < 0) { leftmost_after_zoom = 0; + } else if (l > max_frames) { + leftmost_after_zoom = max_frames - new_page_size; } else { - leftmost_after_zoom = playhead_cursor->current_frame - half_page_size; + leftmost_after_zoom = (nframes64_t) l; } break; @@ -1571,7 +1579,7 @@ Editor::temporal_zoom (gdouble fpu) } else { - double l = - ((new_page_size * ((where - current_leftmost)/(double)current_page)) - where); + l = - ((new_page_size * ((where - current_leftmost)/(double)current_page)) - where); if (l < 0) { leftmost_after_zoom = 0; @@ -1585,7 +1593,7 @@ Editor::temporal_zoom (gdouble fpu) break; case ZoomFocusEdit: - /* try to keep the edit point in the center */ + /* try to keep the edit point in the same place */ where = get_preferred_edit_position (); if (where > 0) { diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index b2d37d1f31..1ae304316b 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -382,8 +382,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, vector all_equivalent_regions; bool commit = false; - cerr << "Set selected regionview from click, op = " << op << " press ? " << press << " ntr ? " << no_track_remove << endl; - if (!clicked_regionview || !clicked_audio_trackview) { return false; } diff --git a/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h b/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h index 0bdfe081b2..7b2c8d9882 100644 --- a/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h +++ b/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h @@ -93,18 +93,15 @@ class DnDTreeView : public DnDTreeViewBase */ suggested_action = Gdk::DragAction (0); TreeView::on_drag_data_received (context, x, y, selection_data, info, time); - std::cerr << "DDR, suggested action\n"; return; } if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") { TreeView::on_drag_data_received (context, x, y, selection_data, info, time); - std::cerr << "\n\nREGULAR TREEVIEW DRAG HAS DROPPED HERE @ " << x << '.' << y << std::endl; } else if (data_column >= 0) { - std::cerr << "DDR, data/object drop\n"; /* object D-n-D */ const void* data = selection_data.get_data(); @@ -115,7 +112,6 @@ class DnDTreeView : public DnDTreeViewBase } } else { - std::cerr << "DDR, unknown drop\n"; /* some kind of target type added by the app, which will be handled by a signal handler */ } }