MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / updateDataSpanFromItems

Method updateDataSpanFromItems

pj_widgets/src/Timeline.cpp:1647–1669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1645}
1646
1647void Timeline::updateDataSpanFromItems() {
1648 if (bar_items_.empty()) {
1649 ruler_item_->setDataSpan(0, 0);
1650 background_item_->setDataSpan(0, 0);
1651 return;
1652 }
1653 // Union the bars' current VISUAL extents (item position + the in-flight drag's
1654 // ghost dx), so the ruler tint AND the empty-area hatch track the dragged
1655 // bar(s) live. Reading the items (not scene_) keeps this correct whether or
1656 // not a host has fed the offset back.
1657 double min_x = std::numeric_limits<double>::max();
1658 double max_x = std::numeric_limits<double>::lowest();
1659 for (const TimelineBarItem* bar : bar_items_) {
1660 const double x0 = bar->pos().x() + bar->ghostDx();
1661 const double x1 = x0 + bar->rect().width();
1662 min_x = std::min(min_x, x0);
1663 max_x = std::max(max_x, x1);
1664 }
1665 const qint64 lo = TimelineScene::pxToNs(min_x, viewport_);
1666 const qint64 hi = TimelineScene::pxToNs(max_x, viewport_);
1667 ruler_item_->setDataSpan(lo, hi);
1668 background_item_->setDataSpan(lo, hi);
1669}
1670
1671void Timeline::repositionPlayhead() {
1672 const double x = TimelineScene::nsToPx(playhead_ns_, viewport_);

Callers

nothing calls this directly

Calls 7

ghostDxMethod · 0.80
rectMethod · 0.80
emptyMethod · 0.45
setDataSpanMethod · 0.45
xMethod · 0.45
posMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected