From 59ec98e2b704d918c236e82f41536ce833890fb0 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Wed, 26 Apr 2017 11:20:14 -0600 Subject: [PATCH] ViewItem: Moved bg_colour_state into ViewItemPaintParams --- pv/view/trace.cpp | 2 +- pv/view/trace.hpp | 1 - pv/view/tracetreeitem.cpp | 5 ----- pv/view/tracetreeitem.hpp | 10 ---------- pv/view/tracetreeitemowner.cpp | 17 ----------------- pv/view/tracetreeitemowner.hpp | 8 -------- pv/view/view.cpp | 6 ------ pv/view/viewitempaintparams.cpp | 3 ++- pv/view/viewitempaintparams.hpp | 7 +++++++ 9 files changed, 10 insertions(+), 49 deletions(-) diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index f6d4164e..e1b51373 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -159,7 +159,7 @@ void Trace::paint_back(QPainter &p, ViewItemPaintParams &pp) if (view->coloured_bg()) p.setBrush(base_->bgcolour()); else - p.setBrush(bgcolour_state_ ? BrightGrayBGColour : DarkGrayBGColour); + p.setBrush(pp.next_bg_colour_state() ? BrightGrayBGColour : DarkGrayBGColour); p.setPen(QPen(Qt::NoPen)); diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp index f9119850..731ed5db 100644 --- a/pv/view/trace.hpp +++ b/pv/view/trace.hpp @@ -125,7 +125,6 @@ private Q_SLOTS: protected: shared_ptr base_; - bool coloured_bg_state_; private: pv::widgets::Popup *popup_; diff --git a/pv/view/tracetreeitem.cpp b/pv/view/tracetreeitem.cpp index 97c31dc4..a70ca32c 100644 --- a/pv/view/tracetreeitem.cpp +++ b/pv/view/tracetreeitem.cpp @@ -138,11 +138,6 @@ QPoint TraceTreeItem::point(const QRect &rect) const return QPoint(rect.right(), get_visual_y()); } -void TraceTreeItem::set_bgcolour_state(bool state) -{ - bgcolour_state_ = state; -} - } // namespace TraceView } // namespace views } // namespace pv diff --git a/pv/view/tracetreeitem.hpp b/pv/view/tracetreeitem.hpp index d1dd67cc..5b0bc615 100644 --- a/pv/view/tracetreeitem.hpp +++ b/pv/view/tracetreeitem.hpp @@ -113,14 +113,6 @@ public: */ QPoint point(const QRect &rect) const; - /** - * Sets the new background colour state: false = dark, true = bright. - * This is to allow for alternating backgrounds but has no effect - * when coloured background colours are used. - * @param state New bg color state to use. - */ - void set_bgcolour_state(bool state); - /** * Computes the vertical extents of the contents of this row item. * @return A pair containing the minimum and maximum y-values. @@ -133,8 +125,6 @@ protected: int layout_v_offset_; int visual_v_offset_; - bool bgcolour_state_; - private: QPropertyAnimation v_offset_animation_; }; diff --git a/pv/view/tracetreeitemowner.cpp b/pv/view/tracetreeitemowner.cpp index e6260885..bff63c76 100644 --- a/pv/view/tracetreeitemowner.cpp +++ b/pv/view/tracetreeitemowner.cpp @@ -110,23 +110,6 @@ pair TraceTreeItemOwner::v_extents() const return extents; } -bool TraceTreeItemOwner::reassign_bgcolour_states(bool next_bgcolour_state) -{ - vector< shared_ptr > items = trace_tree_child_items(); - - // Sort items according to vertical position - sort(items.begin(), items.end(), - [](const shared_ptr a, const shared_ptr b) { - return a->layout_v_offset() > b->layout_v_offset(); }); - - for (const shared_ptr item : items) { - item->set_bgcolour_state(next_bgcolour_state); - next_bgcolour_state = !next_bgcolour_state; - } - - return next_bgcolour_state; -} - void TraceTreeItemOwner::restack_items() { } diff --git a/pv/view/tracetreeitemowner.hpp b/pv/view/tracetreeitemowner.hpp index 58a656d0..cfe7bf7b 100644 --- a/pv/view/tracetreeitemowner.hpp +++ b/pv/view/tracetreeitemowner.hpp @@ -100,14 +100,6 @@ public: */ pair v_extents() const; - /* - * Reassigns background color states to all its children, thereby - * providing them with alternating backgrounds. - * @param next_bgcolour_state First brightness state to use. - * @return The next brightness state to use. - */ - bool reassign_bgcolour_states(bool next_bgcolour_state); - public: virtual void row_item_appearance_changed(bool label, bool content) = 0; diff --git a/pv/view/view.cpp b/pv/view/view.cpp index ab458f26..97a6bcf7 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -655,12 +655,6 @@ void View::restack_all_trace_tree_items() for (auto &o : sorted_owners) o->restack_items(); - // Re-assign background colors - bool next_bgcolour_state = false; - - 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(); diff --git a/pv/view/viewitempaintparams.cpp b/pv/view/viewitempaintparams.cpp index cf0e5b3c..5a0b815a 100644 --- a/pv/view/viewitempaintparams.cpp +++ b/pv/view/viewitempaintparams.cpp @@ -32,7 +32,8 @@ ViewItemPaintParams::ViewItemPaintParams( const QRect &rect, double scale, const pv::util::Timestamp& offset) : rect_(rect), scale_(scale), - offset_(offset) + offset_(offset), + bg_colour_state_(false) { assert(scale > 0.0); } diff --git a/pv/view/viewitempaintparams.hpp b/pv/view/viewitempaintparams.hpp index 3b150a88..9f2125c8 100644 --- a/pv/view/viewitempaintparams.hpp +++ b/pv/view/viewitempaintparams.hpp @@ -75,6 +75,12 @@ public: return (offset_ / scale_).convert_to(); } + bool next_bg_colour_state() { + const bool state = bg_colour_state_; + bg_colour_state_ = !bg_colour_state_; + return state; + } + public: static QFont font(); @@ -84,6 +90,7 @@ private: QRect rect_; double scale_; pv::util::Timestamp offset_; + bool bg_colour_state_; }; } // namespace TraceView -- 2.30.2