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
This commit is contained in:
Paul Davis 2008-01-04 17:23:51 +00:00
parent f7a174a59b
commit d41f7a0a70
6 changed files with 39 additions and 33 deletions

View file

@ -343,7 +343,7 @@ Editor::Editor ()
initialize_canvas (); initialize_canvas ();
edit_controls_vbox.set_spacing (0); 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); vertical_adjustment.signal_value_changed().connect (mem_fun(*this, &Editor::tie_vertical_scrolling), true);
track_canvas.set_hadjustment (horizontal_adjustment); track_canvas.set_hadjustment (horizontal_adjustment);
@ -4046,7 +4046,7 @@ Editor::post_zoom ()
reset_hscrollbar_stepping (); reset_hscrollbar_stepping ();
reset_scrolling_region (); reset_scrolling_region ();
if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame); if (playhead_cursor) playhead_cursor->set_position (playhead_cursor->current_frame);
instant_save (); instant_save ();
@ -4093,10 +4093,11 @@ Editor::idle_visual_changer ()
} }
if (p & VisualChange::TimeOrigin) { 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); horizontal_adjustment.set_value (pending_visual_change.time_origin/frames_per_unit);
/* the signal handler will do the rest */
} else { } else {
update_fixed_rulers(); update_fixed_rulers();
redisplay_tempo (true); redisplay_tempo (true);

View file

@ -749,6 +749,7 @@ class Editor : public PublicEditor
void tie_vertical_scrolling (); void tie_vertical_scrolling ();
void canvas_horizontally_scrolled (); void canvas_horizontally_scrolled ();
void canvas_scroll_to (nframes64_t);
struct VisualChange { struct VisualChange {
enum Type { enum Type {

View file

@ -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 // 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); time_canvas.set_scroll_region ( 0.0, 0.0, last_canvas_unit, canvas_height);
guint track_canvas_width,track_canvas_height; range_marker_drag_rect->property_y2() = canvas_height;
track_canvas.get_size(track_canvas_width,track_canvas_height); transport_loop_range_rect->property_y2() = canvas_height;
range_marker_drag_rect->property_y2() = track_canvas_height; transport_punch_range_rect->property_y2() = canvas_height;
transport_loop_range_rect->property_y2() = track_canvas_height; transport_punchin_line->property_y2() = canvas_height;
transport_punch_range_rect->property_y2() = track_canvas_height; transport_punchout_line->property_y2() = canvas_height;
transport_punchin_line->property_y2() = track_canvas_height;
transport_punchout_line->property_y2() = track_canvas_height;
update_punch_range_view (true); update_punch_range_view (true);
@ -687,13 +685,17 @@ Editor::left_track_canvas (GdkEventCrossing *ev)
void void
Editor::canvas_horizontally_scrolled () Editor::canvas_horizontally_scrolled ()
{ {
/* this is the core function that controls horizontal scrolling of the canvas. it is called nframes64_t time_origin = (nframes_t) floor (horizontal_adjustment.get_value() * frames_per_unit);
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.
*/
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 (); nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
if (rightmost_frame > last_canvas_frame) { if (rightmost_frame > last_canvas_frame) {

View file

@ -1518,6 +1518,7 @@ Editor::temporal_zoom (gdouble fpu)
nframes64_t where; nframes64_t where;
bool in_track_canvas; bool in_track_canvas;
double nfpu; double nfpu;
double l;
nfpu = fpu; nfpu = fpu;
@ -1548,11 +1549,18 @@ Editor::temporal_zoom (gdouble fpu)
break; break;
case ZoomFocusPlayhead: case ZoomFocusPlayhead:
/* try to keep the playhead in the center */ /* try to keep the playhead in the same place */
if (playhead_cursor->current_frame < half_page_size) {
where = playhead_cursor->current_frame;
l = - ((new_page_size * ((where - current_leftmost)/(double)current_page)) - where);
if (l < 0) {
leftmost_after_zoom = 0; leftmost_after_zoom = 0;
} else if (l > max_frames) {
leftmost_after_zoom = max_frames - new_page_size;
} else { } else {
leftmost_after_zoom = playhead_cursor->current_frame - half_page_size; leftmost_after_zoom = (nframes64_t) l;
} }
break; break;
@ -1571,7 +1579,7 @@ Editor::temporal_zoom (gdouble fpu)
} else { } 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) { if (l < 0) {
leftmost_after_zoom = 0; leftmost_after_zoom = 0;
@ -1585,7 +1593,7 @@ Editor::temporal_zoom (gdouble fpu)
break; break;
case ZoomFocusEdit: 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 (); where = get_preferred_edit_position ();
if (where > 0) { if (where > 0) {

View file

@ -382,8 +382,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op,
vector<RegionView*> all_equivalent_regions; vector<RegionView*> all_equivalent_regions;
bool commit = false; bool commit = false;
cerr << "Set selected regionview from click, op = " << op << " press ? " << press << " ntr ? " << no_track_remove << endl;
if (!clicked_regionview || !clicked_audio_trackview) { if (!clicked_regionview || !clicked_audio_trackview) {
return false; return false;
} }

View file

@ -93,18 +93,15 @@ class DnDTreeView : public DnDTreeViewBase
*/ */
suggested_action = Gdk::DragAction (0); suggested_action = Gdk::DragAction (0);
TreeView::on_drag_data_received (context, x, y, selection_data, info, time); TreeView::on_drag_data_received (context, x, y, selection_data, info, time);
std::cerr << "DDR, suggested action\n";
return; return;
} }
if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") { if (selection_data.get_target() == "GTK_TREE_MODEL_ROW") {
TreeView::on_drag_data_received (context, x, y, selection_data, info, time); 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) { } else if (data_column >= 0) {
std::cerr << "DDR, data/object drop\n";
/* object D-n-D */ /* object D-n-D */
const void* data = selection_data.get_data(); const void* data = selection_data.get_data();
@ -115,7 +112,6 @@ class DnDTreeView : public DnDTreeViewBase
} }
} else { } else {
std::cerr << "DDR, unknown drop\n";
/* some kind of target type added by the app, which will be handled by a signal handler */ /* some kind of target type added by the app, which will be handled by a signal handler */
} }
} }