From 3ae160857d0c65b9d6024c2dc57edfcb4b55defc Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 11 Dec 2021 08:38:56 +0100 Subject: [PATCH] profile: reformat timestamp labels The timestamp labels may change their format on zoom from "mm" to "mm:ss", depending on the zoom level. Since the animation kept old labels, this meant that one can end up with a mix of labels. Therefore, always reformat the labels. Of course, this means that the labels switch instantaneously from one format to the other. This is in conflict with the whole idea of "smooth" animation. Such a smooth animation could be realized by adding a "format" flag to the Label structure and keeping thus fading in/out labels if the format changes. Do we want that? Signed-off-by: Berthold Stoeger --- profile-widget/divecartesianaxis.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index 61ad1c4c1..9389e8548 100644 --- a/profile-widget/divecartesianaxis.cpp +++ b/profile-widget/divecartesianaxis.cpp @@ -232,6 +232,12 @@ void DiveCartesianAxis::updateLabel(Label &label, double opacityEnd, double pos) if (label.label) { label.labelPosStart = label.label->pos(); label.labelPosEnd = labelPos(pos); + + // For the time-axis, the format might change from "mm" to "mm:ss", + // or vice versa. Currently, we don't animate that, i.e. it will + // switch instantaneously. + if (position == Position::Bottom) + label.label->set(textForValue(label.value), textColor); } if (label.line) { label.lineStart = label.line->line();