aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-02 13:31:25 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-02 13:31:25 -0300
commiteffb7e2fac59cf2b44aa010b1ee17de24d7c6214 (patch)
tree495ba736725f44d06b3d78b9f7a088373d4896ab /qt-ui
parent23b29bd3cd0982eb921dc5cbf8f9e13074fe9e32 (diff)
downloadsubsurface-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')
-rw-r--r--qt-ui/diveplanner.cpp22
-rw-r--r--qt-ui/diveplanner.h1
-rw-r--r--qt-ui/graphicsview-common.cpp4
3 files changed, 25 insertions, 2 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;
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 41b4e5c89..a7459de1b 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -42,6 +42,7 @@ public:
double minimum() const;
double maximum() const;
qreal valueAt(const QPointF& p);
+ qreal percentAt(const QPointF& p);
qreal posAtValue(qreal value);
void setColor(const QColor& color);
diff --git a/qt-ui/graphicsview-common.cpp b/qt-ui/graphicsview-common.cpp
index 7545557d9..464626f4b 100644
--- a/qt-ui/graphicsview-common.cpp
+++ b/qt-ui/graphicsview-common.cpp
@@ -33,8 +33,8 @@ void fill_profile_color()
profile_color[ALERT_BG] = COLOR(BROOM1_LOWER_TRANS, BLACK1_LOW_TRANS, BROOM1_LOWER_TRANS);
profile_color[ALERT_FG] = COLOR(BLACK1_LOW_TRANS, BLACK1_LOW_TRANS, BLACK1_LOW_TRANS);
profile_color[EVENTS] = COLOR(REDORANGE1, BLACK1_LOW_TRANS, REDORANGE1);
- profile_color[SAMPLE_DEEP] = COLOR(PERSIANRED1, BLACK1_LOW_TRANS, PERSIANRED1);
- profile_color[SAMPLE_SHALLOW] = COLOR(PERSIANRED1, BLACK1_LOW_TRANS, PERSIANRED1);
+ profile_color[SAMPLE_DEEP] = COLOR(QColor(Qt::red).darker(), BLACK1_LOW_TRANS, PERSIANRED1);
+ profile_color[SAMPLE_SHALLOW] = COLOR(QColor(Qt::red).lighter(), BLACK1_LOW_TRANS, PERSIANRED1);
profile_color[SMOOTHED] = COLOR(REDORANGE1_HIGH_TRANS, BLACK1_LOW_TRANS, REDORANGE1_HIGH_TRANS);
profile_color[MINUTE] = COLOR(MEDIUMREDVIOLET1_HIGHER_TRANS, BLACK1_LOW_TRANS, MEDIUMREDVIOLET1_HIGHER_TRANS);
profile_color[TIME_GRID] = COLOR(WHITE1, BLACK1_HIGH_TRANS, TUNDORA1_MED_TRANS);