2017-04-27 18:26:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-01-14 17:23:57 +00:00
|
|
|
#ifndef DIVETEXTITEM_H
|
|
|
|
#define DIVETEXTITEM_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-08-11 08:57:42 +00:00
|
|
|
#include <QFont>
|
2021-08-22 17:48:49 +00:00
|
|
|
#include <QGraphicsPixmapItem>
|
2015-09-03 17:20:19 +00:00
|
|
|
|
|
|
|
class QBrush;
|
2014-01-14 17:23:57 +00:00
|
|
|
|
|
|
|
/* A Line Item that has animated-properties. */
|
2021-08-22 17:48:49 +00:00
|
|
|
class DiveTextItem : public QObject, public QGraphicsPixmapItem {
|
2014-01-14 17:23:57 +00:00
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
|
|
|
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
|
|
|
|
public:
|
2021-08-22 17:48:49 +00: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 20:57:57 +00:00
|
|
|
DiveTextItem(double dpr, double scale, int alignFlags, QGraphicsItem *parent);
|
2021-08-13 07:56:46 +00:00
|
|
|
void set(const QString &text, const QBrush &brush);
|
2014-02-28 04:09:57 +00:00
|
|
|
const QString &text();
|
2021-08-11 20:18:52 +00:00
|
|
|
static double fontHeight(double dpr, double scale);
|
2021-11-13 17:05:31 +00:00
|
|
|
static std::pair<double, double> getLabelSize(double dpr, double scale, const QString &label);
|
2021-08-11 20:18:52 +00:00
|
|
|
double height() const;
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2014-01-14 17:23:57 +00:00
|
|
|
private:
|
|
|
|
int internalAlignFlags;
|
2014-01-21 12:48:26 +00:00
|
|
|
QString internalText;
|
2021-08-09 14:48:08 +00:00
|
|
|
double dpr;
|
2014-02-15 15:03:41 +00:00
|
|
|
double scale;
|
2014-01-14 17:23:57 +00:00
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DIVETEXTITEM_H
|