diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-07-02 13:31:25 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-07-02 13:31:25 -0300 |
commit | effb7e2fac59cf2b44aa010b1ee17de24d7c6214 (patch) | |
tree | 495ba736725f44d06b3d78b9f7a088373d4896ab /qt-ui/diveplanner.cpp | |
parent | 23b29bd3cd0982eb921dc5cbf8f9e13074fe9e32 (diff) | |
download | subsurface-effb7e2fac59cf2b44aa010b1ee17de24d7c6214.tar.gz |
Change the color of the DepthString based on it's deepness
Change the color of the DepthString based on it's deepness
on the profile planner. The new color of the profileString
( the string that follows the mouse stating how deep you are)
is now interpolated from SAMPLE_SHALLOW and SAMPLE_DEEP -
but since those two colors were the same and I had to change
it so that could work, I want somebody to check if my choose
of colors were ok.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index d0ba86f94..8f8a3b534 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -78,10 +78,12 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) timeString = new QGraphicsSimpleTextItem(); timeString->setFlag(QGraphicsItem::ItemIgnoresTransformations); + timeString->setBrush(profile_color[TIME_TEXT].at(0)); scene()->addItem(timeString); depthString = new QGraphicsSimpleTextItem(); depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations); + depthString->setBrush(profile_color[SAMPLE_DEEP].at(0)); scene()->addItem(depthString); diveBg = new QGraphicsPolygonItem(); @@ -290,6 +292,16 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event) timeString->setText(QString::number(rint(timeLine->valueAt(mappedPos))) + "min"); timeString->setPos(mappedPos.x()+1, fromPercent(95, Qt::Vertical)); + // calculate the correct color for the depthString. + // QGradient doesn't returns it's interpolation, meh. + double percent = depthLine->percentAt(mappedPos); + QColor& startColor = profile_color[SAMPLE_SHALLOW].first(); + QColor& endColor = profile_color[SAMPLE_DEEP].first(); + short redDelta = (endColor.red() - startColor.red()) * percent + startColor.red(); + short greenDelta = (endColor.green() - startColor.green()) * percent + startColor.green(); + short blueDelta = (endColor.blue() - startColor.blue()) * percent + startColor.blue(); + depthString->setBrush( QColor(redDelta, greenDelta, blueDelta)); + if (activeDraggedHandler) moveActiveHandler(mappedPos); if (!handles.count()) @@ -469,6 +481,16 @@ qreal Ruler::posAtValue(qreal value) return retValue; } +qreal Ruler::percentAt(const QPointF& p) +{ + qreal value = valueAt(p); + QLineF m = line(); + double size = max - min; + double percent = value / size; + return percent; +} + + double Ruler::maximum() const { return max; |