- if (visible_data.empty())
- return make_pair(0.0, 0.0);
-
- double left_time = DBL_MAX, right_time = DBL_MIN;
- for (const shared_ptr<SignalData> d : visible_data)
- {
- const double start_time = d->get_start_time();
- double samplerate = d->samplerate();
- samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
-
- left_time = min(left_time, start_time);
- right_time = max(right_time, start_time +
- d->get_max_sample_count() / samplerate);
+ for (const shared_ptr<SignalData> d : visible_data) {
+ const vector< shared_ptr<Segment> > segments =
+ d->segments();
+ for (const shared_ptr<Segment> &s : segments) {
+ double samplerate = s->samplerate();
+ samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
+
+ const Timestamp start_time = s->start_time();
+ left_time = left_time ?
+ min(*left_time, start_time) :
+ start_time;
+ right_time = right_time ?
+ max(*right_time, start_time + d->max_sample_count() / samplerate) :
+ start_time + d->max_sample_count() / samplerate;
+ }
+ }
+
+ if (!left_time || !right_time)
+ return make_pair(0, 0);
+
+ assert(*left_time < *right_time);
+ return make_pair(*left_time, *right_time);
+}
+
+void View::enable_sticky_scrolling(bool state)
+{
+ sticky_scrolling_ = state;
+}
+
+void View::enable_coloured_bg(bool state)
+{
+ const vector<shared_ptr<TraceTreeItem>> items(
+ list_by_type<TraceTreeItem>());
+
+ for (shared_ptr<TraceTreeItem> i : items) {
+ // Can't cast to Trace because it's abstract, so we need to
+ // check for any derived classes individually
+
+ shared_ptr<AnalogSignal> a = dynamic_pointer_cast<AnalogSignal>(i);
+ if (a)
+ a->set_coloured_bg(state);
+
+ shared_ptr<LogicSignal> l = dynamic_pointer_cast<LogicSignal>(i);
+ if (l)
+ l->set_coloured_bg(state);
+
+#ifdef ENABLE_DECODE
+ shared_ptr<DecodeTrace> d = dynamic_pointer_cast<DecodeTrace>(i);
+ if (d)
+ d->set_coloured_bg(state);
+#endif