action_view_coloured_bg_->setCheckable(true);
action_view_coloured_bg_->setChecked(true);
- action_view_coloured_bg_->setShortcut(QKeySequence(Qt::Key_S));
+ action_view_coloured_bg_->setShortcut(QKeySequence(Qt::Key_B));
action_view_coloured_bg_->setObjectName(
QString::fromUtf8("actionViewColouredBg"));
action_view_coloured_bg_->setText(tr("Use &coloured backgrounds"));
menu_view->addAction(action_view_coloured_bg_);
+ view_->enable_coloured_bg(action_view_coloured_bg_->isChecked());
+
menu_view->addSeparator();
action_view_show_cursors_->setCheckable(true);
void MainWindow::on_actionViewColouredBg_triggered()
{
+ view_->enable_coloured_bg(action_view_coloured_bg_->isChecked());
}
void MainWindow::on_actionViewShowCursors_triggered()
Trace::Trace(QString name) :
name_(name),
+ coloured_bg_(true), // Default setting is set in MainWindow::setup_ui()
popup_(nullptr),
popup_form_(nullptr)
{
bgcolour_.setAlpha(20);
}
+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)
{
- p.setPen(QPen(Qt::NoPen));
- p.setBrush(bgcolour_);
+ if (coloured_bg_) {
+ p.setPen(QPen(Qt::NoPen));
+ p.setBrush(bgcolour_);
- const std::pair<int, int> extents = v_extents();
+ const std::pair<int, int> extents = v_extents();
- const int x = 0;
- const int y = get_visual_y() + extents.first;
- const int w = pp.right() - pp.left();
- const int h = extents.second - extents.first;
+ const int x = 0;
+ const int y = get_visual_y() + extents.first;
+ const int w = pp.right() - pp.left();
+ const int h = extents.second - extents.first;
- p.drawRect(x, y, w, h);
+ p.drawRect(x, y, w, h);
+ }
}
void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
*/
void set_colour(QColor colour);
+ /**
+ * Enables or disables the coloured background for this trace.
+ */
+ void set_coloured_bg(bool state);
+
/**
* Computes the outline rectangle of the viewport hit-box.
* @param rect the rectangle of the viewport area.
protected:
QString name_;
QColor colour_, bgcolour_;
+ bool coloured_bg_;
private:
pv::widgets::Popup *popup_;
#include <libsigrokcxx/libsigrokcxx.hpp>
+#include "analogsignal.hpp"
#include "decodetrace.hpp"
#include "header.hpp"
#include "logicsignal.hpp"
sticky_scrolling_ = state;
}
+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);
+
+ shared_ptr<DecodeTrace> d = dynamic_pointer_cast<DecodeTrace>(i);
+ if (d)
+ d->set_coloured_bg(state);
+ }
+
+ viewport_->update();
+}
+
bool View::cursors_shown() const
{
return show_cursors_;
*/
void enable_sticky_scrolling(bool state);
+ /**
+ * Enables or disables coloured trace backgrounds. If they're not
+ * coloured then they will use alternating colors.
+ */
+ void enable_coloured_bg(bool state);
+
/**
* Returns true if cursors are displayed. false otherwise.
*/