removal of sundry Adjustments and consolidation of scrolling around two editor-owned...
[ardour.git] / gtk2_ardour / editor.h
index edb0e8761b195c1a4baa90c17844672e6f682d4e..2da7650ce5c12fa7fa830d79621c4e62e26cd790 100644 (file)
@@ -147,10 +147,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void             first_idle ();
        virtual bool     have_idled () const { return _have_idled; }
 
-       framepos_t leftmost_position() const { return leftmost_frame; }
+       framepos_t leftmost_sample() const { return leftmost_frame; }
 
-       framecnt_t current_page_frames() const {
-               return (framecnt_t) floor (_visible_canvas_width * frames_per_pixel);
+       framecnt_t current_page_samples() const {
+               return (framecnt_t) floor (_visible_canvas_width * samples_per_pixel);
        }
 
        double visible_canvas_height () const {
@@ -220,32 +220,12 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void separate_regions_using_location (ARDOUR::Location&);
        void transition_to_rolling (bool forward);
 
-       /* undo related */
-
-       framepos_t unit_to_frame (double unit) const {
-               return (framepos_t) rint (unit * frames_per_pixel);
-       }
-
-       double frame_to_unit (framepos_t frame) const {
-               return rint ((double) frame / (double) frames_per_pixel);
-       }
-
-       double frame_to_unit_unrounded (framepos_t frame) const {
-               return frame / frames_per_pixel;
-       }
-       
-       double frame_to_unit (double frame) const {
-               return rint (frame / frames_per_pixel);
-       }
-
        /* NOTE: these functions assume that the "pixel" coordinate is
-          the result of using the world->canvas affine transform on a
-          world coordinate. These coordinates already take into
-          account any scrolling carried out by adjusting the
-          xscroll_adjustment.
+          in canvas coordinates. These coordinates already take into
+          account any scrolling offsets.
        */
 
-       framepos_t pixel_to_frame (double pixel) const {
+       framepos_t pixel_to_sample (double pixel) const {
 
                /* pixel can be less than zero when motion events
                   are processed. since we've already run the world->canvas
@@ -254,17 +234,19 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
                */
 
                if (pixel >= 0) {
-                       return (framepos_t) rint (pixel * frames_per_pixel);
+                       return (framepos_t) rint (pixel * samples_per_pixel);
                } else {
                        return 0;
                }
        }
 
-       gulong frame_to_pixel (framepos_t frame) const {
-               return (gulong) rint (frame / frames_per_pixel);
+       double sample_to_pixel (framepos_t sample) const {
+               return rint (sample / samples_per_pixel);
        }
 
-       void flush_canvas ();
+       double sample_to_pixel_unrounded (framepos_t sample) const {
+               return sample / samples_per_pixel;
+       }
 
        /* selection */
 
@@ -310,7 +292,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void               set_zoom_focus (Editing::ZoomFocus);
        Editing::ZoomFocus get_zoom_focus () const { return zoom_focus; }
-       double             get_current_zoom () const { return frames_per_pixel; }
+       double             get_current_zoom () const { return samples_per_pixel; }
         void               cycle_zoom_focus ();
        void temporal_zoom_step (bool coarser);
        void tav_zoom_step (bool coarser);
@@ -497,7 +479,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
            VisualState (bool with_tracks);
            ~VisualState ();
            double              y_position;
-           double              frames_per_pixel;
+           double              samples_per_pixel;
            framepos_t          leftmost_frame;
            Editing::ZoomFocus  zoom_focus;
            GUIObjectState*     gui_state;
@@ -517,11 +499,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void cancel_visual_state_op (uint32_t n);
 
        framepos_t leftmost_frame;
-       double      frames_per_pixel;
+       double      samples_per_pixel;
        Editing::ZoomFocus zoom_focus;
 
-       void set_frames_per_pixel (double);
-       bool clamp_frames_per_pixel (double &) const;
+       void set_samples_per_pixel (double);
+       bool clamp_samples_per_pixel (double &) const;
 
        Editing::MouseMode mouse_mode;
        Editing::MouseMode pre_internal_mouse_mode;
@@ -714,12 +696,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        ArdourCanvas::GtkCanvas* _track_canvas;
        ArdourCanvas::GtkCanvasViewport* _track_canvas_viewport;
-        Gtk::Adjustment* _track_canvas_hadj;
-        Gtk::Adjustment* _track_canvas_vadj;
 
         ArdourCanvas::GtkCanvas* _time_bars_canvas;
         ArdourCanvas::GtkCanvasViewport* _time_bars_canvas_viewport;
-       Gtk::Adjustment* _time_bars_canvas_hadj;
        Gtk::Adjustment* _time_bars_canvas_vadj;
 
        bool within_track_canvas;
@@ -988,7 +967,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        /** the adjustment that controls the overall editor vertical scroll position */
        Gtk::Adjustment     vertical_adjustment;
+        Gtk::Adjustment     horizontal_adjustment;
 
+        Gtk::Adjustment     unused_adjustment; // yes, really; Gtk::Layout constructor requires refs
        Gtk::Layout         controls_layout;
        bool control_layout_scroll (GdkEventScroll* ev);
        void reset_controls_layout_width ();
@@ -1053,14 +1034,14 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
                Type pending;
                framepos_t time_origin;
-               double frames_per_pixel;
+               double samples_per_pixel;
                double y_origin;
 
                int idle_handler_id;
                /** true if we are currently in the idle handler */
                bool being_handled;
 
-               VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), frames_per_pixel (0), idle_handler_id (-1), being_handled (false) {}
+               VisualChange() : pending ((VisualChange::Type) 0), time_origin (0), samples_per_pixel (0), idle_handler_id (-1), being_handled (false) {}
                void add (Type t) {
                        pending = Type (pending | t);
                }
@@ -1885,7 +1866,15 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void duplicate_range (bool with_dialog);
 
-       framepos_t event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
+        /** computes the timeline frame (sample) of an event whose coordinates
+        * are in canvas units (pixels, scroll offset included).
+        */
+       framepos_t canvas_event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
+
+        /** computes the timeline frame (sample) of an event whose coordinates
+        * are in window units (pixels, no scroll offset).
+        */
+       framepos_t window_event_frame (GdkEvent const *, double* px = 0, double* py = 0) const;
 
        /* returns false if mouse pointer is not in track or marker canvas
         */
@@ -2092,8 +2081,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void region_view_added (RegionView *);
        void region_view_removed ();
 
-       void update_canvas_now ();
-
        EditorGroupTabs* _group_tabs;
        void fit_route_group (ARDOUR::RouteGroup *);