diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-31 20:48:12 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-02-13 13:02:54 -0800 |
commit | d85b3217840656bf371cd64264ee472a68c3141a (patch) | |
tree | 8f5a9ffb3e956c1b262b3a36e88e0b0895b09878 /stats/chartitem.cpp | |
parent | 5c098eea29fdb1cd663b78db4e430a1c76c2209a (diff) | |
download | subsurface-d85b3217840656bf371cd64264ee472a68c3141a.tar.gz |
statistics: show selected dives in scatter plot
As a visual feedback, show the selected dives in the scatter
plot. React to application-wide selection changes. Currently,
the dive list is deactivated while in statistics mode, but
that may change.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/chartitem.cpp')
-rw-r--r-- | stats/chartitem.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/stats/chartitem.cpp b/stats/chartitem.cpp index c8bdd130e..93f374e14 100644 --- a/stats/chartitem.cpp +++ b/stats/chartitem.cpp @@ -108,7 +108,7 @@ static const int scatterItemDiameter = 10; static const int scatterItemBorder = 1; ChartScatterItem::ChartScatterItem(StatsView &v, ChartZValue z) : HideableChartItem(v, z), - positionDirty(false), textureDirty(false), highlighted(false) + positionDirty(false), textureDirty(false), highlight(Highlight::Unselected) { rect.setSize(QSizeF(static_cast<double>(scatterItemDiameter), static_cast<double>(scatterItemDiameter))); } @@ -138,12 +138,27 @@ static QSGTexture *createScatterTexture(StatsView &view, const QColor &color, co // QApplication finished its thread leads to crashes. Therefore, these // are now normal pointers and the texture objects are leaked. static QSGTexture *scatterItemTexture = nullptr; +static QSGTexture *scatterItemSelectedTexture = nullptr; static QSGTexture *scatterItemHighlightedTexture = nullptr; +QSGTexture *ChartScatterItem::getTexture() const +{ + switch (highlight) { + default: + case Highlight::Unselected: + return scatterItemTexture; + case Highlight::Selected: + return scatterItemSelectedTexture; + case Highlight::Highlighted: + return scatterItemHighlightedTexture; + } +} + void ChartScatterItem::render() { if (!scatterItemTexture) { scatterItemTexture = createScatterTexture(view, fillColor, borderColor); + scatterItemSelectedTexture = createScatterTexture(view, selectedColor, selectedBorderColor); scatterItemHighlightedTexture = createScatterTexture(view, highlightedColor, highlightedBorderColor); } if (!node) { @@ -153,7 +168,7 @@ void ChartScatterItem::render() } updateVisible(); if (textureDirty) { - node->node->setTexture(highlighted ? scatterItemHighlightedTexture : scatterItemTexture); + node->node->setTexture(getTexture()); textureDirty = false; } if (positionDirty) { @@ -181,11 +196,11 @@ bool ChartScatterItem::contains(QPointF point) const return squareDist(point, rect.center()) <= (scatterItemDiameter / 2.0) * (scatterItemDiameter / 2.0); } -void ChartScatterItem::setHighlight(bool highlightedIn) +void ChartScatterItem::setHighlight(Highlight highlightIn) { - if (highlighted == highlightedIn) + if (highlight == highlightIn) return; - highlighted = highlightedIn; + highlight = highlightIn; textureDirty = true; markDirty(); } |