26 #include <QApplication>
27 #include <QFormLayout>
95 const float label_arrow_length = r.height() / 2;
96 const QPointF points[] = {
98 QPointF(r.right() - label_arrow_length, r.top()),
99 QPointF(r.right(), y),
100 QPointF(r.right() - label_arrow_length, r.bottom()),
103 const QPointF highlight_points[] = {
104 QPointF(r.left() + 1, r.top() + 1),
105 QPointF(r.right() - label_arrow_length, r.top() + 1),
106 QPointF(r.right() - 1, y),
107 QPointF(r.right() - label_arrow_length, r.bottom() - 1),
108 QPointF(r.left() + 1, r.bottom() - 1)
113 p.setBrush(Qt::transparent);
114 p.drawPolygon(points,
countof(points));
117 p.setPen(Qt::transparent);
119 p.drawPolygon(points,
countof(points));
122 p.setBrush(Qt::transparent);
123 p.drawPolygon(highlight_points,
countof(highlight_points));
126 p.setBrush(Qt::transparent);
127 p.drawPolygon(points,
countof(points));
131 p.setFont(QApplication::font());
132 p.drawText(QRectF(r.x(), r.y(),
133 r.width() - label_arrow_length, r.height()),
134 Qt::AlignCenter | Qt::AlignVCenter,
name_);
148 popup_ =
new Popup(parent);
150 point(parent->rect())), Popup::Right);
154 connect(
popup_, SIGNAL(closed()),
164 QFontMetrics m(QApplication::font());
165 const QSize text_size(
166 m.boundingRect(QRect(), 0,
name_).width(), m.height());
167 const QSizeF label_size(
169 ceilf((text_size.height() +
LabelPadding.height() * 2) / 2) * 2);
170 const float half_height = label_size.height() / 2;
172 rect.right() - half_height - label_size.width() - 0.5,
174 label_size.width() + half_height,
175 label_size.height());
185 p.setPen(QPen(Qt::NoPen));
187 const std::pair<int, int> extents =
v_extents();
192 const int h = extents.second - extents.first;
194 p.drawRect(x, y, w, h);
200 p.drawLine(QPointF(pp.
left(), y + 0.5f), QPointF(pp.
right(), y + 0.5f));
207 ColourButton *
const colour_button =
new ColourButton(
210 colour_button->set_colour(
colour_);
211 connect(colour_button, SIGNAL(
selected(
const QColor&)),
214 form->addRow(tr(
"Colour"), colour_button);
235 QLineEdit *
const name_edit =
new QLineEdit(parent);
236 name_edit->setText(
name_);
237 connect(name_edit, SIGNAL(textChanged(
const QString&)),
239 form->addRow(tr(
"Name"), name_edit);
QPoint point(const QRect &rect) const
static const QSizeF LabelPadding
virtual void row_item_appearance_changed(bool label, bool content)=0
virtual std::pair< int, int > v_extents() const =0
virtual QMenu * create_context_menu(QWidget *parent)
virtual void populate_popup_form(QWidget *parent, QFormLayout *form)
virtual QMenu * create_context_menu(QWidget *parent)
QFormLayout * popup_form_
virtual bool enabled() const =0
virtual void paint_label(QPainter &p, const QRect &rect, bool hover)
virtual void extents_changed(bool horz, bool vert)=0
void paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
static QColor select_text_colour(QColor background)
pv::widgets::Popup * create_popup(QWidget *parent)
pv::widgets::Popup * popup_
static const unsigned int Cols
virtual void set_name(QString name)
void set_coloured_bg(bool state)
void on_colour_changed(const QColor &colour)
static const int LabelHitPadding
void add_colour_option(QWidget *parent, QFormLayout *form)
static const QColor BrightBGColour
void on_text_changed(const QString &text)
static const unsigned int Rows
static const QPen AxisPen
QRectF label_rect(const QRectF &rect) const
TraceTreeItemOwner * owner_
void set_colour(QColor colour)
static QPen highlight_pen()
static const QColor DarkBGColour
static const QColor Colours[Cols *Rows]
virtual void paint_back(QPainter &p, const ViewItemPaintParams &pp)