right - left, height);
}
-void CursorPair::paint_label(QPainter &p, const QRect &rect)
+void CursorPair::paint_label(QPainter &p, const QRect &rect, bool hover)
{
assert(first_);
assert(second_);
p.drawRoundedRect(delta_rect, radius, radius);
}
- p.setBrush(Cursor::FillColour);
+ p.setBrush(hover ? Cursor::FillColour.lighter() :
+ Cursor::FillColour);
p.setPen(Cursor::FillColour.darker());
p.drawRoundedRect(delta_rect, radius, radius);
public:
QRectF label_rect(const QRectF &rect) const;
- void paint_label(QPainter &p, const QRect &rect);
+ /**
+ * Paints the marker's label to the ruler.
+ * @param p The painter to draw with.
+ * @param rect The rectangle of the ruler client area.
+ * @param hover true if the label is being hovered over by the mouse.
+ */
+ void paint_label(QPainter &p, const QRect &rect, bool hover);
/**
* Paints the background layer of the item with a QPainter
*/
virtual std::pair<int, int> v_extents() const = 0;
- /**
- * Paints the signal label.
- * @param p the QPainter to paint into.
- * @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, const QRect &rect, bool hover) = 0;
-
public:
virtual void hover_point_changed();
// Draw the items
const vector< shared_ptr<TimeItem> > items(view_.time_items());
- for (auto &i : items)
- i->paint_label(p, r);
+ for (auto &i : items) {
+ const bool highlight = !dragging_ &&
+ i->label_rect(r).contains(mouse_point_);
+ i->paint_label(p, r, highlight);
+ }
}
void Ruler::mouseMoveEvent(QMouseEvent *e)
virtual float get_x() const = 0;
- /**
- * Paints the marker's label to the ruler.
- * @param p The painter to draw with.
- * @param rect The rectangle of the ruler client area.
- */
- virtual void paint_label(QPainter &p, const QRect &rect) = 0;
-
protected:
View &view_;
};
label_size.width(), height);
}
-void TimeMarker::paint_label(QPainter &p, const QRect &rect)
+void TimeMarker::paint_label(QPainter &p, const QRect &rect, bool hover)
{
if (!enabled())
return;
}
p.setPen(Qt::transparent);
- p.setBrush(colour_);
+ p.setBrush(hover ? colour_.lighter() : colour_);
p.drawPolygon(points, countof(points));
p.setPen(colour_.lighter());
* Paints the marker's label to the ruler.
* @param p The painter to draw with.
* @param rect The rectangle of the ruler client area.
+ * @param hover true if the label is being hovered over by the mouse.
*/
- void paint_label(QPainter &p, const QRect &rect);
+ void paint_label(QPainter &p, const QRect &rect, bool hover);
/**
* Paints the foreground layer of the item with a QPainter
*/
virtual QRectF label_rect(const QRectF &rect) const = 0;
+ /**
+ * Paints the signal label.
+ * @param p the QPainter to paint into.
+ * @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, const QRect &rect, bool hover) = 0;
+
/**
* Paints the background layer of the item with a QPainter
* @param p the QPainter to paint into.