Make summary zoom happen based on where the drag is started, rather than
[ardour.git] / gtk2_ardour / editor_summary.h
1
2 /*
3     Copyright (C) 2009 Paul Davis
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __gtk_ardour_editor_summary_h__
22 #define __gtk_ardour_editor_summary_h__
23
24 #include "cairo_widget.h"
25 #include "editor_component.h"
26
27 namespace ARDOUR {
28         class Session;
29 }
30
31 class Editor;
32
33 /** Class to provide a visual summary of the contents of an editor window; represents
34  *  the whole session as a set of lines, one per region view.
35  */
36 class EditorSummary : public CairoWidget, public EditorComponent
37 {
38 public:
39         EditorSummary (Editor *);
40
41         void set_session (ARDOUR::Session *);
42         void set_overlays_dirty ();
43
44 private:
45
46         enum Position {
47                 LEFT,
48                 LEFT_TOP,
49                 TOP,
50                 RIGHT_TOP,
51                 RIGHT,
52                 RIGHT_BOTTOM,
53                 BOTTOM,
54                 LEFT_BOTTOM,
55                 INSIDE,
56                 BELOW_OR_ABOVE,
57                 TO_LEFT_OR_RIGHT,
58                 OTHERWISE_OUTSIDE
59         };
60
61         bool on_expose_event (GdkEventExpose *);
62         void on_size_request (Gtk::Requisition *);
63         bool on_button_press_event (GdkEventButton *);
64         bool on_button_release_event (GdkEventButton *);
65         bool on_motion_notify_event (GdkEventMotion *);
66         bool on_scroll_event (GdkEventScroll *);
67
68         void centre_on_click (GdkEventButton *);
69         void render (cairo_t *);
70         void render_region (RegionView*, cairo_t*, double) const;
71         void get_editor (std::pair<double, double> *, std::pair<double, double> *) const;
72         void set_editor (std::pair<double, double> const &, double);
73         void set_editor (std::pair<double, double> const &, std::pair<double, double> const &);
74         void set_editor_x (std::pair<double, double> const &);
75         void set_editor_y (double);
76         void set_editor_y (std::pair<double, double> const &);
77         void playhead_position_changed (nframes64_t);
78         double summary_y_to_editor (double) const;
79         double editor_y_to_summary (double) const;
80         Position get_position (double, double) const;
81         void set_cursor (Position);
82
83         nframes_t _start; ///< start frame of the overview
84         nframes_t _end; ///< end frame of the overview
85
86         /** fraction of the session length by which the overview size should extend past the start and end markers */
87         double _overhang_fraction;
88
89         double _x_scale; ///< pixels per frame for the x axis of the pixmap
90         double _track_height;
91         double _last_playhead;
92
93         std::pair<double, double> _start_editor_x;
94         std::pair<double, double> _start_editor_y;
95         double _start_mouse_x;
96         double _start_mouse_y;
97
98         Position _start_position;
99
100         bool _move_dragging;
101         bool _moved;
102         std::pair<double, double> _view_rectangle_x;
103         std::pair<double, double> _view_rectangle_y;
104
105         bool _zoom_dragging;
106         Position _zoom_position;
107         std::pair<double, double> _pending_zoom_x;
108         std::pair<double, double> _pending_zoom_y;
109
110         PBD::ScopedConnectionList position_connection;
111         PBD::ScopedConnectionList region_property_connection;
112 };
113
114 #endif