1 #include "ardour/session.h"
2 #include "time_axis_view.h"
3 #include "streamview.h"
4 #include "editor_summary.h"
5 #include "gui_thread.h"
7 #include "region_view.h"
11 using namespace ARDOUR;
13 EditorSummary::EditorSummary (Editor* e)
17 _regions_dirty (true),
26 EditorSummary::set_session (Session* s)
30 Region::RegionPropertyChanged.connect (sigc::hide (mem_fun (*this, &EditorSummary::set_dirty)));
32 _session->RegionRemoved.connect (sigc::hide (mem_fun (*this, &EditorSummary::set_dirty)));
33 _session->EndTimeChanged.connect (mem_fun (*this, &EditorSummary::set_dirty));
34 _session->StartTimeChanged.connect (mem_fun (*this, &EditorSummary::set_dirty));
39 EditorSummary::~EditorSummary ()
42 gdk_pixmap_unref (_pixmap);
47 EditorSummary::on_expose_event (GdkEventExpose* event)
49 Gdk::Rectangle const exposure (
50 event->area.x, event->area.y, event->area.width, event->area.height
53 Gdk::Rectangle r = exposure;
54 Gdk::Rectangle content (0, 0, _width, _height);
56 r.intersect (content, intersects);
60 GdkPixmap* p = get_pixmap (get_window()->gobj ());
64 get_style()->get_fg_gc (Gtk::STATE_NORMAL)->gobj(),
75 cairo_t* cr = gdk_cairo_create (get_window()->gobj());
77 cairo_set_source_rgb (cr, 0, 1, 0);
78 cairo_set_line_width (cr, 2);
80 double const s = (_editor->leftmost_position () - _session->current_start_frame ()) * _pixels_per_frame;
81 cairo_move_to (cr, s, 0);
82 cairo_line_to (cr, s, _height);
85 double const e = s + _editor->current_page_frames() * _pixels_per_frame;
86 cairo_move_to (cr, e, 0);
87 cairo_line_to (cr, e, _height);
96 EditorSummary::get_pixmap (GdkDrawable* drawable)
101 gdk_pixmap_unref (_pixmap);
103 _pixmap = gdk_pixmap_new (drawable, _width, _height, -1);
105 cairo_t* cr = gdk_cairo_create (_pixmap);
109 _regions_dirty = false;
116 EditorSummary::render (cairo_t* cr)
122 cairo_set_source_rgb (cr, 0, 0, 0);
123 cairo_rectangle (cr, 0, 0, _width, _height);
128 for (PublicEditor::TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
134 nframes_t const start = _session->current_start_frame ();
135 _pixels_per_frame = static_cast<double> (_width) / (_session->current_end_frame() - start);
136 double const track_height = static_cast<double> (_height) / N;
138 cairo_set_line_width (cr, track_height);
141 for (PublicEditor::TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
142 StreamView* s = (*i)->view ();
145 double const v = ((n % 2) == 0) ? 1 : 0.5;
146 cairo_set_source_rgb (cr, v, v, v);
148 s->foreach_regionview (bind (
149 mem_fun (*this, &EditorSummary::render_region),
152 track_height * (n + 0.5)
161 EditorSummary::render_region (RegionView* r, cairo_t* cr, nframes_t start, double y) const
163 cairo_move_to (cr, (r->region()->position() - start) * _pixels_per_frame, y);
164 cairo_line_to (cr, (r->region()->position() - start + r->region()->length()) * _pixels_per_frame, y);
169 EditorSummary::set_dirty ()
171 ENSURE_GUI_THREAD (mem_fun (*this, &EditorSummary::set_dirty));
173 _regions_dirty = true;
178 EditorSummary::set_bounds_dirty ()
180 ENSURE_GUI_THREAD (mem_fun (*this, &EditorSummary::set_bounds_dirty));
185 EditorSummary::on_size_request (Gtk::Requisition *req)
192 EditorSummary::on_size_allocate (Gtk::Allocation& alloc)
194 Gtk::EventBox::on_size_allocate (alloc);
196 _width = alloc.get_width ();
197 _height = alloc.get_height ();
203 EditorSummary::on_button_press_event (GdkEventButton* ev)
205 if (ev->button == 1) {
207 nframes_t f = (ev->x / _pixels_per_frame) + _session->current_start_frame();
209 nframes_t const h = _editor->current_page_frames () / 2;
216 _editor->reset_x_origin (f);