Expose EditorCursor via public editor API

This is in preparation to subscribe to playhead cursor position
changes in the recorder-UI.

This change also clean up the API, replacing a public variable
with a const access method and follows #12 of
https://ardour.org/styleguide.html
This commit is contained in:
Robin Gareus 2021-01-05 21:58:28 +01:00
parent 8ba7df9105
commit 4769c387f3
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
9 changed files with 99 additions and 92 deletions

View File

@ -339,8 +339,6 @@ Editor::Editor ()
, cd_mark_label (_("CD Markers"))
, videotl_label (_("Video Timeline"))
, videotl_group (0)
, snapped_cursor (0)
, playhead_cursor (0)
, _region_boundary_cache_dirty (true)
, edit_packer (4, 4, true)
, vertical_adjustment (0.0, 0.0, 10.0, 400.0)
@ -402,6 +400,8 @@ Editor::Editor ()
, _last_region_menu_was_main (false)
, _track_selection_change_without_scroll (false)
, _editor_track_selection_change_without_scroll (false)
, _playhead_cursor (0)
, _snapped_cursor (0)
, cd_marker_bar_drag_rect (0)
, range_bar_drag_rect (0)
, transport_bar_drag_rect (0)
@ -1052,7 +1052,7 @@ Editor::control_scroll (float fraction)
it acts like a pointer to an samplepos_t, with
a operator conversion to boolean to check
that it has a value could possibly use
playhead_cursor->current_sample to store the
_playhead_cursor->current_sample to store the
value and a boolean in the class to know
when it's out of date
*/
@ -1072,7 +1072,7 @@ Editor::control_scroll (float fraction)
/* move visuals, we'll catch up with it later */
playhead_cursor->set_position (*_control_scroll_target);
_playhead_cursor->set_position (*_control_scroll_target);
UpdateAllTransportClocks (*_control_scroll_target);
if (*_control_scroll_target > (current_page_samples() / 2)) {
@ -1226,7 +1226,7 @@ Editor::map_position_change (samplepos_t sample)
}
if (!_session->locate_initiated()) {
playhead_cursor->set_position (sample);
_playhead_cursor->set_position (sample);
}
}
@ -1360,7 +1360,7 @@ Editor::set_session (Session *t)
/* catch up with the playhead */
_session->request_locate (playhead_cursor->current_sample (), MustStop);
_session->request_locate (_playhead_cursor->current_sample (), MustStop);
_pending_initial_locate = true;
update_title ();
@ -1388,12 +1388,12 @@ Editor::set_session (Session *t)
_session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::refresh_location_display, this), gui_context());
_session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context());
playhead_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group());
playhead_cursor->show ();
_playhead_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group());
_playhead_cursor->show ();
snapped_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group());
snapped_cursor->set_color (UIConfiguration::instance().color ("edit point"));
snapped_cursor->show ();
_snapped_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group());
_snapped_cursor->set_color (UIConfiguration::instance().color ("edit point"));
_snapped_cursor->show ();
boost::function<void (string)> pc (boost::bind (&Editor::parameter_changed, this, _1));
Config->map_parameters (pc);
@ -1988,8 +1988,8 @@ Editor::add_dstream_context_items (Menu_Helpers::MenuList& edit_items)
select_items.push_back (SeparatorElem());
select_items.push_back (MenuElem (_("Select All After Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), true, true)));
select_items.push_back (MenuElem (_("Select All Before Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), false, true)));
select_items.push_back (MenuElem (_("Select All After Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
select_items.push_back (MenuElem (_("Select All Before Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
select_items.push_back (MenuElem (_("Select All After Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), _playhead_cursor, true)));
select_items.push_back (MenuElem (_("Select All Before Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), _playhead_cursor, false)));
select_items.push_back (MenuElem (_("Select All Between Playhead and Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_between), false)));
select_items.push_back (MenuElem (_("Select All Within Playhead and Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_between), true)));
select_items.push_back (MenuElem (_("Select Range Between Playhead and Edit Point"), sigc::mem_fun(*this, &Editor::select_range_between)));
@ -2062,8 +2062,8 @@ Editor::add_bus_context_items (Menu_Helpers::MenuList& edit_items)
select_items.push_back (SeparatorElem());
select_items.push_back (MenuElem (_("Select All After Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), true, true)));
select_items.push_back (MenuElem (_("Select All Before Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), false, true)));
select_items.push_back (MenuElem (_("Select All After Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true)));
select_items.push_back (MenuElem (_("Select All Before Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false)));
select_items.push_back (MenuElem (_("Select All After Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), _playhead_cursor, true)));
select_items.push_back (MenuElem (_("Select All Before Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_cursor), _playhead_cursor, false)));
edit_items.push_back (MenuElem (_("Select"), *select_menu));
@ -2344,13 +2344,13 @@ Editor::set_state (const XMLNode& node, int version)
samplepos_t ph_pos;
if (_session && node.get_property ("playhead", ph_pos)) {
if (ph_pos >= 0) {
playhead_cursor->set_position (ph_pos);
_playhead_cursor->set_position (ph_pos);
} else {
warning << _("Playhead position stored with a negative value - ignored (use zero instead)") << endmsg;
playhead_cursor->set_position (0);
_playhead_cursor->set_position (0);
}
} else {
playhead_cursor->set_position (0);
_playhead_cursor->set_position (0);
}
node.get_property ("mixer-width", editor_mixer_strip_width);
@ -2544,7 +2544,7 @@ Editor::get_state ()
node->set_property ("edit-point", _edit_point);
node->set_property ("visible-track-count", _visible_track_count);
node->set_property ("playhead", playhead_cursor->current_sample ());
node->set_property ("playhead", _playhead_cursor->current_sample ());
node->set_property ("left-frame", _leftmost_sample);
node->set_property ("y-origin", vertical_adjustment.get_value ());
@ -2615,7 +2615,7 @@ void
Editor::set_snapped_cursor_position (samplepos_t pos)
{
if (_edit_point == EditAtMouse) {
snapped_cursor->set_position(pos);
_snapped_cursor->set_position(pos);
}
}
@ -4575,8 +4575,8 @@ Editor::on_samples_per_pixel_changed ()
c->canvas()->zoomed ();
}
if (playhead_cursor) {
playhead_cursor->set_position (playhead_cursor->current_sample ());
if (_playhead_cursor) {
_playhead_cursor->set_position (_playhead_cursor->current_sample ());
}
refresh_location_display();
@ -4590,7 +4590,7 @@ Editor::on_samples_per_pixel_changed ()
samplepos_t
Editor::playhead_cursor_sample () const
{
return playhead_cursor->current_sample();
return _playhead_cursor->current_sample();
}
void
@ -4772,7 +4772,7 @@ Editor::get_preferred_edit_position (EditIgnoreOption ignore, bool from_context_
case EditAtPlayhead:
if (_dragging_playhead) {
/* NOTE: since the user is dragging with the mouse, this operation will implicitly be Snapped */
where = playhead_cursor->current_sample();
where = _playhead_cursor->current_sample();
} else {
where = _session->audible_sample();
}
@ -5271,7 +5271,7 @@ Editor::located ()
ENSURE_GUI_THREAD (*this, &Editor::located);
if (_session) {
playhead_cursor->set_position (_session->audible_sample ());
_playhead_cursor->set_position (_session->audible_sample ());
if (_follow_playhead && !_pending_initial_locate) {
reset_x_origin_to_follow_playhead ();
}
@ -5764,7 +5764,7 @@ Editor::scroll_release ()
void
Editor::reset_x_origin_to_follow_playhead ()
{
samplepos_t const sample = playhead_cursor->current_sample ();
samplepos_t const sample = _playhead_cursor->current_sample ();
if (sample < _leftmost_sample || sample > _leftmost_sample + current_page_samples()) {
@ -5853,7 +5853,7 @@ Editor::super_rapid_screen_update ()
if (_last_update_time > 0) {
/* interpolate and smoothen playhead position */
const double ds = (now - _last_update_time) * _session->transport_speed() * _session->nominal_sample_rate () * 1e-6;
samplepos_t guess = playhead_cursor->current_sample () + rint (ds);
samplepos_t guess = _playhead_cursor->current_sample () + rint (ds);
err = sample - guess;
guess += err * .12 + _err_screen_engine; // time-constant based on 25fps (super_rapid_screen_update)
@ -5882,7 +5882,7 @@ Editor::super_rapid_screen_update ()
bool ignored;
MusicSample where (sample, 0);
if (!UIConfiguration::instance().get_show_snapped_cursor()) {
snapped_cursor->hide ();
_snapped_cursor->hide ();
} else if (_edit_point == EditAtPlayhead && !_dragging_playhead) {
/* EditAtPlayhead does not snap */
} else if (_edit_point == EditAtSelectedMarker) {
@ -5892,15 +5892,15 @@ Editor::super_rapid_screen_update ()
if (!selection->markers.empty()) {
MusicSample ms (selection->markers.front()->position(), 0);
snap_to (ms); // should use snap_to_with_modifier?
snapped_cursor->set_position (ms.sample);
snapped_cursor->show ();
_snapped_cursor->set_position (ms.sample);
_snapped_cursor->show ();
}
} else if (_edit_point == EditAtMouse && mouse_sample (where.sample, ignored)) {
/* cursor is in the editing canvas. show it. */
snapped_cursor->show ();
_snapped_cursor->show ();
} else {
/* mouse is out of the editing canvas, or edit-point isn't mouse. Hide the snapped_cursor */
snapped_cursor->hide ();
_snapped_cursor->hide ();
}
/* There are a few reasons why we might not update the playhead / viewport stuff:
@ -5922,12 +5922,12 @@ Editor::super_rapid_screen_update ()
return;
}
if (playhead_cursor->current_sample () == sample) {
if (_playhead_cursor->current_sample () == sample) {
return;
}
if (!_pending_locate_request) {
playhead_cursor->set_position (sample);
_playhead_cursor->set_position (sample);
}
if (_session->requested_return_sample() >= 0) {
@ -5949,7 +5949,7 @@ Editor::super_rapid_screen_update ()
if (!_stationary_playhead) {
reset_x_origin_to_follow_playhead ();
} else {
samplepos_t const sample = playhead_cursor->current_sample ();
samplepos_t const sample = _playhead_cursor->current_sample ();
double target = ((double)sample - (double)current_page_samples() / 2.0);
if (target <= 0.0) {
target = 0.0;
@ -5984,7 +5984,7 @@ Editor::session_going_away ()
_last_update_time = 0;
_drags->abort ();
playhead_cursor->hide ();
_playhead_cursor->hide ();
/* rip everything out of the list displays */
@ -6259,7 +6259,7 @@ Editor::ui_parameter_changed (string parameter)
} else if (parameter == "draggable-playhead") {
if (_verbose_cursor) {
playhead_cursor->set_sensitive (UIConfiguration::instance().get_draggable_playhead());
_playhead_cursor->set_sensitive (UIConfiguration::instance().get_draggable_playhead());
}
} else if (parameter == "use-note-bars-for-velocity") {
ArdourCanvas::Note::set_show_velocity_bars (UIConfiguration::instance().get_use_note_bars_for_velocity());

View File

@ -1030,11 +1030,9 @@ private:
int get_videotl_bar_height () const { return videotl_bar_height; }
void toggle_region_video_lock ();
friend class EditorCursor;
EditorCursor* playhead_cursor () const { return _playhead_cursor; }
EditorCursor* snapped_cursor () const { return _snapped_cursor; }
EditorCursor* snapped_cursor;
EditorCursor* playhead_cursor;
samplepos_t playhead_cursor_sample () const;
samplepos_t get_region_boundary (samplepos_t pos, int32_t dir, bool with_selection, bool only_onscreen);
@ -1912,6 +1910,11 @@ private:
bool audio_region_selection_covers (samplepos_t where);
/* playhead and edit cursor */
EditorCursor* _playhead_cursor;
EditorCursor* _snapped_cursor;
/* transport range select process */
ArdourCanvas::Rectangle* cd_marker_bar_drag_rect;

View File

@ -202,13 +202,13 @@ Editor::register_actions ()
reg_sens (editor_actions, "playhead-to-previous-region-boundary", _("Playhead to Previous Region Boundary"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_boundary), true));
reg_sens (editor_actions, "playhead-to-previous-region-boundary-noselection", _("Playhead to Previous Region Boundary (No Track Selection)"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_boundary), false));
reg_sens (editor_actions, "playhead-to-next-region-start", _("Playhead to Next Region Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (Start)));
reg_sens (editor_actions, "playhead-to-next-region-end", _("Playhead to Next Region End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (End)));
reg_sens (editor_actions, "playhead-to-next-region-sync", _("Playhead to Next Region Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (SyncPoint)));
reg_sens (editor_actions, "playhead-to-next-region-start", _("Playhead to Next Region Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), _playhead_cursor, RegionPoint (Start)));
reg_sens (editor_actions, "playhead-to-next-region-end", _("Playhead to Next Region End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), _playhead_cursor, RegionPoint (End)));
reg_sens (editor_actions, "playhead-to-next-region-sync", _("Playhead to Next Region Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), _playhead_cursor, RegionPoint (SyncPoint)));
reg_sens (editor_actions, "playhead-to-previous-region-start", _("Playhead to Previous Region Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (Start)));
reg_sens (editor_actions, "playhead-to-previous-region-end", _("Playhead to Previous Region End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (End)));
reg_sens (editor_actions, "playhead-to-previous-region-sync", _("Playhead to Previous Region Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (SyncPoint)));
reg_sens (editor_actions, "playhead-to-previous-region-start", _("Playhead to Previous Region Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), _playhead_cursor, RegionPoint (Start)));
reg_sens (editor_actions, "playhead-to-previous-region-end", _("Playhead to Previous Region End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), _playhead_cursor, RegionPoint (End)));
reg_sens (editor_actions, "playhead-to-previous-region-sync", _("Playhead to Previous Region Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), _playhead_cursor, RegionPoint (SyncPoint)));
reg_sens (editor_actions, "selected-marker-to-next-region-boundary", _("To Next Region Boundary"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_next_region_boundary), true));
reg_sens (editor_actions, "selected-marker-to-next-region-boundary-noselection", _("To Next Region Boundary (No Track Selection)"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_next_region_boundary), false));
@ -226,8 +226,8 @@ Editor::register_actions ()
reg_sens (editor_actions, "edit-cursor-to-range-start", _("To Range Start"), sigc::mem_fun(*this, &Editor::selected_marker_to_selection_start));
reg_sens (editor_actions, "edit-cursor-to-range-end", _("To Range End"), sigc::mem_fun(*this, &Editor::selected_marker_to_selection_end));
reg_sens (editor_actions, "playhead-to-range-start", _("Playhead to Range Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_selection_start), playhead_cursor));
reg_sens (editor_actions, "playhead-to-range-end", _("Playhead to Range End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_selection_end), playhead_cursor));
reg_sens (editor_actions, "playhead-to-range-start", _("Playhead to Range Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_selection_start), _playhead_cursor));
reg_sens (editor_actions, "playhead-to-range-end", _("Playhead to Range End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_selection_end), _playhead_cursor));
reg_sens (editor_actions, "select-all-objects", _("Select All Objects"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_objects), Selection::Set));

View File

@ -223,9 +223,9 @@ Editor::initialize_canvas ()
range_marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_range_marker_bar_event), range_marker_bar));
transport_marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_transport_marker_bar_event), transport_marker_bar));
playhead_cursor = new EditorCursor (*this, &Editor::canvas_playhead_cursor_event);
_playhead_cursor = new EditorCursor (*this, &Editor::canvas_playhead_cursor_event);
snapped_cursor = new EditorCursor (*this);
_snapped_cursor = new EditorCursor (*this);
_canvas_drop_zone = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, 0.0));
/* this thing is transparent */
@ -1022,7 +1022,7 @@ Editor::color_handler()
bbt_ruler->set_fill_color (base);
bbt_ruler->set_outline_color (text);
playhead_cursor->set_color (UIConfiguration::instance().color ("play head"));
_playhead_cursor->set_color (UIConfiguration::instance().color ("play head"));
meter_bar->set_fill_color (UIConfiguration::instance().color_mod ("meter bar", "marker bar"));
meter_bar->set_outline_color (UIConfiguration::instance().color ("marker bar separator"));

View File

@ -4012,11 +4012,11 @@ CursorDrag::fake_locate (samplepos_t t)
return;
}
_editor->playhead_cursor->set_position (t);
_editor->playhead_cursor ()->set_position (t);
Session* s = _editor->session ();
if (s->timecode_transmission_suspended ()) {
samplepos_t const f = _editor->playhead_cursor->current_sample ();
samplepos_t const f = _editor->playhead_cursor ()->current_sample ();
/* This is asynchronous so it will be sent "now"
*/
s->send_mmc_locate (f);
@ -4036,7 +4036,7 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
{
Drag::start_grab (event, c);
setup_snap_delta (MusicSample (_editor->playhead_cursor->current_sample(), 0));
setup_snap_delta (MusicSample (_editor->playhead_cursor ()->current_sample(), 0));
_grab_zoom = _editor->samples_per_pixel;
@ -4145,7 +4145,7 @@ CursorDrag::finished (GdkEvent* event, bool movement_occurred)
Session* s = _editor->session ();
if (s) {
_editor->_pending_locate_request = true;
s->request_locate (_editor->playhead_cursor->current_sample (), _was_rolling ? MustRoll : RollIfAppropriate);
s->request_locate (_editor->playhead_cursor ()->current_sample (), _was_rolling ? MustRoll : RollIfAppropriate);
s->request_resume_timecode_transmission ();
}
}
@ -4160,7 +4160,7 @@ CursorDrag::aborted (bool)
_editor->_dragging_playhead = false;
}
_editor->playhead_cursor->set_position (adjusted_sample (grab_sample (), 0, false).sample);
_editor->playhead_cursor ()->set_position (adjusted_sample (grab_sample (), 0, false).sample);
}
FadeInDrag::FadeInDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)

View File

@ -743,7 +743,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
switch (item_type) {
case PlayheadCursorItem:
_drags->set (new CursorDrag (this, *playhead_cursor, true), event);
_drags->set (new CursorDrag (this, *_playhead_cursor, true), event);
return true;
case MarkerItem:
@ -806,7 +806,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
case BBTRulerItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)
&& !ArdourKeyboard::indicates_constraint (event->button.state)) {
_drags->set (new CursorDrag (this, *playhead_cursor, false), event);
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
} else if (ArdourKeyboard::indicates_constraint (event->button.state)
&& Keyboard::modifier_state_contains (event->button.state, Keyboard::PrimaryModifier)) {
_drags->set (new TempoTwistDrag (this, item), event);
@ -823,14 +823,14 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateRangeMarker), event);
} else {
_drags->set (new CursorDrag (this, *playhead_cursor, false), event);
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
}
return true;
break;
case CdMarkerBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
_drags->set (new CursorDrag (this, *playhead_cursor, false), event);
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
} else {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateCDMarker), event);
}
@ -839,7 +839,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT
case TransportMarkerBarItem:
if (!Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) {
_drags->set (new CursorDrag (this, *playhead_cursor, false), event);
_drags->set (new CursorDrag (this, *_playhead_cursor, false), event);
} else {
_drags->set (new RangeMarkerBarDrag (this, item, RangeMarkerBarDrag::CreateTransportMarker), event);
}

View File

@ -474,8 +474,8 @@ Editor::nudge_forward (bool next, bool force_playhead)
commit_reversible_command ();
}
} else {
distance = get_nudge_distance (playhead_cursor->current_sample (), next_distance);
_session->request_locate (playhead_cursor->current_sample () + distance);
distance = get_nudge_distance (_playhead_cursor->current_sample (), next_distance);
_session->request_locate (_playhead_cursor->current_sample () + distance);
}
}
@ -569,10 +569,10 @@ Editor::nudge_backward (bool next, bool force_playhead)
} else {
distance = get_nudge_distance (playhead_cursor->current_sample (), next_distance);
distance = get_nudge_distance (_playhead_cursor->current_sample (), next_distance);
if (playhead_cursor->current_sample () > distance) {
_session->request_locate (playhead_cursor->current_sample () - distance);
if (_playhead_cursor->current_sample () > distance) {
_session->request_locate (_playhead_cursor->current_sample () - distance);
} else {
_session->goto_start();
}
@ -963,7 +963,7 @@ Editor::get_region_boundary (samplepos_t pos, int32_t dir, bool with_selection,
void
Editor::cursor_to_region_boundary (bool with_selection, int32_t dir)
{
samplepos_t pos = playhead_cursor->current_sample ();
samplepos_t pos = _playhead_cursor->current_sample ();
samplepos_t target;
if (!_session) {
@ -1044,7 +1044,7 @@ Editor::cursor_to_region_point (EditorCursor* cursor, RegionPoint point, int32_t
break;
}
if (cursor == playhead_cursor) {
if (cursor == _playhead_cursor) {
_session->request_locate (pos);
} else {
cursor->set_position (pos);
@ -1085,7 +1085,7 @@ Editor::cursor_to_selection_start (EditorCursor *cursor)
return;
}
if (cursor == playhead_cursor) {
if (cursor == _playhead_cursor) {
_session->request_locate (pos);
} else {
cursor->set_position (pos);
@ -1114,7 +1114,7 @@ Editor::cursor_to_selection_end (EditorCursor *cursor)
return;
}
if (cursor == playhead_cursor) {
if (cursor == _playhead_cursor) {
_session->request_locate (pos);
} else {
cursor->set_position (pos);
@ -1312,7 +1312,7 @@ Editor::selected_marker_to_selection_end ()
void
Editor::scroll_playhead (bool forward)
{
samplepos_t pos = playhead_cursor->current_sample ();
samplepos_t pos = _playhead_cursor->current_sample ();
samplecnt_t delta = (samplecnt_t) floor (current_page_samples() / 0.8);
if (forward) {
@ -1367,10 +1367,10 @@ Editor::cursor_align (bool playhead_to_edit)
Location* loc = find_location_from_marker (*i, ignored);
if (loc->is_mark()) {
loc->set_start (playhead_cursor->current_sample (), false, true, divisions);
loc->set_start (_playhead_cursor->current_sample (), false, true, divisions);
} else {
loc->set (playhead_cursor->current_sample (),
playhead_cursor->current_sample () + loc->length(), true, divisions);
loc->set (_playhead_cursor->current_sample (),
_playhead_cursor->current_sample () + loc->length(), true, divisions);
}
}
}
@ -1836,7 +1836,7 @@ Editor::temporal_zoom (samplecnt_t spp)
case ZoomFocusPlayhead:
/* centre playhead */
l = playhead_cursor->current_sample () - (new_page_size * 0.5);
l = _playhead_cursor->current_sample () - (new_page_size * 0.5);
if (l < 0) {
leftmost_after_zoom = 0;
@ -1868,7 +1868,7 @@ Editor::temporal_zoom (samplecnt_t spp)
}
} else {
/* use playhead instead */
where = playhead_cursor->current_sample ();
where = _playhead_cursor->current_sample ();
if (where < half_page_size) {
leftmost_after_zoom = 0;
@ -2034,7 +2034,7 @@ Editor::temporal_zoom_session ()
samplecnt_t end = _session->current_end_sample();
if (_session->actively_recording ()) {
samplepos_t cur = playhead_cursor->current_sample ();
samplepos_t cur = _playhead_cursor->current_sample ();
if (cur > end) {
/* recording beyond the end marker; zoom out
* by 5 seconds more so that if 'follow
@ -2067,7 +2067,7 @@ Editor::temporal_zoom_extents ()
samplecnt_t end = ext.second;
if (_session->actively_recording ()) {
samplepos_t cur = playhead_cursor->current_sample ();
samplepos_t cur = _playhead_cursor->current_sample ();
if (cur > end) {
/* recording beyond the end marker; zoom out
* by 5 seconds more so that if 'follow
@ -2441,7 +2441,7 @@ Editor::jump_forward_to_mark ()
return;
}
samplepos_t pos = _session->locations()->first_mark_after (playhead_cursor->current_sample());
samplepos_t pos = _session->locations()->first_mark_after (_playhead_cursor->current_sample());
if (pos < 0) {
return;
@ -2457,11 +2457,11 @@ Editor::jump_backward_to_mark ()
return;
}
samplepos_t pos = _session->locations()->first_mark_before (playhead_cursor->current_sample());
samplepos_t pos = _session->locations()->first_mark_before (_playhead_cursor->current_sample());
//handle the case where we are rolling, and we're less than one-half second past the mark, we want to go to the prior mark...
if (_session->transport_rolling()) {
if ((playhead_cursor->current_sample() - pos) < _session->sample_rate()/2) {
if ((_playhead_cursor->current_sample() - pos) < _session->sample_rate()/2) {
samplepos_t prior = _session->locations()->first_mark_before (pos);
pos = prior;
}
@ -2733,7 +2733,7 @@ Editor::play_with_preroll ()
_session->request_play_range (&lar, true);
_session->set_requested_return_sample (ret); //force auto-return to return to range start, without the preroll
} else {
samplepos_t ph = playhead_cursor->current_sample ();
samplepos_t ph = _playhead_cursor->current_sample ();
const samplepos_t preroll = _session->preroll_samples (ph);
samplepos_t start;
if (ph > preroll) {
@ -2749,7 +2749,7 @@ Editor::play_with_preroll ()
void
Editor::rec_with_preroll ()
{
samplepos_t ph = playhead_cursor->current_sample ();
samplepos_t ph = _playhead_cursor->current_sample ();
samplepos_t preroll = _session->preroll_samples (ph);
_session->request_preroll_record_trim (ph, preroll);
}
@ -5147,7 +5147,7 @@ void
Editor::center_playhead ()
{
float const page = _visible_canvas_width * samples_per_pixel;
center_screen_internal (playhead_cursor->current_sample (), page);
center_screen_internal (_playhead_cursor->current_sample (), page);
}
void
@ -6739,7 +6739,7 @@ Editor::set_auto_punch_range ()
}
Location* tpl = transport_punch_location();
samplepos_t now = playhead_cursor->current_sample();
samplepos_t now = _playhead_cursor->current_sample();
samplepos_t begin = now;
samplepos_t end = _session->current_end_sample();
@ -6755,7 +6755,7 @@ Editor::set_auto_punch_range ()
set_punch_range (begin, end, _("Auto Punch In/Out"));
} else {
// normal case for 2nd press - set the punch out
end = playhead_cursor->current_sample ();
end = _playhead_cursor->current_sample ();
set_punch_range (tpl->start(), now, _("Auto Punch In/Out"));
_session->config.set_punch_out(true);
}
@ -7538,7 +7538,7 @@ Editor::playhead_forward_to_grid ()
return;
}
MusicSample pos (playhead_cursor->current_sample (), 0);
MusicSample pos (_playhead_cursor->current_sample (), 0);
if ( _grid_type == GridTypeNone) {
if (pos.sample < max_samplepos - current_page_samples()*0.1) {
@ -7571,7 +7571,7 @@ Editor::playhead_backward_to_grid ()
return;
}
MusicSample pos (playhead_cursor->current_sample (), 0);
MusicSample pos (_playhead_cursor->current_sample (), 0);
if ( _grid_type == GridTypeNone) {
if ( pos.sample > current_page_samples()*0.1 ) {
@ -7590,7 +7590,7 @@ Editor::playhead_backward_to_grid ()
//handle the case where we are rolling, and we're less than one-half second past the mark, we want to go to the prior mark...
//also see: jump_backward_to_mark
if (_session->transport_rolling()) {
if ((playhead_cursor->current_sample() - pos.sample) < _session->sample_rate()/2) {
if ((_playhead_cursor->current_sample() - pos.sample) < _session->sample_rate()/2) {
pos = snap_to_grid (pos, RoundDownAlways, SnapToGrid_Scaled);
}
}

View File

@ -119,7 +119,7 @@ EditorSummary::set_session (Session* s)
if (_session) {
Region::RegionPropertyChanged.connect (region_property_connection, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context());
PresentationInfo::Change.connect (route_ctrl_id_connection, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context());
_editor->playhead_cursor->PositionChanged.connect (position_connection, invalidator (*this), boost::bind (&EditorSummary::playhead_position_changed, this, _1), gui_context());
_editor->playhead_cursor()->PositionChanged.connect (position_connection, invalidator (*this), boost::bind (&EditorSummary::playhead_position_changed, this, _1), gui_context());
_session->StartTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context());
_session->EndTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context());
_editor->selection->RegionsChanged.connect (sigc::mem_fun(*this, &EditorSummary::set_background_dirty));
@ -301,7 +301,7 @@ EditorSummary::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle
double r,g,b,a; Gtkmm2ext::color_to_rgba(_phead_color, r,g,b,a);
cairo_set_source_rgb (cr, r,g,b); // playhead color
const double ph= playhead_sample_to_position (_editor->playhead_cursor->current_sample());
const double ph= playhead_sample_to_position (_editor->playhead_cursor ()->current_sample());
cairo_move_to (cr, ph, 0);
cairo_line_to (cr, ph, get_height());
cairo_stroke (cr);

View File

@ -83,6 +83,7 @@ class AutomationLine;
class AutomationTimeAxisView;
class ControlPoint;
class DragManager;
class EditorCursor;
class ArdourMarker;
class MeterMarker;
class MixerStrip;
@ -472,6 +473,9 @@ public:
virtual MouseCursors const* cursors () const = 0;
virtual VerboseCursor* verbose_cursor () const = 0;
virtual EditorCursor* playhead_cursor () const = 0;
virtual EditorCursor* snapped_cursor () const = 0;
virtual bool get_smart_mode () const = 0;
virtual void get_pointer_position (double &, double &) const = 0;