popup_(nullptr),
popup_form_(nullptr)
{
- GlobalSettings settings;
- coloured_bg_ = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
-
connect(channel.get(), SIGNAL(name_changed(const QString&)),
this, SLOT(on_name_changed(const QString&)));
connect(channel.get(), SIGNAL(colour_changed(const QColor&)),
this, SLOT(on_colour_changed(const QColor&)));
}
-void Trace::set_coloured_bg(bool state)
-{
- coloured_bg_ = state;
-}
-
void Trace::paint_label(QPainter &p, const QRect &rect, bool hover)
{
const int y = get_visual_y();
void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp)
{
- if (coloured_bg_)
+ const View *view = owner_->view();
+ assert(view);
+
+ if (view->coloured_bg())
p.setBrush(base_->bgcolour());
else
p.setBrush(bgcolour_state_ ? BrightGrayBGColour : DarkGrayBGColour);
*/
virtual void set_colour(QColor colour);
- /**
- * Enables or disables the coloured background for this trace.
- */
- void set_coloured_bg(bool state);
-
/**
* Paints the signal label.
* @param p the QPainter to paint into.
protected:
shared_ptr<data::SignalBase> base_;
- bool coloured_bg_, coloured_bg_state_;
+ bool coloured_bg_state_;
private:
pv::widgets::Popup *popup_;
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
- }
-
+ coloured_bg_ = state;
viewport_->update();
}
+bool View::coloured_bg() const
+{
+ return coloured_bg_;
+}
+
bool View::cursors_shown() const
{
return show_cursors_;
*/
void enable_coloured_bg(bool state);
+ /**
+ * Returns true if the trace background should be drawn with a coloured background.
+ */
+ bool coloured_bg() const;
+
/**
* Enable or disable showing sampling points.
*/