From 3c03e4951edc4164e51297c968e3567822a4d635 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 11 Dec 2021 15:51:31 +0100 Subject: [PATCH] Use updated temporal API 2/2 --- gtk2_ardour/audio_clock.cc | 26 +++++++++++++------------- gtk2_ardour/automation_line.cc | 2 +- gtk2_ardour/editor.cc | 4 ++-- gtk2_ardour/editor_canvas.cc | 2 +- gtk2_ardour/editor_drag.cc | 16 ++++++++-------- gtk2_ardour/editor_export_audio.cc | 2 +- gtk2_ardour/editor_markers.cc | 2 +- gtk2_ardour/editor_mouse.cc | 2 +- gtk2_ardour/editor_ops.cc | 14 +++++++------- gtk2_ardour/editor_selection.cc | 2 +- gtk2_ardour/editor_sources.cc | 2 +- gtk2_ardour/midi_region_view.cc | 6 +++--- gtk2_ardour/region_view.cc | 4 ++-- gtk2_ardour/selection.cc | 6 +++--- gtk2_ardour/step_editor.cc | 2 +- gtk2_ardour/time_axis_view_item.cc | 4 ++-- 16 files changed, 48 insertions(+), 48 deletions(-) diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 25b96c3ff9..6a54e5bdd1 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -784,7 +784,7 @@ AudioClock::end_edit_relative (bool add) editing = false; _layout->set_attributes (normal_attributes); - if (!distance.zero()) { + if (!distance.is_zero ()) { if (add) { AudioClock::set (current_time() + timepos_t (distance), true); } else { @@ -1028,7 +1028,7 @@ AudioClock::set_samples (timepos_t const & w, bool /*force*/) return; } - if (when.negative()) { + if (when.is_negative ()) { when = -when; negative = true; } @@ -1078,9 +1078,9 @@ AudioClock::set_seconds (timepos_t const & when, bool /*force*/) } if (when >= _limit_pos || when <= -_limit_pos) { - set_out_of_bounds (when.negative()); + set_out_of_bounds (when.is_negative ()); } else { - if (when.negative()) { + if (when.is_negative ()) { snprintf (buf, sizeof (buf), "%12.1f", when.samples() / (float)_session->sample_rate()); } else { snprintf (buf, sizeof (buf), " %11.1f", when.samples() / (float)_session->sample_rate()); @@ -1162,7 +1162,7 @@ AudioClock::set_minsec (timepos_t const & when, bool /*force*/) } if (when >= _limit_pos || when <= -_limit_pos) { - set_out_of_bounds (when.negative()); + set_out_of_bounds (when.is_negative ()); } else { print_minsec (when.samples(), buf, sizeof (buf), _session->sample_rate()); _layout->set_text (buf); @@ -1185,7 +1185,7 @@ AudioClock::set_timecode (timepos_t const & w, bool /*force*/) return; } - if (when.negative()) { + if (when.is_negative ()) { when = -when; negative = true; } @@ -1224,7 +1224,7 @@ AudioClock::set_bbt (timepos_t const & w, timecnt_t const & o, bool /*force*/) return; } - if (when.negative()) { + if (when.is_negative ()) { when = -when; negative = true; } @@ -1232,14 +1232,14 @@ AudioClock::set_bbt (timepos_t const & w, timecnt_t const & o, bool /*force*/) /* handle a common case */ if (is_duration) { - if (when.zero()) { + if (when.is_zero ()) { BBT.bars = 0; BBT.beats = 0; BBT.ticks = 0; } else { TempoMap::SharedPtr tmap (TempoMap::use()); - if (offset.zero()) { + if (offset.is_zero ()) { offset = timecnt_t (bbt_reference_time); } @@ -1292,7 +1292,7 @@ AudioClock::set_bbt (timepos_t const & w, timecnt_t const & o, bool /*force*/) if (_with_info) { timepos_t pos; - if (bbt_reference_time.negative()) { + if (bbt_reference_time.is_negative ()) { pos = when; } else { pos = bbt_reference_time; @@ -1784,7 +1784,7 @@ AudioClock::on_scroll_event (GdkEventScroll *ev) case GDK_SCROLL_UP: step = get_incremental_step (f, current_time()); - if (!step.zero()) { + if (!step.is_zero ()) { if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { step *= 10; } @@ -1795,7 +1795,7 @@ AudioClock::on_scroll_event (GdkEventScroll *ev) case GDK_SCROLL_DOWN: step = get_incremental_step (f, current_time()); - if (!step.zero()) { + if (!step.is_zero ()) { if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { step *= 10; } @@ -1840,7 +1840,7 @@ AudioClock::on_motion_notify_event (GdkEventMotion *ev) if (drag_accum > 0) { /* positive, so downward motion ... decrement clock */ - if (!step.zero() && (step < pos)) { + if (!step.is_zero () && (step < pos)) { AudioClock::set (pos.earlier (step), false); } else { AudioClock::set (timepos_t () , false); diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 29021f517f..5758e411c3 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -1030,7 +1030,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events) continue; } - if (tx >= timepos_t::max (tx.time_domain()) || tx.negative() || tx >= _maximum_time) { + if (tx >= timepos_t::max (tx.time_domain()) || tx.is_negative () || tx >= _maximum_time) { continue; } diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index a2e5fecc3a..51a5edf1fe 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3844,11 +3844,11 @@ Editor::duplicate_range (bool with_dialog) } if ((current_mouse_mode() == MouseRange)) { - if (!selection->time.length().zero()) { + if (!selection->time.length().is_zero()) { duplicate_selection (times); } } else if (get_smart_mode()) { - if (!selection->time.length().zero()) { + if (!selection->time.length().is_zero()) { duplicate_selection (times); } else duplicate_some_regions (rs, times); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 81db9bb8c7..168f6ee91a 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -650,7 +650,7 @@ Editor::session_gui_extents (bool use_extra) const if (session_extent_end >= timepos_t::max (Temporal::AudioTime)) { session_extent_end = timepos_t::max (Temporal::AudioTime); } - if (session_extent_start.negative()) { + if (session_extent_start.is_negative()) { session_extent_start = timepos_t (0); } diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index a25e811d85..13d0eb8a8f 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -877,7 +877,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, Temporal::timepos_t & timecnt_t const sd = snap_delta (event->button.state); timepos_t sync_snap (pending_region_position + (sync_offset * sync_dir) + sd); _editor->snap_to_with_modifier (sync_snap, event); - if (sync_offset.zero() && sd.zero()) { + if (sync_offset.is_zero () && sd.is_zero ()) { pending_region_position = sync_snap; } else { pending_region_position = _primary->region()->adjust_to_sync (sync_snap).earlier (sd); @@ -890,7 +890,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, Temporal::timepos_t & pending_region_position = _last_position; } - if (!_earliest_time_limit.zero() && pending_region_position <= _earliest_time_limit) { + if (!_earliest_time_limit.is_zero () && pending_region_position <= _earliest_time_limit) { pending_region_position = _earliest_time_limit; return 0.0; } @@ -909,7 +909,7 @@ RegionMotionDrag::compute_x_delta (GdkEvent const * event, Temporal::timepos_t & for (list::const_iterator i = _views.begin(); i != _views.end(); ++i) { const timepos_t off = i->view->region()->position() + total_dx; - if (off.negative()) { + if (off.is_negative()) { dx = dx - _editor->time_to_pixel_unrounded (off); pending_region_position = pending_region_position.earlier (timecnt_t (off, timepos_t (pending_region_position.time_domain()))); break; @@ -2449,7 +2449,7 @@ RegionRippleDrag::motion (GdkEvent* event, bool first_move) } timepos_t where = adjusted_current_time (event); - assert (!where.negative()); + assert (!where.is_negative()); timepos_t after; double delta = compute_x_delta (event, after); @@ -4850,7 +4850,7 @@ MarkerDrag::motion (GdkEvent* event, bool) copy_location->set_end (new_end, false); } else if (new_start < copy_location->end()) { copy_location->set_start (new_start, false); - } else if (newpos.positive()) { + } else if (newpos.is_positive()) { //_editor->snap_to (next, RoundUpAlways, true); copy_location->set_end (next, false); copy_location->set_start (newpos, false); @@ -4863,7 +4863,7 @@ MarkerDrag::motion (GdkEvent* event, bool) copy_location->set_start (new_start, false); } else if (new_end > copy_location->start()) { copy_location->set_end (new_end, false); - } else if (newpos.positive()) { + } else if (newpos.is_positive()) { //_editor->snap_to (next, RoundDownAlways, true); copy_location->set_start (next, false); copy_location->set_end (newpos, false); @@ -6428,13 +6428,13 @@ NoteDrag::motion (GdkEvent * event, bool first_move) timecnt_t const tdx = _x_constrained ? timecnt_t::zero (_cumulative_dx.time_domain()) : dx_qn - _cumulative_dx; double const tdy = _y_constrained ? 0 : -dy * _note_height - _cumulative_dy; - if (!tdx.zero() || tdy) { + if (!tdx.is_zero () || tdy) { _cumulative_dx = dx_qn; _cumulative_dy += tdy; int8_t note_delta = total_dy(); - if (!tdx.zero() || tdy) { + if (!tdx.is_zero () || tdy) { if (_copy) { _region->move_copies (dx_qn, tdy, note_delta); } else { diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index fca2375378..eff3e9761a 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -347,7 +347,7 @@ Editor::write_region (string path, boost::shared_ptr region) /* don't do duplicate of the entire source if that's what is going on here */ - if (region->start().zero() && region->length() == region->source_length(0)) { + if (region->start().is_zero () && region->length() == region->source_length(0)) { /* XXX should link(2) to create a new inode with "path" */ return true; } diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 7702261f9d..0e798cb978 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -619,7 +619,7 @@ Editor::LocationMarkers::set_position (timepos_t const & startt, timepos_t const & endt) { start->set_position (startt); - if (end && !endt.zero()) { + if (end && !endt.is_zero ()) { end->set_position (endt); } } diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 98ea551b6f..d96039ce42 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2389,7 +2389,7 @@ Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event) timepos_t where = get_preferred_edit_position(); - if (where.negative()) { + if (where.is_negative()) { return; } diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 3c10edeb54..691d9928d7 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -352,12 +352,12 @@ Editor::move_range_selection_start_or_end_to_region_boundary (bool move_end, boo int dir = next ? 1 : -1; /* so we don't find the current region again */ - if (dir > 0 || pos.positive()) { + if (dir > 0 || pos.is_positive()) { pos.increment (); } timepos_t const target = get_region_boundary (pos, dir, true, false); - if (target.negative()) { + if (target.is_negative ()) { return; } @@ -1014,7 +1014,7 @@ Editor::cursor_to_region_point (EditorCursor* cursor, RegionPoint point, int32_t TimeAxisView *ontrack = 0; // so we don't find the current region again.. - if (dir > 0 || pos.positive()) + if (dir > 0 || pos.is_positive()) pos = pos.increment(); if (!selection->tracks.empty()) { @@ -1157,7 +1157,7 @@ Editor::selected_marker_to_region_boundary (bool with_selection, int32_t dir) timepos_t pos = loc->start(); // so we don't find the current region again.. - if (dir > 0 || pos.positive()) { + if (dir > 0 || pos.is_positive()) { pos = pos.increment(); } @@ -1972,7 +1972,7 @@ Editor::get_selection_extents (timepos_t &start, timepos_t &end) const } //range check - if ((start.zero() && end.zero()) || end < start) { + if ((start.is_zero () && end.is_zero ()) || end < start) { ret = false; } @@ -7343,7 +7343,7 @@ Editor::split_region_at_points (boost::shared_ptr r, AnalysisFeatureList * shouldn't we have some kind of lower limit on region size? */ - if (len.zero() || len.negative()) { + if (len.is_zero () || len.is_negative()) { break; } @@ -8188,7 +8188,7 @@ Editor::do_remove_time () timecnt_t distance = d.distance(); - if (distance.zero()) { + if (distance.is_zero ()) { return; } diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index bee6852635..8a73074af2 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -2030,7 +2030,7 @@ Editor::select_all_selectables_using_time_selection () const timecnt_t distance = start.distance (end); - if (distance.negative() || distance.zero()) { + if (distance.is_negative () || distance.is_zero ()) { return; } diff --git a/gtk2_ardour/editor_sources.cc b/gtk2_ardour/editor_sources.cc index 65695bb0b0..629901203d 100644 --- a/gtk2_ardour/editor_sources.cc +++ b/gtk2_ardour/editor_sources.cc @@ -612,7 +612,7 @@ EditorSources::format_position (timepos_t const & pos, char* buf, size_t bufsize Temporal::BBT_Time bbt; Timecode::Time timecode; - if (pos.negative()) { + if (pos.is_negative ()) { error << string_compose (_("EditorSources::format_position: negative timecode position: %1"), pos) << endmsg; snprintf (buf, bufsize, "invalid"); return; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 20a76f4730..9d413e4996 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -3022,9 +3022,9 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ Temporal::Beats snap_delta_beats; int sign = 1; - if (snap_delta_time.positive()) { + if (snap_delta_time.is_positive()) { snap_delta_beats = _region->region_distance_to_region_beats (timecnt_t (snap_delta_time, _region->position())); - } else if (snap_delta_time.negative()) { + } else if (snap_delta_time.is_negative()) { snap_delta_beats = _region->region_distance_to_region_beats (timecnt_t (-snap_delta_time, _region->position())); sign = -1; } @@ -4154,7 +4154,7 @@ MidiRegionView::trim_front_starting () void MidiRegionView::trim_front_ending () { - if (_region->start().negative()) { + if (_region->start().is_negative()) { /* Trim drag made start time -ve; fix this */ midi_region()->fix_negative_start (); } diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 63fafb1bd8..508b43ad28 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -832,7 +832,7 @@ RegionView::region_sync_changed () sync_offset = _region->sync_offset (sync_dir); - if (sync_offset.zero()) { + if (sync_offset.is_zero ()) { /* no need for a sync mark */ if (sync_mark) { sync_mark->hide(); @@ -1039,7 +1039,7 @@ RegionView::update_coverage_frame (LayerDisplay d) } } t = pl->find_next_region_boundary (t, 1); - if (t.negative()) { + if (t.is_negative()) { break; } me = new_me; diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index 1d1c486756..48d00b7d54 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -483,7 +483,7 @@ Selection::add (timepos_t const & start, timepos_t const & end) void Selection::move_time (timecnt_t const & distance) { - if (distance.zero()) { + if (distance.is_zero ()) { return; } @@ -741,7 +741,7 @@ Selection::set (timepos_t const & start, timepos_t const & end) clear_objects(); // enforce region/object exclusivity clear_time(); - if ((start.zero() && end.zero()) || end < start) { + if ((start.is_zero () && end.is_zero ()) || end < start) { return 0; } @@ -777,7 +777,7 @@ Selection::set_preserving_all_ranges (timepos_t const & start, timepos_t const & { clear_objects(); // enforce region/object exclusivity - if ((start.zero() && end.zero()) || (end < start)) { + if ((start.is_zero () && end.is_zero ()) || (end < start)) { return; } diff --git a/gtk2_ardour/step_editor.cc b/gtk2_ardour/step_editor.cc index 927a46daf6..511d2340ef 100644 --- a/gtk2_ardour/step_editor.cc +++ b/gtk2_ardour/step_editor.cc @@ -135,7 +135,7 @@ StepEditor::reset_step_edit_beat_pos () const timepos_t ep = _editor.get_preferred_edit_position(); timecnt_t distance_from_start (step_edit_region->position().distance (ep)); - if (distance_from_start.negative()) { + if (distance_from_start.is_negative()) { /* this can happen with snap enabled, and the edit point == Playhead. we snap the position of the new region, and it can end up after the edit point. */ diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc index 978a276b05..7092ce575b 100644 --- a/gtk2_ardour/time_axis_view_item.cc +++ b/gtk2_ardour/time_axis_view_item.cc @@ -182,7 +182,7 @@ TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_co wide_enough_for_name = wide; high_enough_for_name = high; - if (duration.zero ()) { + if (duration.is_zero ()) { warning << "Time Axis Item Duration == 0" << endl; } @@ -336,7 +336,7 @@ TimeAxisViewItem::set_duration (timecnt_t const & dur, void* src) return false; } - if (dur.zero()) { + if (dur.is_zero()) { group->hide(); }