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));
protected:
shared_ptr<data::SignalBase> base_;
- bool coloured_bg_state_;
private:
pv::widgets::Popup *popup_;
return QPoint(rect.right(), get_visual_y());
}
-void TraceTreeItem::set_bgcolour_state(bool state)
-{
- bgcolour_state_ = state;
-}
-
} // namespace TraceView
} // namespace views
} // namespace pv
*/
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.
int layout_v_offset_;
int visual_v_offset_;
- bool bgcolour_state_;
-
private:
QPropertyAnimation v_offset_animation_;
};
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()
{
}
*/
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;
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();
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);
}
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();
QRect rect_;
double scale_;
pv::util::Timestamp offset_;
+ bool bg_colour_state_;
};
} // namespace TraceView