QRectF max_rect(-Padding, 0, Padding, 0);
for (auto &i : view_)
if (i->enabled())
- max_rect = max_rect.united(i->label_rect(0));
+ max_rect = max_rect.united(i->label_rect(QRect()));
return QSize(max_rect.width() + Padding + BaselineOffset, 0);
}
shared_ptr<RowItem> Header::get_mouse_over_row_item(const QPoint &pt)
{
- const int w = width() - BaselineOffset;
+ const QRect r(BaselineOffset, 0, width() - BaselineOffset, height());
for (auto &i : view_)
- if (i->enabled() && i->label_rect(w).contains(pt))
+ if (i->enabled() && i->label_rect(r).contains(pt))
return i;
return shared_ptr<RowItem>();
}
// The trace labels are not drawn with the arrows exactly on the
// left edge of the widget, because then the selection shadow
// would be clipped away.
- const int w = width() - BaselineOffset;
+ const QRect rect(BaselineOffset, 0, width() - BaselineOffset, height());
vector< shared_ptr<RowItem> > row_items(
view_.begin(), view_.end());
assert(r);
const bool highlight = !dragging_ &&
- r->label_rect(w).contains(mouse_point_);
- r->paint_label(painter, w, highlight);
+ r->label_rect(rect).contains(mouse_point_);
+ r->paint_label(painter, rect, highlight);
}
painter.end();
/**
* Paints the signal label.
* @param p the QPainter to paint into.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @param hover true if the label is being hovered over by the mouse.
*/
- virtual void paint_label(QPainter &p, int right, bool hover) = 0;
+ virtual void paint_label(QPainter &p, const QRect &rect, bool hover) = 0;
/**
* Computes the outline rectangle of a label.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @return Returns the rectangle of the signal label.
*/
- virtual QRectF label_rect(int right) const = 0;
+ virtual QRectF label_rect(const QRectF &rect) const = 0;
public:
virtual void hover_point_changed();
colour_ = colour;
}
-void Trace::paint_label(QPainter &p, int right, bool hover)
+void Trace::paint_label(QPainter &p, const QRect &rect, bool hover)
{
const int y = get_visual_y();
if (!enabled())
return;
- const QRectF r = label_rect(right);
+ const QRectF r = label_rect(rect);
// Paint the label
const float label_arrow_length = r.height() / 2;
return popup_;
}
-QRectF Trace::label_rect(int right) const
+QRectF Trace::label_rect(const QRectF &rect) const
{
using pv::view::View;
ceilf((text_size.height() + View::LabelPadding.height() * 2) / 2) * 2);
const float half_height = label_size.height() / 2;
return QRectF(
- right - half_height - label_size.width() - 0.5,
+ rect.right() - half_height - label_size.width() - 0.5,
get_visual_y() + 0.5f - half_height,
label_size.width() + half_height,
label_size.height());
/**
* Paints the signal label.
* @param p the QPainter to paint into.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @param hover true if the label is being hovered over by the mouse.
*/
- virtual void paint_label(QPainter &p, int right, bool hover);
+ virtual void paint_label(QPainter &p, const QRect &rect, bool hover);
virtual QMenu* create_context_menu(QWidget *parent);
/**
* Computes the outline rectangle of a label.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @return Returns the rectangle of the signal label.
*/
- QRectF label_rect(int right) const;
+ QRectF label_rect(const QRectF &rect) const;
protected:
/**
return RowItemOwner::v_extents();
}
-void TraceGroup::paint_label(QPainter &p, int right, bool hover)
+void TraceGroup::paint_label(QPainter &p, const QRect &rect, bool hover)
{
- const QRectF r = label_rect(right).adjusted(
+ const QRectF r = label_rect(rect).adjusted(
LineThickness / 2, LineThickness / 2,
-LineThickness / 2, -LineThickness / 2);
p.drawPolyline(points, countof(points));
}
-QRectF TraceGroup::label_rect(int right) const
+QRectF TraceGroup::label_rect(const QRectF &rect) const
{
- QRectF rect;
+ QRectF child_rect;
for (const shared_ptr<RowItem> r : child_items())
if (r && r->enabled())
- rect = rect.united(r->label_rect(right));
+ child_rect = child_rect.united(r->label_rect(rect));
- return QRectF(rect.x() - Width - Padding, rect.y(),
- Width, rect.height());
+ return QRectF(child_rect.x() - Width - Padding, child_rect.y(),
+ Width, child_rect.height());
}
bool TraceGroup::pt_in_label_rect(int left, int right, const QPoint &point)
* area.
* @param hover true if the label is being hovered over by the mouse.
*/
- void paint_label(QPainter &p, int right, bool hover);
+ void paint_label(QPainter &p, const QRect &rect, bool hover);
/**
* Computes the outline rectangle of a label.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @return Returns the rectangle of the signal label.
*/
- QRectF label_rect(int right) const;
+ QRectF label_rect(const QRectF &rect) const;
/**
* Determines if a point is in the header label rect.
update_scroll();
}
-void View::paint_label(QPainter &p, int right, bool hover)
+void View::paint_label(QPainter &p, const QRect &rect, bool hover)
{
(void)p;
- (void)right;
+ (void)rect;
(void)hover;
}
-QRectF View::label_rect(int right)
+QRectF View::label_rect(const QRectF &rect)
{
- (void)right;
+ (void)rect;
return QRectF();
}
/**
* Satisifies RowItem functionality.
* @param p the QPainter to paint into.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @param hover true if the label is being hovered over by the mouse.
*/
- void paint_label(QPainter &p, int right, bool hover);
+ void paint_label(QPainter &p, const QRect &rect, bool hover);
/**
* Computes the outline rectangle of a label.
- * @param right the x-coordinate of the right edge of the header
- * area.
+ * @param rect the rectangle of the header area.
* @return Returns the rectangle of the signal label.
*/
- QRectF label_rect(int right);
+ QRectF label_rect(const QRectF &rect);
static bool add_channels_to_owner(
const std::vector< std::shared_ptr<sigrok::Channel> > &channels,