Handle changed session duration & resizing canvas better wrt end marker, remove unuse...
authorNick Mainsbridge <beatroute@iprimus.com.au>
Sun, 19 Oct 2008 07:55:42 +0000 (07:55 +0000)
committerNick Mainsbridge <beatroute@iprimus.com.au>
Sun, 19 Oct 2008 07:55:42 +0000 (07:55 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@3982 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_mixer.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/editor_ops.cc
gtk2_ardour/editor_tempodisplay.cc
gtk2_ardour/mixer_ui.cc

index 7b5685858df797bc48e29bd03c7ec2816766da6e..d1bad2d2bd65424aa31be23759e012af85352495 100644 (file)
@@ -344,7 +344,6 @@ Editor::Editor ()
        _new_regionviews_show_envelope = false;
        current_timefx = 0;
        in_edit_group_row_change = false;
-       last_canvas_frame = 0;
        playhead_cursor = 0;
        button_release_can_deselect = true;
        _dragging_playhead = false;
@@ -1174,18 +1173,15 @@ Editor::handle_new_duration ()
        }
 
        ENSURE_GUI_THREAD (mem_fun (*this, &Editor::handle_new_duration));
+       nframes64_t new_end = session->current_end_frame() + (nframes64_t) floorf (current_page_frames() * 0.10f);
 
-       nframes64_t new_end = session->get_maximum_extent() + (nframes64_t) floorf (current_page_frames() * 0.10f);
-                                 
-       if (new_end > last_canvas_frame) {
-               last_canvas_frame = new_end;
-               horizontal_adjustment.set_upper (last_canvas_frame / frames_per_unit);
-               horizontal_adjustment.set_page_size (current_page_frames()/frames_per_unit);
-               //reset_scrolling_region ();
-       }
+       horizontal_adjustment.set_upper (new_end / frames_per_unit);
+       horizontal_adjustment.set_page_size (current_page_frames()/frames_per_unit);
 
-       horizontal_adjustment.set_value (leftmost_frame/frames_per_unit);
-       //cerr << "Editor::handle_new_duration () called ha v:l:u:ps:lcf = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << last_canvas_frame << endl;//DEBUG
+       if (horizontal_adjustment.get_value() + canvas_width > horizontal_adjustment.get_upper()) {
+               horizontal_adjustment.set_value (horizontal_adjustment.get_upper() - canvas_width);
+       }
+       //cerr << "Editor::handle_new_duration () called ha v:l:u:ps:lcf = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << endl;//DEBUG
 }
 
 void
@@ -1329,7 +1325,6 @@ Editor::connect_to_session (Session *t)
                sfbrowser->set_session (session);
        }
 
-       last_canvas_frame = 0; // force update in handle_new_duration()
        handle_new_duration ();
 
        redisplay_regions ();
@@ -4056,7 +4051,8 @@ Editor::end_location_changed (Location* location)
 {
        ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::end_location_changed), location));
        //reset_scrolling_region ();
-       horizontal_adjustment.set_upper ( location->start());
+       nframes64_t session_span = location->start() + (nframes64_t) floorf (current_page_frames() * 0.10f);
+       horizontal_adjustment.set_upper (session_span / frames_per_unit);
 }
 
 int
@@ -4674,14 +4670,14 @@ Editor::idle_visual_changer ()
 
                if (session) {
                        csf = session->current_start_frame();
-                       cef = session->current_end_frame() + (current_page_frames() / 24);// Add a little extra so we can see the end marker
+                       cef = session->current_end_frame();
                }
 
                /* if we seek beyond the current end of the canvas, move the end */
 
                if (current_time_origin != pending_visual_change.time_origin) {
-                       last_canvas_frame = (cef > (pending_visual_change.time_origin + current_page_frames())) ? cef : pending_visual_change.time_origin + current_page_frames();
-                       horizontal_adjustment.set_upper ((cef - csf) / frames_per_unit);
+                       cef += current_page_frames() / 10; // Add a little extra so we can see the end marker
+                       horizontal_adjustment.set_upper (cef / frames_per_unit);
                        horizontal_adjustment.set_value (pending_visual_change.time_origin / frames_per_unit);
                } else {
                        update_fixed_rulers();
index bd161f792b2ff0cfa0ccc301dd5fcecc06f8045c..279de992986721dcdb361b076fcb5cf8b1167fc1 100644 (file)
@@ -877,7 +877,6 @@ class Editor : public PublicEditor
        double canvas_width;
        double canvas_height;
        double full_canvas_height;
-       nframes64_t last_canvas_frame;
 
        bool track_canvas_map_handler (GdkEventAny*);
 
index a1930e58d7bbb3078f2c842d16ef3a181ddbc9f4..f0a016d0394c2a7a4c0c2dc4cb678b7f0c8500c7 100644 (file)
@@ -340,6 +340,17 @@ Editor::track_canvas_size_allocated ()
                for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
                        (*x)->set_line_vpos (0, canvas_height);
                }
+
+               vertical_adjustment.set_page_size (canvas_height);
+               last_trackview_group_vertical_offset = get_trackview_group_vertical_offset ();
+               if ((vertical_adjustment.get_value() + canvas_height) >= vertical_adjustment.get_upper()) {
+                       /* 
+                          We're increasing the size of the canvas while the bottom is visible.
+                          We scroll down to keep in step with the controls layout.
+                       */
+                       vertical_adjustment.set_value (full_canvas_height - canvas_height + 1);
+               }
+       
                
        }
 
@@ -348,15 +359,6 @@ Editor::track_canvas_size_allocated ()
        update_fixed_rulers();
        redisplay_tempo (false);
 
-       last_trackview_group_vertical_offset = get_trackview_group_vertical_offset ();
-       if ((vertical_adjustment.get_value() + canvas_height) >= vertical_adjustment.get_upper()) {
-               /* 
-                  We're increasing the size of the canvas while the bottom is visible.
-                  We scroll down to keep in step with the controls layout.
-               */
-               vertical_adjustment.set_value (full_canvas_height - canvas_height + 1);
-       } 
-       
        Resized (); /* EMIT_SIGNAL */
                
        return false;
@@ -866,12 +868,6 @@ void
 Editor::canvas_scroll_to (nframes64_t time_origin)
 {
        leftmost_frame = time_origin;
-       nframes64_t rightmost_frame = leftmost_frame + current_page_frames ();
-
-       if (rightmost_frame > last_canvas_frame) {
-               last_canvas_frame = rightmost_frame;
-               //reset_scrolling_region ();
-       }
 }
 
 void
index cce057d050df77658b4c36e2c95e21517e87f393..6bfc325f6de62426c3c7a4548bcb5ef023e032f0 100644 (file)
@@ -324,7 +324,6 @@ Editor::session_going_away ()
        entered_track = 0;
        last_update_frame = 0;
        drag_info.item = 0;
-       last_canvas_frame = 0;
 
        playhead_cursor->canvas_item.hide ();
 
index cabeceb0575cfae42b30ed6ca8d27b6abeb47629..1a03f66f2427935d32794bd4281fd5d4f0f7731e 100644 (file)
@@ -4009,7 +4009,6 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
                        
                boost::shared_ptr<Region> new_region;
 
-
                if (drag_info.copy) {
                        /* we already made a copy */
                        new_region = rv->region();
index 426bf09c7efdb13574f9a8f36e3dbb9b7c54f4b6..1efe4a31adc9d4ee2c2489ebbe8185dad004674b 100644 (file)
@@ -1856,7 +1856,6 @@ Editor::temporal_zoom_session ()
        ENSURE_GUI_THREAD (mem_fun (*this, &Editor::temporal_zoom_session));
 
        if (session) {
-               last_canvas_frame = ((session->current_end_frame() - session->current_start_frame()) + (current_page_frames() / 24));
                temporal_zoom_by_frame (session->current_start_frame(), session->current_end_frame(), "zoom to session");
        }
 }
index 609b5b221c8428bdb173cde8331c07b735057a06..923c2fbd1c6a2da4f0e89b102ea51f4102f0d7d4 100644 (file)
@@ -105,9 +105,9 @@ Editor::tempo_map_changed (Change ignored)
        if (tempo_lines)
                tempo_lines->tempo_map_changed();
 
-       compute_current_bbt_points(leftmost_frame, leftmost_frame + (nframes_t)(edit_packer.get_width() * frames_per_unit));
-       session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers
-       update_tempo_based_rulers ();
+       compute_current_bbt_points(leftmost_frame, leftmost_frame + current_page_frames());
+       session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
+       update_tempo_based_rulers ();// redraw metric markers
        redraw_measures ();
 }
 
@@ -118,7 +118,7 @@ Editor::redisplay_tempo (bool immediate_redraw)
                return;
        }
        
-       compute_current_bbt_points (leftmost_frame, leftmost_frame + (nframes_t)(edit_packer.get_width() * frames_per_unit)); // redraw rulers and measures
+       compute_current_bbt_points (leftmost_frame, leftmost_frame + current_page_frames()); // redraw rulers and measures
 
        redraw_measures();
        update_tempo_based_rulers ();
index 2b4eb09e16b531dc4e1c800783c76ffc8e310444..202a55ee1d9298e3eb1a109ee70c581a016bfa3e 100644 (file)
@@ -264,18 +264,19 @@ void
 Mixer_UI::show_window ()
 {
        present ();
-
-       set_window_pos_and_size ();
-
-       /* now reset each strips width so the right widgets are shown */
-       MixerStrip* ms;
-
-       TreeModel::Children rows = track_model->children();
-       TreeModel::Children::iterator ri;
-
-       for (ri = rows.begin(); ri != rows.end(); ++ri) {
-               ms = (*ri)[track_columns.strip];
-               ms->set_width (ms->get_width(), ms->width_owner());
+       if (!_visible) {
+               set_window_pos_and_size ();
+               
+               /* now reset each strips width so the right widgets are shown */
+               MixerStrip* ms;
+               
+               TreeModel::Children rows = track_model->children();
+               TreeModel::Children::iterator ri;
+               
+               for (ri = rows.begin(); ri != rows.end(); ++ri) {
+                       ms = (*ri)[track_columns.strip];
+                       ms->set_width (ms->get_width(), ms->width_owner());
+               }
        }
        _visible = true;
 }