]> sigrok.org Git - pulseview.git/commitdiff
ViewItem: Moved bg_colour_state into ViewItemPaintParams
authorJoel Holdsworth <redacted>
Wed, 26 Apr 2017 17:20:14 +0000 (11:20 -0600)
committerUwe Hermann <redacted>
Wed, 3 May 2017 17:08:10 +0000 (19:08 +0200)
pv/view/trace.cpp
pv/view/trace.hpp
pv/view/tracetreeitem.cpp
pv/view/tracetreeitem.hpp
pv/view/tracetreeitemowner.cpp
pv/view/tracetreeitemowner.hpp
pv/view/view.cpp
pv/view/viewitempaintparams.cpp
pv/view/viewitempaintparams.hpp

index f6d4164e0794fbad801dffabcdef01572e064e2c..e1b51373ae667616895f09f76c224283fd4f410c 100644 (file)
@@ -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));
 
index f911985023b9f8e26af823d3ad9b11a59507db28..731ed5dbd5980b38a26477b55920ddffc165069a 100644 (file)
@@ -125,7 +125,6 @@ private Q_SLOTS:
 
 protected:
        shared_ptr<data::SignalBase> base_;
-       bool coloured_bg_state_;
 
 private:
        pv::widgets::Popup *popup_;
index 97c31dc43d462057c95f2979730ef2e7291a3dee..a70ca32cf80c3b952baaa9707ab140e0f479c300 100644 (file)
@@ -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
index d1dd67ccfc7bcbb2ca464f432a770025e1af3af9..5b0bc6153aadabcdfe377b7e808707a600b9b9ab 100644 (file)
@@ -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_;
 };
index e62608851b4e76121b8d21791128a4c3341ac24f..bff63c762135e2b402941a856118b7097cc77079 100644 (file)
@@ -110,23 +110,6 @@ pair<int, int> TraceTreeItemOwner::v_extents() const
        return extents;
 }
 
-bool TraceTreeItemOwner::reassign_bgcolour_states(bool next_bgcolour_state)
-{
-       vector< shared_ptr<TraceTreeItem> > items = trace_tree_child_items();
-
-       // Sort items according to vertical position
-       sort(items.begin(), items.end(),
-               [](const shared_ptr<TraceTreeItem> a, const shared_ptr<TraceTreeItem> b) {
-               return a->layout_v_offset() > b->layout_v_offset(); });
-
-       for (const shared_ptr<TraceTreeItem> item : items) {
-               item->set_bgcolour_state(next_bgcolour_state);
-               next_bgcolour_state = !next_bgcolour_state;
-       }
-
-       return next_bgcolour_state;
-}
-
 void TraceTreeItemOwner::restack_items()
 {
 }
index 58a656d084d0259fa73c29c1d2d46b49dfa05191..cfe7bf7b5f5cf0d69ec4acb2faeb61055743092c 100644 (file)
@@ -100,14 +100,6 @@ public:
         */
        pair<int, int> 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;
 
index ab458f26bf36e981d49a1992826dbddb41e3d6e1..97a6bcf74b5bc78d7068c9d9b1615f203208b418 100644 (file)
@@ -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();
index cf0e5b3c8d5dbabe5591abe66c6921c5f861dee3..5a0b815af67d20d8ed11f0f6cacacf06736ce5b3 100644 (file)
@@ -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);
 }
index 3b150a883243b5a0d4ac52300627bee0731a86d5..9f2125c86159271ab981df0b46e2d201eac6bdc4 100644 (file)
@@ -75,6 +75,12 @@ public:
                return (offset_ / scale_).convert_to<double>();
        }
 
+       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