Use ardour/session_state_utils.h in Editor::redisplay_snapshots
[ardour.git] / gtk2_ardour / editor_rulers.cc
index 6f4f4bdb6876a4000e1569ae2f79d950b826ec37..cfc71575104bb0a2e0c6d416834f82a925d75edf 100644 (file)
@@ -57,8 +57,9 @@ Editor::initialize_rulers ()
        
        _ruler_separator = new Gtk::HSeparator();
        _ruler_separator->set_size_request(-1, 2);
+       _ruler_separator->set_name("TimebarPadding");
        _ruler_separator->show();
-
+       
        _smpte_ruler = gtk_custom_hruler_new ();
        smpte_ruler = Glib::wrap (_smpte_ruler);
        smpte_ruler->set_name ("SMPTERuler");
@@ -251,7 +252,7 @@ Editor::ruler_mouse_motion (GdkEventMotion* ev)
        if (session == 0 || !ruler_pressed_button) {
                return FALSE;
        }
-       
+
                double wcx=0,wcy=0;
        double cx=0,cy=0;
 
@@ -268,21 +269,22 @@ Editor::ruler_mouse_motion (GdkEventMotion* ev)
        nframes_t where = leftmost_frame + pixel_to_frame (x);
 
        /// ripped from maybe_autoscroll, and adapted to work here
-       nframes_t one_page = (nframes_t) rint (canvas_width * frames_per_unit);
-       nframes_t rightmost_frame = leftmost_frame + one_page;
+       nframes_t rightmost_frame = leftmost_frame + current_page_frames ();
+
+       jack_nframes_t frame = pixel_to_frame (cx);
 
        if (autoscroll_timeout_tag < 0) {
-               if (where > rightmost_frame) {
+               if (frame > rightmost_frame) {
                        if (rightmost_frame < max_frames) {
                                start_canvas_autoscroll (1);
                        }
-               } else if (where <= leftmost_frame) {
+               } else if (frame < leftmost_frame) {
                        if (leftmost_frame > 0) {
                                start_canvas_autoscroll (-1);
                        }
                } 
        } else {
-               if (where >= leftmost_frame && where < rightmost_frame) {
+               if (frame >= leftmost_frame && frame < rightmost_frame) {
                        stop_canvas_autoscroll ();
                }
        }
@@ -607,9 +609,9 @@ Editor::update_ruler_visibility ()
        bbt_ruler->signal_motion_notify_event().connect (mem_fun(*this, &Editor::ruler_mouse_motion));
        frames_ruler->signal_motion_notify_event().connect (mem_fun(*this, &Editor::ruler_mouse_motion));
        minsec_ruler->signal_motion_notify_event().connect (mem_fun(*this, &Editor::ruler_mouse_motion));
-
-       ruler_children.insert (canvaspos, Element(*_ruler_separator, PACK_SHRINK, PACK_START));
        
+       ruler_children.insert (canvaspos, Element(*_ruler_separator, PACK_SHRINK, PACK_START));
+
        if (ruler_shown[ruler_metric_minsec]) {
                lab_children.push_back (Element(minsec_label, PACK_SHRINK, PACK_START));
                ruler_children.insert (canvaspos, Element(*minsec_ruler, PACK_SHRINK, PACK_START));
@@ -728,12 +730,7 @@ Editor::update_just_smpte ()
                return;
        }
 
-       /* XXX Note the potential loss of accuracy here as we convert from
-          an uint32_t (or larger) to a float ... what to do ?
-       */
-
-       nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
-       nframes_t rightmost_frame = leftmost_frame + page;
+       nframes_t rightmost_frame = leftmost_frame + current_page_frames();
 
        if (ruler_shown[ruler_metric_smpte]) {
                gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_smpte_ruler), leftmost_frame, rightmost_frame,
@@ -750,17 +747,11 @@ Editor::update_fixed_rulers ()
                return;
        }
 
-       /* XXX Note the potential loss of accuracy here as we convert from
-          an uint32_t (or larger) to a float ... what to do ?
-       */
-
-       nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
-
        ruler_metrics[ruler_metric_smpte].units_per_pixel = frames_per_unit;
        ruler_metrics[ruler_metric_frames].units_per_pixel = frames_per_unit;
        ruler_metrics[ruler_metric_minsec].units_per_pixel = frames_per_unit;
 
-       rightmost_frame = leftmost_frame + page;
+       rightmost_frame = leftmost_frame + current_page_frames ();
 
        /* these force a redraw, which in turn will force execution of the metric callbacks
           to compute the relevant ticks to display.
@@ -789,15 +780,10 @@ Editor::update_tempo_based_rulers ()
                return;
        }
 
-       /* XXX Note the potential loss of accuracy here as we convert from
-          an uint32_t (or larger) to a float ... what to do ?
-       */
-
-       nframes_t page = (nframes_t) floor (canvas_width * frames_per_unit);
        ruler_metrics[ruler_metric_bbt].units_per_pixel = frames_per_unit;
 
        if (ruler_shown[ruler_metric_bbt]) {
-               gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_bbt_ruler), leftmost_frame, leftmost_frame+page, 
+               gtk_custom_ruler_set_range (GTK_CUSTOM_RULER(_bbt_ruler), leftmost_frame, leftmost_frame+current_page_frames(),
                                            leftmost_frame, session->current_end_frame());
        }
 }