mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Workout Widget Smart Guide Y-Axis
.. now shows markers on Y-axis when moving / dragging points etc around.
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
static const double IHEIGHT = 10;
|
||||
static const double THEIGHT = 25;
|
||||
static const double BHEIGHT = 35;
|
||||
static const double LWIDTH = 55;
|
||||
static const double LWIDTH = 65;
|
||||
static const double RWIDTH = 35;
|
||||
|
||||
// axis tic marks
|
||||
@@ -1298,9 +1298,8 @@ WorkoutWidget::paintEvent(QPaintEvent*)
|
||||
painter.setPen(markerPen);
|
||||
|
||||
QString label = QString("%1w").arg(i);
|
||||
QRect bound = fontMetrics.boundingRect(label);
|
||||
painter.drawText(QPoint(canvas().left()+SPACING,
|
||||
y+bound.height()), // we use ascent not height to line up numbers
|
||||
y+(fontMetrics.ascent()/2)), // we use ascent not height to line up numbers
|
||||
label);
|
||||
|
||||
#if 0 // ONLY SHOW GRIDLINES FROM POWERSCALE
|
||||
|
||||
@@ -400,6 +400,13 @@ WWSmartGuide::paint(QPainter *painter)
|
||||
QPointF br(-1,-1);
|
||||
int selected=0;
|
||||
|
||||
//
|
||||
// FIND SCOPE TO MARK GUDIES FOR
|
||||
//
|
||||
// Currently we add guides when items are selected
|
||||
// or you are dragging a block or point around
|
||||
//
|
||||
|
||||
// If not dragging points or blocks just mark any selected items
|
||||
if (workoutWidget()->state == WorkoutWidget::none) {
|
||||
|
||||
@@ -455,6 +462,13 @@ WWSmartGuide::paint(QPainter *painter)
|
||||
QRectF boundary (workoutWidget()->transform(tl.x(), tl.y()),
|
||||
workoutWidget()->transform(br.x(), br.y()));
|
||||
|
||||
|
||||
QFontMetrics fontMetrics(workoutWidget()->markerFont);
|
||||
painter->setFont(workoutWidget()->markerFont);
|
||||
|
||||
//
|
||||
// X-AXIS GUIDES
|
||||
//
|
||||
if (selected > 0) {
|
||||
|
||||
// for now just paint the boundary tics on the x-axis
|
||||
@@ -473,8 +487,6 @@ WWSmartGuide::paint(QPainter *painter)
|
||||
|
||||
// now the text - but only if we have a gap!
|
||||
if (br.x() > tl.x()) {
|
||||
QFontMetrics fontMetrics(workoutWidget()->markerFont);
|
||||
painter->setFont(workoutWidget()->markerFont);
|
||||
|
||||
// paint time at very bottom of bottom in the middle
|
||||
// of the elongated tic marks
|
||||
@@ -513,8 +525,6 @@ WWSmartGuide::paint(QPainter *painter)
|
||||
|
||||
// now the left text - but only if we have a gap!
|
||||
if (left < tl.x()) {
|
||||
QFontMetrics fontMetrics(workoutWidget()->markerFont);
|
||||
painter->setFont(workoutWidget()->markerFont);
|
||||
|
||||
// paint time at very bottom of bottom in the middle
|
||||
// of the elongated tic marks
|
||||
@@ -527,8 +537,6 @@ WWSmartGuide::paint(QPainter *painter)
|
||||
|
||||
// now the right text - but only if we have a gap!
|
||||
if (right > br.x()) {
|
||||
QFontMetrics fontMetrics(workoutWidget()->markerFont);
|
||||
painter->setFont(workoutWidget()->markerFont);
|
||||
|
||||
// paint time at very bottom of bottom in the middle
|
||||
// of the elongated tic marks
|
||||
@@ -545,6 +553,38 @@ WWSmartGuide::paint(QPainter *painter)
|
||||
painter->drawLine(boundary.bottomLeft()-QPointF(20,0), boundary.topLeft()-QPointF(20,0));
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Y-AXIS GUIDES
|
||||
//
|
||||
if (selected > 0) {
|
||||
|
||||
// for now just paint the boundary tics on the y-axis
|
||||
QPen linePen(GColor(CPLOTMARKER));
|
||||
linePen.setWidthF(0);
|
||||
painter->setPen(linePen);
|
||||
|
||||
// top line width indicators
|
||||
painter->drawLine(workoutWidget()->left().left(), boundary.topRight().y(),
|
||||
workoutWidget()->left().right(), boundary.topRight().y());
|
||||
|
||||
painter->drawLine(workoutWidget()->left().left(), boundary.bottomLeft().y(),
|
||||
workoutWidget()->left().right(), boundary.bottomLeft().y());
|
||||
|
||||
|
||||
// now the texts
|
||||
// paint the bottom value
|
||||
QString text = QString("%1w").arg(double(tl.y()), 0, 'f', 0);
|
||||
QRect bound = fontMetrics.boundingRect(text);
|
||||
painter->drawText(workoutWidget()->left().left(), boundary.top()-SPACING, text);
|
||||
if (br.y() < tl.y()) {
|
||||
|
||||
// paint the bottom value UNDERNEATH the line, just in case they are really close!
|
||||
text = QString("%1w").arg(double(br.y()), 0, 'f', 0);
|
||||
bound = fontMetrics.boundingRect(text);
|
||||
painter->drawText(workoutWidget()->left().left(), boundary.bottom()+SPACING+fontMetrics.ascent(), text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user