Changeset - a05995d9dbe1
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 7 years ago 2018-10-01 15:49:25
hy@ozderya.net
v-center the text and add margin
1 file changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/zoomer.cpp
Show inline comments
 
@@ -21,12 +21,13 @@
 
#include <qwt_plot.h>
 
#include <QPen>
 
#include <QMouseEvent>
 
#include <QtMath>
 

	
 
static const int VALUE_POINT_DIAM = 4;
 
static const int VALUE_TEXT_MARGIN = VALUE_POINT_DIAM + 2;
 

	
 
Zoomer::Zoomer(QWidget* widget, const Stream* stream, bool doReplot) :
 
    ScrollZoomer(widget)
 
{
 
    is_panning = false;
 
    _stream = stream;
 
@@ -142,13 +143,16 @@ void Zoomer::drawValues(QPainter* painte
 

	
 
            painter->setBrush(_stream->channel(ci)->color());
 
            painter->setPen(Qt::NoPen);
 
            painter->drawEllipse(p, VALUE_POINT_DIAM, VALUE_POINT_DIAM);
 

	
 
            painter->setPen(Qt::white);
 
            painter->drawText(p, QString("%1").arg(val));
 
            // We give a very small (1x1) rectangle but disable clipping
 
            painter->drawText(QRectF(p.x() + VALUE_TEXT_MARGIN, p.y(), 1, 1),
 
                              Qt::AlignVCenter | Qt::TextDontClip,
 
                              QString("%1").arg(val));
 
        }
 
    }
 

	
 
    painter->restore();
 
}
 

	
 
@@ -179,13 +183,13 @@ QRect Zoomer::trackerRect(const QFont& f
 
}
 

	
 
QRect Zoomer::valueTrackerRect(const QFont& font) const
 
{
 
    // TODO: consider using actual tracker values for width calculation
 
    const int textWidth = qCeil(QwtText("-8.8888888").textSize(font).width());
 
    const int width = textWidth + VALUE_POINT_DIAM;
 
    const int width = textWidth + VALUE_POINT_DIAM + VALUE_TEXT_MARGIN;
 
    const int x = trackerPosition().x() - VALUE_POINT_DIAM;
 
    const auto pickRect = pickArea().boundingRect();
 

	
 
    return QRect(x, pickRect.y(), width, pickRect.height());
 
}
 

	
0 comments (0 inline, 0 general)