Skip to content

Commit

Permalink
Handle tooltip comments of overlapping annotations
Browse files Browse the repository at this point in the history
This handles the tooltips displaying the comments of overlapping
annotations, as long as only one of the annotations that contain
the mouse cursor has a tooltip.

Before, SpectrogramPlot::getAnnotationComment() would return the
comment of the first annotation that contains the mouse cursor,
even if such a comment is an empty QString. The empty QString
would cause that no tooltip is displayed. Now
SpectrogramPlot::getAnnotationComment() only returns non-empty
comments. Therefore, if only one annotation with a comment contains
the mouse cursor, the tooltip for that comment will be displayed.

This still does not handle the case when multiple annotations with
comments contain the mouse cursor, since it is not clear what is
best to do in this case. For now,
SpectrogramPlot::getAnnotationComment() simply returns one of the
applicable comments.

Signed-off-by: Daniel Estévez <[email protected]>
daniestevez authored and miek committed Oct 16, 2023
1 parent 290572e commit 9ab2b0b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/spectrogramplot.cpp
Original file line number Diff line number Diff line change
@@ -211,7 +211,7 @@ QString *SpectrogramPlot::mouseAnnotationComment(const QMouseEvent *event) {
int mouse_y = pos.y();

for (auto& a : visibleAnnotationLocations) {
if (a.isInside(mouse_x, mouse_y)) {
if (!a.annotation.comment.isEmpty() && a.isInside(mouse_x, mouse_y)) {
return &a.annotation.comment;
}
}

0 comments on commit 9ab2b0b

Please sign in to comment.