2017-04-27 20:26:36 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-01-14 15:23:57 -02:00
|
|
|
#ifndef DIVETEXTITEM_H
|
|
|
|
#define DIVETEXTITEM_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-08-11 10:57:42 +02:00
|
|
|
#include <QFont>
|
2021-08-22 19:48:49 +02:00
|
|
|
#include <QGraphicsPixmapItem>
|
2015-09-03 14:20:19 -03:00
|
|
|
|
|
|
|
class QBrush;
|
2014-01-14 15:23:57 -02:00
|
|
|
|
|
|
|
/* A Line Item that has animated-properties. */
|
2021-08-22 19:48:49 +02:00
|
|
|
class DiveTextItem : public QObject, public QGraphicsPixmapItem {
|
2014-01-14 15:23:57 -02:00
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
|
|
|
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
|
|
|
|
public:
|
2021-08-22 19:48:49 +02:00
|
|
|
// Note: vertical centring is based on the actual rendered text, not on the font metrics.
|
|
|
|
// This is fine for placing text in the "tankbar", but it will look disastrous when
|
|
|
|
// placing text items next to each other. This may have to be fixed.
|
2021-08-12 22:57:57 +02:00
|
|
|
DiveTextItem(double dpr, double scale, int alignFlags, QGraphicsItem *parent);
|
2021-08-13 09:56:46 +02:00
|
|
|
void set(const QString &text, const QBrush &brush);
|
2014-02-27 20:09:57 -08:00
|
|
|
const QString &text();
|
2021-08-11 22:18:52 +02:00
|
|
|
static double fontHeight(double dpr, double scale);
|
2021-11-13 18:05:31 +01:00
|
|
|
static std::pair<double, double> getLabelSize(double dpr, double scale, const QString &label);
|
2021-08-11 22:18:52 +02:00
|
|
|
double height() const;
|
2014-02-27 20:09:57 -08:00
|
|
|
|
2014-01-14 15:23:57 -02:00
|
|
|
private:
|
|
|
|
int internalAlignFlags;
|
2014-01-21 10:48:26 -02:00
|
|
|
QString internalText;
|
2021-08-09 16:48:08 +02:00
|
|
|
double dpr;
|
2014-02-15 07:03:41 -08:00
|
|
|
double scale;
|
2014-01-14 15:23:57 -02:00
|
|
|
};
|
|
|
|
|
2014-02-11 19:14:46 +01:00
|
|
|
#endif // DIVETEXTITEM_H
|