diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index df344a5124..37f1a9865a 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -366,8 +366,8 @@ ARDOUR_UI::setup_transport () set_size_request_to_display_given_text (io_latency_value, "1000 spl", 0, 0); /* connect signals */ - ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (primary_clock, &MainClock::set), false, timecnt_t::zero (Temporal::AudioTime))); - ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (secondary_clock, &MainClock::set), false, timecnt_t::zero (Temporal::AudioTime))); + ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (primary_clock, &MainClock::set), false)); + ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (secondary_clock, &MainClock::set), false)); primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed)); secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed)); diff --git a/gtk2_ardour/ardour_ui3.cc b/gtk2_ardour/ardour_ui3.cc index 4cd2ef1585..67c4f69263 100644 --- a/gtk2_ardour/ardour_ui3.cc +++ b/gtk2_ardour/ardour_ui3.cc @@ -185,12 +185,12 @@ ARDOUR_UI::update_transport_clocks (samplepos_t p) primary_clock->set (pos); break; case DeltaEditPoint: - primary_clock->set (pos, false, timecnt_t (editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD))); + primary_clock->set_duration (pos.distance (editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD)), false); break; case DeltaOriginMarker: { Location* loc = _session->locations()->clock_origin_location (); - primary_clock->set (pos, false, timecnt_t (loc ? loc->start_sample() : 0)); + primary_clock->set_duration (pos.distance (loc->start())); } break; } @@ -200,12 +200,12 @@ ARDOUR_UI::update_transport_clocks (samplepos_t p) secondary_clock->set (pos); break; case DeltaEditPoint: - secondary_clock->set (pos, false, timecnt_t (editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD))); + secondary_clock->set_duration (pos.distance (editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD)), false); break; case DeltaOriginMarker: { Location* loc = _session->locations()->clock_origin_location (); - secondary_clock->set (pos, false, timecnt_t (loc ? loc->start_sample() : 0)); + secondary_clock->set_duration (pos.distance (loc->start())); } break; } diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc index 8b262dbd58..68de11e1df 100644 --- a/gtk2_ardour/ardour_ui_options.cc +++ b/gtk2_ardour/ardour_ui_options.cc @@ -380,21 +380,17 @@ ARDOUR_UI::parameter_changed (std::string p) if (editor) editor->toggle_meter_updating(); } else if (p == "primary-clock-delta-mode") { if (UIConfiguration::instance().get_primary_clock_delta_mode() != NoDelta) { - primary_clock->set_is_duration (true, timepos_t()); primary_clock->set_editable (false); primary_clock->set_widget_name ("transport delta"); } else { - primary_clock->set_is_duration (false, timepos_t()); primary_clock->set_editable (true); primary_clock->set_widget_name ("transport"); } } else if (p == "secondary-clock-delta-mode") { if (UIConfiguration::instance().get_secondary_clock_delta_mode() != NoDelta) { - secondary_clock->set_is_duration (true, timepos_t()); secondary_clock->set_editable (false); secondary_clock->set_widget_name ("secondary delta"); } else { - secondary_clock->set_is_duration (false, timepos_t()); secondary_clock->set_editable (true); secondary_clock->set_widget_name ("secondary"); } diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index b25e1f6c22..fdd1e795e7 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -101,7 +101,6 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string& , corner_radius (4) , font_size (10240) , editing (false) - , bbt_reference_time (timepos_t::from_superclock (-1)) /* needs to be some negative value but SR may not be available at init */ , last_pdelta (0) , last_sdelta (0) , dragging (false) @@ -120,7 +119,7 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string& _mode = BBT; /* lie to force mode switch */ set_mode (Timecode); - AudioClock::set (last_when, true); + AudioClock::set (last_when(), true); if (!is_transient) { clocks.push_back (this); @@ -523,7 +522,7 @@ AudioClock::end_edit (bool modify) case BBT: if (is_duration) { - pos = sample_duration_from_bbt_string (bbt_reference_time, edit_string); + pos = sample_duration_from_bbt_string (last_when(), edit_string); } else { pos = samples_from_bbt_string (timepos_t(), edit_string); } @@ -807,7 +806,7 @@ AudioClock::end_edit_relative (bool add) void AudioClock::tempo_map_changed () { - AudioClock::set (last_when, true); + AudioClock::set (last_when(), true); } void @@ -819,69 +818,71 @@ AudioClock::session_configuration_changed (std::string p) } if (p == "sync-source" || p == "external-sync") { - AudioClock::set (current_time(), true); - return; - } - - if (p != "timecode-offset" && p != "timecode-offset-negative") { - return; - } - - timepos_t current; - - switch (_mode) { - case Timecode: if (is_duration) { - current = timepos_t (current_duration ()); + AudioClock::set_duration (current_duration(), true); } else { - current = current_time (); + AudioClock::set (current_time(), true); + } + return; + } + + if (p == "timecode-offset" && p == "timecode-offset-negative") { + switch (_mode) { + case Timecode: + if (is_duration) { + AudioClock::set_duration (current_duration(), true); + } else { + AudioClock::set (current_time(), true); + } + break; + default: + break; } - AudioClock::set (current, true); - break; - default: - break; } } void -AudioClock::set (timepos_t const & w, bool force, timecnt_t const & offset) +AudioClock::set_duration (Temporal::timecnt_t const & dur, bool force) { - timepos_t when (w); + is_duration = true; if ((!force && !get_visible()) || !_session) { return; } - _offset = offset; - if (is_duration) { - when = when.earlier (offset); + timepos_t when; + + /* extent semantics, not length */ + + timecnt_t d; + + /* durations for timecode display should use extent, not length + * + * reminder: length = end - start ; extent = end - start - 1 + * + * start + length = end + * start + extent = last_point_inside duration + */ + + switch (_mode) { + case Timecode: + d = dur.is_zero() ? dur : dur.decrement_by_domain (); + break; + default: + d = dur; + break; } - if (when > _limit_pos) { - when = _limit_pos; - } else if (when < -_limit_pos) { - when = -_limit_pos; + /* Converting a negative duration to a position throws */ + + if (d.is_negative()) { + when = timepos_t (d); + } else { + when = -timepos_t (-d); } - if (when == last_when && !force) { -#if 0 // XXX return if no change and no change forced. verify Aug/2014 - if (_mode != Timecode && _mode != MinSec) { - /* may need to force display of TC source - * time, so don't return early. - */ - /* ^^ Why was that?, delta times? - * Timecode FPS, pull-up/down, etc changes - * trigger a 'session_property_changed' which - * eventually calls set(last_when, true) - * - * re-rendering the clock every 40ms or so just - * because we can is not ideal. - */ - return; - } -#else + if (when == last_when() && !force) { return; -#endif } bool btn_en = false; @@ -894,7 +895,7 @@ AudioClock::set (timepos_t const & w, bool force, timecnt_t const & offset) break; case BBT: - set_bbt (when, offset, force); + set_bbt (dur, force); btn_en = true; break; @@ -913,12 +914,61 @@ AudioClock::set (timepos_t const & w, bool force, timecnt_t const & offset) } finish_set (when, btn_en); + last_time = dur; } void -AudioClock::set_duration (Temporal::timecnt_t const & d, bool force, Temporal::timecnt_t const & offset) +AudioClock::set (timepos_t const & w, bool force) { - set (timepos_t (d), force, offset); + is_duration = false; + + timepos_t when (w); + + if ((!force && !get_visible()) || !_session) { + return; + } + + if (when > _limit_pos) { + when = _limit_pos; + } else if (when < -_limit_pos) { + when = -_limit_pos; + } + + if (when == last_when() && !force) { + return; + } + + bool btn_en = false; + + if (!editing) { + + switch (_mode) { + case Timecode: + set_timecode (when, force); + break; + + case BBT: + set_bbt (timecnt_t (when), force); + btn_en = true; + break; + + case MinSec: + set_minsec (when, force); + break; + + case Seconds: + set_seconds (when, force); + break; + + case Samples: + set_samples (when, force); + break; + } + } + + finish_set (when, btn_en); + + last_time = timecnt_t (last_time.distance(), when); } void @@ -947,7 +997,6 @@ AudioClock::finish_set (Temporal::timepos_t const & when, bool btn_en) } queue_draw (); - last_when = when; } void @@ -1209,49 +1258,44 @@ AudioClock::set_timecode (timepos_t const & w, bool /*force*/) } void -AudioClock::set_bbt (timepos_t const & w, timecnt_t const & o, bool /*force*/) +AudioClock::set_bbt (timecnt_t const & w, bool /*force*/) { - timepos_t when (w); - timecnt_t offset (o); + timepos_t pos (w); char buf[64]; Temporal::BBT_Time BBT; bool negative = false; - if (_off || when >= _limit_pos || when < -_limit_pos) { + if (_off || pos >= _limit_pos || pos < -_limit_pos) { _layout->set_text (" ---|--|----"); _left_btn.set_text ("", false); _right_btn.set_text ("", false); return; } - if (when.is_negative ()) { - when = -when; + if (pos.is_negative ()) { + pos = -pos; negative = true; } /* handle a common case */ if (is_duration) { - if (when.is_zero ()) { + if (pos.is_zero ()) { BBT.bars = 0; BBT.beats = 0; BBT.ticks = 0; } else { TempoMap::SharedPtr tmap (TempoMap::use()); - if (offset.is_zero ()) { - offset = timecnt_t (bbt_reference_time); - } - - const int divisions = tmap->meter_at (timepos_t (offset)).divisions_per_bar(); + const int divisions = tmap->meter_at (w.position()).divisions_per_bar(); Temporal::BBT_Time sub_bbt; if (negative) { - BBT = tmap->bbt_at (timepos_t (tmap->quarters_at (timepos_t (offset)))); - sub_bbt = tmap->bbt_at (timepos_t (offset - when)); + BBT = tmap->bbt_at (timepos_t (tmap->quarters_at (w.position()))); + sub_bbt = tmap->bbt_at (last_when().earlier (w.position())); } else { - BBT = tmap->bbt_at (timepos_t (tmap->quarters_at (when + offset))); - sub_bbt = tmap->bbt_at (timepos_t (offset)); + BBT = tmap->bbt_at (timepos_t (tmap->quarters_at (w.end()))); + sub_bbt = tmap->bbt_at (w.position()); } BBT.bars -= sub_bbt.bars; @@ -1276,7 +1320,7 @@ AudioClock::set_bbt (timepos_t const & w, timecnt_t const & o, bool /*force*/) } } } else { - BBT = TempoMap::use()->bbt_at (when); + BBT = TempoMap::use()->bbt_at (pos); } if (negative) { @@ -1290,13 +1334,6 @@ AudioClock::set_bbt (timepos_t const & w, timecnt_t const & o, bool /*force*/) _layout->set_text (buf); if (_with_info) { - timepos_t pos; - - if (bbt_reference_time.is_negative ()) { - pos = when; - } else { - pos = bbt_reference_time; - } TempoMetric m (TempoMap::use()->metric_at (pos)); @@ -1356,7 +1393,7 @@ AudioClock::set_session (Session *s) } } - AudioClock::set (last_when, true); + AudioClock::set (last_when(), true); } } @@ -1927,7 +1964,7 @@ AudioClock::get_incremental_step (Field field, timepos_t const & pos) timepos_t AudioClock::current_time () const { - return last_when; + return last_when(); } timecnt_t @@ -1944,7 +1981,7 @@ AudioClock::current_duration (timepos_t pos) const case MinSec: case Seconds: case Samples: - ret = timecnt_t (last_when, pos); + ret = timecnt_t (last_when(), pos); break; } @@ -1954,28 +1991,28 @@ AudioClock::current_duration (timepos_t pos) const bool AudioClock::bbt_validate_edit (string & str) { - AnyTime any; + BBT_Time bbt; - if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &any.bbt.bars, &any.bbt.beats, &any.bbt.ticks) != 3) { + if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &bbt.bars, &bbt.beats, &bbt.ticks) != 3) { return false; } - if (any.bbt.ticks > Temporal::ticks_per_beat) { + if (bbt.ticks > Temporal::ticks_per_beat) { return false; } - if (!is_duration && any.bbt.bars == 0) { + if (!is_duration && bbt.bars == 0) { return false; } - if (!is_duration && any.bbt.beats == 0) { + if (!is_duration && bbt.beats == 0) { /* user could not have mean zero beats because for a * non-duration clock that's impossible. Assume that they * mis-entered things and meant Bar|1|ticks */ char buf[128]; - snprintf (buf, sizeof (buf), "%" PRIu32 "|%" PRIu32 "|%" PRIu32, any.bbt.bars, 1, any.bbt.ticks); + snprintf (buf, sizeof (buf), "%" PRIu32 "|%" PRIu32 "|%" PRIu32, bbt.bars, 1, bbt.ticks); str = buf; } @@ -2278,7 +2315,7 @@ AudioClock::set_mode (Mode m, bool noemit) break; } - AudioClock::set (last_when, true); + AudioClock::set (last_when(), true); if (!is_transient && !noemit) { ModeChanged (); /* EMIT SIGNAL (the static one)*/ @@ -2287,12 +2324,6 @@ AudioClock::set_mode (Mode m, bool noemit) mode_changed (); /* EMIT SIGNAL (the member one) */ } -void -AudioClock::set_bbt_reference (timepos_t const & pos) -{ - bbt_reference_time = pos; -} - void AudioClock::on_style_changed (const Glib::RefPtr& old_style) { @@ -2319,28 +2350,6 @@ AudioClock::set_editable (bool yn) editable = yn; } -void -AudioClock::set_is_duration (bool yn, timepos_t const & p) -{ - if (yn == is_duration) { - if (yn) { - /* just reset position */ - duration_position = p; - } - - return; - } - - is_duration = yn; - if (yn) { - duration_position = p; - } else { - duration_position = timepos_t (); - } - - set (last_when, true); -} - void AudioClock::set_off (bool yn) { @@ -2350,11 +2359,15 @@ AudioClock::set_off (bool yn) _off = yn; - /* force a redraw. last_when will be preserved, but the clock text will + /* force a redraw. last_time will be preserved, but the clock text will * change */ - AudioClock::set (last_when, true); + if (is_duration) { + AudioClock::set_duration (last_time, true); + } else { + AudioClock::set (last_when(), true); + } } void diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index f671d8c6b9..48f30dae89 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -73,14 +73,14 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr void focus (); - virtual void set (Temporal::timepos_t const &, bool force = false, Temporal::timecnt_t const & offset = Temporal::timecnt_t()); - void set_duration (Temporal::timecnt_t const &, bool force = false, Temporal::timecnt_t const & offset = Temporal::timecnt_t()); + /* overriden by MainClock */ + virtual void set (Temporal::timepos_t const &, bool force = false); + void set_duration (Temporal::timecnt_t const &, bool force = false); void set_from_playhead (); void locate (); void set_mode (Mode, bool noemit = false); void set_bbt_reference (Temporal::timepos_t const &); - void set_is_duration (bool, Temporal::timepos_t const &); void copy_text_to_clipboard () const; @@ -199,8 +199,9 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr std::string pre_edit_string; std::string input_string; - Temporal::timepos_t bbt_reference_time; - Temporal::timepos_t last_when; + Temporal::timecnt_t last_time; + Temporal::timepos_t last_when() const { return last_time.position(); } + bool last_pdelta; bool last_sdelta; @@ -221,7 +222,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr void set_slave_info (); void set_timecode (Temporal::timepos_t const &, bool); - void set_bbt (Temporal::timepos_t const &, Temporal::timecnt_t const &, bool); + void set_bbt (Temporal::timecnt_t const &, bool); void set_minsec (Temporal::timepos_t const &, bool); void set_seconds (Temporal::timepos_t const &, bool); void set_samples (Temporal::timepos_t const &, bool); diff --git a/gtk2_ardour/big_clock_window.cc b/gtk2_ardour/big_clock_window.cc index ecb3c12492..dfabc440f7 100644 --- a/gtk2_ardour/big_clock_window.cc +++ b/gtk2_ardour/big_clock_window.cc @@ -39,7 +39,7 @@ BigClockWindow::BigClockWindow (AudioClock& c) : ArdourWindow (_("Big Clock")) , clock (c) { - ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (clock, &AudioClock::set), false, Temporal::timecnt_t())); + ARDOUR_UI::Clock.connect (sigc::bind (sigc::mem_fun (clock, &AudioClock::set), false)); clock.set_corner_radius (0.0); diff --git a/gtk2_ardour/edit_note_dialog.cc b/gtk2_ardour/edit_note_dialog.cc index 13ab3930d6..8e11ccebea 100644 --- a/gtk2_ardour/edit_note_dialog.cc +++ b/gtk2_ardour/edit_note_dialog.cc @@ -97,9 +97,7 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, set n) _time_clock.set_session (_region_view->get_time_axis_view().session ()); _time_clock.set_mode (AudioClock::BBT); - timecnt_t dur = _region_view->source_relative_distance (timecnt_t ((*_events.begin())->note()->time(), timepos_t()), BeatTime); - timepos_t pos = _region_view->region()->source_position() + dur; - + const timepos_t pos (_region_view->region_relative_distance (timecnt_t ((*_events.begin())->note()->time (), timepos_t()), BeatTime)); _time_clock.set (pos, true); l = manage (left_aligned_label (_("Length"))); @@ -110,15 +108,7 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, set n) _length_clock.set_session (_region_view->get_time_axis_view().session ()); _length_clock.set_mode (AudioClock::BBT); - - dur = _region_view->region_relative_distance (timecnt_t ((*_events.begin())->note()->end_time (), timepos_t()), BeatTime); - pos = _region_view->region()->position() + dur; - timecnt_t offset; - dur = _region_view->region_relative_distance (timecnt_t ((*_events.begin())->note()->time (), timepos_t()), BeatTime); - offset = timecnt_t (_region_view->region()->position(), timepos_t()) + dur; - - _length_clock.set_is_duration (true, pos); - _length_clock.set (pos, true, offset); + _length_clock.set_duration (timecnt_t ((*_events.begin())->note()->length()), true); /* Set up `set all notes...' buttons' sensitivity */ diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 48d3ca6fcd..4af0414758 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -4333,7 +4333,7 @@ MarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) s = min (s, e); e = max (s, e); if (e < timepos_t::max (e.time_domain())) { - e.increment(); + e.increment_by_domain(); } _editor->session()->locations()->find_all_between (s, e, ll, Location::Flags (0)); for (Locations::LocationList::iterator i = ll.begin(); i != ll.end(); ++i) { @@ -6632,7 +6632,7 @@ EditorRubberbandSelectDrag::select_things (int button_state, timepos_t const & x _editor->begin_reversible_selection_op (X_("rubberband selection")); - _editor->select_all_within (x1, x2.decrement(), y1, y2, _editor->track_views, op, false); + _editor->select_all_within (x1, x2.decrement_by_domain(), y1, y2, _editor->track_views, op, false); _editor->commit_reversible_selection_op (); } diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index f4cdf6a6f1..092a30979f 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -1310,7 +1310,7 @@ Editor::marker_menu_select_all_selectables_using_range () bool is_start; if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) { - select_all_within (l->start(), l->end().decrement(), 0, DBL_MAX, track_views, Selection::Set, false); + select_all_within (l->start(), l->end(), 0, DBL_MAX, track_views, Selection::Set, false); } } diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index f2dd50629c..82639bc66c 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -350,7 +350,7 @@ Editor::move_range_selection_start_or_end_to_region_boundary (bool move_end, boo /* so we don't find the current region again */ if (dir > 0 || pos.is_positive()) { - pos = pos.increment (); + pos = pos.increment_by_domain (); } timepos_t const target = get_region_boundary (pos, dir, true, false); @@ -835,7 +835,7 @@ Editor::build_region_boundary_cache () } } - pos = lpos.increment(); + pos = lpos.increment_by_domain(); } /* finally sort to be sure that the order is correct */ @@ -976,7 +976,7 @@ Editor::cursor_to_region_boundary (bool with_selection, int32_t dir) // so we don't find the current region again.. if (dir > 0 || pos > 0) { - pos = pos.increment(); + pos = pos.increment_by_domain(); } if ((target = get_region_boundary (pos, dir, with_selection, false)) < 0) { @@ -1012,7 +1012,7 @@ Editor::cursor_to_region_point (EditorCursor* cursor, RegionPoint point, int32_t // so we don't find the current region again.. if (dir > 0 || pos.is_positive()) - pos = pos.increment(); + pos = pos.increment_by_domain(); if (!selection->tracks.empty()) { @@ -1155,7 +1155,7 @@ Editor::selected_marker_to_region_boundary (bool with_selection, int32_t dir) // so we don't find the current region again.. if (dir > 0 || pos.is_positive()) { - pos = pos.increment(); + pos = pos.increment_by_domain(); } if ((target = get_region_boundary (pos, dir, with_selection, false)) < 0) { @@ -1199,7 +1199,7 @@ Editor::selected_marker_to_region_point (RegionPoint point, int32_t dir) // so we don't find the current region again.. if (dir > 0 || pos > 0) { - pos = pos.increment(); + pos = pos.increment_by_domain(); } if (!selection->tracks.empty()) { @@ -3428,7 +3428,7 @@ Editor::separate_under_selected_regions () } //Partition on the region bounds - playlist->partition ((*rl)->position().decrement(), (*rl)->end(), true); + playlist->partition ((*rl)->position().decrement_by_domain(), (*rl)->end(), true); //Re-add region that was just removed due to the partition operation playlist->add_region ((*rl), (*rl)->position()); @@ -3553,7 +3553,7 @@ Editor::region_fill_track () timepos_t const end (_session->current_end_sample ()); - if (regions.empty () || regions.end_time().increment() >= end) { + if (regions.empty () || regions.end_time().increment_by_domain() >= end) { return; } @@ -3972,7 +3972,8 @@ Editor::trim_to_region(bool forward) continue; } - region->trim_end (next_region->position().decrement()); + /* new end is 1 domain unit before the next region */ + region->trim_end (next_region->position().decrement_by_domain()); arv->region_changed (PropertyChange (ARDOUR::Properties::length)); } else { @@ -9634,7 +9635,7 @@ Editor::effective_ripple_mark_start (boost::shared_ptr target_playlist } if (last_region_end_before_at < pos) { - pos = last_region_end_before_at.increment(); + pos = last_region_end_before_at.increment_by_domain(); } #endif diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 0f57542e97..cdcccf8d74 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -2186,7 +2186,7 @@ Editor::select_all_selectables_using_edit (bool after, bool from_context_menu) } else { if ((end = get_preferred_edit_position(EDIT_IGNORE_NONE, from_context_menu)) > 1) { start = timepos_t (); - end = end.decrement(); + end = end.decrement_by_domain(); } else { return; } diff --git a/gtk2_ardour/insert_remove_time_dialog.cc b/gtk2_ardour/insert_remove_time_dialog.cc index 55883cc7ac..89136865d5 100644 --- a/gtk2_ardour/insert_remove_time_dialog.cc +++ b/gtk2_ardour/insert_remove_time_dialog.cc @@ -74,14 +74,10 @@ InsertRemoveTimeDialog::InsertRemoveTimeDialog (PublicEditor& e, bool remove) //if a Range is selected, assume the user wants to insert/remove the length of the range if ( _editor.get_selection().time.length() != 0 ) { - position_clock.set (_editor.get_selection().time.start_time(), true); - duration_clock.set (_editor.get_selection().time.end_time(), true, timecnt_t (_editor.get_selection().time.start_time())); - duration_clock.set_bbt_reference (_editor.get_selection().time.start_time()); + duration_clock.set_duration (_editor.get_selection().time.start_time().distance (_editor.get_selection().time.start_time()), true); } else { timepos_t const pos = _editor.get_preferred_edit_position (EDIT_IGNORE_MOUSE); - position_clock.set (pos, true); - duration_clock.set_bbt_reference (pos); - duration_clock.set (timepos_t()); + duration_clock.set_duration (timecnt_t (pos)); } if (!remove) { diff --git a/gtk2_ardour/main_clock.cc b/gtk2_ardour/main_clock.cc index 1ffd903ab2..d098240bdb 100644 --- a/gtk2_ardour/main_clock.cc +++ b/gtk2_ardour/main_clock.cc @@ -108,7 +108,7 @@ MainClock::absolute_time () const } void -MainClock::set (timepos_t const & when, bool force, timecnt_t const & /*offset*/) +MainClock::set (timepos_t const & when, bool force) { ClockDeltaMode mode; if (_primary) { @@ -126,12 +126,12 @@ MainClock::set (timepos_t const & when, bool force, timecnt_t const & /*offset*/ AudioClock::set (when, force); break; case DeltaEditPoint: - AudioClock::set (when, force, timecnt_t (PublicEditor::instance().get_preferred_edit_position (Editing::EDIT_IGNORE_PHEAD))); + AudioClock::set_duration (when.distance (PublicEditor::instance().get_preferred_edit_position (Editing::EDIT_IGNORE_PHEAD)), force); break; case DeltaOriginMarker: { Location* loc = AudioEngine::instance()->session()->locations()->clock_origin_location (); - AudioClock::set (when, force, loc ? timecnt_t (loc->start()) : timecnt_t()); + AudioClock::set_duration (when.distance (loc ? loc->start() : timepos_t (when.time_domain())), force); } break; } diff --git a/gtk2_ardour/main_clock.h b/gtk2_ardour/main_clock.h index c8e89fd549..a87ca600c5 100644 --- a/gtk2_ardour/main_clock.h +++ b/gtk2_ardour/main_clock.h @@ -31,7 +31,7 @@ public: MainClock (const std::string& clock_name, const std::string& widget_name, bool primary); Temporal::timepos_t absolute_time () const; void set_session (ARDOUR::Session *s); - void set (Temporal::timepos_t const &, bool force = false, Temporal::timecnt_t const & offset = Temporal::timecnt_t ()); + void set (Temporal::timepos_t const &, bool force = false); private: diff --git a/gtk2_ardour/region_editor.cc b/gtk2_ardour/region_editor.cc index b7c5f6e717..242e537984 100644 --- a/gtk2_ardour/region_editor.cc +++ b/gtk2_ardour/region_editor.cc @@ -334,7 +334,11 @@ RegionEditor::length_clock_changed () in_command = true; _region->clear_changes (); - _region->trim_end (_region->position() + len.decrement()); + /* new end is actually 1 domain unit before the clock duration + * would otherwise indicate + */ + const timepos_t new_end = (_region->position() + len).decrement_by_domain (); + _region->trim_end (new_end); _session->add_command(new StatefulDiffCommand (_region)); } diff --git a/gtk2_ardour/region_selection.cc b/gtk2_ardour/region_selection.cc index 7f3309eade..913d642b3c 100644 --- a/gtk2_ardour/region_selection.cc +++ b/gtk2_ardour/region_selection.cc @@ -316,7 +316,7 @@ RegionSelection::end_time () const timepos_t e (timepos_t::zero (front()->region()->position().time_domain())); for (RegionSelection::const_iterator i = begin(); i != end(); ++i) { - e = max (e, (*i)->region()->end ()); + e = max (e, (*i)->region()->nt_last ()); } return e; diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 143d49f019..7f7e43af83 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -1008,7 +1008,7 @@ RegionView::update_coverage_frame (LayerDisplay d) while (t < end) { - t = t.increment (); + t = t.increment_by_domain (); /* is this region is on top at time t? */ bool const new_me = pl->region_is_audible_at (_region, t); @@ -1086,7 +1086,7 @@ RegionView::trim_front (timepos_t const & new_bound, bool no_overlap) /* Only trim region on the left if the first sample has gone beyond the left region's last sample. */ if (region_left && (region_left->nt_last() > _region->position() || regions_touching)) { - region_left->trim_end (_region->position().decrement()); + region_left->trim_end (_region->position().decrement_by_domain()); } } @@ -1113,7 +1113,7 @@ RegionView::trim_end (timepos_t const & new_bound, bool no_overlap) bool regions_touching = false; - if (region_right && (last == region_right->position().decrement())) { + if (region_right && (last == region_right->position().decrement_by_domain())) { regions_touching = true; } diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index dd50cefa8d..ea3e8eef63 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -218,7 +218,6 @@ SoundFileBox::SoundFileBox (bool /*persistent*/) table.attach (timecode_clock, 1, 2, row, row+1, FILL, FILL); row+=1; table.attach (tempomap_value, 1, 2, row, row+1, FILL, FILL); row+=1; - length_clock.set_is_duration (true, timepos_t()); length_clock.set_mode (ARDOUR_UI::instance()->primary_clock->mode()); timecode_clock.set_mode (AudioClock::Timecode); @@ -380,7 +379,7 @@ SoundFileBox::setup_labels (const string& filename) } } else { channels_value.set_text (""); - length_clock.set (timepos_t()); + length_clock.set_duration (timecnt_t()); tempomap_value.set_text (_("No tempo data")); } @@ -401,7 +400,7 @@ SoundFileBox::setup_labels (const string& filename) samplerate_value.set_text (""); tags_entry.get_buffer()->set_text (""); - length_clock.set (timepos_t()); + length_clock.set_duration (timecnt_t()); timecode_clock.set (timepos_t()); tags_entry.set_sensitive (false); @@ -433,7 +432,6 @@ SoundFileBox::setup_labels (const string& filename) samplecnt_t const nfr = _session ? _session->nominal_sample_rate() : 25; double src_coef = (double) nfr / sf_info.samplerate; - length_clock.set_is_duration (true, timepos_t()); length_clock.set_duration (timecnt_t (samplecnt_t (llrint (sf_info.length * src_coef + 0.5))), true); timecode_clock.set (timepos_t (samplepos_t (llrint (sf_info.timecode * src_coef + 0.5))), true); diff --git a/gtk2_ardour/strip_silence_dialog.cc b/gtk2_ardour/strip_silence_dialog.cc index 1222e2f2f2..88108ed071 100644 --- a/gtk2_ardour/strip_silence_dialog.cc +++ b/gtk2_ardour/strip_silence_dialog.cc @@ -63,9 +63,6 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list const & v) views.push_back (ViewInterval (*r)); } - _minimum_length->set_is_duration (true, views.front().view->region()->position()); - _fade_length->set_is_duration (true, views.front().view->region()->position()); - Gtk::HBox* hbox = Gtk::manage (new Gtk::HBox); Gtk::Table* table = Gtk::manage (new Gtk::Table (3, 3)); @@ -106,7 +103,6 @@ StripSilenceDialog::StripSilenceDialog (Session* s, list const & v) _fade_length->set_session (s); _fade_length->set_mode (AudioClock::Samples); - _fade_length->set_is_duration (true, timepos_t()); _fade_length->set_duration (timecnt_t (_fade_length_value), true); hbox->pack_start (*table); diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index aed370613e..99301ccfda 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -895,7 +895,7 @@ TimeAxisView::show_selection (TimeSelection& ts) rect = get_selection_rect ((*i).id); x1 = _editor.time_to_pixel (start); - x2 = _editor.time_to_pixel (end.decrement()); + x2 = _editor.time_to_pixel (end.decrement_by_domain()); y2 = current_height() - 1; if (dynamic_cast(this)) { diff --git a/gtk2_ardour/time_fx_dialog.cc b/gtk2_ardour/time_fx_dialog.cc index aa83b5181d..bdd9296442 100644 --- a/gtk2_ardour/time_fx_dialog.cc +++ b/gtk2_ardour/time_fx_dialog.cc @@ -148,9 +148,8 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, timecnt_t const & oldlen, tim vector strings; duration_clock = manage (new AudioClock (X_("stretch"), true, X_("stretch"), true, false, true, false, true)); duration_clock->set_session (e.session()); - duration_clock->set (timepos_t (new_length), true); duration_clock->set_mode (AudioClock::BBT); - duration_clock->set_bbt_reference (position); + duration_clock->set_duration (timecnt_t (new_length, position)); Gtk::Alignment* clock_align = manage (new Gtk::Alignment); clock_align->add (*duration_clock); diff --git a/gtk2_ardour/time_info_box.cc b/gtk2_ardour/time_info_box.cc index df472e28e0..82c47b4a19 100644 --- a/gtk2_ardour/time_info_box.cc +++ b/gtk2_ardour/time_info_box.cc @@ -242,8 +242,8 @@ TimeInfoBox::region_selection_changed () selection_end->set_off (false); selection_length->set_off (false); selection_start->set (s); - selection_end->set (e); - selection_length->set_duration (timecnt_t (e), false, timecnt_t (s)); + selection_end->set (e.decrement_by_domain()); + selection_length->set_duration (s.distance (e), true); } void @@ -273,8 +273,7 @@ TimeInfoBox::selection_changed () selection_end->set_off (false); selection_length->set_off (false); selection_start->set (selection.time.start_time()); - selection_end->set (selection.time.end_time()); - selection_length->set_is_duration (true, selection.time.start_time()); + selection_end->set (selection.time.end_time().decrement_by_domain()); selection_length->set_duration (selection.time.start_time().distance (selection.time.end_time())); } else { selection_start->set_off (true); @@ -293,9 +292,8 @@ TimeInfoBox::selection_changed () selection_end->set_off (false); selection_length->set_off (false); selection_start->set (s); - selection_end->set (e); - selection_length->set_is_duration (true, s); - selection_length->set (e, false, timecnt_t (s)); + selection_end->set (e.decrement_by_domain()); + selection_length->set_duration (s.distance (e), false); } } else { /* this is more efficient than tracking changes per region in large selections */ @@ -326,9 +324,8 @@ TimeInfoBox::selection_changed () selection_end->set_off (false); selection_length->set_off (false); selection_start->set (s); - selection_end->set (e); - selection_length->set_is_duration (true, s); - selection_length->set (e, false, timecnt_t (s)); + selection_end->set (e.decrement_by_domain()); + selection_length->set_duration(s.distance (e)); } else { selection_start->set_off (true); selection_end->set_off (true); @@ -339,9 +336,8 @@ TimeInfoBox::selection_changed () selection_end->set_off (false); selection_length->set_off (false); selection_start->set (selection.time.start_time()); - selection_end->set (selection.time.end_time()); - selection_length->set_is_duration (true, selection.time.start_time()); - selection_length->set_duration (selection.time.start_time().distance (selection.time.end_time())); + selection_end->set (selection.time.end_time().decrement_by_domain()); + selection_length->set_duration (selection.time.length()); } break;