X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fview.cpp;h=c9b08bf8c0445de0783d5bbb16d4d4275f5066f1;hp=6a342915972312b96e29e731fd75fed59191df6e;hb=9d4010c7f02b1c7575db2fb163b0d6daf323c1a9;hpb=92ff2b60d60c8191a6f4a923b5a9099ec544adbd diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 6a342915..c9b08bf8 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -42,6 +42,7 @@ #include +#include "analogsignal.hpp" #include "decodetrace.hpp" #include "header.hpp" #include "logicsignal.hpp" @@ -408,8 +409,7 @@ pair View::get_time_extents() const { boost::optional left_time, right_time; const set< shared_ptr > visible_data = get_visible_data(); - for (const shared_ptr d : visible_data) - { + for (const shared_ptr d : visible_data) { const vector< shared_ptr > segments = d->segments(); for (const shared_ptr &s : segments) { @@ -438,6 +438,31 @@ void View::enable_sticky_scrolling(bool state) sticky_scrolling_ = state; } +void View::enable_coloured_bg(bool state) +{ + const vector> items( + list_by_type()); + + for (shared_ptr i : items) { + // Can't cast to Trace because it's abstract, so we need to + // check for any derived classes individually + + shared_ptr a = dynamic_pointer_cast(i); + if (a) + a->set_coloured_bg(state); + + shared_ptr l = dynamic_pointer_cast(i); + if (l) + l->set_coloured_bg(state); + + shared_ptr d = dynamic_pointer_cast(i); + if (d) + d->set_coloured_bg(state); + } + + viewport_->update(); +} + bool View::cursors_shown() const { return show_cursors_; @@ -521,6 +546,12 @@ void View::restack_all_trace_tree_items() for (auto &o : sorted_owners) o->restack_items(); + // Re-assign background colors + bool next_bgcolour_state = 0; + + for (auto &o : sorted_owners) + next_bgcolour_state = o->reassign_bgcolour_states(next_bgcolour_state); + // Animate the items to their destination for (const auto &i : items) i->animate_to_layout_v_offset(); @@ -727,8 +758,7 @@ vector< shared_ptr > View::extract_new_traces_for_channels( { vector< shared_ptr > filtered_traces; - for (const auto &channel : channels) - { + for (const auto &channel : channels) { const auto map_iter = signal_map.find(channel); if (map_iter == signal_map.end()) continue; @@ -793,7 +823,7 @@ bool View::eventFilter(QObject *object, QEvent *event) bool View::viewportEvent(QEvent *e) { - switch(e->type()) { + switch (e->type()) { case QEvent::Paint: case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: @@ -804,7 +834,6 @@ bool View::viewportEvent(QEvent *e) case QEvent::TouchUpdate: case QEvent::TouchEnd: return false; - default: return QAbstractScrollArea::viewportEvent(e); } @@ -920,8 +949,7 @@ void View::signals_changed() signal_map[sig->channel()] = sig; // Populate channel groups - for (auto entry : sr_dev->channel_groups()) - { + for (auto entry : sr_dev->channel_groups()) { const shared_ptr &group = entry.second; if (group->channels().size() <= 1)