diff --git a/src/WorkoutWidget.cpp b/src/WorkoutWidget.cpp index f4221a7bf..428a75411 100644 --- a/src/WorkoutWidget.cpp +++ b/src/WorkoutWidget.cpp @@ -133,7 +133,7 @@ WorkoutWidget::eventFilter(QObject *obj, QEvent *event) // // - // 1 MOUSE MOVE + // 1 MOUSE MOVE [we always repaint] // if (event->type() == QEvent::MouseMove) { @@ -157,12 +157,10 @@ WorkoutWidget::eventFilter(QObject *obj, QEvent *event) if (point->bounding().contains(p)) { if (!point->hover) { point->hover = true; - updateNeeded=true; } } else { if (point->hover) { point->hover = false; - updateNeeded=true; } } } @@ -173,7 +171,7 @@ WorkoutWidget::eventFilter(QObject *obj, QEvent *event) // we're dragging this point around, get on and // do that, but apply constrains if (dragging) { - updateNeeded = movePoint(p); + movePoint(p); // this may possibly be too expensive // on slower hardware? @@ -188,8 +186,11 @@ WorkoutWidget::eventFilter(QObject *obj, QEvent *event) // we're selecting via a rectangle atRect = p; - updateNeeded=selectPoints(); // go and check / select + selectPoints(); // go and check / select } + + // always repaint... + repaint(); } // diff --git a/src/WorkoutWidgetItems.cpp b/src/WorkoutWidgetItems.cpp index f42349e97..70ec6d52f 100644 --- a/src/WorkoutWidgetItems.cpp +++ b/src/WorkoutWidgetItems.cpp @@ -202,6 +202,9 @@ WWPoint::paint(QPainter *painter) void WWLine::paint(QPainter *painter) { + // cursor (we pain the block the cursor is in + QPoint c = workoutWidget()->mapFromGlobal(QCursor::pos()); + // thin ? QPen linePen(GColor(CPOWER)); linePen.setWidth(1); @@ -209,10 +212,12 @@ WWLine::paint(QPainter *painter) QPoint origin = workoutWidget()->transform(0,0); QPainterPath path(QPointF(origin.x(), origin.y())); + QPainterPath cursorBlock; // join the dots and make a path as you go QPointF last(0,0); + bool foundCursor=false; foreach(WWPoint *p, workoutWidget()->points()) { // might be better to always use float? @@ -220,9 +225,26 @@ WWLine::paint(QPainter *painter) QPointF dot(center.x(), center.y()); // path... - if (last.x() && last.y()) painter->drawLine(last, dot); path.lineTo(dot); + + // cursor in ? + if (last.x() > 0 && !foundCursor && c.x() > last.x() && c.x() < dot.x() && dot.x() > last.x()) { + + // we found it then + foundCursor = true; + + // found the cursor + QPointF begin(last.x(), workoutWidget()->canvas().bottom()); + QPainterPath block(begin); + block.lineTo(last); + block.lineTo(dot); + block.lineTo(dot.x(),begin.y()); + block.lineTo(begin); + cursorBlock = block; + } + + // moving on last = dot; } @@ -246,8 +268,23 @@ WWLine::paint(QPainter *painter) linearGradient.setColorAt(1.0, brush_color2); linearGradient.setSpread(QGradient::PadSpread); - painter->fillPath(path, QBrush(linearGradient)); + painter->fillPath(path, QBrush(linearGradient)); } + + if (foundCursor) { + QColor brush_color1 = GColor(CPLOTMARKER); + brush_color1.setAlpha(240); + QColor brush_color2 = GColor(CPLOTMARKER); + brush_color2.setAlpha(128); + + QLinearGradient linearGradient(0, 0, 0, workoutWidget()->transform(0,0).y()); + linearGradient.setColorAt(0.0, brush_color1); + linearGradient.setColorAt(1.0, brush_color2); + linearGradient.setSpread(QGradient::PadSpread); + + painter->fillPath(cursorBlock, QBrush(linearGradient)); + } + } void