Add a playhead marker to the summary.

git-svn-id: svn://localhost/ardour2/branches/3.0@5206 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-06-17 00:29:56 +00:00
parent 6f6c8b3dba
commit 34930fc8cf
6 changed files with 42 additions and 11 deletions

View file

@ -4720,7 +4720,7 @@ Editor::post_zoom ()
playhead_cursor->set_position (playhead_cursor->current_frame); playhead_cursor->set_position (playhead_cursor->current_frame);
} }
_summary->set_bounds_dirty (); _summary->set_overlays_dirty ();
instant_save (); instant_save ();
} }
@ -4828,7 +4828,7 @@ Editor::idle_visual_changer ()
redisplay_tempo (true); redisplay_tempo (true);
} }
_summary->set_bounds_dirty (); _summary->set_overlays_dirty ();
//cerr << "Editor::idle_visual_changer () called ha v:l:u:ps:fpu = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << frames_per_unit << endl;//DEBUG //cerr << "Editor::idle_visual_changer () called ha v:l:u:ps:fpu = " << horizontal_adjustment.get_value() << ":" << horizontal_adjustment.get_lower() << ":" << horizontal_adjustment.get_upper() << ":" << horizontal_adjustment.get_page_size() << ":" << frames_per_unit << endl;//DEBUG
pending_visual_change.idle_handler_id = -1; pending_visual_change.idle_handler_id = -1;

View file

@ -138,6 +138,8 @@ struct EditorCursor {
void set_position (nframes64_t); void set_position (nframes64_t);
void set_length (double units); void set_length (double units);
void set_y_axis (double position); void set_y_axis (double position);
sigc::signal<void, nframes64_t> PositionChanged;
}; };
class Editor : public PublicEditor class Editor : public PublicEditor

View file

@ -362,7 +362,7 @@ Editor::track_canvas_size_allocated ()
reset_hscrollbar_stepping (); reset_hscrollbar_stepping ();
update_fixed_rulers(); update_fixed_rulers();
redisplay_tempo (false); redisplay_tempo (false);
_summary->set_bounds_dirty (); _summary->set_overlays_dirty ();
Resized (); /* EMIT_SIGNAL */ Resized (); /* EMIT_SIGNAL */
@ -773,7 +773,7 @@ Editor::tie_vertical_scrolling ()
controls_layout.get_vadjustment()->set_value (vertical_adjustment.get_value()); controls_layout.get_vadjustment()->set_value (vertical_adjustment.get_value());
if (pending_visual_change.idle_handler_id < 0) { if (pending_visual_change.idle_handler_id < 0) {
_summary->set_bounds_dirty (); _summary->set_overlays_dirty ();
} }
} }
@ -797,7 +797,7 @@ Editor::scroll_canvas_horizontally ()
redisplay_tempo (true); redisplay_tempo (true);
if (pending_visual_change.idle_handler_id < 0) { if (pending_visual_change.idle_handler_id < 0) {
_summary->set_bounds_dirty (); _summary->set_overlays_dirty ();
} }
#ifndef GTKOSX #ifndef GTKOSX

View file

@ -59,6 +59,8 @@ EditorCursor::~EditorCursor ()
void void
EditorCursor::set_position (nframes64_t frame) EditorCursor::set_position (nframes64_t frame)
{ {
PositionChanged (frame);
double new_pos = editor.frame_to_unit (frame); double new_pos = editor.frame_to_unit (frame);
if (new_pos != points.front().get_x()) { if (new_pos != points.front().get_x()) {

View file

@ -43,6 +43,7 @@ EditorSummary::EditorSummary (Editor* e)
_height (64), _height (64),
_x_scale (1), _x_scale (1),
_y_scale (1), _y_scale (1),
_last_playhead (-1),
_move_dragging (false), _move_dragging (false),
_moved (false), _moved (false),
_zoom_dragging (false) _zoom_dragging (false)
@ -64,6 +65,7 @@ EditorSummary::set_session (Session* s)
_session->RegionRemoved.connect (sigc::hide (mem_fun (*this, &EditorSummary::set_dirty))); _session->RegionRemoved.connect (sigc::hide (mem_fun (*this, &EditorSummary::set_dirty)));
_session->EndTimeChanged.connect (mem_fun (*this, &EditorSummary::set_dirty)); _session->EndTimeChanged.connect (mem_fun (*this, &EditorSummary::set_dirty));
_session->StartTimeChanged.connect (mem_fun (*this, &EditorSummary::set_dirty)); _session->StartTimeChanged.connect (mem_fun (*this, &EditorSummary::set_dirty));
_editor->playhead_cursor->PositionChanged.connect (mem_fun (*this, &EditorSummary::playhead_position_changed));
set_dirty (); set_dirty ();
} }
@ -110,14 +112,14 @@ EditorSummary::on_expose_event (GdkEventExpose* event)
); );
} }
cairo_t* cr = gdk_cairo_create (get_window()->gobj());
/* Render the view rectangle */ /* Render the view rectangle */
pair<double, double> x; pair<double, double> x;
pair<double, double> y; pair<double, double> y;
get_editor (&x, &y); get_editor (&x, &y);
cairo_t* cr = gdk_cairo_create (get_window()->gobj());
cairo_move_to (cr, x.first, y.first); cairo_move_to (cr, x.first, y.first);
cairo_line_to (cr, x.second, y.first); cairo_line_to (cr, x.second, y.first);
cairo_line_to (cr, x.second, y.second); cairo_line_to (cr, x.second, y.second);
@ -129,6 +131,18 @@ EditorSummary::on_expose_event (GdkEventExpose* event)
cairo_set_source_rgba (cr, 1, 1, 1, 0.5); cairo_set_source_rgba (cr, 1, 1, 1, 0.5);
cairo_stroke (cr); cairo_stroke (cr);
/* Playhead */
cairo_set_line_width (cr, 1);
/* XXX: colour should be set from configuration file */
cairo_set_source_rgba (cr, 1, 0, 0, 1);
double const p = _editor->playhead_cursor->current_frame * _x_scale;
cairo_move_to (cr, p, 0);
cairo_line_to (cr, p, _height);
cairo_stroke (cr);
_last_playhead = p;
cairo_destroy (cr); cairo_destroy (cr);
return true; return true;
@ -243,11 +257,11 @@ EditorSummary::set_dirty ()
queue_draw (); queue_draw ();
} }
/** Set the summary so that just the view boundary markers will be re-rendered */ /** Set the summary so that just the overlays (viewbox, playhead etc.) will be re-rendered */
void void
EditorSummary::set_bounds_dirty () EditorSummary::set_overlays_dirty ()
{ {
ENSURE_GUI_THREAD (mem_fun (*this, &EditorSummary::set_bounds_dirty)); ENSURE_GUI_THREAD (mem_fun (*this, &EditorSummary::set_overlays_dirty));
queue_draw (); queue_draw ();
} }
@ -454,6 +468,7 @@ EditorSummary::on_scroll_event (GdkEventScroll* ev)
yr.first -= amount; yr.first -= amount;
yr.second -= amount; yr.second -= amount;
} }
} }
set_editor (xr, yr); set_editor (xr, yr);
@ -489,3 +504,13 @@ EditorSummary::set_editor (pair<double,double> const & x, pair<double, double> c
} }
} }
} }
void
EditorSummary::playhead_position_changed (nframes64_t p)
{
if (int (p * _x_scale) != int (_last_playhead)) {
set_overlays_dirty ();
}
}

View file

@ -39,7 +39,7 @@ public:
void set_session (ARDOUR::Session *); void set_session (ARDOUR::Session *);
void set_dirty (); void set_dirty ();
void set_bounds_dirty (); void set_overlays_dirty ();
private: private:
void centre_on_click (GdkEventButton *); void centre_on_click (GdkEventButton *);
@ -56,6 +56,7 @@ private:
void render_region (RegionView*, cairo_t*, nframes_t, double) const; void render_region (RegionView*, cairo_t*, nframes_t, double) const;
void get_editor (std::pair<double, double> *, std::pair<double, double> *) const; void get_editor (std::pair<double, double> *, std::pair<double, double> *) const;
void set_editor (std::pair<double, double> const &, std::pair<double, double> const &); void set_editor (std::pair<double, double> const &, std::pair<double, double> const &);
void playhead_position_changed (nframes64_t);
Editor* _editor; ///< our editor Editor* _editor; ///< our editor
ARDOUR::Session* _session; ///< our session ARDOUR::Session* _session; ///< our session
@ -65,6 +66,7 @@ private:
int _height; ///< pixmap height int _height; ///< pixmap height
double _x_scale; ///< pixels per frame for the x axis of the pixmap double _x_scale; ///< pixels per frame for the x axis of the pixmap
double _y_scale; double _y_scale;
double _last_playhead;
std::pair<double, double> _start_editor_x; std::pair<double, double> _start_editor_x;
std::pair<double, double> _start_editor_y; std::pair<double, double> _start_editor_y;