leftmost_position => leftmost_sample, current_page_frames => current_page_samples
[ardour.git] / gtk2_ardour / editor.cc
index 7f49c56d7be29f85b35edaf4bbb1bcd0de030db8..c0f5fd8ba9434aee44fd9815ae45a5ad0b0ec7db 100644 (file)
@@ -246,9 +246,7 @@ Editor::Editor ()
        , range_mark_label (_("Range Markers"))
        , transport_mark_label (_("Loop/Punch Ranges"))
        , cd_mark_label (_("CD Markers"))
-#ifdef WITH_VIDEOTIMELINE
        , videotl_label (_("Video Timeline"))
-#endif
        , edit_packer (4, 4, true)
 
          /* the values here don't matter: layout widgets
@@ -440,7 +438,6 @@ Editor::Editor ()
        cd_mark_label.hide();
        cd_mark_label.set_no_show_all();
 
-#ifdef WITH_VIDEOTIMELINE
        videotl_bar_height = 4;
        videotl_label.set_name ("EditorRulerLabel");
        videotl_label.set_size_request (-1, (int)timebar_height * videotl_bar_height);
@@ -448,7 +445,6 @@ Editor::Editor ()
        videotl_label.set_padding (5,0);
        videotl_label.hide();
        videotl_label.set_no_show_all();
-#endif
 
        range_mark_label.set_name ("EditorRulerLabel");
        range_mark_label.set_size_request (-1, (int)timebar_height);
@@ -517,12 +513,6 @@ Editor::Editor ()
        time_bars_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
        time_bars_event_box.signal_button_release_event().connect (sigc::mem_fun(*this, &Editor::ruler_label_button_release));
 
-       /* these enable us to have a dedicated window (for cursor setting, etc.)
-          for the canvas areas.
-       */
-
-       track_canvas_event_box.add (*_track_canvas_viewport);
-
        time_canvas_event_box.add (time_canvas_vbox);
        time_canvas_event_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
 
@@ -543,7 +533,7 @@ Editor::Editor ()
        /* time bars canvas */
        edit_packer.attach (*_time_bars_canvas_viewport, 2, 3, 1, 2,    FILL,    FILL, 0, 0);
        /* track canvas */
-       edit_packer.attach (track_canvas_event_box,  2, 3, 2, 3,    FILL|EXPAND, FILL|EXPAND, 0, 0);
+       edit_packer.attach (*_track_canvas_viewport,  2, 3, 2, 3,    FILL|EXPAND, FILL|EXPAND, 0, 0);
 
        bottom_hbox.set_border_width (2);
        bottom_hbox.set_spacing (3);
@@ -788,6 +778,7 @@ Editor::~Editor()
         delete button_bindings;
        delete _routes;
        delete _route_groups;
+       delete _time_bars_canvas_viewport;
        delete _track_canvas_viewport;
        delete _drags;
 }
@@ -1042,7 +1033,7 @@ Editor::control_scroll (float fraction)
                return;
        }
 
-       double step = fraction * current_page_frames();
+       double step = fraction * current_page_samples();
 
        /*
                _control_scroll_target is an optional<T>
@@ -1063,7 +1054,7 @@ Editor::control_scroll (float fraction)
        if ((fraction < 0.0f) && (*_control_scroll_target < (framepos_t) fabs(step))) {
                *_control_scroll_target = 0;
        } else if ((fraction > 0.0f) && (max_framepos - *_control_scroll_target < step)) {
-               *_control_scroll_target = max_framepos - (current_page_frames()*2); // allow room for slop in where the PH is on the screen
+               *_control_scroll_target = max_framepos - (current_page_samples()*2); // allow room for slop in where the PH is on the screen
        } else {
                *_control_scroll_target += (framepos_t) floor (step);
        }
@@ -1073,9 +1064,9 @@ Editor::control_scroll (float fraction)
        playhead_cursor->set_position (*_control_scroll_target);
        UpdateAllTransportClocks (*_control_scroll_target);
 
-       if (*_control_scroll_target > (current_page_frames() / 2)) {
+       if (*_control_scroll_target > (current_page_samples() / 2)) {
                /* try to center PH in window */
-               reset_x_origin (*_control_scroll_target - (current_page_frames()/2));
+               reset_x_origin (*_control_scroll_target - (current_page_samples()/2));
        } else {
                reset_x_origin (0);
        }
@@ -2130,9 +2121,9 @@ Editor::set_snap_to (SnapType st)
                ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_begin;
                ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_end;
                
-               compute_current_bbt_points (leftmost_frame, leftmost_frame + current_page_frames(),
+               compute_current_bbt_points (leftmost_frame, leftmost_frame + current_page_samples(),
                                            current_bbt_points_begin, current_bbt_points_end);
-               compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_frames(),
+               compute_bbt_ruler_scale (leftmost_frame, leftmost_frame + current_page_samples(),
                                         current_bbt_points_begin, current_bbt_points_end);
                update_tempo_based_rulers (current_bbt_points_begin, current_bbt_points_end);
                break;
@@ -2842,12 +2833,12 @@ Editor::snap_to_internal (framepos_t& start, int32_t direction, bool for_mark)
        case SnapMagnetic:
 
                if (presnap > start) {
-                       if (presnap > (start + unit_to_frame(snap_threshold))) {
+                       if (presnap > (start + pixel_to_sample(snap_threshold))) {
                                start = presnap;
                        }
 
                } else if (presnap < start) {
-                       if (presnap < (start - unit_to_frame(snap_threshold))) {
+                       if (presnap < (start - pixel_to_sample(snap_threshold))) {
                                start = presnap;
                        }
                }
@@ -4296,7 +4287,6 @@ Editor::set_frames_per_pixel (double fpp)
        instant_save ();
 }
 
-#ifdef WITH_VIDEOTIMELINE
 void
 Editor::queue_visual_videotimeline_update ()
 {
@@ -4309,7 +4299,6 @@ Editor::queue_visual_videotimeline_update ()
         */
        ensure_visual_change_idle_handler ();
 }
-#endif
 
 void
 Editor::ensure_visual_change_idle_handler ()
@@ -4355,18 +4344,16 @@ Editor::idle_visual_changer ()
                ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_begin;
                ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_end;
                
-               compute_current_bbt_points (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames(),
+               compute_current_bbt_points (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_samples(),
                                            current_bbt_points_begin, current_bbt_points_end);
-               compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_frames(),
+               compute_bbt_ruler_scale (pending_visual_change.time_origin, pending_visual_change.time_origin + current_page_samples(),
                                         current_bbt_points_begin, current_bbt_points_end);
                update_tempo_based_rulers (current_bbt_points_begin, current_bbt_points_end);
        }
 
-#ifdef WITH_VIDEOTIMELINE
        if (p & VisualChange::ZoomLevel) {
                update_video_timeline();
        }
-#endif
 
        if (p & VisualChange::TimeOrigin) {
                set_horizontal_position (pending_visual_change.time_origin / frames_per_pixel);
@@ -4381,11 +4368,10 @@ Editor::idle_visual_changer ()
                update_fixed_rulers ();
                redisplay_tempo (true);
        }
-#ifdef WITH_VIDEOTIMELINE
+
        if (!(p & VisualChange::ZoomLevel)) {
                update_video_timeline();
        }
-#endif
 
        _summary->set_overlays_dirty ();
 
@@ -4414,7 +4400,7 @@ Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_men
        EditPoint ep = _edit_point;
 
        if (from_context_menu && (ep == EditAtMouse)) {
-               return  event_frame (&context_click_event, 0, 0);
+               return  window_event_frame (&context_click_event, 0, 0);
        }
 
        if (entered_marker) {
@@ -5186,14 +5172,14 @@ Editor::reset_x_origin_to_follow_playhead ()
 {
        framepos_t const frame = playhead_cursor->current_frame ();
 
-       if (frame < leftmost_frame || frame > leftmost_frame + current_page_frames()) {
+       if (frame < leftmost_frame || frame > leftmost_frame + current_page_samples()) {
 
                if (_session->transport_speed() < 0) {
 
-                       if (frame > (current_page_frames() / 2)) {
-                               center_screen (frame-(current_page_frames()/2));
+                       if (frame > (current_page_samples() / 2)) {
+                               center_screen (frame-(current_page_samples()/2));
                        } else {
-                               center_screen (current_page_frames()/2);
+                               center_screen (current_page_samples()/2);
                        }
 
                } else {
@@ -5204,10 +5190,10 @@ Editor::reset_x_origin_to_follow_playhead ()
                                /* moving left */
                                if (_session->transport_rolling()) {
                                        /* rolling; end up with the playhead at the right of the page */
-                                       l = frame - current_page_frames ();
+                                       l = frame - current_page_samples ();
                                } else {
                                        /* not rolling: end up with the playhead 1/4 of the way along the page */
-                                       l = frame - current_page_frames() / 4;
+                                       l = frame - current_page_samples() / 4;
                                }
                        } else {
                                /* moving right */
@@ -5216,7 +5202,7 @@ Editor::reset_x_origin_to_follow_playhead ()
                                        l = frame;
                                } else {
                                        /* not rolling: end up with the playhead 3/4 of the way along the page */
-                                       l = frame - 3 * current_page_frames() / 4;
+                                       l = frame - 3 * current_page_samples() / 4;
                                }
                        }
 
@@ -5224,7 +5210,7 @@ Editor::reset_x_origin_to_follow_playhead ()
                                l = 0;
                        }
                        
-                       center_screen_internal (l + (current_page_frames() / 2), current_page_frames ());
+                       center_screen_internal (l + (current_page_samples() / 2), current_page_samples ());
                }
        }
 }
@@ -5295,11 +5281,11 @@ Editor::super_rapid_screen_update ()
                        */
 #if 0
                        // FIXME DO SOMETHING THAT WORKS HERE - this is 2.X code
-                       double target = ((double)frame - (double)current_page_frames()/2.0) / frames_per_pixel;
+                       double target = ((double)frame - (double)current_page_samples()/2.0) / frames_per_pixel;
                        if (target <= 0.0) {
                                target = 0.0;
                        }
-                       if (fabs(target - current) < current_page_frames() / frames_per_pixel) {
+                       if (fabs(target - current) < current_page_samples() / frames_per_pixel) {
                                target = (target * 0.15) + (current * 0.85);
                        } else {
                                /* relax */