mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
AudioClock: make last_when public and use it instead of current_time
Having current_time as a public alias of the private last_when did not add any clarity to the abstraction of last_time. A small step, but still room for improvement.
This commit is contained in:
parent
498dac3bc8
commit
728e463d01
12 changed files with 33 additions and 40 deletions
|
|
@ -2255,7 +2255,7 @@ void
|
|||
ARDOUR_UI::primary_clock_value_changed ()
|
||||
{
|
||||
if (_session) {
|
||||
_session->request_locate (primary_clock->current_time ().samples());
|
||||
_session->request_locate (primary_clock->last_when ().samples());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2263,7 +2263,7 @@ void
|
|||
ARDOUR_UI::big_clock_value_changed ()
|
||||
{
|
||||
if (_session) {
|
||||
_session->request_locate (big_clock->current_time ().samples());
|
||||
_session->request_locate (big_clock->last_when ().samples());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2271,7 +2271,7 @@ void
|
|||
ARDOUR_UI::secondary_clock_value_changed ()
|
||||
{
|
||||
if (_session) {
|
||||
_session->request_locate (secondary_clock->current_time ().samples());
|
||||
_session->request_locate (secondary_clock->last_when ().samples());
|
||||
}
|
||||
}
|
||||
void
|
||||
|
|
|
|||
|
|
@ -782,9 +782,9 @@ AudioClock::end_edit_relative (bool add)
|
|||
|
||||
if (!distance.is_zero ()) {
|
||||
if (add) {
|
||||
AudioClock::set (current_time() + timepos_t (distance), true);
|
||||
AudioClock::set (last_when() + timepos_t (distance), true);
|
||||
} else {
|
||||
timepos_t c = current_time();
|
||||
timepos_t c = last_when();
|
||||
|
||||
if (c > timepos_t (distance)|| _negative_allowed) {
|
||||
AudioClock::set (c.earlier (distance), true);
|
||||
|
|
@ -818,7 +818,7 @@ AudioClock::session_configuration_changed (std::string p)
|
|||
if (is_duration) {
|
||||
set_duration (current_duration(), true);
|
||||
} else {
|
||||
AudioClock::set (current_time(), true);
|
||||
AudioClock::set (last_when(), true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -829,7 +829,7 @@ AudioClock::session_configuration_changed (std::string p)
|
|||
if (is_duration) {
|
||||
set_duration (current_duration(), true);
|
||||
} else {
|
||||
AudioClock::set (current_time(), true);
|
||||
AudioClock::set (last_when(), true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1817,27 +1817,27 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
|
|||
switch (ev->direction) {
|
||||
|
||||
case GDK_SCROLL_UP:
|
||||
step = get_incremental_step (f, current_time());
|
||||
step = get_incremental_step (f, last_when());
|
||||
if (!step.is_zero ()) {
|
||||
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
|
||||
step *= 10;
|
||||
}
|
||||
AudioClock::set (current_time() + step, true);
|
||||
AudioClock::set (last_when() + step, true);
|
||||
ValueChanged (); /* EMIT_SIGNAL */
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_SCROLL_DOWN:
|
||||
step = get_incremental_step (f, current_time());
|
||||
step = get_incremental_step (f, last_when());
|
||||
if (!step.is_zero ()) {
|
||||
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
|
||||
step *= 10;
|
||||
}
|
||||
|
||||
if (!_negative_allowed && current_time() < step) {
|
||||
if (!_negative_allowed && last_when() < step) {
|
||||
AudioClock::set (timepos_t (), true);
|
||||
} else {
|
||||
AudioClock::set (current_time().earlier (step), true);
|
||||
AudioClock::set (last_when().earlier (step), true);
|
||||
}
|
||||
|
||||
ValueChanged (); /* EMIT_SIGNAL */
|
||||
|
|
@ -1867,7 +1867,7 @@ AudioClock::on_motion_notify_event (GdkEventMotion *ev)
|
|||
if (drag_accum) {
|
||||
|
||||
|
||||
timepos_t pos = current_time ();
|
||||
timepos_t pos = last_when ();
|
||||
timepos_t step = get_incremental_step (drag_field, pos);
|
||||
|
||||
step *= fabs (drag_accum);
|
||||
|
|
@ -1958,12 +1958,6 @@ AudioClock::get_incremental_step (Field field, timepos_t const & pos)
|
|||
return f;
|
||||
}
|
||||
|
||||
timepos_t
|
||||
AudioClock::current_time () const
|
||||
{
|
||||
return last_when();
|
||||
}
|
||||
|
||||
timecnt_t
|
||||
AudioClock::current_duration (timepos_t pos) const
|
||||
{
|
||||
|
|
@ -2238,7 +2232,7 @@ AudioClock::locate ()
|
|||
return;
|
||||
}
|
||||
|
||||
_session->request_locate (current_time().samples());
|
||||
_session->request_locate (last_when().samples());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
|||
|
||||
std::string name() const { return _name; }
|
||||
|
||||
Temporal::timepos_t current_time () const;
|
||||
Temporal::timepos_t last_when () const { return last_time.position(); }
|
||||
Temporal::timecnt_t current_duration (Temporal::timepos_t position = Temporal::timepos_t()) const;
|
||||
void set_session (ARDOUR::Session *s);
|
||||
void set_negative_allowed (bool yn);
|
||||
|
|
@ -194,7 +194,6 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
|||
std::string input_string;
|
||||
|
||||
Temporal::timecnt_t last_time;
|
||||
Temporal::timepos_t last_when() const { return last_time.position(); }
|
||||
|
||||
bool last_pdelta;
|
||||
bool last_sdelta;
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ AudioTriggerPropertiesBox::beats_changed ()
|
|||
void
|
||||
AudioTriggerPropertiesBox::start_clock_changed ()
|
||||
{
|
||||
trigger()->set_start(_start_clock.current_time());
|
||||
trigger()->set_start(_start_clock.last_when());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ EditNoteDialog::done (int r)
|
|||
boost::shared_ptr<ARDOUR::Region> region (_region_view->region ());
|
||||
|
||||
/* convert current clock time into an offset from the start of the source */
|
||||
timecnt_t const time_clock_source_relative = region->source_position ().distance (_time_clock.current_time ());
|
||||
timecnt_t const time_clock_source_relative = region->source_position ().distance (_time_clock.last_when ());
|
||||
|
||||
/* convert that into a position in Beats - this will be the new note time (as an offset inside the source) */
|
||||
Beats const new_note_time_source_relative_beats = time_clock_source_relative.beats ();
|
||||
|
|
|
|||
|
|
@ -191,13 +191,13 @@ InsertRemoveTimeDialog::move_locked_markers () const
|
|||
timepos_t
|
||||
InsertRemoveTimeDialog::position () const
|
||||
{
|
||||
return position_clock.current_time();
|
||||
return position_clock.last_when();
|
||||
}
|
||||
|
||||
timecnt_t
|
||||
InsertRemoveTimeDialog::distance () const
|
||||
{
|
||||
return duration_clock.current_duration (position_clock.current_time());
|
||||
return duration_clock.current_duration (position_clock.last_when());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -446,10 +446,10 @@ LocationEditRow::locate_button_pressed (LocationPart part)
|
|||
{
|
||||
switch (part) {
|
||||
case LocStart:
|
||||
_session->request_locate (start_clock.current_time().samples());
|
||||
_session->request_locate (start_clock.last_when().samples());
|
||||
break;
|
||||
case LocEnd:
|
||||
_session->request_locate (end_clock.current_time().samples());
|
||||
_session->request_locate (end_clock.last_when().samples());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -460,7 +460,7 @@ bool
|
|||
LocationEditRow::locate_to_clock (GdkEventButton* ev, AudioClock* clock)
|
||||
{
|
||||
if (Keyboard::is_button2_event (ev)) {
|
||||
_session->request_locate (clock->current_time().samples());
|
||||
_session->request_locate (clock->last_when().samples());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -475,10 +475,10 @@ LocationEditRow::clock_changed (LocationPart part)
|
|||
|
||||
switch (part) {
|
||||
case LocStart:
|
||||
location->set_start (start_clock.current_time(), false);
|
||||
location->set_start (start_clock.last_when(), false);
|
||||
break;
|
||||
case LocEnd:
|
||||
location->set_end (end_clock.current_time(), false);
|
||||
location->set_end (end_clock.last_when(), false);
|
||||
if (location->is_session_range()) {
|
||||
_session->set_session_range_is_free (false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,9 +101,9 @@ timepos_t
|
|||
MainClock::absolute_time () const
|
||||
{
|
||||
if (get_is_duration ()) {
|
||||
return current_time ();
|
||||
return last_when ();
|
||||
} else {
|
||||
return current_time ();
|
||||
return last_when ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -668,7 +668,7 @@ void
|
|||
ClockOption::save_clock_time ()
|
||||
{
|
||||
Timecode::Time TC;
|
||||
_session->sample_to_timecode (_clock.current_time().samples(), TC, false, false);
|
||||
_session->sample_to_timecode (_clock.last_when().samples(), TC, false, false);
|
||||
_set (Timecode::timecode_format_time(TC));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ PatchChangeDialog::patch () const
|
|||
Temporal::Beats t = Temporal::Beats();
|
||||
|
||||
if (_region) {
|
||||
t = _region->absolute_time_to_source_beats (_time.current_time ());
|
||||
t = _region->absolute_time_to_source_beats (_time.last_when ());
|
||||
}
|
||||
|
||||
return Evoral::PatchChange<Temporal::Beats> (
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ RegionEditor::position_clock_changed ()
|
|||
in_command = true;
|
||||
|
||||
_region->clear_changes ();
|
||||
_region->set_position (position_clock.current_time());
|
||||
_region->set_position (position_clock.last_when());
|
||||
_session->add_command(new StatefulDiffCommand (_region));
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ RegionEditor::end_clock_changed ()
|
|||
in_command = true;
|
||||
|
||||
_region->clear_changes ();
|
||||
_region->trim_end (end_clock.current_time());
|
||||
_region->trim_end (end_clock.last_when());
|
||||
_session->add_command(new StatefulDiffCommand (_region));
|
||||
}
|
||||
|
||||
|
|
@ -425,7 +425,7 @@ RegionEditor::sync_offset_absolute_clock_changed ()
|
|||
PublicEditor::instance().begin_reversible_command (_("change region sync point"));
|
||||
|
||||
_region->clear_changes ();
|
||||
_region->set_sync_position (sync_offset_absolute_clock.current_time());
|
||||
_region->set_sync_position (sync_offset_absolute_clock.last_when());
|
||||
_session->add_command (new StatefulDiffCommand (_region));
|
||||
|
||||
PublicEditor::instance().commit_reversible_command ();
|
||||
|
|
@ -437,7 +437,7 @@ RegionEditor::sync_offset_relative_clock_changed ()
|
|||
PublicEditor::instance().begin_reversible_command (_("change region sync point"));
|
||||
|
||||
_region->clear_changes ();
|
||||
_region->set_sync_position (sync_offset_relative_clock.current_time() + _region->position ());
|
||||
_region->set_sync_position (sync_offset_relative_clock.last_when() + _region->position ());
|
||||
_session->add_command (new StatefulDiffCommand (_region));
|
||||
|
||||
PublicEditor::instance().commit_reversible_command ();
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ TimeInfoBox::clock_button_release_event (GdkEventButton* ev, AudioClock* src)
|
|||
|
||||
if (ev->button == 1) {
|
||||
if (!src->off()) {
|
||||
_session->request_locate (src->current_time ().samples());
|
||||
_session->request_locate (src->last_when ().samples());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue